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

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Typedefs | Enumerations | Functions
SS ADC

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.

## Enumerations
enum | qm_ss_adc_status_t { QM_SS_ADC_IDLE = 0x0, QM_SS_ADC_COMPLETE = 0x1, QM_SS_ADC_OVERFLOW = 0x2, QM_SS_ADC_UNDERFLOW = 0x4, QM_SS_ADC_SEQERROR = 0x8 }
| SS ADC status. More...
enum | qm_ss_adc_resolution_t { QM_SS_ADC_RES_6_BITS = 0x5, QM_SS_ADC_RES_8_BITS = 0x7, QM_SS_ADC_RES_10_BITS = 0x9, QM_SS_ADC_RES_12_BITS = 0xB }
| SS ADC resolution type. More...
enum | qm_ss_adc_mode_t { QM_SS_ADC_MODE_DEEP_PWR_DOWN, QM_SS_ADC_MODE_PWR_DOWN, QM_SS_ADC_MODE_STDBY, QM_SS_ADC_MODE_NORM_CAL, QM_SS_ADC_MODE_NORM_NO_CAL }
| SS ADC operating mode type. More...
enum | qm_ss_adc_channel_t { QM_SS_ADC_CH_0, QM_SS_ADC_CH_1, QM_SS_ADC_CH_2, QM_SS_ADC_CH_3, QM_SS_ADC_CH_4, QM_SS_ADC_CH_5, QM_SS_ADC_CH_6, QM_SS_ADC_CH_7, QM_SS_ADC_CH_8, QM_SS_ADC_CH_9, QM_SS_ADC_CH_10, QM_SS_ADC_CH_11, QM_SS_ADC_CH_12, QM_SS_ADC_CH_13, QM_SS_ADC_CH_14, QM_SS_ADC_CH_15, QM_SS_ADC_CH_16, QM_SS_ADC_CH_17, QM_SS_ADC_CH_18 }
| SS ADC channels type. More...
enum | qm_ss_adc_cb_source_t { QM_SS_ADC_TRANSFER, QM_SS_ADC_MODE_CHANGED, QM_SS_ADC_CAL_COMPLETE }
| SS ADC interrupt callback source. More...

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

## Detailed Description

Analog to Digital Converter (ADC) for the Sensor Subsystem.

## Enumeration Type Documentation

enum qm_ss_adc_cb_source_t

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.

Enumerator
QM_SS_ADC_CH_0 | ADC Channel 0.
QM_SS_ADC_CH_1 | ADC Channel 1.
QM_SS_ADC_CH_2 | ADC Channel 2.
QM_SS_ADC_CH_3 | ADC Channel 3.
QM_SS_ADC_CH_4 | ADC Channel 4.
QM_SS_ADC_CH_5 | ADC Channel 5.
QM_SS_ADC_CH_6 | ADC Channel 6.
QM_SS_ADC_CH_7 | ADC Channel 7.
QM_SS_ADC_CH_8 | ADC Channel 8.
QM_SS_ADC_CH_9 | ADC Channel 9.
QM_SS_ADC_CH_10 | ADC Channel 10.
QM_SS_ADC_CH_11 | ADC Channel 11.
QM_SS_ADC_CH_12 | ADC Channel 12.
QM_SS_ADC_CH_13 | ADC Channel 13.
QM_SS_ADC_CH_14 | ADC Channel 14.
QM_SS_ADC_CH_15 | ADC Channel 15.
QM_SS_ADC_CH_16 | ADC Channel 16.
QM_SS_ADC_CH_17 | ADC Channel 17.
QM_SS_ADC_CH_18 | ADC Channel 18.

Definition at line 64 of file qm_ss_adc.h.

enum qm_ss_adc_mode_t

SS ADC operating mode type.

Enumerator
QM_SS_ADC_MODE_DEEP_PWR_DOWN | Deep power down mode.
QM_SS_ADC_MODE_PWR_DOWN | Power down mode.
QM_SS_ADC_MODE_STDBY | Standby mode.
QM_SS_ADC_MODE_NORM_CAL | Normal mode, with calibration.
QM_SS_ADC_MODE_NORM_NO_CAL | Normal mode, no calibration.

Definition at line 53 of file qm_ss_adc.h.

enum qm_ss_adc_resolution_t

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.

## Function Documentation

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.

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.

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.

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

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.

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.

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

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

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

Parameters

  [in] | adc | SS ADC port index.
  [in] | ctx | SS ADC context structure. 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 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.

Parameters

  [in] | adc | SS ADC port index.
  [out] | ctx | SS ADC context structure. 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 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.

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.

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.

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

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