HWA
Bare metal programming with style
hwa/atmel/avr/examples/02-2-blink-watchdog-irq/main.c

Blink a LED using the watchdog IRQ

/* This file is part of the HWA project.
* Copyright (c) 2012,2015 Christophe Duparquet.
* All rights reserved. Read LICENSE.TXT for details.
*/
#include BOARD_H
/* Watchdog timeout
*/
#define TIMEOUT 250ms
/* Service watchdog IRQ
*/
HW_ISR( (watchdog0,irq) )
{
/* Blink the LED
*/
hw( toggle, PIN_LED );
}
int main ( )
{
/* Create a HWA context preloaded with RESET values to
* collect the hardware configuration
*/
hwa( begin, reset );
/* Configure the LED pin
*/
hwa( configure, PIN_LED, mode, digital_output );
/* Configure the watchdog to trigger an IRQ every TIMEOUT
*/
hwa( configure, watchdog0,
timeout, TIMEOUT,
action, irq );
/* Configure the core to enter idle mode when asked to sleep
*/
hwa( configure, core0,
sleep, enabled,
sleep_mode, idle );
/* Write this configuration into the hardware
*/
hwa( commit );
/* Enable interrupts
*/
hw( enable, interrupts );
/* Sleep between interrupts
*/
for(;;)
hw( wait, irq );
return 0 ;
}
hwa
#define hwa(...)
hwa( action, object [,...] ) stores an action for an object into a HWA context.
Definition: hwa_macros.h:552
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
HW_ISR
#define HW_ISR(...)
Definition: hwa_interrupts.h:80