cpu/sam0_common: add rtc_get_tamper()

Add a function to query which tamper event woke the CPU from hibernation.
This commit is contained in:
Benjamin Valentin 2021-03-11 22:30:27 +01:00
parent e768a85f62
commit 73dbda99ac
2 changed files with 19 additions and 0 deletions

View File

@ -1144,6 +1144,15 @@ int rtc_tamper_register(gpio_t pin, gpio_flank_t flank);
* @brief Enable Tamper Detection IRQs
*/
void rtc_tamper_enable(void);
/**
* @brief Get and clear the RTC tamper event that has woken the CPU
* from Deep Sleep.
*
* @return The set bits in the return value correspond to the tamper
* pin index inside the @ref rtc_tamper_pins array.
*/
uint8_t rtc_get_tamper_event(void);
/** @} */
/**

View File

@ -374,6 +374,16 @@ void rtc_tamper_enable(void)
DEBUG("tamper enabled\n");
}
uint8_t rtc_get_tamper_event(void)
{
uint32_t ret = RTC->MODE0.TAMPID.reg;
/* clear tamper event */
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_TAMPER;
RTC->MODE0.TAMPID.reg = ret;
return ret & RTC_TAMPID_TAMPID_Msk;
}
#endif /* RTC_NUM_OF_TAMPERS */
void rtt_set_overflow_cb(rtt_cb_t cb, void *arg)