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)
 Main function. More...
 
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 

int main ( void  )

Main function.

Main function.

This function initializes the MAC, initiates a MLME reset request (wpan_mlme_reset_req()), and implements a the main loop.

Main function.

The master example begins by initializing required board resources. The system clock, basic GPIO pin mapping, and interrupt vectors are established.

A memory location on a TWI slave is written with a fixed test pattern which is then read back into a separate buffer. As a basic sanity check, the original write-buffer values are compared with values read from the slave to a separate buffer. An LED on the development board is illuminated when there is a match between the written and read data.

Returns
Nothing.

Main function.

Main function.

Initializes the clock system, board and serial output, then sets up the Sleep Manager unit test suite and runs it.

Main function.

Initializes the clock system, board and serial output, then sets up the IOPORT Service unit test suite and runs it.

Main function.

Initializes the clock system, board and serial output, then sets up the USART unit test suite and runs it.

Main function.

Initializes the clock system, board and serial output, then sets up the TWI unit test suite and runs it.

Main function.

Returns
error code

The SAM3X_EK, SAM3X Arduino board and SAM4C_EK use two bytes length internal address EEPROM.

TWI and QT600 interface initialization

References BUTTON_MASK, DEBOUNCE_TICKS, DEBOUNCE_TIMEOUT, LED_MASK, tc_timeout_init(), tc_timeout_start_singleshot(), tc_timeout_test_and_clear_expired(), and toggle_led().

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