Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_adc.h
1 #ifndef _BC_ADC_H
2 #define _BC_ADC_H
3 
4 #include <bc_common.h>
5 #include <stm32l083xx.h>
6 
10 
12 
13 typedef enum
14 {
17 
20 
23 
26 
29 
32 
34 
36 
37 typedef enum
38 {
41 
44 
47 
50 
53 
56 
59 
62 
65 
67 
69 
70 typedef enum
71 {
74 
76  BC_ADC_RESOLUTION_10_BIT = ADC_CFGR1_RES_0,
77 
79  BC_ADC_RESOLUTION_8_BIT = ADC_CFGR1_RES_1,
80 
82  BC_ADC_RESOLUTION_6_BIT = ADC_CFGR1_RES_1 | ADC_CFGR1_RES_0,
83 
85 
87 
88 typedef enum
89 {
92 
94 
96 
97 void bc_adc_init();
98 
102 
103 bool bc_adc_is_ready();
104 
110 
111 bool bc_adc_get_value(bc_adc_channel_t channel, uint16_t *result);
112 
119 
120 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);
121 
126 
128 
134 
135 bool bc_adc_async_get_value(bc_adc_channel_t channel, uint16_t *result);
136 
142 
143 bool bc_adc_async_get_voltage(bc_adc_channel_t channel, float *result);
144 
149 
150 bool bc_adc_get_vdda_voltage(float *vdda_voltage);
151 
155 
156 bool bc_adc_calibration(void);
157 
161 
163 
167 
169 
171 
172 #endif // _BC_ADC_H
void bc_adc_resolution_set(bc_adc_channel_t channel, bc_adc_resolution_t resolution)
Set ADC resolution for specific channel.
Definition: bc_adc.c:104
ADC 256x oversampling.
Definition: bc_adc.h:64
bool bc_adc_calibration(void)
Calibration.
Definition: bc_adc.c:342
ADC 32x oversampling.
Definition: bc_adc.h:55
ADC 2x oversampling.
Definition: bc_adc.h:43
ADC 16x oversampling.
Definition: bc_adc.h:52
ADC 10 bit resolution.
Definition: bc_adc.h:76
bc_adc_oversampling_t
ADC oversampling.
Definition: bc_adc.h:37
ADC 6 bit resolution.
Definition: bc_adc.h:82
ADC channel A2.
Definition: bc_adc.h:22
ADC channel A4.
Definition: bc_adc.h:28
ADC 4x oversampling.
Definition: bc_adc.h:46
ADC 8 bit resolution.
Definition: bc_adc.h:79
void bc_adc_oversampling_set(bc_adc_channel_t channel, bc_adc_oversampling_t oversampling)
Set ADC oversampling for specific channel.
Definition: bc_adc.c:99
void bc_adc_init()
Initialize ADC converter.
Definition: bc_adc.c:64
ADC 8x oversampling.
Definition: bc_adc.h:49
ADC channel A5.
Definition: bc_adc.h:31
bool bc_adc_async_get_voltage(bc_adc_channel_t channel, float *result)
Get asynchronous measurement result in volts.
Definition: bc_adc.c:278
bool bc_adc_async_get_value(bc_adc_channel_t channel, uint16_t *result)
Get asynchronous measurement result.
Definition: bc_adc.c:272
ADC channel A0.
Definition: bc_adc.h:16
ADC channel A1.
Definition: bc_adc.h:19
ADC no oversampling.
Definition: bc_adc.h:40
ADC 128x oversampling.
Definition: bc_adc.h:61
bc_adc_resolution_t
ADC resolution.
Definition: bc_adc.h:70
bool bc_adc_get_vdda_voltage(float *vdda_voltage)
Get voltage on VDDA pin.
Definition: bc_adc.c:284
ADC 12 bit resolution.
Definition: bc_adc.h:73
bc_adc_event_t
ADC event.
Definition: bc_adc.h:88
bool bc_adc_async_measure(bc_adc_channel_t channel)
Begins reading the ADC channel voltage in asynchronous mode.
Definition: bc_adc.c:232
ADC 64x oversampling.
Definition: bc_adc.h:58
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.
Definition: bc_adc.c:216
ADC channel A3.
Definition: bc_adc.h:25
bc_adc_channel_t
ADC channel.
Definition: bc_adc.h:13
ADC event.
Definition: bc_adc.h:91
bool bc_adc_get_value(bc_adc_channel_t channel, uint16_t *result)
Reads the ADC channel value.
Definition: bc_adc.c:176
bool bc_adc_is_ready()
Check if ADC is ready for reading.
Definition: bc_adc.c:171