46 #if defined(_SILICON_LABS_GECKO_INTERNAL_SDID_80)
47 #define TEMPDRV_ERRATA_FIX
50 #ifdef TEMPDRV_ERRATA_FIX
51 #define TEMPDRV_INT_CALLBACK_DEPTH 1
54 #define TEMPDRV_INT_CALLBACK_DEPTH 0
57 #define TEMPDRV_CALLBACK_DEPTH (TEMPDRV_INT_CALLBACK_DEPTH + TEMPDRV_CUSTOM_CALLBACK_DEPTH)
58 #define TEMPDRV_CUSTOM_CALLBACK_INDEX TEMPDRV_INT_CALLBACK_DEPTH
66 static bool TEMPDRV_InitState =
false;
67 static bool TEMPDRV_EnableState =
false;
74 static int32_t calibrationEMU;
75 static int32_t calibrationTEMP;
77 static uint8_t fallbackEMU = 0x90;
78 static uint8_t fallbackTEMP = 25;
80 #if (EMU_CUSTOM_IRQ_HANDLER == false)
118 activeCallback = lowCallback->
callback;
129 activeCallback = highCallback->
callback;
138 #if defined(TEMPDRV_ERRATA_FIX)
148 #define ERRATA_MID_LIMIT 65
149 #define ERRATA_HIGH_LIMIT 80
150 #define ERRATA_HYSTERESIS 8
181 ErrataState_t errataState;
185 if (temp < ERRATA_MID_LIMIT)
189 else if (temp < ERRATA_HIGH_LIMIT)
199 tempdrvHighCallbacks[0] = errataHighTemp[errataState];
200 tempdrvLowCallbacks[0] = errataLowTemp[errataState];
240 if (rev.
major == 0x01)
251 limitLow =
convertToEmu(ERRATA_MID_LIMIT - ERRATA_HYSTERESIS);
259 limitLow =
convertToEmu(ERRATA_HIGH_LIMIT - ERRATA_HYSTERESIS);
266 #else // TEMPDRV_ERRATA_FIX
270 #endif // TEMPDRV_ERRATA_FIX
286 for (index = TEMPDRV_CUSTOM_CALLBACK_INDEX; index < TEMPDRV_CALLBACK_DEPTH; index++)
288 if (set[index].callback==NULL)
348 for (index = TEMPDRV_CUSTOM_CALLBACK_INDEX; index < TEMPDRV_CALLBACK_DEPTH; index++)
350 if (set[index].callback == callback)
378 for (index = TEMPDRV_CUSTOM_CALLBACK_INDEX; index < TEMPDRV_CALLBACK_DEPTH; index++)
381 if (set[index].callback!=NULL)
384 if (set[index].temp == emu)
406 int32_t res = (int32_t) calibrationTEMP - ((emu * 8) / 5);
432 int32_t res = (int32_t) calibrationEMU - ((temp * 5) >> 3);
442 return (uint8_t) res;
470 for (index = 0; index < TEMPDRV_CALLBACK_DEPTH; index++)
473 if (tempdrvHighCallbacks[index].callback!=NULL)
477 highCallback = &tempdrvHighCallbacks[index];
481 if (tempdrvHighCallbacks[index].temp>highCallback->
temp)
483 highCallback = &tempdrvHighCallbacks[index];
502 for (index = 0; index < TEMPDRV_CALLBACK_DEPTH; index++)
505 if (tempdrvLowCallbacks[index].callback!=NULL)
509 lowCallback = &tempdrvLowCallbacks[index];
513 if (tempdrvLowCallbacks[index].temp<lowCallback->temp)
515 lowCallback = &tempdrvLowCallbacks[index];
549 uint32_t DItemp, DIemu;
552 TEMPDRV_InitState =
true;
557 highCallback = &nullCallback;
558 lowCallback = &nullCallback;
568 DItemp = fallbackTEMP;
573 calibrationEMU = (DIemu) + ((5*(DItemp))/8);
574 calibrationTEMP = (DItemp) + (8*(DIemu)/5);
599 TEMPDRV_InitState =
false;
620 if (TEMPDRV_EnableState != enable)
622 TEMPDRV_EnableState = enable;
652 set = tempdrvHighCallbacks;
657 set = tempdrvLowCallbacks;
664 uint8_t index, count=0;
665 for (index = TEMPDRV_CUSTOM_CALLBACK_INDEX; index < TEMPDRV_CALLBACK_DEPTH; index++)
668 if (set[index].callback!=NULL)
755 if (TEMPDRV_InitState ==
false)
760 if (callback == NULL)
772 set = tempdrvHighCallbacks;
782 set = tempdrvLowCallbacks;
816 if (callback == NULL)
static int8_t convertToTemp(uint8_t emu)
Convert EMU value to degrees Celsius.
static void updateInterrupts(void)
Update interrupts based on active callbacks.
static bool removeCallback(TEMPDRV_CallbackSet_t *set, TEMPDRV_Callback_t callback)
Remove a callback from the set.
#define ECODE_EMDRV_TEMPDRV_DUP_TEMP
Requested temperature is a duplicate.
TEMPDRV_Callback_t callback
Callback function.
void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev)
Get chip major/minor revision.
__STATIC_INLINE void EMU_IntDisable(uint32_t flags)
Disable one or more EMU interrupts.
static bool checkForDuplicates(TEMPDRV_CallbackSet_t *set, int8_t temp)
Check if another callback has registered the same temperature.
#define _EMU_TEMPLIMITS_TEMPLOW_SHIFT
static int8_t findCallbackSpace(TEMPDRV_CallbackSet_t *set)
Find an empty spot for callback in set.
void(* TEMPDRV_Callback_t)(int8_t temp, TEMPDRV_LimitType_t limit)
TEMPDRV temperature limit callback function.
int8_t TEMPDRV_GetTemp(void)
Get the current temperature.
void EMU_SetBiasMode(EMU_BiasMode_TypeDef mode)
Adjust the bias refresh rate.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define EMU_LOCK_LOCKKEY_LOCKED
#define EMU_LOCK_LOCKKEY_UNLOCK
#define _DEVINFO_EMUTEMP_EMUTEMPROOM_MASK
#define _EMU_TEMPLIMITS_TEMPHIGH_SHIFT
Ecode_t TEMPDRV_DeInit(void)
De-initialize the TEMP driver.
static uint8_t convertToEmu(int8_t temp)
Convert a temperature in °C to an EMU sensor value.
void TEMPDRV_IRQHandler(void)
TEMPDRV Interrupt Handler.
#define EMU_LOCK_LOCKKEY_LOCK
#define _EMU_TEMPLIMITS_TEMPHIGH_MASK
#define _DEVINFO_CAL_TEMP_SHIFT
static void errataInit(void)
Errata Initialization.
static Ecode_t addCallback(TEMPDRV_CallbackSet_t *set, int8_t temp, TEMPDRV_Callback_t callback)
Attempt to add a callback to a set.
#define ECODE_EMDRV_TEMPDRV_BAD_LIMIT
Temperature mismatch with limit.
#define _DEVINFO_EMUTEMP_EMUTEMPROOM_SHIFT
void EMU_IRQHandler(void)
EMU Interrupt Handler.
#define ECODE_EMDRV_TEMPDRV_NO_INIT
Function requires prior initialization.
uint32_t Ecode_t
Typedef for API function error code return values.
uint8_t temp
Limit temperature (EMU value)
__STATIC_INLINE void EMU_IntEnable(uint32_t flags)
Enable one or more EMU interrupts.
uint8_t TEMPDRV_GetActiveCallbacks(TEMPDRV_LimitType_t limit)
Get the number of active callbacks for a limit.
#define ECODE_EMDRV_TEMPDRV_PARAM_ERROR
Illegal input parameter.
#define _EMU_TEMPLIMITS_TEMPLOW_MASK
Ecode_t TEMPDRV_UnregisterCallback(TEMPDRV_Callback_t callback)
Unregister a callback in the TEMP driver.
#define ECODE_EMDRV_TEMPDRV_NO_SPACE
No more space to register.
Ecode_t TEMPDRV_Enable(bool enable)
Enable or disable the TEMP driver.
Energy management unit (EMU) peripheral API.
__STATIC_INLINE void EMU_IntClear(uint32_t flags)
Clear one or more pending EMU interrupts.
#define ECODE_EMDRV_TEMPDRV_NO_CALLBACK
Can't find callback.
static void disableInterrupts(void)
Turn off and clear EMU temperature related interrupts.
static void errataStateUpdate(int8_t temp)
Errata State Update.
enum TEMPDRV_LimitType TEMPDRV_LimitType_t
#define ECODE_EMDRV_TEMPDRV_OK
Success return value.
Ecode_t TEMPDRV_RegisterCallback(int8_t temp, TEMPDRV_LimitType_t limit, TEMPDRV_Callback_t callback)
Register a callback in the TEMP driver.
__STATIC_INLINE uint32_t EMU_IntGetEnabled(void)
Get enabled and pending EMU interrupt flags. Useful for handling more interrupt sources in the same i...
Ecode_t TEMPDRV_Init(void)
Initialize the TEMP driver.
#define _DEVINFO_CAL_TEMP_MASK
static void errataCallback(int8_t temp, TEMPDRV_LimitType_t limit)
Errata Callback.