The temperature measurement module provides a simple yet flexible API allows the user to measure temperatures, choosing the measurement resolution and the output unit of measurement.
- Diversity
- This module supports diversity, like defining a callback at link time. Check Diversity Settings for all diversity parameters.
- Note
- This mod provides an implementation of the interrupt vector TSEN_IRQHandler and enables and disables the interrupt TSEN_IRQn. By including this mod you can thus no longer use the interrupt driver functionality.
-
This mod will initialize (enable a clock and provide power) the TSEN driver (by calling Chip_TSen_Init) prior to making a measurement, and de-initialize it when the measurement is complete. Using the TSEN HW block directly is thus highly discouraged when using this mod.
-
This mod will by default use the temperature calibration values as determined during production at the factory site. When a recalibration is in order, these values can be changed by changing the registers NSS_TSEN_T.SP1, NSS_TSEN_T.SP2 and NSS_TSEN_T.SP3 for the
a
, b
resp. alpha
parameters. See the temperature application note for details on this recalibration.
- Example 1: measure temperature, waiting for the result
-
- Example 2: measure temperature, receive the result in a callback
- Callback: Main code:
◆ TMEAS_ERROR
Returned value of TMeas_Measure to indicate a measurement is already in progress.
◆ pTMeas_Cb_t
Callback function type to report temperature measurement results.
- See also
- TMeas_Measure
- Parameters
-
resolution | : The value as given when TMeas_Measure was called. |
format | : The value as given when TMeas_Measure was called. |
value | : The measured temperature, converted to the format given by format . For the NATIVE format, the 16 LSBits are to be used. For all other formats, temperature is to be cast to an int32_t . |
context | : The value as given when TMeas_Measure was called. |
◆ TMEAS_FORMAT_T
Possible temperature output formats.
◆ TMeas_Measure()
Make one temperature measurement.
- Parameters
-
resolution | : The required resolution. The higher the resolution, the longer it takes to take one measurement. |
format | : The required output format. |
synchronous | : Not looked at when TMEAS_CB is not defined; true is then always assumed. Else:
- If
true the function is synchronous, and will only return once the measurement is complete.
- Else the function is asynchronous; it will return immediately, and once the temperature sensor has completed its measurement, the temperature is reported via the callback function
TMEAS_CB .
|
context | : Context information for the caller. You can fill in any value here: it is not used by this mod, only stored and sent back in a later call to TMEAS_CB . Use this as an aid for your own housekeeping, or disregard this argument: it doesn't impede the mod's working in any way. |
- Returns
- If no measurement could be taken (TSEN HW block in use), TMEAS_ERROR is returned.
- Else, if
synchronous
equals true
, the measured temperature.
- Else,
0
to indicate a measurement is ongoing and the callback will be called when the measurement is ready.
- Note
TMEAS_CB
will be called under interrupt.
-
This function is not re-entrant.
- See also
- pTMeas_Cb_t