![]() |
MCUXpresso SDK API Reference Manual
Rev 2.12.1
NXP Semiconductors
|
ADC driver supports read voltage for internal sensor for external pin. More...
The MCUXpresso SDK provides a driver for the GPADC.
The typical workflow:
Optionally, GPADC_SetThreshold can be called to set the threshold for each sensor, meanwhile, GPADC_RegisterCallback can register the callback when voltage out of threshold range. the external pin shares the same threshold with kGPADC_SensorVBAT_ExtPin.
Macros | |
| #define | FSL_GPADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
| GPADC driver version. More... | |
Typedefs | |
| typedef void(* | gpadc_callback_t )(void) |
| GPADC callback. More... | |
Enumerations | |
| enum | gpadc_sensor_t { kGPADC_SensorReserved = E_PN76_PCRM_GPADC_SENSOR_RESERVED, kGPADC_SensorRSSI = E_PN76_PCRM_GPADC_SENSOR_RSSI_OUT, kGPADC_SensorBandgap = E_PN76_PCRM_GPADC_SENSOR_VBG_SNS, kGPADC_SensorTempPmu = E_PN76_PCRM_GPADC_SENSOR_TEMP_PMU, kGPADC_SensorTempClif = E_PN76_PCRM_GPADC_SENSOR_TEMP_CLIF, kGPADC_SensorXtalPeakDet = E_PN76_PCRM_GPADC_SENSOR_XTAL_PEAK_DET, kGPADC_SensorVBAT_ExtPin = E_PN76_PCRM_GPADC_SENSOR_VBAT, kGPADC_SensorGround = E_PN76_PCRM_GPADC_SENSOR_GROUND, kGPADC_SensorVDDPA = E_PN76_PCRM_GPADC_SENSOR_VDDPA } |
| GPADC sensor selection. More... | |
| enum | gpadc_value_type_t { kGPADC_TypeVal = E_PN76_PCRM_GPADC_TYPE_VAL, kGPADC_TypeMin = E_PN76_PCRM_GPADC_TYPE_MIN, kGPADC_TypeMax = E_PN76_PCRM_GPADC_TYPE_MAX, kGPADC_TypeIIR = E_PN76_PCRM_GPADC_TYPE_IIR, kGPADC_TypeAvg = E_PN76_PCRM_GPADC_TYPE_AVG, kGPADC_TypeConv = E_PN76_PCRM_GPADC_TYPE_CONV, kGPADC_TypeGross = E_PN76_PCRM_GPADC_TYPE_GROSS, kGPADC_TypeSingleEnd = E_PN76_PCRM_GPADC_TYPE_SINGLE_ENDED, kGPADC_TypeDifferential = E_PN76_PCRM_GPADC_TYPE_DIFFERENTIAL, kGPADC_TypeConvGrossMask = E_PN76_PCRM_GPADC_TYPE_CONV_GROSS_MASK, kGPADC_TypeValMask = E_PN76_PCRM_GPADC_TYPE_VAL_MASK, kGPADC_TypeMeasureTypeMask, kGPADC_TypeValConv = E_PN76_PCRM_GPADC_TYPE_VAL_CONV, kGPADC_TypeMinConv = E_PN76_PCRM_GPADC_TYPE_MIN_CONV, kGPADC_TypeMaxConv = E_PN76_PCRM_GPADC_TYPE_MAX_CONV, kGPADC_TypeIIRConv = E_PN76_PCRM_GPADC_TYPE_IIR_CONV, kGPADC_TypeAvgConv = E_PN76_PCRM_GPADC_TYPE_AVG_CONV, kGPADC_TypeValGross = E_PN76_PCRM_GPADC_TYPE_VAL_GROSS, kGPADC_TypeMinGross = E_PN76_PCRM_GPADC_TYPE_MIN_GROSS, kGPADC_TypeMaxGross = E_PN76_PCRM_GPADC_TYPE_MAX_GROSS, kGPADC_TypeIIRGross = E_PN76_PCRM_GPADC_TYPE_IIR_GROSS, kGPADC_TypeAvgGross = E_PN76_PCRM_GPADC_TYPE_AVG_GROSS, kGPADC_TypeValConvDiff = E_PN76_PCRM_GPADC_TYPE_VAL_CONV_DIFF, kGPADC_TypeMinConvDiff = E_PN76_PCRM_GPADC_TYPE_MIN_CONV_DIFF, kGPADC_TypeMaxConvDiff = E_PN76_PCRM_GPADC_TYPE_MAX_CONV_DIFF, kGPADC_TypeIIRConvDiff = E_PN76_PCRM_GPADC_TYPE_IIR_CONV_DIFF, kGPADC_TypeAvgConvDiff = E_PN76_PCRM_GPADC_TYPE_AVG_CONV_DIFF, kGPADC_TypeValGrossDiff = E_PN76_PCRM_GPADC_TYPE_VAL_GROSS_DIFF, kGPADC_TypeMinGrossDiff = E_PN76_PCRM_GPADC_TYPE_MIN_GROSS_DIFF, kGPADC_TypeMaxGrossDiff = E_PN76_PCRM_GPADC_TYPE_MAX_GROSS_DIFF, kGPADC_TypeIIRGrossDiff = E_PN76_PCRM_GPADC_TYPE_IIR_GROSS_DIFF, kGPADC_TypeAvgGrossDiff = E_PN76_PCRM_GPADC_TYPE_AVG_GROSS_DIFF } |
| Enum for Different General Purpose Analog to Digital Converter (GPADC) value types. More... | |
Functions | |
| static pn_status_t | GPADC_Init (void) |
| Performs GPADC Initialization. More... | |
| pn_status_t | GPADC_ReadSensor (gpadc_sensor_t eSensor, gpadc_value_type_t eType, int32_t *milliVolt) |
| This function returns the requested sensor value. More... | |
| pn_status_t | GPADC_ReadSensorOneShot (gpadc_sensor_t eSensor, gpadc_value_type_t eType, int32_t *milliVolt) |
| This function returns the instant value of requested sensor. More... | |
| static pn_status_t | GPADC_SetThreshold (gpadc_sensor_t eSensor, gpadc_value_type_t eType, int16_t wLowThreshold, int16_t wHighThreshold) |
| This function Sets the thresholds for requested sensor. More... | |
| static pn_status_t | GPADC_GetThreshold (gpadc_sensor_t eSensor, gpadc_value_type_t eType, int16_t *wLowThreshold, int16_t *wHighThreshold) |
| This function Reads the thresholds of requested sensor. More... | |
| static void | GPADC_Deinit (void) |
| Performs GPADC De-Initialization. More... | |
| static pn_status_t | GPADC_ExtPin_Init (void) |
| This API will initialize for the MUX that was enabled to measure the voltage on external ADC pin AD1. More... | |
| static void | GPADC_ExtPin_DeInit (void) |
| De-Initialize the GPADC after disabling measurement for external Analog signal. More... | |
| static pn_status_t | GPADC_ExtPin_ReadRawData (int16_t *pwValue) |
| This API reads the raw data from external pin. More... | |
| pn_status_t | GPADC_ExtPin_Read (int32_t *milliVolt) |
| This API reads the voltage from external pin. More... | |
| static bool | GPADC_ExtPin_GetEnableStatus (void) |
| This API will return the status of whether the MUX is enabled for measuring the external ADC pin. More... | |
| pn_status_t | GPADC_RegisterCallback (gpadc_sensor_t sensor, gpadc_callback_t callback) |
| Regsiter GPADC IRQ callback. More... | |
| void | GPADC_HandleIRQ (void) |
| Function to handle the GPADC IRQ. | |
| #define FSL_GPADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
| typedef void(* gpadc_callback_t)(void) |
| enum gpadc_sensor_t |
| enum gpadc_value_type_t |
|
inlinestatic |
This function Initialized the GPADC by mapping the channels and performing calibration.
| pn_status_t GPADC_ReadSensor | ( | gpadc_sensor_t | eSensor, |
| gpadc_value_type_t | eType, | ||
| int32_t * | milliVolt | ||
| ) |
This API reads the requested sensor value based on the value type.
When calling this API, each sensor is fixed mapped to seperate channel, the channels can work simultaneously, the ADC value type can be averaged, minimum, maximum.
| eSensor,: | Sensor used to get General Purpose Analog to Digital Converter (GPADC) value. |
| eType,: | Type of acquisition (either gross value or real scale value). |
| *milliVolt,: | Voltage. |
| kStatus_PN_Success | On Success. |
| kStatus_PN_InternalError | On wrong sensor acquisition request. |
| pn_status_t GPADC_ReadSensorOneShot | ( | gpadc_sensor_t | eSensor, |
| gpadc_value_type_t | eType, | ||
| int32_t * | milliVolt | ||
| ) |
This API reads the sensor once and returns the value.
When calling this API, there is only one ADC channel used, it is mapped to desired sensor dynamically on request.
| eSensor,: | Sensor used to get General Purpose Analog to Digital Converter (GPADC) value. |
| eType,: | Type of acquisition (either gross value or real scale value). |
| *milliVolt,: | Voltage. |
| kStatus_PN_Success | On Success. |
| kStatus_PN_InternalError | on wrong sensor acquisition request. |
|
inlinestatic |
It configures both high and low thresholds.
| eSensor,: | Sensor whose threshold is to be configured, PN76_PCRM_GpadcSensor_t. |
| eType,: | type of threshold (either gross value or real scale value) PN76_PCRM_GpadcValueType_t values |
| wLowThreshold,: | Low threshold below which an interrupt will be triggered |
| wHighThreshold,: | High threshold above which an interrupt will be triggered |
| kStatus_PN_Success | On Success. |
| kStatus_PN_InternalError | if the sensor is not mapped on any of the channels. |
| kStatus_PN_ParameterError | If kGPADC_SensorReserved sensor is requested. |
| kStatus_PN_ParameterError | if kGPADC_SensorAny sensor is requested, since kGPADC_SensorAny has no support of real scale threshold |
|
inlinestatic |
It returns both high and low thresholds.
| eSensor,: | Sensor whose threshold is to be acquired, PN76_PCRM_GpadcSensor_t. |
| eType,: | type of threshold (either gross value or real scale value) PN76_PCRM_GpadcValueType_t values |
| *wLowThreshold,: | Low threshold below which an interrupt will be triggered |
| *wHighThreshold,: | High threshold above which an interrupt will be triggered |
| kStatus_PN_Success | On Success. |
| kStatus_PN_InternalError | if the sensor is not mapped on any of the channels. |
| kStatus_PN_ParameterError | if kGPADC_SensorAny sensor selected, since kGPADC_SensorAny has no support of real scale threshold |
|
inlinestatic |
This function disabled the GPADC module.
|
inlinestatic |
| kStatus_PN_Success | : Initialization of MUX for measurement on AD1 pin is successfull. |
| Other | values Indicates an error occured. Please refer to pn_status_t enum. |
|
inlinestatic |
|
inlinestatic |
| *pwValue | : Raw Data that is being read from the ADC. Only valid if return value is kStatus_PN_Success. |
| kStatus_PN_Success,: | GPADC One Shot mode is executed successfully and read data is stored in the parameter. |
| Other | values Indicates an error occured. Please refer to pn_status_t enum. |
| pn_status_t GPADC_ExtPin_Read | ( | int32_t * | milliVolt | ) |
| *milliVolt | : Voltage read from the ADC. Only valid if return value is kStatus_PN_Success. |
| kStatus_PN_Success,: | GPADC One Shot mode is executed successfully and read data is stored in the parameter. |
| Other | values Indicates an error occured. Please refer to pn_status_t enum. |
|
inlinestatic |
| true | Indicates that MUX is enabled to measure the voltage on external pin. |
| false | Indicates that MUX is disabled to measure the voltage on external pin. |
| pn_status_t GPADC_RegisterCallback | ( | gpadc_sensor_t | sensor, |
| gpadc_callback_t | callback | ||
| ) |
| sensor | Which sensor to register. |
| callback | The callback to register. |
| kStatus_PN_Success | Register succeed. |
| kStatus_PN_InternalError | Register failed because of internal error. |
| kStatus_PN_ParameterError | Register failed because of wrong parameter. |