File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed
Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -1353,10 +1353,26 @@ void rtc_tamper_init(void);
13531353 * @param pin The GPIO pin to be used for tamper detection
13541354 * @param flank The Flank to trigger the even
13551355 *
1356- * @return 0 on success, -1 if pin is not RTC pin
1356+ * @return 0 on success, -1 if pin is not an RTC pin
13571357 */
13581358int rtc_tamper_register (gpio_t pin , gpio_flank_t flank );
13591359
1360+ /**
1361+ * @brief (Re-)Enable Tamper Detection pin
1362+ *
1363+ * @param pin The GPIO pin to be used for tamper detection
1364+ *
1365+ * @return 0 on success, -1 if pin is not an RTC pin
1366+ */
1367+ int rtc_tamper_pin_enable (gpio_t pin );
1368+
1369+ /**
1370+ * @brief Disable Tamper Detection pin
1371+ *
1372+ * @param pin The GPIO pin to no longer be used for tamper detection
1373+ */
1374+ void rtc_tamper_pin_disable (gpio_t pin );
1375+
13601376/**
13611377 * @brief Enable Tamper Detection IRQs
13621378 */
Original file line number Diff line number Diff line change @@ -481,6 +481,10 @@ void gpio_irq_enable(gpio_t pin)
481481
482482 /* enable wake from deep sleep */
483483 _set_extwake (pin , true);
484+
485+ if (IS_ACTIVE (MODULE_PERIPH_GPIO_TAMPER_WAKE )) {
486+ rtc_tamper_pin_enable (pin );
487+ }
484488}
485489
486490void gpio_irq_disable (gpio_t pin )
@@ -502,6 +506,10 @@ void gpio_irq_disable(gpio_t pin)
502506
503507 /* disable wake from deep sleep */
504508 _set_extwake (pin , false);
509+
510+ if (IS_ACTIVE (MODULE_PERIPH_GPIO_TAMPER_WAKE )) {
511+ rtc_tamper_pin_disable (pin );
512+ }
505513}
506514
507515#if defined(CPU_COMMON_SAML1X )
Original file line number Diff line number Diff line change 2727#include <stdint.h>
2828#include <string.h>
2929
30+ #include "atomic_utils.h"
3031#include "pm_layered.h"
3132#include "periph/rtc.h"
3233#include "periph/rtt.h"
@@ -503,6 +504,30 @@ int rtc_tamper_register(gpio_t pin, gpio_flank_t flank)
503504 return 0 ;
504505}
505506
507+ int rtc_tamper_pin_enable (gpio_t pin )
508+ {
509+ int in = _rtc_pin (pin );
510+
511+ if (in < 0 ) {
512+ return -1 ;
513+ }
514+
515+ atomic_set_bit_u32 (atomic_bit_u32 (& tampctr , 2 * in ));
516+
517+ return 0 ;
518+ }
519+
520+ void rtc_tamper_pin_disable (gpio_t pin )
521+ {
522+ int in = _rtc_pin (pin );
523+
524+ if (in < 0 ) {
525+ return ;
526+ }
527+
528+ atomic_clear_bit_u32 (atomic_bit_u32 (& tampctr , 2 * in ));
529+ }
530+
506531void rtc_tamper_enable (void )
507532{
508533 DEBUG ("enable tamper\n" );
You can’t perform that action at this time.
0 commit comments