Firmware SDK
twr_analog_sensor

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...
 

Detailed Description

Driver for generic analog sensor.

Enumeration Type Documentation

◆ twr_analog_sensor_event_t

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.

Function Documentation

◆ twr_analog_sensor_get_result()

bool twr_analog_sensor_get_result ( twr_analog_sensor_t self,
void *  result 
)

Get measurement result.

Parameters
[in]selfInstance
[out]resultPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

◆ twr_analog_sensor_init()

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.

Parameters
[in]selfInstance
[in]adc_channelADC channel
[in]adc_formatADC result format
[in]driverOptional driver interface (can be NULL)

Definition at line 9 of file twr_analog_sensor.c.

Here is the call graph for this function:

◆ twr_analog_sensor_measure()

bool twr_analog_sensor_measure ( twr_analog_sensor_t self)

Start measurement manually.

Parameters
[in]selfInstance
Returns
true On success
false When other measurement is in progress

Definition at line 51 of file twr_analog_sensor.c.

Referenced by twr_analog_sensor_set_update_interval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_analog_sensor_set_event_handler()

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.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 29 of file twr_analog_sensor.c.

◆ twr_analog_sensor_set_update_interval()

void twr_analog_sensor_set_update_interval ( twr_analog_sensor_t self,
twr_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 35 of file twr_analog_sensor.c.

Here is the call graph for this function: