TI-RTOS Drivers
tidrivers_cc13xx_cc26xx_2_20_00_08
|
ADC driver interface.
============================================================================
The ADC header file should be included in an application as follows:
The ADC driver operates as a simplified ADC module with only single channel sampling support. It also operates on blocking only mode which means users have to wait the current sampling finished before starting another sampling. The sampling channel needs to be specified in the ADC_open() before calling ADC_convert().
The APIs in this driver serve as an interface to a typical TI-RTOS application. The specific peripheral implementations are responsible to create all the SYS/BIOS specific primitives to allow for thread-safe operation.
A ADC conversion with a ADC peripheral is started by calling ADC_convert(). The result value is returned by ADC_convert() once the conversion is finished.
This module serves as the main interface for TI-RTOS applications. Its purpose is to redirect the module's APIs to specific peripheral implementations which are specified using a pointer to a ADC_FxnTable.
The ADC driver interface module is joined (at link time) to a NULL-terminated array of ADC_Config data structures named ADC_config. ADC_config is implemented in the application with each entry being an instance of a ADC peripheral. Each entry in ADC_config contains a:
The ADC driver interface produces log statements if instrumentation is enabled.
Diagnostics Mask | Log details |
---|---|
Diags_USER1 | basic operations performed |
Diags_USER2 | detailed operations performed |
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | ADC_Params |
ADC Parameters. More... | |
struct | ADC_FxnTable |
The definition of a ADC function table that contains the required set of functions to control a specific ADC driver implementation. More... | |
struct | ADC_Config |
ADC Global configuration. More... | |
Macros | |
#define | ADC_CMD_RESERVED (32) |
#define | ADC_STATUS_RESERVED (-32) |
#define | ADC_STATUS_SUCCESS (0) |
Successful status code returned by ADC_control(). More... | |
#define | ADC_STATUS_ERROR (-1) |
Generic error status code returned by ADC_control(). More... | |
#define | ADC_STATUS_UNDEFINEDCMD (-2) |
An error status code returned by ADC_control() for undefined command codes. More... | |
Typedefs | |
typedef struct ADC_Config * | ADC_Handle |
A handle that is returned from a ADC_open() call. More... | |
typedef struct ADC_Params | ADC_Params |
ADC Parameters. More... | |
typedef void(* | ADC_CloseFxn) (ADC_Handle handle) |
A function pointer to a driver specific implementation of ADC_close(). More... | |
typedef int_fast16_t(* | ADC_ControlFxn) (ADC_Handle handle, uint_fast16_t cmd, void *arg) |
A function pointer to a driver specific implementation of ADC_control(). More... | |
typedef int_fast16_t(* | ADC_ConvertFxn) (ADC_Handle handle, uint16_t *value) |
A function pointer to a driver specific implementation of ADC_ConvertFxn(). More... | |
typedef uint32_t(* | ADC_ConvertRawToMicroVolts) (ADC_Handle handle, uint16_t rawAdcValue) |
A function pointer to a driver specific implementation of ADC_convertRawToMicroVolts(). More... | |
typedef void(* | ADC_InitFxn) (ADC_Handle handle) |
A function pointer to a driver specific implementation of ADC_init(). More... | |
typedef ADC_Handle(* | ADC_OpenFxn) (ADC_Handle handle, ADC_Params *params) |
A function pointer to a driver specific implementation of ADC_open(). More... | |
typedef struct ADC_FxnTable | ADC_FxnTable |
The definition of a ADC function table that contains the required set of functions to control a specific ADC driver implementation. More... | |
typedef struct ADC_Config | ADC_Config |
ADC Global configuration. More... | |
Functions | |
void | ADC_close (ADC_Handle handle) |
Function to close a ADC driver. More... | |
int_fast16_t | ADC_control (ADC_Handle handle, uint_fast16_t cmd, void *arg) |
Function performs implementation specific features on a given ADC_Handle. More... | |
int_fast16_t | ADC_convert (ADC_Handle handle, uint16_t *value) |
Function to perform ADC conversion. More... | |
uint32_t | ADC_convertRawToMicroVolts (ADC_Handle handle, uint16_t rawAdcValue) |
Function performs conversion from raw ADC result to actual value in microvolts. More... | |
void | ADC_init (void) |
Function to initializes the ADC driver. More... | |
ADC_Handle | ADC_open (uint_fast16_t index, ADC_Params *params) |
Function to initialize the ADC peripheral. More... | |
void | ADC_Params_init (ADC_Params *params) |
Function to initialize the ADC_Params struct to its defaults. More... | |
#define ADC_CMD_RESERVED (32) |
#define ADC_STATUS_RESERVED (-32) |
Common ADC_control status code reservation offset. ADC driver implementations should offset status codes with ADC_STATUS_RESERVED growing negatively.
Example implementation specific status codes:
#define ADC_STATUS_SUCCESS (0) |
Successful status code returned by ADC_control().
ADC_control() returns ADC_STATUS_SUCCESS if the control code was executed successfully.
#define ADC_STATUS_ERROR (-1) |
Generic error status code returned by ADC_control().
ADC_control() returns ADC_STATUS_ERROR if the control code was not executed successfully.
#define ADC_STATUS_UNDEFINEDCMD (-2) |
An error status code returned by ADC_control() for undefined command codes.
ADC_control() returns ADC_STATUS_UNDEFINEDCMD if the control code is not recognized by the driver implementation.
typedef struct ADC_Config* ADC_Handle |
A handle that is returned from a ADC_open() call.
typedef struct ADC_Params ADC_Params |
ADC Parameters.
ADC parameters are used to with the ADC_open() call. Only custom argument is supported in the parameters. Default values for these parameters are set using ADC_Params_init().
typedef void(* ADC_CloseFxn) (ADC_Handle handle) |
A function pointer to a driver specific implementation of ADC_close().
typedef int_fast16_t(* ADC_ControlFxn) (ADC_Handle handle, uint_fast16_t cmd, void *arg) |
A function pointer to a driver specific implementation of ADC_control().
typedef int_fast16_t(* ADC_ConvertFxn) (ADC_Handle handle, uint16_t *value) |
A function pointer to a driver specific implementation of ADC_ConvertFxn().
typedef uint32_t(* ADC_ConvertRawToMicroVolts) (ADC_Handle handle, uint16_t rawAdcValue) |
A function pointer to a driver specific implementation of ADC_convertRawToMicroVolts().
typedef void(* ADC_InitFxn) (ADC_Handle handle) |
A function pointer to a driver specific implementation of ADC_init().
typedef ADC_Handle(* ADC_OpenFxn) (ADC_Handle handle, ADC_Params *params) |
A function pointer to a driver specific implementation of ADC_open().
typedef struct ADC_FxnTable ADC_FxnTable |
The definition of a ADC function table that contains the required set of functions to control a specific ADC driver implementation.
typedef struct ADC_Config ADC_Config |
ADC Global configuration.
The ADC_Config structure contains a set of pointers used to characterize the ADC driver implementation.
This structure needs to be defined before calling ADC_init() and it must not be changed thereafter.
void ADC_close | ( | ADC_Handle | handle | ) |
Function to close a ADC driver.
handle | An ADC handle returned from ADC_open() |
int_fast16_t ADC_control | ( | ADC_Handle | handle, |
uint_fast16_t | cmd, | ||
void * | arg | ||
) |
Function performs implementation specific features on a given ADC_Handle.
handle | A ADC handle returned from ADC_open() |
cmd | A command value defined by the driver specific implementation |
arg | An optional R/W (read/write) argument that is accompanied with cmd |
int_fast16_t ADC_convert | ( | ADC_Handle | handle, |
uint16_t * | value | ||
) |
Function to perform ADC conversion.
Function to perform ADC single channel single sample conversion.
handle | An ADC_Handle |
value | A pointer to the conversion result |
uint32_t ADC_convertRawToMicroVolts | ( | ADC_Handle | handle, |
uint16_t | rawAdcValue | ||
) |
Function performs conversion from raw ADC result to actual value in microvolts.
handle | A ADC handle returned from ADC_open() |
rawAdcValue | A sampling result return from ADC_convert() |
void ADC_init | ( | void | ) |
Function to initializes the ADC driver.
ADC_Handle ADC_open | ( | uint_fast16_t | index, |
ADC_Params * | params | ||
) |
Function to initialize the ADC peripheral.
Function to initialize the ADC peripheral specified by the particular index value.
index | Logical peripheral number for the ADC indexed into the ADC_config table |
params | Pointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only). |
void ADC_Params_init | ( | ADC_Params * | params | ) |
Function to initialize the ADC_Params struct to its defaults.
params | An pointer to ADC_Params structure for initialization |
Defaults values are: custom = NULL