35 lines
621 B
C
35 lines
621 B
C
#include "id_driver.h"
|
|
#include "gpio_driver.h"
|
|
#include "config.h"
|
|
|
|
static uint8_t current_id;
|
|
|
|
static uint8_t id_read_pins(void)
|
|
{
|
|
uint8_t val = 0;
|
|
|
|
if (gpio_get_level(ID_PORT, ID_PIN_1)) val |= 0x01;
|
|
if (gpio_get_level(ID_PORT, ID_PIN_2)) val |= 0x02;
|
|
if (gpio_get_level(ID_PORT, ID_PIN_3)) val |= 0x04;
|
|
if (gpio_get_level(ID_PORT, ID_PIN_4)) val |= 0x08;
|
|
|
|
return val;
|
|
}
|
|
|
|
ret_code_t id_driver_init(void)
|
|
{
|
|
current_id = id_read_pins();
|
|
|
|
return RET_OK;
|
|
}
|
|
|
|
uint8_t id_get_value(void)
|
|
{
|
|
return current_id;
|
|
}
|
|
|
|
uint8_t id_get_slave_address(void)
|
|
{
|
|
return ID_BASE_ADDR + current_id;
|
|
}
|