1 #ifndef _TWR_ANALOG_SENSOR_H
2 #define _TWR_ANALOG_SENSOR_H
5 #include <twr_scheduler.h>
49 TWR_ANALOG_SENSOR_STATE_ERROR = -1,
50 TWR_ANALOG_SENSOR_STATE_ENABLE = 0,
51 TWR_ANALOG_SENSOR_STATE_MEASURE = 1,
52 TWR_ANALOG_SENSOR_STATE_DISABLE = 2,
53 TWR_ANALOG_SENSOR_STATE_UPDATE = 3
55 } twr_analog_sensor_state_t;
65 bool _measurement_active;
67 twr_analog_sensor_state_t _state;
twr_adc_channel_t
ADC channel.
bool twr_analog_sensor_get_result(twr_analog_sensor_t *self, void *result)
Get measurement result.
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.
bool twr_analog_sensor_measure(twr_analog_sensor_t *self)
Start measurement manually.
twr_analog_sensor_event_t
Callback events.
struct twr_analog_sensor_t twr_analog_sensor_t
Analog sensor instance.
void twr_analog_sensor_set_update_interval(twr_analog_sensor_t *self, twr_tick_t interval)
Set measurement interval.
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.
@ TWR_ANALOG_SENSOR_EVENT_ERROR
Error event.
@ TWR_ANALOG_SENSOR_EVENT_UPDATE
Update event.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
uint64_t twr_tick_t
Timestamp data type.
Analog sensor driver interface.