Compare commits
8 Commits
master
...
SecondEdit
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8155cf109c | ||
![]() |
bd4731143d | ||
![]() |
5cde05f4a3 | ||
![]() |
499125d2fd | ||
![]() |
267b8e7bf2 | ||
![]() |
1d8dd7eb63 | ||
![]() |
0a8e7f5b0b | ||
![]() |
811c9a5aba |
1
.hgtags
1
.hgtags
@ -1 +1,2 @@
|
|||||||
b4caefc05db1ac8c142e4427a59d7771e3ae1d38 WORKS_1
|
b4caefc05db1ac8c142e4427a59d7771e3ae1d38 WORKS_1
|
||||||
|
78b8b97f294d32c8d383ece023b32cd8076805f0 WORKS_2
|
||||||
|
@ -7,6 +7,8 @@ P2.2 G
|
|||||||
P2.1 C
|
P2.1 C
|
||||||
P2.0 1
|
P2.0 1
|
||||||
P1.5 2
|
P1.5 2
|
||||||
|
P1.2 3
|
||||||
|
P1.1 LED
|
||||||
P1.0 T
|
P1.0 T
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <msp430g2553.h>
|
||||||
|
|
||||||
|
|
||||||
#include "PontCoopScheduler.h"
|
#include "PontCoopScheduler.h"
|
||||||
|
|
||||||
|
@ -47,64 +47,59 @@ const tPin *NUMBERS[] = { NUMBER0, NUMBER1, NUMBER2, NUMBER3, NUMBER4,
|
|||||||
NUMBER5, NUMBER6, NUMBER7, NUMBER8, NUMBER9, ALL_PATTERN, H_PATTERN,
|
NUMBER5, NUMBER6, NUMBER7, NUMBER8, NUMBER9, ALL_PATTERN, H_PATTERN,
|
||||||
I_PATTERN, EMPTY_PATTERN };
|
I_PATTERN, EMPTY_PATTERN };
|
||||||
|
|
||||||
const tPin DIGITS[] = { DIGIT_0, DIGIT_1, PINS_END };
|
const tPin DIGITS[] = { DIGIT_0, DIGIT_1, DIGIT_2, PINS_END };
|
||||||
|
|
||||||
|
|
||||||
uint8_t digitValues[2] = { EMPTY_ID, EMPTY_ID };
|
uint8_t digitValues[] = { EMPTY_ID, EMPTY_ID, EMPTY_ID };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void displayInit(void *handleArg) {
|
void displayInit(void *handleArg) {
|
||||||
for (tPin d = DIGIT_0; d <= DIGIT_1; d++) {
|
for (tPin s = SEG_A; s <= SEG_F; s++) {
|
||||||
gpioSetPin(d, LOW);
|
|
||||||
for (tPin s = SEG_A; s <= SEG_G; s++) {
|
|
||||||
gpioSetPin(s, HIGH);
|
|
||||||
ms_active_delay(INIT_CYCLE_DELAY);
|
|
||||||
gpioSetPin(s, LOW);
|
gpioSetPin(s, LOW);
|
||||||
}
|
}
|
||||||
|
for (tPin d = DIGIT_2; d >= DIGIT_0; d--) {
|
||||||
|
gpioSetPin(d, LOW);
|
||||||
|
gpioSetPin(SEG_G, HIGH);
|
||||||
|
ms_active_delay(INIT_CYCLE_DELAY);
|
||||||
|
gpioSetPin(SEG_G, LOW);
|
||||||
gpioSetPin(d, HIGH);
|
gpioSetPin(d, HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showNumber(uint8_t n) {
|
static void showNumber(uint8_t n) {
|
||||||
const tPin *pattern = NUMBERS[ALL_ID];
|
for (const tPin *pattern = NUMBERS[ALL_ID]; *pattern != PINS_END; pattern++) {
|
||||||
do {
|
|
||||||
gpioSetPin(*pattern, LOW);
|
gpioSetPin(*pattern, LOW);
|
||||||
pattern++;
|
}
|
||||||
} while (*pattern != PINS_END);
|
for (const tPin *pattern = NUMBERS[n]; *pattern != PINS_END; pattern++) {
|
||||||
pattern = NUMBERS[n];
|
|
||||||
do {
|
|
||||||
gpioSetPin(*pattern, HIGH);
|
gpioSetPin(*pattern, HIGH);
|
||||||
pattern++;
|
}
|
||||||
} while (*pattern != PINS_END);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void displaySetValue(uint8_t v) {
|
void displaySetValue(uint8_t v) {
|
||||||
if (v >= 100) {
|
uint32_t a,b,c,d;
|
||||||
digitValues[1] = H_ID;
|
a = v;
|
||||||
digitValues[0] = I_ID;
|
b = a / 100;
|
||||||
} else {
|
c = (a - b * 100) / 10;
|
||||||
digitValues[1] = v / 10;
|
d = a - c * 10 - b * 100;
|
||||||
digitValues[0] = v - digitValues[1] * 10;
|
digitValues[2] = (b == 0) ? EMPTY_ID : (uint8_t)b;
|
||||||
}
|
digitValues[1] = ((c == 0) && (b == 0)) ? EMPTY_ID : (uint8_t)c;
|
||||||
|
digitValues[0] = (uint8_t)d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayExec(void *handleArg) {
|
void displayExec(void *handleArg) {
|
||||||
static uint8_t activeDigit = 0;
|
static uint8_t activeDigit = 0;
|
||||||
|
|
||||||
activeDigit++;
|
activeDigit++;
|
||||||
if (activeDigit == 2) {
|
if (activeDigit == 3) {
|
||||||
activeDigit = 0;
|
activeDigit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tPin *digit = DIGITS;
|
for (const tPin *digit = DIGITS; *digit != PINS_END; digit++) {
|
||||||
do {
|
|
||||||
gpioSetPin(*digit, HIGH);
|
gpioSetPin(*digit, HIGH);
|
||||||
digit++;
|
}
|
||||||
} while (*digit != PINS_END);
|
|
||||||
|
|
||||||
digit = DIGITS + activeDigit;
|
gpioSetPin(DIGITS[activeDigit], LOW);
|
||||||
gpioSetPin(*digit, LOW);
|
|
||||||
|
|
||||||
showNumber(digitValues[activeDigit]);
|
showNumber(digitValues[activeDigit]);
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,12 @@
|
|||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "PontCoopScheduler.h"
|
#include "PontCoopScheduler.h"
|
||||||
|
#include "powerDown.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 uint32_t MY_POWER_DOWN_DELAY = 120000;
|
||||||
|
|
||||||
const uint8_t COOKING_TIME = 120;
|
const uint8_t COOKING_TIME = 120;
|
||||||
uint8_t restCookingTime;
|
uint8_t restCookingTime;
|
||||||
@ -28,14 +29,8 @@ bool timerRunning;
|
|||||||
bool timerStarted;
|
bool timerStarted;
|
||||||
|
|
||||||
|
|
||||||
void eggTimerPowerDown(void *handleArg) {
|
|
||||||
P1DIR = 0;
|
|
||||||
P2DIR = 0;
|
|
||||||
P1OUT = 0;
|
|
||||||
P2OUT = 0;
|
|
||||||
ADC10CTL0 = 0;
|
|
||||||
LPM4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void eggTimerStart(void *handleArg) {
|
void eggTimerStart(void *handleArg) {
|
||||||
if (! timerStarted) {
|
if (! timerStarted) {
|
||||||
@ -62,7 +57,8 @@ 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);
|
schDel(powerDown, NULL);
|
||||||
|
schAdd(powerDown, NULL, MY_POWER_DOWN_DELAY, 0);
|
||||||
timerRunning = false;
|
timerRunning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ extern const uint32_t EGG_TIMER_CYCLE;
|
|||||||
void eggTimerInit(void *handleArg);
|
void eggTimerInit(void *handleArg);
|
||||||
void eggTimerExec(void *handleArg);
|
void eggTimerExec(void *handleArg);
|
||||||
void eggTimerStart(void *handleArg);
|
void eggTimerStart(void *handleArg);
|
||||||
|
void eggTimerAlarm(void *handleArg);
|
||||||
|
|
||||||
|
|
||||||
#endif /* EGGTIMER_H_ */
|
#endif /* EGGTIMER_H_ */
|
||||||
|
10
src/gpio.c
10
src/gpio.c
@ -19,6 +19,13 @@ extern tPinCfg pinCfg[];
|
|||||||
|
|
||||||
|
|
||||||
void gpioInitPins() {
|
void gpioInitPins() {
|
||||||
|
P1OUT = 0;
|
||||||
|
P1DIR = 0;
|
||||||
|
P1REN = 0;
|
||||||
|
P2OUT = 0;
|
||||||
|
P2DIR = 0;
|
||||||
|
P2REN = 0;
|
||||||
|
|
||||||
for (tPin p = PINS_FIRST; p < PINS_END; p += 1) {
|
for (tPin p = PINS_FIRST; p < PINS_END; p += 1) {
|
||||||
tPinCfg pin = pinCfg[p];
|
tPinCfg pin = pinCfg[p];
|
||||||
if (pin.portId == PORT1) {
|
if (pin.portId == PORT1) {
|
||||||
@ -26,6 +33,7 @@ void gpioInitPins() {
|
|||||||
P1DIR |= pin.bit;
|
P1DIR |= pin.bit;
|
||||||
P1SEL &= ~pin.bit;
|
P1SEL &= ~pin.bit;
|
||||||
P1SEL2 &= ~pin.bit;
|
P1SEL2 &= ~pin.bit;
|
||||||
|
gpioSetPin(p, pin.defaultOut);
|
||||||
} else if (pin.direction == PIN_IN) {
|
} else if (pin.direction == PIN_IN) {
|
||||||
P1DIR &= ~pin.bit;
|
P1DIR &= ~pin.bit;
|
||||||
P1SEL &= ~pin.bit;
|
P1SEL &= ~pin.bit;
|
||||||
@ -43,6 +51,7 @@ void gpioInitPins() {
|
|||||||
P2DIR |= pin.bit;
|
P2DIR |= pin.bit;
|
||||||
P2SEL &= ~pin.bit;
|
P2SEL &= ~pin.bit;
|
||||||
P2SEL2 &= ~pin.bit;
|
P2SEL2 &= ~pin.bit;
|
||||||
|
gpioSetPin(p, pin.defaultOut);
|
||||||
} else if (pin.direction == PIN_IN) {
|
} else if (pin.direction == PIN_IN) {
|
||||||
P2DIR &= ~pin.bit;
|
P2DIR &= ~pin.bit;
|
||||||
P2SEL &= ~pin.bit;
|
P2SEL &= ~pin.bit;
|
||||||
@ -56,7 +65,6 @@ void gpioInitPins() {
|
|||||||
P2OUT |= pin.bit;
|
P2OUT |= pin.bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gpioSetPin(p, pin.defaultOut);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ typedef enum {
|
|||||||
SEG_G,
|
SEG_G,
|
||||||
DIGIT_0,
|
DIGIT_0,
|
||||||
DIGIT_1,
|
DIGIT_1,
|
||||||
|
DIGIT_2,
|
||||||
BUTTON_1,
|
BUTTON_1,
|
||||||
LED_1,
|
LED_1,
|
||||||
PINS_END
|
PINS_END
|
||||||
|
@ -18,6 +18,7 @@ tPinCfg pinCfg[PINS_END] = {
|
|||||||
{PORT2, BIT2, PIN_OUT, LOW}, //G
|
{PORT2, BIT2, PIN_OUT, LOW}, //G
|
||||||
{PORT2, BIT0, PIN_OUT, HIGH}, //0
|
{PORT2, BIT0, PIN_OUT, HIGH}, //0
|
||||||
{PORT1, BIT5, PIN_OUT, HIGH}, //1
|
{PORT1, BIT5, PIN_OUT, HIGH}, //1
|
||||||
|
{PORT1, BIT2, PIN_OUT, HIGH}, //2
|
||||||
{PORT1, BIT0, PIN_IN_PULLUP, LOW}, // BUTTON_1
|
{PORT1, BIT0, PIN_IN_PULLUP, LOW}, // BUTTON_1
|
||||||
{PORT1, BIT1, PIN_OUT, LOW}, //TESTPIN1
|
{PORT1, BIT1, PIN_OUT, LOW}, // LED_1
|
||||||
};
|
};
|
||||||
|
13
src/main.c
13
src/main.c
@ -19,12 +19,17 @@
|
|||||||
#include "measure.h"
|
#include "measure.h"
|
||||||
#include "eggTimer.h"
|
#include "eggTimer.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
#include "powerDown.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
WDTCTL = WDTPW | WDTHOLD;
|
WDTCTL = WDTPW | WDTHOLD;
|
||||||
|
|
||||||
|
__disable_interrupt();
|
||||||
|
|
||||||
// highest possible system clock
|
// highest possible system clock
|
||||||
DCOCTL = DCO0 | DCO1 | DCO2;
|
DCOCTL = DCO0 | DCO1 | DCO2;
|
||||||
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
||||||
@ -36,6 +41,8 @@ int main() {
|
|||||||
timeInit();
|
timeInit();
|
||||||
schInit();
|
schInit();
|
||||||
|
|
||||||
|
schAdd(powerDown, NULL, 1800000, 0); // default thermometer power down timeout: 30min
|
||||||
|
|
||||||
// interrupts are required for delay function in displayInit();
|
// interrupts are required for delay function in displayInit();
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
displayInit(NULL);
|
displayInit(NULL);
|
||||||
@ -57,11 +64,7 @@ int main() {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
schExec();
|
schExec();
|
||||||
|
//LPM3;
|
||||||
// put it into the idle loop, it is not time critical
|
|
||||||
// but should get as much time as possible to avoid
|
|
||||||
// flicker
|
|
||||||
//displayExec(NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
src/powerDown.c
Normal file
23
src/powerDown.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* powerDown.c
|
||||||
|
*
|
||||||
|
* Created on: Sep 11, 2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <msp430g2553.h>
|
||||||
|
|
||||||
|
|
||||||
|
void powerDown(void *handleArg) {
|
||||||
|
P1OUT = 0;
|
||||||
|
P1DIR = 0xff;
|
||||||
|
P1REN = 0;
|
||||||
|
P2OUT = 0;
|
||||||
|
P2DIR = 0xff;
|
||||||
|
P2REN = 0;
|
||||||
|
ADC10CTL0 = 0;
|
||||||
|
|
||||||
|
LPM4;
|
||||||
|
while (1);
|
||||||
|
}
|
14
src/powerDown.h
Normal file
14
src/powerDown.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* powerDown.h
|
||||||
|
*
|
||||||
|
* Created on: Sep 11, 2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef POWERDOWN_H_
|
||||||
|
#define POWERDOWN_H_
|
||||||
|
|
||||||
|
void powerDown(void *handleArg);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* POWERDOWN_H_ */
|
@ -16,6 +16,7 @@
|
|||||||
volatile uint32_t timestamp;
|
volatile uint32_t timestamp;
|
||||||
|
|
||||||
ISR(TIMER0_A0, TA0_ISR) {
|
ISR(TIMER0_A0, TA0_ISR) {
|
||||||
|
LPM3_EXIT;
|
||||||
timestamp++;
|
timestamp++;
|
||||||
schUpdate();
|
schUpdate();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user