ADC Driver

The ADC driver is used for reading analog voltage and interacting with an end device’s ADC functionality.

Type Definitions

Name Definition Description
ATMO_ADC_DriverInstance_t typedef struct ATMO_ADC_DriverInstance_t ATMO_ADC_DriverInstance_t  

Enumerations

enum ATMO_ADC_Status_t

ADC Driver Return Enumerations

Name Value Description
ATMO_ADC_Status_Success 0x00u Operation was successful
ATMO_ADC_Status_Fail 0x01u Operation failed
ATMO_ADC_Status_Initialized 0x02u Peripheral already initialized
ATMO_ADC_Status_Invalid 0x03u Invalid operation
ATMO_ADC_Status_NotSupported 0x04u Feature not supported by platform
ATMO_ADC_Status_Unknown 0x05u Some other status not defined
ATMO_ADC_Status_Busy 0x20u Conversion in progress
ATMO_ADC_Status_Timeout 0x21u Conversion timed out

enum ATMO_ADC_VoltageUnits_t

Name Value
ATMO_ADC_VoltageUnits_Volts 0x0001u
ATMO_ADC_VoltageUnits_MilliVolts 0x0002u
ATMO_ADC_VoltageUnits_MicroVolts 0x0003u
ATMO_ADC_VoltageUnits_NanoVolts 0x0004u

Functions

ATMO_Status_t ATMO_ADC_AddDriverInstance(const ATMO_ADC_DriverInstance_t *driverInstance, ATMO_DriverInstanceData_t *driverInstanceData, ATMO_DriverInstanceHandle_t *instanceNumber)

Register low level driver instance with main ADC driver

Parameter Direction Type
instanceNumber N/A ATMO_DriverInstanceHandle_t *
driverInstanceData N/A ATMO_DriverInstanceData_t *
driverInstance N/A const ATMO_ADC_DriverInstance_t *
Return Type
ATMO_Status_t

ATMO_ADC_Status_t ATMO_ADC_Init(ATMO_DriverInstanceHandle_t instance)

This routine initializes data structures needed for the ADC driver

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_ADC_Status_t

ATMO_ADC_Status_t ATMO_ADC_DeInit(ATMO_DriverInstanceHandle_t instance)

This routine de-initializes the specified ADC peripheral instance.

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_ADC_Status_t

ATMO_ADC_Status_t ATMO_ADC_ReadRaw(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, int32_t *value, uint32_t numSamplesToAverage)

This routine initiates an ADC conversion and reads the raw data. The value is formated as signed 2s complement with ‘precision’ data bits plus sign bit (sign extended). The precision is set during initialization. This is a blocking function and will not return until all samples have been taken or a timeout occurs.

Parameter Direction Type
numSamplesToAverage N/A uint32_t
value N/A int32_t *
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_ADC_Status_t

ATMO_ADC_Status_t ATMO_ADC_Read(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_ADC_VoltageUnits_t units, int32_t *voltage, uint32_t numSamplesToAverage)

This routine initiates an ADC conversion and converts the raw data to voltage. The calculated voltage is returned as an integer where 1 lsb = the specified unit(e.g. volts, millivolts, microvolts). This is a blocking function and will not return until all samples have been taken or a timeout occurs.

Parameter Direction Type
numSamplesToAverage N/A uint32_t
voltage N/A int32_t *
units N/A ATMO_ADC_VoltageUnits_t
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_ADC_Status_t