Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_analog_sensor

Driver for generic analog sensor. More...

Data Structures

struct  bc_analog_sensor_driver_t
 Analog sensor driver interface. More...
 

Typedefs

typedef struct bc_analog_sensor_t bc_analog_sensor_t
 Analog sensor instance.
 

Enumerations

enum  bc_analog_sensor_event_t {
  BC_ANALOG_SENSOR_EVENT_ERROR = 0,
  BC_ANALOG_SENSOR_EVENT_UPDATE = 1
}
 Callback events. More...
 

Functions

void bc_analog_sensor_init (bc_analog_sensor_t *self, bc_adc_channel_t adc_channel, const bc_analog_sensor_driver_t *driver)
 Initialize generic analog sensor. More...
 
void bc_analog_sensor_set_event_handler (bc_analog_sensor_t *self, void(*event_handler)(bc_analog_sensor_t *, bc_analog_sensor_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_analog_sensor_set_update_interval (bc_analog_sensor_t *self, bc_tick_t interval)
 Set measurement interval. More...
 
bool bc_analog_sensor_measure (bc_analog_sensor_t *self)
 Start measurement manually. More...
 
bool bc_analog_sensor_get_result (bc_analog_sensor_t *self, void *result)
 Get measurement result. More...
 

Detailed Description

Driver for generic analog sensor.

Enumeration Type Documentation

Callback events.

Enumerator
BC_ANALOG_SENSOR_EVENT_ERROR 

Error event.

BC_ANALOG_SENSOR_EVENT_UPDATE 

Update event.

Definition at line 13 of file bc_analog_sensor.h.

Function Documentation

bool bc_analog_sensor_get_result ( bc_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
void bc_analog_sensor_init ( bc_analog_sensor_t self,
bc_adc_channel_t  adc_channel,
const bc_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 bc_analog_sensor.c.

Here is the call graph for this function:

bool bc_analog_sensor_measure ( bc_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 bc_analog_sensor.c.

Referenced by bc_analog_sensor_set_update_interval().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_analog_sensor_set_event_handler ( bc_analog_sensor_t self,
void(*)(bc_analog_sensor_t *, bc_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 bc_analog_sensor.c.

void bc_analog_sensor_set_update_interval ( bc_analog_sensor_t self,
bc_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 35 of file bc_analog_sensor.c.

Here is the call graph for this function: