diff --git a/src/PontCoopScheduler.c b/src/PontCoopScheduler.c index fbcdfe4..af536e2 100644 --- a/src/PontCoopScheduler.c +++ b/src/PontCoopScheduler.c @@ -7,6 +7,8 @@ #include +#include + #include "PontCoopScheduler.h" diff --git a/src/eggTimer.h b/src/eggTimer.h index 3195e4b..820b63d 100644 --- a/src/eggTimer.h +++ b/src/eggTimer.h @@ -18,7 +18,7 @@ extern const uint32_t EGG_TIMER_CYCLE; void eggTimerInit(void *handleArg); void eggTimerExec(void *handleArg); void eggTimerStart(void *handleArg); - +void eggTimerAlarm(void *handleArg); #endif /* EGGTIMER_H_ */ diff --git a/src/gpio.c b/src/gpio.c index 4d64ed6..db5fe0a 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -19,6 +19,13 @@ extern tPinCfg pinCfg[]; void gpioInitPins() { + P1OUT = 0; + P1DIR = 0; + P1REN = 0; + P2OUT = 0; + P2DIR = 0; + P2REN = 0; + for (tPin p = PINS_FIRST; p < PINS_END; p += 1) { tPinCfg pin = pinCfg[p]; if (pin.portId == PORT1) { diff --git a/src/gpio.h b/src/gpio.h index ffae80c..eaddff1 100644 --- a/src/gpio.h +++ b/src/gpio.h @@ -51,6 +51,7 @@ typedef enum { DIGIT_1, BUTTON_1, LED_1, + POWER, PINS_END } tPin; diff --git a/src/gpioCfg.c b/src/gpioCfg.c index 31797e3..dba83b5 100644 --- a/src/gpioCfg.c +++ b/src/gpioCfg.c @@ -19,5 +19,6 @@ tPinCfg pinCfg[PINS_END] = { {PORT2, BIT0, PIN_OUT, HIGH}, //0 {PORT1, BIT5, PIN_OUT, HIGH}, //1 {PORT1, BIT0, PIN_IN_PULLUP, LOW}, // BUTTON_1 - {PORT1, BIT1, PIN_OUT, LOW}, //TESTPIN1 + {PORT1, BIT1, PIN_OUT, LOW}, // LED_1 + {PORT1, BIT2, PIN_OUT, HIGH}, // POWER }; diff --git a/src/main.c b/src/main.c index d953f43..e8bfc69 100644 --- a/src/main.c +++ b/src/main.c @@ -19,9 +19,23 @@ #include "measure.h" #include "eggTimer.h" #include "button.h" +#include "gpio.h" +void powerDown(void *handleArg) { + P1OUT = 0; + P1DIR = 0xff; + P1REN = 0; + P2OUT = 0; + P2DIR = 0xff; + P2REN = 0; + ADC10CTL0 = 0; + + LPM4; + while (1); +} + int main() { WDTCTL = WDTPW | WDTHOLD; @@ -36,6 +50,18 @@ int main() { timeInit(); schInit(); + + schAdd(eggTimerAlarm, NULL, 0, 37); + schAdd(powerDown, NULL, 5000, 0); + + + + + + + + +#if 0 // interrupts are required for delay function in displayInit(); __enable_interrupt(); displayInit(NULL); @@ -52,11 +78,12 @@ int main() { schAdd(eggTimerExec, NULL, 0, EGG_TIMER_CYCLE); schAdd(buttonExec, NULL, 0, BUTTON_CYCLE); - +#endif __enable_interrupt(); while (1) { schExec(); + LPM3; // put it into the idle loop, it is not time critical // but should get as much time as possible to avoid diff --git a/src/time.c b/src/time.c index a7fd15f..6d67a0d 100644 --- a/src/time.c +++ b/src/time.c @@ -16,6 +16,7 @@ volatile uint32_t timestamp; ISR(TIMER0_A0, TA0_ISR) { + LPM3_EXIT; timestamp++; schUpdate(); }