Skip to content

Commit

Permalink
Move power stuff to power.h
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek committed Apr 8, 2011
1 parent c3d75aa commit 4ad01d8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
18 changes: 3 additions & 15 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <util/delay.h>

#include "timer.h"
#include "uart.h"
#include "at45.h"
#include "loader.h"
#include "power.h"


static inline
void power_down()
{
cli();

/* switch off leds */
PORTE |= (1 << PE2);
PORTG |= (1 << PG1);

/* switch off speaker power */
PORTE |= (1 << PE7);

set_sleep_mode(SLEEP_MODE_IDLE);
sei();
sleep_mode();
}

int main()
{
Expand All @@ -32,7 +20,7 @@ int main()
//DDRB = (1 << PB6);
DDRG = (1 << PG1) ; /* ring */
DDRE = ((1 << PE2) | /* LED */
(1 << PE7)); /* Speaker Power */
(1 << PE7)); /* Speaker and Flash Power */
DDRB &= ~((1 << PB4) | /* COM on */
(1 << PB5)); /* HANG */

Expand Down
37 changes: 37 additions & 0 deletions power.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef DISCONNECT_POWER_H
#define DISCONNECT_POWER_H
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>


static inline
void power_down()
{
cli();

/* switch off leds */
PORTE |= (1 << PE2);
PORTG |= (1 << PG1);

/* switch off speaker power */
PORTE |= (1 << PE7);

set_sleep_mode(SLEEP_MODE_IDLE);
sei();
sleep_mode();
}

static inline
void main_power_on()
{
PORTE &= ~(1 << PE7);
}

static inline
void main_power_off()
{
PORTE |= (1 << PE7);
}

#endif /* DISCONNECT_POWER_H */

0 comments on commit 4ad01d8

Please sign in to comment.