MKMxxZxxACxx5 Bare Metal Software Drivers  R4.1.6
Reference Manual
ADC API Specification

Overview

This section describes functions and macros of the driver's API.

Macros

#define ADC_Start(ch, inp)
 Starts conversion by software. More...
 
#define ADC_Ready(ch)
 Returns nonzero value when conversion completed. More...
 
#define ADC_Read(ch)
 Returns value from the result register. More...
 
#define ADC_Init(cfg, avg, CHA, CHB, CHC, CHD, ip, callback)
 ADC channel initialization. More...
 
#define ADC_ExecCalib(cfg, calib)
 ADC calibration function. More...
 
#define ADC_SaveCalib(calib)
 Updates ADC registers by calibration values. More...
 

Macro Definition Documentation

#define ADC_Start (   ch,
  inp 
)

This macro triggers conversion by software. Note that only conversion upon SC1A register (CHA) can be triggered by both software and hardware. The conversions upon SC1B (CHB),SC1C (CHC) and SC1D (CHD) registers can only be triggered by HW trigger source.

Parameters
chCHA.
inpSelect one of the ADC Input Channels (MUXA).
Note
Implemented as an inline macro.
#define ADC_Ready (   ch)

This macro returns nonzero value when conversion completed and new value converted by the ADC resides in the result register. Read value from the respective result register by ADC_Read().

Parameters
chCHA,CHB,CHC,CHD.
Returns
true (non-zero) conversion completed (COCO flag is asserted),
false conversion pending (COCO flag is deasserted).
Note
Implemented as an inline macro.
See also
ADC_Read
#define ADC_Read (   ch)

This macro returns value from the respective result register.

Parameters
chCHA,CHB,CHC,CHD.
Returns
uint16 right-justified value converted by the ADC. The number of effective bits depends on the conversion mode.
Note
Implemented as an inline macro.
See also
ADC_Ready
#define ADC_Init (   cfg,
  avg,
  CHA,
  CHB,
  CHC,
  CHD,
  ip,
  callback 
)

This function initializes Analogue Digital Converter (ADC). It also installs callback function for interrupt vector 32.

Parameters
cfgSelect one of the ADC Configuration Structures.
avgSelect one of the ADC Hardware Averaging Options.
CHASelect one of the ADC Channel Configuration Structures (Channel A).
CHBSelect one of the ADC Channel Configuration Structures (Channel B).
CHCSelect one of the ADC Channel Configuration Structures (Channel C).
CHDSelect one of the ADC Channel Configuration Structures (Channel D).
ipSelect one of the ARM Cortex-M0+ Interrupt Priority Levels.
callbackPointer to the ADC Callback Function.
Note
Implemented as a function call.
Warning
Note that only conversion upon SC1A register (CHA) can be triggered by both software and hardware. The conversions upon SC1B (CHB),SC1C (CHC) and SC1D (CHD) registers can only be triggered by HW trigger source.
#define ADC_ExecCalib (   cfg,
  calib 
)

This function runs calibration procedure and updates calibration registers of the ADC module.

Parameters
cfgSelect configuration structure:
ADC_MODULE_16B_SWTRG_IREF_CONFIG, ADC_MODULE_16B_SWTRG_XREF_CONFIG.
calibPointer to tADC_CALIB structure.
Returns
true (non-zero) error occurred during calibration,
false calibration successful.
Note
Implemented as a function call.
See also
ADC_SaveCalib
#define ADC_SaveCalib (   calib)

This function updates register of the ADC by calibration values from the structure passed by pointer.

Parameters
calibPointer to tADC_CALIB structure.
Note
Implemented as a function call.
See also
ADC_ExecCalib