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

Driver for ADC (analog to digital converter) More...

Enumerations

enum  bc_adc_channel_t {
  BC_ADC_CHANNEL_A0 = 0,
  BC_ADC_CHANNEL_A1 = 1,
  BC_ADC_CHANNEL_A2 = 2,
  BC_ADC_CHANNEL_A3 = 3,
  BC_ADC_CHANNEL_A4 = 4,
  BC_ADC_CHANNEL_A5 = 5
}
 ADC channel. More...
 
enum  bc_adc_oversampling_t {
  BC_ADC_OVERSAMPLING_NONE = 0,
  BC_ADC_OVERSAMPLING_2 = 1,
  BC_ADC_OVERSAMPLING_4 = 2,
  BC_ADC_OVERSAMPLING_8 = 3,
  BC_ADC_OVERSAMPLING_16 = 4,
  BC_ADC_OVERSAMPLING_32 = 5,
  BC_ADC_OVERSAMPLING_64 = 6,
  BC_ADC_OVERSAMPLING_128 = 7,
  BC_ADC_OVERSAMPLING_256 = 8
}
 ADC oversampling. More...
 
enum  bc_adc_resolution_t {
  BC_ADC_RESOLUTION_12_BIT = 0,
  BC_ADC_RESOLUTION_10_BIT = ADC_CFGR1_RES_0,
  BC_ADC_RESOLUTION_8_BIT = ADC_CFGR1_RES_1,
  BC_ADC_RESOLUTION_6_BIT = ADC_CFGR1_RES_1 | ADC_CFGR1_RES_0
}
 ADC resolution. More...
 
enum  bc_adc_event_t { BC_ADC_EVENT_DONE }
 ADC event. More...
 

Functions

void bc_adc_init ()
 Initialize ADC converter.
 
bool bc_adc_is_ready ()
 Check if ADC is ready for reading. More...
 
bool bc_adc_get_value (bc_adc_channel_t channel, uint16_t *result)
 Reads the ADC channel value. More...
 
bool bc_adc_set_event_handler (bc_adc_channel_t channel, void(*event_handler)(bc_adc_channel_t, bc_adc_event_t, void *), void *event_param)
 Set callback function. More...
 
bool bc_adc_async_measure (bc_adc_channel_t channel)
 Begins reading the ADC channel voltage in asynchronous mode. More...
 
bool bc_adc_async_get_value (bc_adc_channel_t channel, uint16_t *result)
 Get asynchronous measurement result. More...
 
bool bc_adc_async_get_voltage (bc_adc_channel_t channel, float *result)
 Get asynchronous measurement result in volts. More...
 
bool bc_adc_get_vdda_voltage (float *vdda_voltage)
 Get voltage on VDDA pin. More...
 
bool bc_adc_calibration (void)
 Calibration. More...
 
void bc_adc_resolution_set (bc_adc_channel_t channel, bc_adc_resolution_t resolution)
 Set ADC resolution for specific channel. More...
 
void bc_adc_oversampling_set (bc_adc_channel_t channel, bc_adc_oversampling_t oversampling)
 Set ADC oversampling for specific channel. More...
 

Detailed Description

Driver for ADC (analog to digital converter)

Enumeration Type Documentation

ADC channel.

Enumerator
BC_ADC_CHANNEL_A0 

ADC channel A0.

BC_ADC_CHANNEL_A1 

ADC channel A1.

BC_ADC_CHANNEL_A2 

ADC channel A2.

BC_ADC_CHANNEL_A3 

ADC channel A3.

BC_ADC_CHANNEL_A4 

ADC channel A4.

BC_ADC_CHANNEL_A5 

ADC channel A5.

Definition at line 13 of file bc_adc.h.

ADC event.

Enumerator
BC_ADC_EVENT_DONE 

ADC event.

Definition at line 88 of file bc_adc.h.

ADC oversampling.

Enumerator
BC_ADC_OVERSAMPLING_NONE 

ADC no oversampling.

