1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

Merge pull request #21846 from benpicco/cpu/sam0-gpio_tamper

cpu/sam0_common: clear tamper wake on `gpio_irq_disable()`
This commit is contained in:
crasbe 2025-11-06 23:12:11 +00:00 committed by GitHub
commit 84aad9948d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 1 deletions

View File

@ -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
*/

View File

@ -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)

View File

@ -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");