Intel® Quark™ Microcontroller Software Interface
1.4.0
Intel® Quark™ Microcontroller BSP
|
Analog to Digital Converter (ADC) for the Sensor Subsystem. More...
Data Structures | |
struct | qm_ss_adc_config_t |
SS ADC configuration type. More... | |
struct | qm_ss_adc_xfer_t |
SS ADC transfer type. More... | |
Typedefs | |
typedef uint16_t | qm_ss_adc_sample_t |
SS ADC sample size type. | |
typedef uint8_t | qm_ss_adc_calibration_t |
SS ADC calibration type. | |
Functions | |
int | qm_ss_adc_set_mode (const qm_ss_adc_t adc, const qm_ss_adc_mode_t mode) |
Switch operating mode of SS ADC. More... | |
int | qm_ss_adc_irq_set_mode (const qm_ss_adc_t adc, const qm_ss_adc_mode_t mode, void(*callback)(void *data, int error, qm_ss_adc_status_t status, qm_ss_adc_cb_source_t source), void *callback_data) |
Switch operating mode of SS ADC. More... | |
int | qm_ss_adc_calibrate (const qm_ss_adc_t adc) |
Calibrate the SS ADC. More... | |
int | qm_ss_adc_irq_calibrate (const qm_ss_adc_t adc, void(*callback)(void *data, int error, qm_ss_adc_status_t status, qm_ss_adc_cb_source_t source), void *callback_data) |
Calibrate the SS ADC. More... | |
int | qm_ss_adc_set_calibration (const qm_ss_adc_t adc, const qm_ss_adc_calibration_t cal) |
Set SS ADC calibration data. More... | |
int | qm_ss_adc_get_calibration (const qm_ss_adc_t adc, qm_ss_adc_calibration_t *const cal) |
Get the current calibration data for an SS ADC. More... | |
int | qm_ss_adc_set_config (const qm_ss_adc_t adc, const qm_ss_adc_config_t *const cfg) |
Set SS ADC configuration. More... | |
int | qm_ss_adc_convert (const qm_ss_adc_t adc, qm_ss_adc_xfer_t *const xfer, qm_ss_adc_status_t *const status) |
Synchronously read values from the ADC. More... | |
int | qm_ss_adc_irq_convert (const qm_ss_adc_t adc, qm_ss_adc_xfer_t *const xfer) |
Asynchronously read values from the SS ADC. More... | |
int | qm_ss_adc_save_context (const qm_ss_adc_t adc, qm_ss_adc_context_t *const ctx) |
Save SS ADC context. More... | |
int | qm_ss_adc_restore_context (const qm_ss_adc_t adc, const qm_ss_adc_context_t *const ctx) |
Restore SS ADC context. More... | |
Analog to Digital Converter (ADC) for the Sensor Subsystem.
SS ADC interrupt callback source.
Enumerator | |
---|---|
QM_SS_ADC_TRANSFER |
Transfer complete or error callback. |
QM_SS_ADC_MODE_CHANGED |
Mode change complete callback. |
QM_SS_ADC_CAL_COMPLETE |
Calibration complete callback. |
Definition at line 89 of file qm_ss_adc.h.
enum qm_ss_adc_channel_t |
SS ADC channels type.
Definition at line 64 of file qm_ss_adc.h.
enum qm_ss_adc_mode_t |
SS ADC operating mode type.
Definition at line 53 of file qm_ss_adc.h.
SS ADC resolution type.
Enumerator | |
---|---|
QM_SS_ADC_RES_6_BITS |
6-bit mode. |
QM_SS_ADC_RES_8_BITS |
8-bit mode. |
QM_SS_ADC_RES_10_BITS |
10-bit mode. |
QM_SS_ADC_RES_12_BITS |
12-bit mode. |
Definition at line 43 of file qm_ss_adc.h.
enum qm_ss_adc_status_t |
SS ADC status.
Enumerator | |
---|---|
QM_SS_ADC_IDLE |
ADC idle. |
QM_SS_ADC_COMPLETE |
ADC data available. |
QM_SS_ADC_OVERFLOW |
ADC overflow error. |
QM_SS_ADC_UNDERFLOW |
ADC underflow error. |
QM_SS_ADC_SEQERROR |
ADC sequencer error. |
Definition at line 32 of file qm_ss_adc.h.
int qm_ss_adc_calibrate | ( | const qm_ss_adc_t | adc | ) |
Calibrate the SS 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_ss_adc_convert | ( | const qm_ss_adc_t | adc, |
qm_ss_adc_xfer_t *const | xfer, | ||
qm_ss_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 564 of file qm_ss_adc.c.
References qm_ss_adc_xfer_t::ch, qm_ss_adc_xfer_t::ch_len, QM_SS_ADC_CTRL, QM_SS_ADC_INTSTAT, QM_SS_ADC_SAMPLE, QM_SS_ADC_SET, qm_ss_adc_xfer_t::samples, and qm_ss_adc_xfer_t::samples_len.
int qm_ss_adc_get_calibration | ( | const qm_ss_adc_t | adc, |
qm_ss_adc_calibration_t *const | cal | ||
) |
Get the current calibration data for an SS ADC.
[in] | adc | Which ADC to get calibration for. |
[out] | cal | Calibration data. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
int qm_ss_adc_irq_calibrate | ( | const qm_ss_adc_t | adc, |
void(*)(void *data, int error, qm_ss_adc_status_t status, qm_ss_adc_cb_source_t source) | callback, | ||
void * | callback_data | ||
) |
Calibrate the SS 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. |
Definition at line 479 of file qm_ss_adc.c.
References QM_SS_IO_CREG_MST0_CTRL.
int qm_ss_adc_irq_convert | ( | const qm_ss_adc_t | adc, |
qm_ss_adc_xfer_t *const | xfer | ||
) |
Asynchronously read values from the SS 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 638 of file qm_ss_adc.c.
References qm_ss_adc_xfer_t::ch, qm_ss_adc_xfer_t::ch_len, QM_SS_ADC_CTRL, QM_SS_ADC_SET, qm_ss_adc_xfer_t::samples, and qm_ss_adc_xfer_t::samples_len.
int qm_ss_adc_irq_set_mode | ( | const qm_ss_adc_t | adc, |
const qm_ss_adc_mode_t | mode, | ||
void(*)(void *data, int error, qm_ss_adc_status_t status, qm_ss_adc_cb_source_t source) | callback, | ||
void * | callback_data | ||
) |
Switch operating mode of SS ADC.
This call is non-blocking and will call the user callback on completion. An interrupt will not be generated if the user requests the same mode the ADC is currently in (default mode on boot is deep power down).
[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 405 of file qm_ss_adc.c.
References QM_SS_ADC_MODE_NORM_NO_CAL, and QM_SS_IO_CREG_MST0_CTRL.
int qm_ss_adc_restore_context | ( | const qm_ss_adc_t | adc, |
const qm_ss_adc_context_t *const | ctx | ||
) |
Restore SS ADC context.
Restore the configuration of the specified ADC peripheral after exiting sleep.
Note: Previous calibration data is not restored with this function, the user may need to recalibrate the ADC. The user will need to set the ADC_ENA bit in the ADC Control register as it is initialized to 0.
[in] | adc | SS ADC port index. |
[in] | ctx | SS ADC context structure. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 712 of file qm_ss_adc.c.
References qm_ss_adc_context_t::adc_ctrl, qm_ss_adc_context_t::adc_divseqstat, qm_ss_adc_context_t::adc_seq, qm_ss_adc_context_t::adc_set, QM_SS_ADC_CTRL, QM_SS_ADC_DIVSEQSTAT, QM_SS_ADC_SEQ, and QM_SS_ADC_SET.
int qm_ss_adc_save_context | ( | const qm_ss_adc_t | adc, |
qm_ss_adc_context_t *const | ctx | ||
) |
Save SS ADC context.
Save the configuration of the specified ADC peripheral before entering sleep.
Note: Calibration data is not saved with this function. The value of the ADC_ENA bit in the ADC Control register is also not saved with this function.
[in] | adc | SS ADC port index. |
[out] | ctx | SS ADC context structure. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 685 of file qm_ss_adc.c.
References qm_ss_adc_context_t::adc_ctrl, qm_ss_adc_context_t::adc_divseqstat, qm_ss_adc_context_t::adc_seq, qm_ss_adc_context_t::adc_set, QM_SS_ADC_CTRL, QM_SS_ADC_DIVSEQSTAT, QM_SS_ADC_SEQ, and QM_SS_ADC_SET.
int qm_ss_adc_set_calibration | ( | const qm_ss_adc_t | adc, |
const qm_ss_adc_calibration_t | cal | ||
) |
Set SS ADC calibration data.
[in] | adc | Which ADC to set calibration for. |
[in] | cal | Calibration data. |
0 | on success. |
Negative | errno for possible error codes. |
int qm_ss_adc_set_config | ( | const qm_ss_adc_t | adc, |
const qm_ss_adc_config_t *const | cfg | ||
) |
Set SS 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 335 of file qm_ss_adc.c.
References QM_SS_ADC_RES_12_BITS, QM_SS_ADC_SET, qm_ss_adc_config_t::resolution, and qm_ss_adc_config_t::window.
int qm_ss_adc_set_mode | ( | const qm_ss_adc_t | adc, |
const qm_ss_adc_mode_t | mode | ||
) |
Switch operating mode of SS 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 361 of file qm_ss_adc.c.
References QM_SS_ADC_MODE_NORM_CAL, QM_SS_ADC_MODE_NORM_NO_CAL, QM_SS_IO_CREG_MST0_CTRL, and QM_SS_IO_CREG_SLV0_OBSR.