ruuvi.drivers.c
${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
|
Interface for controlling ADC onboard MCU. More...
Go to the source code of this file.
Data Structures | |
struct | ri_adc_pin_config_t |
struct | ri_adc_pins_config_t |
struct | ri_adc_channel_config_t |
struct | ri_adc_config_t |
struct | ri_adc_get_data_t |
Enumerations | |
enum | ri_adc_channel_t { RI_ADC_GND , RI_ADC_AIN0 , RI_ADC_AIN1 , RI_ADC_AIN2 , RI_ADC_AIN3 , RI_ADC_AIN4 , RI_ADC_AIN5 , RI_ADC_AIN6 , RI_ADC_AIN7 , RI_ADC_AINVDD , RI_ADC_CH_NUM } |
Enable implementation selected by application. More... | |
enum | ri_adc_vref_t { RI_ADC_VREF_INTERNAL , RI_ADC_VREF_EXTERNAL } |
enum | ri_adc_mode_t { RI_ADC_MODE_SINGLE } |
enum | ri_adc_oversample_t { RI_ADC_OVERSAMPLE_DISABLED , RI_ADC_OVERSAMPLE_2X , RI_ADC_OVERSAMPLE_4X , RI_ADC_OVERSAMPLE_8X , RI_ADC_OVERSAMPLE_16X , RI_ADC_OVERSAMPLE_32X , RI_ADC_OVERSAMPLE_64X , RI_ADC_OVERSAMPLE_128X , RI_ADC_OVERSAMPLE_256X } |
enum | ri_adc_resolution_t { RI_ADC_RESOLUTION_8BIT , RI_ADC_RESOLUTION_10BIT , RI_ADC_RESOLUTION_12BIT , RI_ADC_RESOLUTION_14BIT } |
enum | ri_adc_gain_t { RI_ADC_GAIN1_6 , RI_ADC_GAIN1_5 , RI_ADC_GAIN1_4 , RI_ADC_GAIN1_3 , RI_ADC_GAIN1_2 , RI_ADC_GAIN1 , RI_ADC_GAIN2 , RI_ADC_GAIN4 } |
Functions | |
bool | ri_adc_is_init (void) |
Check if ADC is initialized. More... | |
rd_status_t | ri_adc_init (ri_adc_config_t *p_config) |
Initialization of ADC. More... | |
rd_status_t | ri_adc_uninit (bool config_default) |
Uninitialize ADC. More... | |
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. More... | |
rd_status_t | ri_adc_stop (uint8_t channel_num) |
Stop use ADC channel. More... | |
rd_status_t | ri_adc_get_raw_data (uint8_t channel_num, int16_t *p_data) |
Get raw ADC data. More... | |
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. More... | |
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. More... | |
bool | ri_adc_mcu_is_valid_ch (const uint8_t ch) |
Return true if given channel index can be used by underlying implementation. More... | |
Interface for controlling ADC onboard MCU.
Definition in file ruuvi_interface_adc_mcu.h.
enum ri_adc_channel_t |
Enable implementation selected by application.
Definition at line 27 of file ruuvi_interface_adc_mcu.h.
enum ri_adc_gain_t |
Enumerator | |
---|---|
RI_ADC_GAIN1_6 | |
RI_ADC_GAIN1_5 | |
RI_ADC_GAIN1_4 | |
RI_ADC_GAIN1_3 | |
RI_ADC_GAIN1_2 | |
RI_ADC_GAIN1 | |
RI_ADC_GAIN2 | |
RI_ADC_GAIN4 |
Definition at line 104 of file ruuvi_interface_adc_mcu.h.
enum ri_adc_mode_t |
Enumerator | |
---|---|
RI_ADC_MODE_SINGLE | Single ended mode. |
Definition at line 50 of file ruuvi_interface_adc_mcu.h.
enum ri_adc_oversample_t |
Definition at line 59 of file ruuvi_interface_adc_mcu.h.
enum ri_adc_resolution_t |
Enumerator | |
---|---|
RI_ADC_RESOLUTION_8BIT | |
RI_ADC_RESOLUTION_10BIT | |
RI_ADC_RESOLUTION_12BIT | |
RI_ADC_RESOLUTION_14BIT |
Definition at line 73 of file ruuvi_interface_adc_mcu.h.
enum ri_adc_vref_t |
Enumerator | |
---|---|
RI_ADC_VREF_INTERNAL | Internal voltage reference. |
RI_ADC_VREF_EXTERNAL | External voltage reference. |
Definition at line 43 of file ruuvi_interface_adc_mcu.h.
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.
[in] | channel_num | ADC channel. |
[in] | p_pins | ADC pin config. |
[in] | p_config | ADC channel config. |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_STATE | if ADC channel is locked. |
RD_ERROR_INVALID_PARAM | if input channel incorrect. |
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.
[in] | channel_num | ADC channel. |
[in] | p_config | ADC output config. |
[out] | p_data | ADC data in volts. |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_PARAM | if input incorrect. |
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.
[in] | channel_num | ADC channel. |
[in] | p_config | ADC output config. |
[out] | p_data | ADC data as a ratio to VDD. |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_PARAM | if input incorrect. |
rd_status_t ri_adc_get_raw_data | ( | uint8_t | channel_num, |
int16_t * | p_data | ||
) |
Get raw ADC data.
[in] | channel_num | ADC channel. |
[in,out] | p_data | raw ADC data. |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_STATE | if ADC channel is locked. |
rd_status_t ri_adc_init | ( | ri_adc_config_t * | p_config | ) |
Initialization of ADC.
[in] | p_config | Configuration of ADC. |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_STATE | if ADC is already initialized or smth goes wrong. |
bool ri_adc_is_init | ( | void | ) |
Check if ADC is initialized.
true | if ADC is initialized. |
false | if ADC is not initialized. |
bool ri_adc_mcu_is_valid_ch | ( | const uint8_t | ch | ) |
Return true if given channel index can be used by underlying implementation.
[in] | ch | Channel to check. |
true | Channel can be used (but might be reserved). |
false | Channel is out of bounds. |
rd_status_t ri_adc_stop | ( | uint8_t | channel_num | ) |
Stop use ADC channel.
[in] | channel_num | ADC channel |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_STATE | if ADC channel is locked. |
RD_ERROR_INVALID_PARAM | if input channel incorrect. |
rd_status_t ri_adc_uninit | ( | bool | config_default | ) |
Uninitialize ADC.
[in] | config_default | Reset config to default. |
RD_SUCCESS | on success. |
RD_ERROR_INVALID_STATE | if ADC lock can't be released. Reboot. |