Intel® Quark™ Microcontroller Software Interface
1.4.0
Intel® Quark™ Microcontroller BSP
|
Analog to Digital Converter (ADC). More...
Data Structures | |
struct | qm_adc_config_t |
ADC configuration type. More... | |
struct | qm_adc_xfer_t |
ADC transfer type. More... | |
Typedefs | |
typedef uint16_t | qm_adc_sample_t |
ADC sample size type. | |
typedef uint8_t | qm_adc_calibration_t |
ADC calibration type. | |
Enumerations | |
enum | qm_adc_status_t { QM_ADC_IDLE, QM_ADC_COMPLETE, QM_ADC_OVERFLOW } |
enum | qm_adc_resolution_t { QM_ADC_RES_6_BITS, QM_ADC_RES_8_BITS, QM_ADC_RES_10_BITS, QM_ADC_RES_12_BITS } |
ADC resolution type. More... | |
enum | qm_adc_mode_t { QM_ADC_MODE_DEEP_PWR_DOWN, QM_ADC_MODE_PWR_DOWN, QM_ADC_MODE_STDBY, QM_ADC_MODE_NORM_CAL, QM_ADC_MODE_NORM_NO_CAL } |
ADC operating mode type. More... | |
enum | qm_adc_channel_t { QM_ADC_CH_0, QM_ADC_CH_1, QM_ADC_CH_2, QM_ADC_CH_3, QM_ADC_CH_4, QM_ADC_CH_5, QM_ADC_CH_6, QM_ADC_CH_7, QM_ADC_CH_8, QM_ADC_CH_9, QM_ADC_CH_10, QM_ADC_CH_11, QM_ADC_CH_12, QM_ADC_CH_13, QM_ADC_CH_14, QM_ADC_CH_15, QM_ADC_CH_16, QM_ADC_CH_17, QM_ADC_CH_18 } |
ADC channels type. More... | |
enum | qm_adc_cb_source_t { QM_ADC_TRANSFER, QM_ADC_MODE_CHANGED, QM_ADC_CAL_COMPLETE } |
ADC interrupt callback source. More... | |
Functions | |
int | qm_adc_set_mode (const qm_adc_t adc, const qm_adc_mode_t mode) |
Switch operating mode of ADC. More... | |
int | qm_adc_irq_set_mode (const qm_adc_t adc, const qm_adc_mode_t mode, void(*callback)(void *data, int error, qm_adc_status_t status, qm_adc_cb_source_t source), void *callback_data) |
Switch operating mode of ADC. More... | |
int | qm_adc_calibrate (const qm_adc_t adc) |
Calibrate the ADC. More... | |
int | qm_adc_irq_calibrate (const qm_adc_t adc, void(*callback)(void *data, int error, qm_adc_status_t status, qm_adc_cb_source_t source), void *callback_data) |
Calibrate the ADC. More... | |
int | qm_adc_set_calibration (const qm_adc_t adc, const qm_adc_calibration_t cal) |
Set ADC calibration data. More... | |
int | qm_adc_get_calibration (const qm_adc_t adc, qm_adc_calibration_t *const cal) |
Get the current calibration data for an ADC. More... | |
int | qm_adc_set_config (const qm_adc_t adc, const qm_adc_config_t *const cfg) |
Set ADC configuration. More... | |
int | qm_adc_convert (const qm_adc_t adc, qm_adc_xfer_t *const xfer, qm_adc_status_t *const status) |
Synchronously read values from the ADC. More... | |
int | qm_adc_irq_convert (const qm_adc_t adc, qm_adc_xfer_t *const xfer) |
Asynchronously read values from the ADC. More... | |
Analog to Digital Converter (ADC).
enum qm_adc_cb_source_t |
enum qm_adc_channel_t |
ADC channels type.
enum qm_adc_mode_t |
enum qm_adc_resolution_t |
enum qm_adc_status_t |
int qm_adc_calibrate | ( | const qm_adc_t | adc | ) |
Calibrate the ADC.
It is necessary to calibrate if it is intended to use Normal Mode With Calibration. The calibration must be performed if the ADC is used for the first time or has been in deep power down mode. This call is blocking.
[in] | adc | Which ADC to calibrate. |
0 | on success. |
Negative | errno for possible error codes. |
int qm_adc_convert | ( | const qm_adc_t | adc, |
qm_adc_xfer_t *const | xfer, | ||
qm_adc_status_t *const | status | ||
) |
Synchronously read values from the ADC.
This blocking call can read 1-32 ADC values into the array provided.
[in] | adc | Which ADC to read. |
[in,out] | xfer | Channel and sample info. This must not be NULL. |
[out] | status | Get status of the ADC device. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 345 of file qm_adc.c.
References qm_adc_xfer_t::ch, qm_adc_xfer_t::ch_len, QM_ADC_COMPLETE, qm_adc_xfer_t::samples, and qm_adc_xfer_t::samples_len.
int qm_adc_get_calibration | ( | const qm_adc_t | adc, |
qm_adc_calibration_t *const | cal | ||
) |
int qm_adc_irq_calibrate | ( | const qm_adc_t | adc, |
void(*)(void *data, int error, qm_adc_status_t status, qm_adc_cb_source_t source) | callback, | ||
void * | callback_data | ||
) |
Calibrate the ADC.
It is necessary to calibrate if it is intended to use Normal Mode With Calibration. The calibration must be performed if the ADC is used for the first time or has been in deep power down mode. This call is non-blocking and will call the user callback on completion.
[in] | adc | Which ADC to calibrate. |
[in] | callback | Callback called on completion. |
[in] | callback_data | The callback user data. |
0 | on success. |
Negative | errno for possible error codes. |
int qm_adc_irq_convert | ( | const qm_adc_t | adc, |
qm_adc_xfer_t *const | xfer | ||
) |
Asynchronously read values from the ADC.
This is a non-blocking call and will call the user provided callback after the requested number of samples have been converted.
[in] | adc | Which ADC to read. |
[in,out] | xfer | Channel sample and callback info. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 391 of file qm_adc.c.
References qm_adc_xfer_t::ch, qm_adc_xfer_t::ch_len, qm_adc_xfer_t::samples, and qm_adc_xfer_t::samples_len.
int qm_adc_irq_set_mode | ( | const qm_adc_t | adc, |
const qm_adc_mode_t | mode, | ||
void(*)(void *data, int error, qm_adc_status_t status, qm_adc_cb_source_t source) | callback, | ||
void * | callback_data | ||
) |
Switch operating mode of ADC.
This call is non-blocking and will call the user callback on completion.
[in] | adc | Which ADC to enable. |
[in] | mode | ADC operating mode. |
[in] | callback | Callback called on completion. |
[in] | callback_data | The callback user data. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 302 of file qm_adc.c.
References QM_ADC_MODE_NORM_CAL, and QM_ADC_MODE_NORM_NO_CAL.
int qm_adc_set_calibration | ( | const qm_adc_t | adc, |
const qm_adc_calibration_t | cal | ||
) |
int qm_adc_set_config | ( | const qm_adc_t | adc, |
const qm_adc_config_t *const | cfg | ||
) |
Set ADC configuration.
This sets the sample window and resolution.
[in] | adc | Which ADC to configure. |
[in] | cfg | ADC configuration. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 329 of file qm_adc.c.
References QM_ADC_RES_12_BITS, qm_adc_config_t::resolution, and qm_adc_config_t::window.
int qm_adc_set_mode | ( | const qm_adc_t | adc, |
const qm_adc_mode_t | mode | ||
) |
Switch operating mode of ADC.
This call is blocking.
[in] | adc | Which ADC to enable. |
[in] | mode | ADC operating mode. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 271 of file qm_adc.c.
References QM_ADC_MODE_NORM_CAL, and QM_ADC_MODE_NORM_NO_CAL.
Referenced by qm_power_soc_deep_sleep(), and qm_power_soc_sleep().