BC_ADC_OVERSAMPLING_2 

ADC 2x oversampling.

BC_ADC_OVERSAMPLING_4 

ADC 4x oversampling.

BC_ADC_OVERSAMPLING_8 

ADC 8x oversampling.

BC_ADC_OVERSAMPLING_16 

ADC 16x oversampling.

BC_ADC_OVERSAMPLING_32 

ADC 32x oversampling.

BC_ADC_OVERSAMPLING_64 

ADC 64x oversampling.

BC_ADC_OVERSAMPLING_128 

ADC 128x oversampling.

BC_ADC_OVERSAMPLING_256 

ADC 256x oversampling.

Definition at line 37 of file bc_adc.h.

ADC resolution.

Enumerator
BC_ADC_RESOLUTION_12_BIT 

ADC 12 bit resolution.

BC_ADC_RESOLUTION_10_BIT 

ADC 10 bit resolution.

BC_ADC_RESOLUTION_8_BIT 

ADC 8 bit resolution.

BC_ADC_RESOLUTION_6_BIT 

ADC 6 bit resolution.

Definition at line 70 of file bc_adc.h.

Function Documentation

bool bc_adc_async_get_value ( bc_adc_channel_t  channel,
uint16_t *  result 
)

Get asynchronous measurement result.

Parameters
[in]channelADC channel
[out]resultPointer to variable where result will be stored
Returns
true On success
false On failure

Definition at line 272 of file bc_adc.c.

bool bc_adc_async_get_voltage ( bc_adc_channel_t  channel,
float *  result 
)

Get asynchronous measurement result in volts.

Parameters
[in]channelADC channel
[out]resultPointer to variable where result in volts will be stored
Returns
true On success
false On failure

Definition at line 278 of file bc_adc.c.

bool bc_adc_async_measure ( bc_adc_channel_t  channel)

Begins reading the ADC channel voltage in asynchronous mode.

Parameters
[in]channelADC channel
Returns
true On success
false On failure

Definition at line 232 of file bc_adc.c.

Here is the call graph for this function:

bool bc_adc_calibration ( void  )

Calibration.

Returns
true On success
false On failure

Definition at line 342 of file bc_adc.c.

Referenced by bc_adc_init().

Here is the caller graph for this function:

bool bc_adc_get_value ( bc_adc_channel_t  channel,
uint16_t *  result 
)

Reads the ADC channel value.

Parameters
[in]channelADC channel
[out]resultPointer to destination where ADC conversion will be stored
Returns
true On success
false On failure

Definition at line 176 of file bc_adc.c.

bool bc_adc_get_vdda_voltage ( float *  vdda_voltage)

Get voltage on VDDA pin.

Parameters
[out]vdda_voltagePointer to destination where VDDA will be stored
Returns
true On valid VDDA
false On valid VDDA

Definition at line 284 of file bc_adc.c.

bool bc_adc_is_ready ( )

Check if ADC is ready for reading.

Returns
true If ready
false If not ready

Definition at line 171 of file bc_adc.c.

void bc_adc_oversampling_set ( bc_adc_channel_t  channel,
bc_adc_oversampling_t  oversampling 
)

Set ADC oversampling for specific channel.

Parameters
[in]channelADC channel
[in]oversamplingOversampling can be 2, 4, 8, 16, 32, 64, 128 or 256

Definition at line 99 of file bc_adc.c.

void bc_adc_resolution_set ( bc_adc_channel_t  channel,
bc_adc_resolution_t  resolution 
)

Set ADC resolution for specific channel.

Parameters
[in]channelADC channel
[in]resolutionResolution can be 6, 8, 10 or 12 bit

Definition at line 104 of file bc_adc.c.

bool bc_adc_set_event_handler ( bc_adc_channel_t  channel,
void(*)(bc_adc_channel_t, bc_adc_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]channelADC channel
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)
Returns
true On success
false On failure

Definition at line 216 of file bc_adc.c.

Referenced by bc_analog_sensor_init().

Here is the caller graph for this function: