ruuvi.drivers.c ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
Loading...
Searching...
No Matches
ruuvi_interface_adc_mcu.h
Go to the documentation of this file.
1#ifndef RUUVI_INTERFACE_ADC_MCU_H
2#define RUUVI_INTERFACE_ADC_MCU_H
22#if RI_ADC_ENABLED
23# define RUUVI_NRF5_SDK15_ADC_ENABLED RUUVI_NRF5_SDK15_ENABLED
24#endif
25
26/* Analog input channels of device */
41
42/* ADC reference voltage. */
48
49/* ADC mode */
50typedef enum
51{
53#ifdef RI_ADC_ADV_MODE_CONFIG
54 RI_ADC_MODE_DIFFERENTIAL
55#endif
57
58/* ADC oversampling mode. */
71
72/* ADC resolutions. */
80
81#ifdef RI_ADC_ADV_CONFIG
82/* ADC pin resistor. */
83typedef enum
84{
85 RI_ADC_RESISTOR_DISABLED,
86 RI_ADC_RESISTOR_PULLDOWN,
87 RI_ADC_RESISTOR_PULLUP,
88 RI_ADC_RESISTOR_VDD1_2,
89} nri_adc_resistor_t;
90
91/* ADC acq_time. */
92typedef enum
93{
94 RI_ADC_ACQTIME_3US,
95 RI_ADC_ACQTIME_5US,
96 RI_ADC_ACQTIME_10US,
97 RI_ADC_ACQTIME_15US,
98 RI_ADC_ACQTIME_20US,
99 RI_ADC_ACQTIME_40US,
100} ri_adc_acqtime_t;
101#endif
102
103/* ADC gain. */
115
116/* ADC pin config struct. */
117typedef struct
118{
120#ifdef RI_ADC_ADV_CONFIG
121 nri_adc_resistor_t resistor;
122#endif
124
125/* ADC x2 pins config struct. */
126typedef struct
127{
129#ifdef RI_ADC_ADV_MODE_CONFIG
131#endif
133
134/* ADC channel config struct. */
135typedef struct
136{
140#ifdef RI_ADC_ADV_CONFIG
141 ri_adc_acqtime_t acqtime;
142#endif
144
145/* ADC config struct. */
151
152/* ADC result config struct. */
153typedef struct
154{
155 float vdd;
156 float divider;
158
165bool ri_adc_is_init (void);
175
183rd_status_t ri_adc_uninit (bool config_default);
184
196rd_status_t ri_adc_configure (uint8_t channel_num,
197 ri_adc_pins_config_t * p_pins,
198 ri_adc_channel_config_t * p_config);
199
208rd_status_t ri_adc_stop (uint8_t channel_num);
209
218rd_status_t ri_adc_get_raw_data (uint8_t channel_num,
219 int16_t * p_data);
220
232 ri_adc_get_data_t * p_config,
233 float * p_data);
234
246 ri_adc_get_data_t * p_config,
247 float * p_data);
248
256bool ri_adc_mcu_is_valid_ch (const uint8_t ch);
257#endif
uint32_t rd_status_t
bitfield for representing errors
Ruuvi error codes and error check function.
Ruuvi sensor interface Lifecycle: Beta
rd_status_t ri_adc_uninit(bool config_default)
Uninitialize ADC.
rd_status_t ri_adc_get_raw_data(uint8_t channel_num, int16_t *p_data)
Get raw ADC data.
@ RI_ADC_MODE_SINGLE
Single ended mode.
@ RI_ADC_VREF_EXTERNAL
External voltage reference.
@ RI_ADC_VREF_INTERNAL
Internal voltage reference.
rd_status_t ri_adc_get_data_ratio(uint8_t channel_num, ri_adc_get_data_t *p_config, float *p_data)
Get ADC data in volts.
@ RI_ADC_RESOLUTION_8BIT
@ RI_ADC_RESOLUTION_14BIT
@ RI_ADC_RESOLUTION_10BIT
@ RI_ADC_RESOLUTION_12BIT
rd_status_t ri_adc_get_data_absolute(uint8_t channel_num, ri_adc_get_data_t *p_config, float *p_data)
Get ADC data in volts.
ri_adc_channel_t
Enable implementation selected by application.
@ RI_ADC_CH_NUM
Number of ADC inputs.
@ RI_ADC_AIN4
Channel 4 of ADC.
@ RI_ADC_AIN6
Channel 6 of ADC.
@ RI_ADC_AIN0
Channel 0 of ADC.
@ RI_ADC_AIN1
Channel 1 of ADC.
@ RI_ADC_AIN3
Channel 3 of ADC.
@ RI_ADC_AINVDD
Analog supply voltage.
@ RI_ADC_AIN2
Channel 2 of ADC.
@ RI_ADC_AIN5
Channel 5 of ADC.
@ RI_ADC_AIN7
Channel 7 of ADC.
@ RI_ADC_GND
GND of device.
bool ri_adc_mcu_is_valid_ch(const uint8_t ch)
Return true if given channel index can be used by underlying implementation.
@ RI_ADC_OVERSAMPLE_DISABLED
@ RI_ADC_OVERSAMPLE_128X
@ RI_ADC_OVERSAMPLE_8X
@ RI_ADC_OVERSAMPLE_256X
@ RI_ADC_OVERSAMPLE_4X
@ RI_ADC_OVERSAMPLE_16X
@ RI_ADC_OVERSAMPLE_64X
@ RI_ADC_OVERSAMPLE_32X
@ RI_ADC_OVERSAMPLE_2X
rd_status_t ri_adc_stop(uint8_t channel_num)
Stop use ADC channel.
rd_status_t ri_adc_configure(uint8_t channel_num, ri_adc_pins_config_t *p_pins, ri_adc_channel_config_t *p_config)
Configure ADC channel.
rd_status_t ri_adc_init(ri_adc_config_t *p_config)
Initialization of ADC.
bool ri_adc_is_init(void)
Check if ADC is initialized.
ri_adc_oversample_t oversample
ri_adc_resolution_t resolution