megaAVR Timer/Counter (TC) Timeout Driver Example 2
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | BUTTON_MASK (1 << 0) |
#define | DEBOUNCE_TICKS (50 * TC_TIMEOUT_TICK_HZ / 1000) |
Length of debounce timeout, in ticks. More... | |
#define | LED_MASK (1 << 0) |
Enumerations | |
enum | { DEBOUNCE_TIMEOUT } |
Functions | |
int | main (void) |
static void | toggle_led (uint8_t mask) |
Toggle LED. More... | |
#define BUTTON_MASK (1 << 0) |
Referenced by main().
#define DEBOUNCE_TICKS (50 * TC_TIMEOUT_TICK_HZ / 1000) |
Length of debounce timeout, in ticks.
We want 50ms debounce timeout so we calculate that from the actual tick rate defined by TC_TIMEOUT_TICK_HZ.
Referenced by main().
#define LED_MASK (1 << 0) |
Referenced by main().
int main | ( | void | ) |
|
inlinestatic |
Toggle LED.
Newer megaAVR devices can toggle a I/O pin by writing to PIN register, while on older ones this needs to be done by a read-modify-write operation. This function abstract these differences.
mask | Mask of port LEDs to toggle |
Referenced by main().