diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-24 10:35:28 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-24 10:35:28 +0800 |
| commit | d617852905decfbf2abb82adea157dd954d46580 (patch) | |
| tree | 7663174c8e3154a084afa2c8a9c7e9beeadb644f /ding.c | |
| parent | c3d001a15f759051cfc5994cd6dbc21013a3f2f3 (diff) | |
| download | avr-nrf24l01-driver-d617852905decfbf2abb82adea157dd954d46580.tar.gz | |
Fix duplicate packet by debouncing btn.
Diffstat (limited to 'ding.c')
| -rw-r--r-- | ding.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -43,7 +43,7 @@ static inline void init_btns(void) static inline int is_btn_pressed(unsigned char btn) { if (!((PIND >> btn) & 0x01)) { - _delay_us(2000); + _delay_ms(100); return !((PIND >> btn) & 0x01); } @@ -95,12 +95,16 @@ ISR(RX_PCINTVEC) ISR(INT0_vect) { - if (is_btn_pressed(LOCK_PIN)) + if (is_btn_pressed(LOCK_PIN)) { lock = 1; + uart_write_line("IRQ0"); + } } ISR(INT1_vect) { - if (is_btn_pressed(UNLOCK_PIN)) + if (is_btn_pressed(UNLOCK_PIN)) { lock = 1; + uart_write_line("IRQ1"); + } } |
