TEMPDRV Temperature Driver#
TEMPDRV Temperature Driver provides an interface and various functionalities to the EMU internal temperature sensor.
Subsequent sections provide more insight into TEMPDRV driver.
Introduction#
TEMPDRV provides a user-friendly interface to the EMU internal temperature sensor, which is present on the EFR32 and some EFM32 devices. TEMPDRV supports application-specific callbacks at given temperature thresholds. EMU internal temperature sensor runs in energy modes EM0-EM4 and can wake up the core whenever temperature changes. Also, EMU temperature sensor runs continuously and measurements are taken every 250 ms.
Note
TEMPDRV uses the EMU peripheral and not the ADC peripheral. ADC contains another internal temperature sensor, which is not touched by the TEMPDRV.
TEMPDRV provides an important errata fix for the EFR32 first generation devices when operating at high temperature environments (above 50°C). The "EMU_E201 - High Temperature Operation" errata is described in the EFR32 errata. To implement the errata fix in a user application, include the TEMPDRV and call TEMPDRV_Init() at the start of the program. This will activate the errata fix code, which modifies registers based on changes in the EMU temperature.
TEMPDRV Usage#
Modules#
Enumerations#
Typedefs#
TEMPDRV temperature limit callback function.
Functions#
EMU Interrupt Handler.
TEMPDRV IRQ Handler.
Initialize the TEMP driver.
De-initialize the TEMP driver.
Enable or disable the TEMP driver.
Get the number of active callbacks for a limit.
Get the current temperature.
Register a callback in the TEMP driver.
Unregister a callback in the TEMP driver.
Enumeration Documentation#
TEMPDRV_LimitType_t#
TEMPDRV_LimitType_t
Temperature limit.
This is used in the TEMPDRV to specify the direction of temperature change.
Enumerator | |
---|---|
TEMPDRV_LIMIT_LOW | Temperature low. |
TEMPDRV_LIMIT_HIGH | Temperature high. |
102
of file platform/emdrv/tempdrv/inc/tempdrv.h
Typedef Documentation#
TEMPDRV_Callback_t#
typedef void(* TEMPDRV_Callback_t) (int8_t temp, TEMPDRV_LimitType_t limit) )(int8_t temp, TEMPDRV_LimitType_t limit)
TEMPDRV temperature limit callback function.
[in] | temp | The current temperature at the time when the EMU temperature triggers an interrupt. Note that this is not necessarily the same temperature as was specified when registering a callback. |
[in] | limit | The upper/lower limit reached |
Called from the interrupt context. The callback function is called when the current temperature is equal to or exceeds one of the temperature limits that have been registered with the driver.
124
of file platform/emdrv/tempdrv/inc/tempdrv.h
Function Documentation#
EMU_IRQHandler#
void EMU_IRQHandler (void )
EMU Interrupt Handler.
N/A |
The EMU_IRQHandler provided by TEMPDRV will call TEMPDRV_IRQHandler. Configure EMU_CUSTOM_IRQ_HANDLER = true if the application wants to implement its own EMU_IRQHandler. This is typically needed if one of the non-temperature related EMU interrupt flags are in use.
125
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_IRQHandler#
void TEMPDRV_IRQHandler (void )
TEMPDRV IRQ Handler.
N/A |
This IRQ Handler should be called from within the EMU_IRQHandler to enable TEMPDRV callbacks. This is included by default with EMU_CUSTOM_IRQ_HANDLER defined as false.
142
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_Init#
Ecode_t TEMPDRV_Init (void )
Initialize the TEMP driver.
N/A |
This will clear all the registered callbacks and enable the EMU IRQ in the NVIC. Calling this function will also enable the EMU_E201 errata fix for first generation Pearl, Jade and EFR32 devices.
Returns
ECODE_EMDRV_TEMPDRV_OK on success.
557
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_DeInit#
Ecode_t TEMPDRV_DeInit (void )
De-initialize the TEMP driver.
N/A |
This will clear all the registered callbacks and disable the EMU IRQ in the NVIC.
Returns
ECODE_EMDRV_TEMPDRV_OK on success.
589
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_Enable#
Ecode_t TEMPDRV_Enable (bool enable)
Enable or disable the TEMP driver.
[in] | enable | true to enable the TEMP driver, false to disable the TEMP driver. |
Returns
ECODE_EMDRV_TEMPDRV_OK on success.
610
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_GetActiveCallbacks#
uint8_t TEMPDRV_GetActiveCallbacks (TEMPDRV_LimitType_t limit)
Get the number of active callbacks for a limit.
[in] | limit | Limit type, refer to TEMPDRV_LimitType_t. |
Returns
Number of active callbacks
633
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_GetTemp#
int8_t TEMPDRV_GetTemp (void )
Get the current temperature.
N/A |
Returns
Current temperature in degrees Celsius.
664
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_RegisterCallback#
Ecode_t TEMPDRV_RegisterCallback (int8_t temp, TEMPDRV_LimitType_t limit, TEMPDRV_Callback_t callback)
Register a callback in the TEMP driver.
[in] | temp | Temperature to trigger on given in number of °C. |
[in] | limit | Limit type, refer to TEMPDRV_LimitType_t. Using TEMPDRV_LIMIT_LOW will register a callback when the EMU temperature reaches |
[in] | callback | User defined function to call when temperature threshold is reached or passed. |
This function is used for registering an application callback when the temperature changes. Note that when calling this function an application must specify the direction of the temperature change, use TEMPDRV_LIMIT_LOW to receive a callback when the temperature drops below the specified temp and use TEMPDRV_LIMIT_HIGH to receive a callback when the temperature increases above the specified temp.
Note
The user registered callback will be cleared once it's called. This means that the callback functions are not persistent, and have to be managed by the application. This feature can be used to implement a user controlled hysteresis. So for instance to register a callback at 50°C with a 5°C hysteresis you can first register a callback at 50°C or above using this function, and when the callback fires you can use this function again to register a callback when the temperature decreases to 45°C or below. Each time a callback fires you only need to call the TEMPDRV_RegisterCallback() function, there is no need to call TEMPDRV_UnregisterCallback().
It's important to know the current temperature before calling this function. Attempting to register a callback that would fire immediately is not supported and will result in a return value of ECODE_EMDRV_TEMPDRV_BAD_LIMIT. Examples of an illegal scenario would be to register a callback for a temperature that is higher than the current temperature and with a limit set to TEMPDRV_LIMIT_LOW.
Returns
ECODE_EMDRV_TEMPDRV_OK on success.
ECODE_EMDRV_TEMPDRV_PARAM_ERROR if the callback is NULL.
ECODE_EMDRV_TEMPDRV_NO_INIT if the user has forgot to call TEMPDRV_Init() before attempting to register a callback.
ECODE_EMDRV_TEMPDRV_BAD_LIMIT is returned if
temp
is below the current temperature andlimit
is TEMPDRV_LIMIT_LOW. It is also returned iftemp
is above the current temperature andlimit
is TEMPDRV_LIMIT_HIGH.
ECODE_EMDRV_TEMPDRV_DUP_TEMP is returned if a duplicate callback is detected. A duplicate callback is if you attempt to register a new callback with the same
temp
and the samelimit
as some already registered callback.
745
of file platform/emdrv/tempdrv/src/tempdrv.c
TEMPDRV_UnregisterCallback#
Ecode_t TEMPDRV_UnregisterCallback (TEMPDRV_Callback_t callback)
Unregister a callback in the TEMP driver.
[in] | callback | Callback to unregister. |
Returns
ECODE_EMDRV_TEMPDRV_OK on success.
ECODE_EMDRV_TEMPDRV_PARAM_ERROR if the callback is NULL.
ECODE_EMDRV_TEMPDRV_NO_CALLBACK if the callback was not found.
798
of file platform/emdrv/tempdrv/src/tempdrv.c