mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 05:53:49 +01:00
cpu/sam0_common: clear tamper wake on gpio_irq_disable()
This commit is contained in:
parent
5d26414ecf
commit
15ffad4e39
@ -1353,10 +1353,26 @@ void rtc_tamper_init(void);
|
||||
* @param pin The GPIO pin to be used for tamper detection
|
||||
* @param flank The Flank to trigger the even
|
||||
*
|
||||
* @return 0 on success, -1 if pin is not RTC pin
|
||||
* @return 0 on success, -1 if pin is not an RTC pin
|
||||
*/
|
||||
int rtc_tamper_register(gpio_t pin, gpio_flank_t flank);
|
||||
|
||||
/**
|
||||
* @brief (Re-)Enable Tamper Detection pin
|
||||
*
|
||||
* @param pin The GPIO pin to be used for tamper detection
|
||||
*
|
||||
* @return 0 on success, -1 if pin is not an RTC pin
|
||||
*/
|
||||
int rtc_tamper_pin_enable(gpio_t pin);
|
||||
|
||||
/**
|
||||
* @brief Disable Tamper Detection pin
|
||||
*
|
||||
* @param pin The GPIO pin to no longer be used for tamper detection
|
||||
*/
|
||||
void rtc_tamper_pin_disable(gpio_t pin);
|
||||
|
||||
/**
|
||||
* @brief Enable Tamper Detection IRQs
|
||||
*/
|
||||
|
||||
@ -481,6 +481,10 @@ void gpio_irq_enable(gpio_t pin)
|
||||
|
||||
/* enable wake from deep sleep */
|
||||
_set_extwake(pin, true);
|
||||
|
||||
if (IS_ACTIVE(MODULE_PERIPH_GPIO_TAMPER_WAKE)) {
|
||||
rtc_tamper_pin_enable(pin);
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_irq_disable(gpio_t pin)
|
||||
@ -502,6 +506,10 @@ void gpio_irq_disable(gpio_t pin)
|
||||
|
||||
/* disable wake from deep sleep */
|
||||
_set_extwake(pin, false);
|
||||
|
||||
if (IS_ACTIVE(MODULE_PERIPH_GPIO_TAMPER_WAKE)) {
|
||||
rtc_tamper_pin_disable(pin);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CPU_COMMON_SAML1X)
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atomic_utils.h"
|
||||
#include "pm_layered.h"
|
||||
#include "periph/rtc.h"
|
||||
#include "periph/rtt.h"
|
||||
@ -503,6 +504,30 @@ int rtc_tamper_register(gpio_t pin, gpio_flank_t flank)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtc_tamper_pin_enable(gpio_t pin)
|
||||
{
|
||||
int in = _rtc_pin(pin);
|
||||
|
||||
if (in < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
atomic_set_bit_u32(atomic_bit_u32(&tampctr, 2 * in));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtc_tamper_pin_disable(gpio_t pin)
|
||||
{
|
||||
int in = _rtc_pin(pin);
|
||||
|
||||
if (in < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_clear_bit_u32(atomic_bit_u32(&tampctr, 2 * in));
|
||||
}
|
||||
|
||||
void rtc_tamper_enable(void)
|
||||
{
|
||||
DEBUG("enable tamper\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user