Firmware SDK
|
Driver for generic analog sensor. More...
Data Structures | |
struct | twr_analog_sensor_driver_t |
Analog sensor driver interface. More... | |
Typedefs | |
typedef struct twr_analog_sensor_t | twr_analog_sensor_t |
Analog sensor instance. | |
Enumerations | |
enum | twr_analog_sensor_event_t { TWR_ANALOG_SENSOR_EVENT_ERROR = 0 , TWR_ANALOG_SENSOR_EVENT_UPDATE = 1 } |
Callback events. More... | |
Functions | |
void | twr_analog_sensor_init (twr_analog_sensor_t *self, twr_adc_channel_t adc_channel, const twr_analog_sensor_driver_t *driver) |
Initialize generic analog sensor. More... | |
void | twr_analog_sensor_set_event_handler (twr_analog_sensor_t *self, void(*event_handler)(twr_analog_sensor_t *, twr_analog_sensor_event_t, void *), void *event_param) |
Set callback function. More... | |
void | twr_analog_sensor_set_update_interval (twr_analog_sensor_t *self, twr_tick_t interval) |
Set measurement interval. More... | |
bool | twr_analog_sensor_measure (twr_analog_sensor_t *self) |
Start measurement manually. More... | |
bool | twr_analog_sensor_get_result (twr_analog_sensor_t *self, void *result) |
Get measurement result. More... | |
Driver for generic analog sensor.
Callback events.
Enumerator | |
---|---|
TWR_ANALOG_SENSOR_EVENT_ERROR | Error event. |
TWR_ANALOG_SENSOR_EVENT_UPDATE | Update event. |
Definition at line 13 of file twr_analog_sensor.h.
bool twr_analog_sensor_get_result | ( | twr_analog_sensor_t * | self, |
void * | result | ||
) |
Get measurement result.
[in] | self | Instance |
[out] | result | Pointer to variable where result will be stored |
void twr_analog_sensor_init | ( | twr_analog_sensor_t * | self, |
twr_adc_channel_t | adc_channel, | ||
const twr_analog_sensor_driver_t * | driver | ||
) |
Initialize generic analog sensor.
[in] | self | Instance |
[in] | adc_channel | ADC channel |
[in] | adc_format | ADC result format |
[in] | driver | Optional driver interface (can be NULL) |
Definition at line 9 of file twr_analog_sensor.c.
bool twr_analog_sensor_measure | ( | twr_analog_sensor_t * | self | ) |
Start measurement manually.
[in] | self | Instance |
Definition at line 51 of file twr_analog_sensor.c.
Referenced by twr_analog_sensor_set_update_interval().
void twr_analog_sensor_set_event_handler | ( | twr_analog_sensor_t * | self, |
void(*)(twr_analog_sensor_t *, twr_analog_sensor_event_t, void *) | event_handler, | ||
void * | event_param | ||
) |
Set callback function.
[in] | self | Instance |
[in] | event_handler | Function address |
[in] | event_param | Optional event parameter (can be NULL) |
Definition at line 29 of file twr_analog_sensor.c.
void twr_analog_sensor_set_update_interval | ( | twr_analog_sensor_t * | self, |
twr_tick_t | interval | ||
) |
Set measurement interval.
[in] | self | Instance |
[in] | interval | Measurement interval |
Definition at line 35 of file twr_analog_sensor.c.