The MCUXpresso SDK provides a peripheral driver for the Temperature Sensor (TSENS) module of MCUXpresso SDK devices.
Function groups
The TSENS driver supports initialization/configuration/operation for optimization/customization purpose.
Initialization and deinitialization
The function TSENS_Init() initializes the TSENS with specified configurations. The function TSENS_GetDefaultConfig() gets the default configurations.
The function TSENS_Deinit() disables all interrupts and the module clock.
Get temperature
The function TSENS_StartMeasurement starts a TSENS conversion.
The function TSENS_GetTemperature() gets the temperature value in last measurement.
Calibration configuration
The function TSENS_GetDefaultCalibrationConfig() gets the default calibration parameters.
The function TSENS_SetCalibrationConfig() configures calibration parameters.
Status
Provides functions to get the TSENS status.
Interrupt
Provides functions to enable/disable TSENS interrupts and set interrupt conditions.
Typical use case
TSENS basic Configuration
Example to get temperature through the usage of conversion ready interrupt. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/tsens
|
enum | _tsens_interrupt_enable {
kTSENS_ConversionReadyInterruptEnable,
kTSENS_LowThresholdInterruptEnable = TSENS_IMSC_TLOE_MASK,
kTSENS_HighThresholdInterruptEnable = TSENS_IMSC_THIE_MASK
} |
| TSENS interrupt. More...
|
|
enum | _tsens_flags {
kTSENS_LowCoarseRangeFlag = TSENS_SR_TRANLOC_MASK,
kTSENS_HighCoarseRangeFlag = TSENS_SR_TRANHIC_MASK,
kTSENS_LowFineRangeFlag = TSENS_SR_TRANLOF_MASK,
kTSENS_HighFineRangeFlag = TSENS_SR_TRANHIF_MASK,
kTSENS_ConversionSuccessFlag = TSENS_SR_TSUCC_MASK,
kTSENS_ConversionReadyInterruptFlag = TSENS_RIS_RDYI_MASK << 16U,
kTSENS_LowThresholdInterruptFlag,
kTSENS_HighThresholdInterruptFlag
} |
| TSENS status flags. More...
|
|
enum | tsens_resolution_mode_t {
kTSENS_Resolution7bit = 2U,
kTSENS_Resolution8bit,
kTSENS_Resolution9bit,
kTSENS_Resolution10bit,
kTSENS_Resolution11bit,
kTSENS_Resolution12bit
} |
| TSENS resolution modes. More...
|
|
enum | tsens_output_mode_t {
kTSENS_OutputRawData = 0U,
kTSENS_OutputCalibratedData
} |
| TSENS output modes. More...
|
|
This structure holds the configuration settings for the temperature sensor. To initialize this structure to reasonable defaults, call the TSENS_GetDefaultConfig() function and pass a pointer to your config structure instance.
bool tsens_config_t::enableVolatgeCalibration |
struct tsens_calibration_config_t |
This structure holds the configuration settings for the calibration parameters. To initialize this structure to reasonable defaults, call the TSENS_GetCalibrationDefaultConfig() function and pass a pointer to your config structure instance.
The calibration values A, B, and alpha for the default resolution settings are determined during the calibration phase of the manufacturing process and stored in EEPROM.
#define FSL_TSENS_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1. */` |
Enumerator |
---|
kTSENS_ConversionReadyInterruptEnable |
The temperature sensor conversion ready interrupt.
|
kTSENS_LowThresholdInterruptEnable |
The temperature sensor low threshold interrupt.
|
kTSENS_HighThresholdInterruptEnable |
The temperature sensor high threshold interrupt.
|
Enumerator |
---|
kTSENS_LowCoarseRangeFlag |
Coarse range mask, out of range (too low).
|
kTSENS_HighCoarseRangeFlag |
Coarse range mask, out of range (too high).
|
kTSENS_LowFineRangeFlag |
Fine range mask, out of range (too low).
|
kTSENS_HighFineRangeFlag |
Fine range mask, out of range (too low).
|
kTSENS_ConversionSuccessFlag |
Successful conversion mask.
|
kTSENS_ConversionReadyInterruptFlag |
A temperature conversion has finished.
|
kTSENS_LowThresholdInterruptFlag |
A temperature conversion has finished and the value is below the value stored in TLO.
|
kTSENS_HighThresholdInterruptFlag |
A temperature conversion has finished and the value exceeds the THI threshold value.
|
Enumerator |
---|
kTSENS_Resolution7bit |
7-bit resoultion mode
|
kTSENS_Resolution8bit |
8-bit resoultion mode
|
kTSENS_Resolution9bit |
9-bit resoultion mode
|
kTSENS_Resolution10bit |
10-bit resoultion mode
|
kTSENS_Resolution11bit |
11-bit resoultion mode
|
kTSENS_Resolution12bit |
12-bit resoultion mode
|
Enumerator |
---|
kTSENS_OutputRawData |
Raw data mode, unsigned fixed point (5.11)
|
kTSENS_OutputCalibratedData |
Calibrated data mode, signed fixed point (10.6)
|
- Parameters
-
base | TSENS peripheral base address. |
config | Pointer to configuration structure. Refer to "tsens_config_t" structure. |
void TSENS_Deinit |
( |
TSENS_Type * |
base | ) |
|
- Parameters
-
base | TSENS peripheral base address. |
This function initializes the user configuration structure to default value. The default value are:
- Parameters
-
config | Pointer to TSENS configuration structure. Refer to "tsens_config_t" structure. |
static void TSENS_StartMeasurement |
( |
TSENS_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
bas | TSENS peripheral base address. |
static uint32_t TSENS_GetTemperature |
( |
TSENS_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | TSENS peripheral base address. |
- Return values
-
- Parameters
-
base | TSENS peripheral base address. |
caliConfig | Pointer to TSENS calibration configuration structure. Refer to "tsens_calibration_config_t" structure. |
- Parameters
-
base | TSENS peripheral base address. |
caliConfig | Pointer to TSENS calibration configuration structure. Refer to "tsens_calibration_config_t" structure. |
static void TSENS_SetLowTemperatureThreshold |
( |
TSENS_Type * |
base, |
|
|
uint16_t |
temperature |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | TSENS peripheral base address. |
temperature | Low temperature threshold. |
static void TSENS_SetHighTemperatureThreshold |
( |
TSENS_Type * |
base, |
|
|
uint16_t |
temperature |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | TSENS peripheral base address. |
temperature | high temperature threshold. |
static void TSENS_EnableInterrupt |
( |
TSENS_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
bas | TSENS peripheral base address. |
mask | The interrupt mask. Refer to "_tsens_interrupt" enumeration. |
static void TSENS_DisableInterrupt |
( |
TSENS_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
bas | TSENS peripheral base address. |
mask | The interrupt mask. Refer to "_tsens_interrupt" enumeration. |
static uint32_t TSENS_GetStatusFlags |
( |
TSENS_Type * |
base | ) |
|
|
inlinestatic |
This function gets all TSENS status flags. The flags are returned as the logical OR value of the enumerators _tsens_flags. To check for a specific status, compare the return value with enumerators in the _tsens_flags. For example, to check whether the measurement value is ready in data register:
- Parameters
-
base | TSENS peripheral base address. |
- Returns
- TSENS status flags which are given in the enumerators in the _tsens_flags.
static uint32_t TSENS_GetInterruptStatusFlags |
( |
TSENS_Type * |
base | ) |
|
|
inlinestatic |
This function gets all TSENS interrupt status flags. The flags are returned as the logical OR value of the enumerators _tsens_interrupt_enable. To check for a specific status, compare the return value with enumerators in the _tsens_interrupt_enable. For example, to check whether the conversion ready interrupt is enabled:
- Parameters
-
base | TSENS peripheral base address. |
- Returns
- TSENS interrupt status flags which are given in the enumerators in the _tsens_interrupt_enable.
static void TSENS_ClearInterruptStatusFlags |
( |
TSENS_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | LPADC peripheral base address. |
mask | Mask value for interrupt flags to be cleared. Refer to "tsens_status_flags". |