Microchip® Advanced Software Framework

tc_timeout_example2.c File Reference

megaAVR Timer/Counter (TC) Timeout Driver Example 2

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "tc_timeout.h"

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().

anonymous enum
Enumerator
DEBOUNCE_TIMEOUT 

static void toggle_led ( uint8_t  mask)
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.

Parameters
maskMask of port LEDs to toggle

Referenced by main().