Microchip® Advanced Software Framework

low_power_demo.c File Reference

Low Power Demo for AVR XMEGA.

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

#include <asf.h>
#include "conf_low_power_demo.h"

Functions

 ISR (SWITCH0_INT_VECT)
 ISR for switches on SWITCHPORT0. More...
 
 ISR (SWITCH1_INT_VECT)
 ISR for switches on SWITCHPORT1. More...
 
static void lowpower_init (void)
 Initialize low power mode. More...
 
static void lowpower_interrupt (void)
 RTC compare ISR. More...
 
int main (void)
 Run low power demo. More...
 

ISR ( SWITCH0_INT_VECT  )

ISR for switches on SWITCHPORT0.

This ISR calls the lowpower_interrupt function, and handles bouncing from the switches to not generate more than one interrupt per press. It also waits till a switch is no longer pressed before going back to the main routine.

References cpu_irq_disable, cpu_irq_enable, delay_ms, and lowpower_interrupt().

ISR ( SWITCH1_INT_VECT  )

ISR for switches on SWITCHPORT1.

This ISR calls the lowpower_interrupt function, and handles bouncing from the switches to not generate more than one interrupt per press. It also waits till a switch is no longer pressed before going back to the main routine.

References cpu_irq_disable, cpu_irq_enable, delay_ms, and lowpower_interrupt().

static void lowpower_init ( void  )
static

Initialize low power mode.

Disconnect all peripherals, enable pull-up on all I/O pins, disable watchdog timer and brown out detection, and JTAG-interface (if configured in conf_low_power_demo.h )

References ccp_write_io(), ioport_configure_pin(), ioport_configure_port_pin(), IOPORT_DIR_INPUT, IOPORT_INPUT_DISABLE, IOPORT_PULL_UP, sysclk_disable_peripheral_clock(), and wdt_disable().

Referenced by main().

static void lowpower_interrupt ( void  )
static

RTC compare ISR.

This function updates the sleep mode locks so that the device cycles through the different sleep modes.

References SLEEPMGR_ACTIVE, SLEEPMGR_ESTDBY, SLEEPMGR_IDLE, sleepmgr_lock_mode(), SLEEPMGR_PDOWN, SLEEPMGR_PSAVE, SLEEPMGR_STDBY, and sleepmgr_unlock_mode().

Referenced by ISR().

int main ( void  )

Run low power demo.

This function initializes the XMEGA to the least power consuming state, before initializing the sleep manager interrupts on switchports. The device is then put to sleep, and the sleep mode is configured by the interrupt routines.

References board_init(), cpu_irq_enable, ioport_configure_port_pin(), IOPORT_LEVEL, IOPORT_PULL_UP, lowpower_init(), pmic_init(), SLEEPMGR_ACTIVE, sleepmgr_enter_sleep(), sleepmgr_init(), sleepmgr_lock_mode(), and sysclk_init().