Intel® Quark™ Microcontroller Software Interface 1.4.0 Intel® Quark™ Microcontroller BSP

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Typedefs | Enumerations | Functions
Quark D2000 ADC

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...

## Detailed Description

Analog to Digital Converter (ADC).

## Enumeration Type Documentation

enum qm_adc_cb_source_t

ADC interrupt callback source.

Enumerator
QM_ADC_TRANSFER | Transfer complete or error callback.
QM_ADC_MODE_CHANGED | Mode change complete callback.
QM_ADC_CAL_COMPLETE | Calibration complete callback.

Definition at line 85 of file qm_adc.h.

enum qm_adc_channel_t

ADC channels type.

Enumerator
QM_ADC_CH_0 | ADC Channel 0.
QM_ADC_CH_1 | ADC Channel 1.
QM_ADC_CH_2 | ADC Channel 2.
QM_ADC_CH_3 | ADC Channel 3.
QM_ADC_CH_4 | ADC Channel 4.
QM_ADC_CH_5 | ADC Channel 5.
QM_ADC_CH_6 | ADC Channel 6.
QM_ADC_CH_7 | ADC Channel 7.
QM_ADC_CH_8 | ADC Channel 8.
QM_ADC_CH_9 | ADC Channel 9.
QM_ADC_CH_10 | ADC Channel 10.
QM_ADC_CH_11 | ADC Channel 11.
QM_ADC_CH_12 | ADC Channel 12.
QM_ADC_CH_13 | ADC Channel 13.
QM_ADC_CH_14 | ADC Channel 14.
QM_ADC_CH_15 | ADC Channel 15.
QM_ADC_CH_16 | ADC Channel 16.
QM_ADC_CH_17 | ADC Channel 17.
QM_ADC_CH_18 | ADC Channel 18.

Definition at line 60 of file qm_adc.h.

enum qm_adc_mode_t

ADC operating mode type.

Enumerator
QM_ADC_MODE_DEEP_PWR_DOWN | Deep power down mode.
QM_ADC_MODE_PWR_DOWN | Power down mode.
QM_ADC_MODE_STDBY | Standby mode.
QM_ADC_MODE_NORM_CAL | Normal mode, with calibration.
QM_ADC_MODE_NORM_NO_CAL | Normal mode, no calibration.

Definition at line 49 of file qm_adc.h.

enum qm_adc_resolution_t

ADC resolution type.

Enumerator
QM_ADC_RES_6_BITS | 6-bit mode.
QM_ADC_RES_8_BITS | 8-bit mode.
QM_ADC_RES_10_BITS | 10-bit mode.
QM_ADC_RES_12_BITS | 12-bit mode.

Definition at line 39 of file qm_adc.h.

enum qm_adc_status_t

Enumerator
QM_ADC_IDLE | ADC idle.
QM_ADC_COMPLETE | ADC transfer complete.
QM_ADC_OVERFLOW | ADC FIFO overflow error.

Definition at line 30 of file qm_adc.h.

## Function Documentation

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.

Parameters

  [in] | adc | Which ADC to calibrate.

Returns
  Standard errno return type for QMSI.

Return values

  0 | on success.
  Negative | errno for possible error codes.

Definition at line 204 of file qm_adc.c.

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.

Parameters

  [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.

Returns
  Standard errno return type for QMSI.

Return values

  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
| ) |  |

Get the current calibration data for an ADC.

Parameters

  [in] | adc | Which ADC to get calibration for.
  [out] | cal | Calibration data. This must not be NULL.

Returns
  Standard errno return type for QMSI.

Return values

  0 | on success.
  Negative | errno for possible error codes.

Definition at line 261 of file qm_adc.c.

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.

Parameters

  [in] | adc | Which ADC to calibrate.
  [in] | callback | Callback called on completion.
  [in] | callback_data | The callback user data.

Returns
  Standard errno return type for QMSI.

Return values

  0 | on success.
  Negative | errno for possible error codes.

Definition at line 220 of file qm_adc.c.

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.

Parameters

  [in] | adc | Which ADC to read.
  [in,out] | xfer | Channel sample and callback info. This must not be NULL.

Returns
  Standard errno return type for QMSI.

Return values

  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.

Parameters

  [in] | adc | Which ADC to enable.
  [in] | mode | ADC operating mode.
  [in] | callback | Callback called on completion.
  [in] | callback_data | The callback user data.

Returns
  Standard errno return type for QMSI.

Return values

  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
| ) |  |

Set ADC calibration data.

Parameters

  [in] | adc | Which ADC to set calibration for.
  [in] | cal | Calibration data.

Returns
  Standard errno return type for QMSI.

Return values

  0 | on success.
  Negative | errno for possible error codes.

Definition at line 242 of file qm_adc.c.

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.

Parameters

  [in] | adc | Which ADC to configure.
  [in] | cfg | ADC configuration. This must not be NULL.

Returns
  Standard errno return type for QMSI.

Return values

  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.

Parameters

  [in] | adc | Which ADC to enable.
  [in] | mode | ADC operating mode.

Returns
  Standard errno return type for QMSI.

Return values

  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().