power down after two minutes

This commit is contained in:
Wolfgang Hottgenroth
2016-09-08 23:28:32 +02:00
parent 20dd4d587b
commit e60b3b73eb
2 changed files with 13 additions and 4 deletions

View File

@ -9,14 +9,18 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <msp430g2553.h>
#include "eggTimer.h" #include "eggTimer.h"
#include "displayMuxer.h" #include "displayMuxer.h"
#include "button.h" #include "button.h"
#include "gpio.h" #include "gpio.h"
#include "PontCoopScheduler.h"
const uint32_t EGG_TIMER_CYCLE = 1000; const uint32_t EGG_TIMER_CYCLE = 1000;
const uint32_t LED_CYCLE = 250; const uint32_t LED_CYCLE = 250;
const uint32_t POWER_DOWN_DELAY = 120000;
const uint8_t COOKING_TIME = 120; const uint8_t COOKING_TIME = 120;
uint8_t restCookingTime; uint8_t restCookingTime;
@ -24,6 +28,14 @@ bool timerRunning;
bool timerStarted; bool timerStarted;
void eggTimerPowerDown(void *handleArg) {
P1DIR = 0;
P2DIR = 0;
P1OUT = 0;
P2OUT = 0;
LPM4;
}
void eggTimerStart(void *handleArg) { void eggTimerStart(void *handleArg) {
if (! timerStarted) { if (! timerStarted) {
timerRunning = true; timerRunning = true;
@ -49,6 +61,7 @@ void eggTimerExec(void *handleArg) {
if (restCookingTime == 0) { if (restCookingTime == 0) {
// activate alarm // activate alarm
schAdd(eggTimerAlarm, NULL, 0, LED_CYCLE); schAdd(eggTimerAlarm, NULL, 0, LED_CYCLE);
schAdd(eggTimerPowerDown, NULL, POWER_DOWN_DELAY, 0);
timerRunning = false; timerRunning = false;
} }
} }

View File

@ -18,15 +18,11 @@ volatile uint32_t timestamp;
ISR(TIMER0_A0, TA0_ISR) { ISR(TIMER0_A0, TA0_ISR) {
timestamp++; timestamp++;
schUpdate(); schUpdate();
// P1OUT ^= BIT0;
} }
void timeInit() { void timeInit() {
timestamp = 0; timestamp = 0;
// P1DIR |= BIT0;
TACCR0 = 32; TACCR0 = 32;
TACCTL0 = CCIE; TACCTL0 = CCIE;
TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR; TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR;