Compare commits
14 Commits
master
...
ThirdEditi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d2080e1db4 | ||
![]() |
fe8fb9ce58 | ||
![]() |
8f5d767d7e | ||
![]() |
d18f01704e | ||
![]() |
6aa4ce84e4 | ||
![]() |
2a85a9a400 | ||
![]() |
56e23d237c | ||
![]() |
c0c7d2afd0 | ||
![]() |
75fee98f11 | ||
![]() |
4ce993230f | ||
![]() |
275779c0b3 | ||
![]() |
63d3d29852 | ||
![]() |
8ad6c780f7 | ||
![]() |
5416467068 |
42
.cproject
42
.cproject
@ -25,10 +25,20 @@
|
||||
<option defaultValue="dk.xpg.msp430eclipse.compiler.option.optimization.level.none" id="dk.xpg.msp430eclipse.compiler.option.optimization.level.925149145" name="Optimization Level" superClass="dk.xpg.msp430eclipse.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option defaultValue="dk.xpg.msp430eclipse.compiler.option.debugging.level.default" id="dk.xpg.msp430eclipse.compiler.option.debugging.level.154569899" name="Debugging Level" superClass="dk.xpg.msp430eclipse.compiler.option.debugging.level" valueType="enumerated"/>
|
||||
<option id="dk.xpg.msp430eclipse.compiler.option.language.standard.1380069728" name="Standard" superClass="dk.xpg.msp430eclipse.compiler.option.language.standard" value="dk.xpg.msp430eclipse.compiler.option.language.standard.gnu99" valueType="enumerated"/>
|
||||
<option id="dk.xpg.msp430eclipse.compiler.option.includes.paths.1500718177" name="Include paths (-I)" superClass="dk.xpg.msp430eclipse.compiler.option.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislib}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislibformsp430}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/src}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.1393043846" name="C Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input"/>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.1115664253" name="C++ Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.assembler.gcc.423309473" name="MSP430 Assembler" superClass="dk.xpg.msp430eclipse.tool.assembler.gcc">
|
||||
<option id="dk.xpg.msp430eclipse.assembler.option.general.include.497233956" name="Include Paths (-I)" superClass="dk.xpg.msp430eclipse.assembler.option.general.include" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislib}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislibformsp430}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/src}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.assembler.input.1627828012" name="Assembler Files" superClass="dk.xpg.msp430eclipse.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.linker.gcc.1414250393" name="MSP430 Linker" superClass="dk.xpg.msp430eclipse.tool.linker.gcc">
|
||||
@ -38,7 +48,9 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="hottislibformsp430|hottislib|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="hottislib"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="hottislibformsp430"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
@ -68,10 +80,20 @@
|
||||
<tool id="dk.xpg.msp430eclipse.tool.compiler.gcc.1604096089" name="MSP430 C Compiler" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc">
|
||||
<option defaultValue="dk.xpg.msp430eclipse.compiler.option.optimization.level.most" id="dk.xpg.msp430eclipse.compiler.option.optimization.level.957179260" name="Optimization Level" superClass="dk.xpg.msp430eclipse.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option defaultValue="dk.xpg.msp430eclipse.compiler.option.debugging.level.none" id="dk.xpg.msp430eclipse.compiler.option.debugging.level.1445781415" name="Debugging Level" superClass="dk.xpg.msp430eclipse.compiler.option.debugging.level" valueType="enumerated"/>
|
||||
<option id="dk.xpg.msp430eclipse.compiler.option.includes.paths.1393153740" name="Include paths (-I)" superClass="dk.xpg.msp430eclipse.compiler.option.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislib}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislibformsp430}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/src}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.2129325944" name="C Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input"/>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.2128986642" name="C++ Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.assembler.gcc.1072807233" name="MSP430 Assembler" superClass="dk.xpg.msp430eclipse.tool.assembler.gcc">
|
||||
<option id="dk.xpg.msp430eclipse.assembler.option.general.include.905243057" name="Include Paths (-I)" superClass="dk.xpg.msp430eclipse.assembler.option.general.include" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislib}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/hottislibformsp430}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/teathermotimerng/src}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.assembler.input.20110081" name="Assembler Files" superClass="dk.xpg.msp430eclipse.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.linker.gcc.2090938199" name="MSP430 Linker" superClass="dk.xpg.msp430eclipse.tool.linker.gcc">
|
||||
@ -92,9 +114,21 @@
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="TeaThermoTimer.dk.xpg.msp430eclipse.project.gcc.elf.2012413821" name="MSP430 Cross Target Application" projectType="dk.xpg.msp430eclipse.project.gcc.elf"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.release.1716607718;dk.xpg.msp430eclipse.configuration.app.release.1716607718.;dk.xpg.msp430eclipse.tool.compiler.gcc.1604096089;dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.2128986642">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.debug.1048602252;dk.xpg.msp430eclipse.configuration.app.debug.1048602252.;dk.xpg.msp430eclipse.tool.compiler.gcc.1489133124;dk.xpg.msp430eclipse.tool.compiler.gcc.input.1393043846">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.debug.1048602252;dk.xpg.msp430eclipse.configuration.app.debug.1048602252.;dk.xpg.msp430eclipse.tool.compiler.gcc.1489133124;dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.1115664253">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.release.1716607718;dk.xpg.msp430eclipse.configuration.app.release.1716607718.;dk.xpg.msp430eclipse.tool.compiler.gcc.1604096089;dk.xpg.msp430eclipse.tool.compiler.gcc.input.2129325944">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/Debug/
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
[submodule "hottislib"]
|
||||
path = hottislib
|
||||
url = git@gitlab.com:wolutator/hottislib.git
|
||||
[submodule "hottislibformsp430"]
|
||||
path = hottislibformsp430
|
||||
url = git@gitlab.com:wolutator/hottislibformsp430.git
|
@ -7,6 +7,8 @@ P2.2 G
|
||||
P2.1 C
|
||||
P2.0 1
|
||||
P1.5 2
|
||||
P1.2 3
|
||||
P1.1 LED
|
||||
P1.0 T
|
||||
|
||||
|
||||
|
1
hottislib
Submodule
1
hottislib
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit bba75fe8e7dd424590091481284843e85c6a1199
|
1
hottislibformsp430
Submodule
1
hottislibformsp430
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 2be95189f47854a076f93122ea20b4053107d41a
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* PontCoopScheduler.c
|
||||
*
|
||||
* Created on: 29.08.2016
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "PontCoopScheduler.h"
|
||||
|
||||
tTask tasks[MAX_NUM_OF_TASKS];
|
||||
|
||||
|
||||
void schInit() {
|
||||
for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) {
|
||||
tasks[i].delay = 0;
|
||||
tasks[i].period = 0;
|
||||
tasks[i].run = 0;
|
||||
tasks[i].exec = NULL;
|
||||
tasks[i].handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void schAdd(void (*exec)(void *), void *handle, uint32_t delay, uint32_t period) {
|
||||
for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) {
|
||||
if (tasks[i].exec == NULL) {
|
||||
tasks[i].delay = delay;
|
||||
tasks[i].period = period;
|
||||
tasks[i].run = 0;
|
||||
tasks[i].exec = exec;
|
||||
tasks[i].handle = handle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void schDel(void (*exec)(void *), void *handle) {
|
||||
for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) {
|
||||
if ((tasks[i].exec == exec) && (tasks[i].handle == handle)) {
|
||||
tasks[i].exec = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void schExec() {
|
||||
for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) {
|
||||
if (tasks[i].exec != NULL && tasks[i].run > 0) {
|
||||
tasks[i].run--;
|
||||
tasks[i].exec(tasks[i].handle);
|
||||
if (tasks[i].period == 0) {
|
||||
tasks[i].exec = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void schUpdate() {
|
||||
for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) {
|
||||
if (tasks[i].exec != NULL) {
|
||||
if (tasks[i].delay == 0) {
|
||||
tasks[i].delay = tasks[i].period;
|
||||
tasks[i].run++;
|
||||
} else {
|
||||
tasks[i].delay--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* PontCoopScheduler.h
|
||||
*
|
||||
* Created on: 29.08.2016
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef PONTCOOPSCHEDULER_H_
|
||||
#define PONTCOOPSCHEDULER_H_
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
#define MAX_NUM_OF_TASKS 8
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t delay;
|
||||
uint32_t period;
|
||||
uint8_t run;
|
||||
void (*exec)(void *handle);
|
||||
void *handle;
|
||||
} tTask;
|
||||
|
||||
|
||||
void schInit();
|
||||
void schAdd(void (*exec)(void *), void *handle, uint32_t delay, uint32_t period);
|
||||
void schDel(void (*exec)(void *), void *handle);
|
||||
void schExec();
|
||||
void schUpdate();
|
||||
|
||||
|
||||
#endif /* PONTCOOPSCHEDULER_H_ */
|
@ -47,64 +47,59 @@ const tPin *NUMBERS[] = { NUMBER0, NUMBER1, NUMBER2, NUMBER3, NUMBER4,
|
||||
NUMBER5, NUMBER6, NUMBER7, NUMBER8, NUMBER9, ALL_PATTERN, H_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) {
|
||||
for (tPin d = DIGIT_0; d <= DIGIT_1; d++) {
|
||||
for (tPin s = SEG_A; s <= SEG_F; s++) {
|
||||
gpioSetPin(s, LOW);
|
||||
}
|
||||
for (tPin d = DIGIT_2; d >= DIGIT_0; d--) {
|
||||
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(SEG_G, HIGH);
|
||||
ms_active_delay(INIT_CYCLE_DELAY);
|
||||
gpioSetPin(SEG_G, LOW);
|
||||
gpioSetPin(d, HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
static void showNumber(uint8_t n) {
|
||||
const tPin *pattern = NUMBERS[ALL_ID];
|
||||
do {
|
||||
for (const tPin *pattern = NUMBERS[ALL_ID]; *pattern != PINS_END; pattern++) {
|
||||
gpioSetPin(*pattern, LOW);
|
||||
pattern++;
|
||||
} while (*pattern != PINS_END);
|
||||
pattern = NUMBERS[n];
|
||||
do {
|
||||
}
|
||||
for (const tPin *pattern = NUMBERS[n]; *pattern != PINS_END; pattern++) {
|
||||
gpioSetPin(*pattern, HIGH);
|
||||
pattern++;
|
||||
} while (*pattern != PINS_END);
|
||||
}
|
||||
}
|
||||
|
||||
void displaySetValue(uint8_t v) {
|
||||
if (v >= 100) {
|
||||
digitValues[1] = H_ID;
|
||||
digitValues[0] = I_ID;
|
||||
} else {
|
||||
digitValues[1] = v / 10;
|
||||
digitValues[0] = v - digitValues[1] * 10;
|
||||
}
|
||||
uint32_t a,b,c,d;
|
||||
a = v;
|
||||
b = a / 100;
|
||||
c = (a - b * 100) / 10;
|
||||
d = a - c * 10 - b * 100;
|
||||
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) {
|
||||
static uint8_t activeDigit = 0;
|
||||
|
||||
activeDigit++;
|
||||
if (activeDigit == 2) {
|
||||
if (activeDigit == 3) {
|
||||
activeDigit = 0;
|
||||
}
|
||||
|
||||
const tPin *digit = DIGITS;
|
||||
do {
|
||||
for (const tPin *digit = DIGITS; *digit != PINS_END; digit++) {
|
||||
gpioSetPin(*digit, HIGH);
|
||||
digit++;
|
||||
} while (*digit != PINS_END);
|
||||
}
|
||||
|
||||
digit = DIGITS + activeDigit;
|
||||
gpioSetPin(*digit, LOW);
|
||||
gpioSetPin(DIGITS[activeDigit], LOW);
|
||||
|
||||
showNumber(digitValues[activeDigit]);
|
||||
}
|
||||
|
@ -16,11 +16,12 @@
|
||||
#include "button.h"
|
||||
#include "gpio.h"
|
||||
#include "PontCoopScheduler.h"
|
||||
#include "powerDown.h"
|
||||
|
||||
|
||||
const uint32_t EGG_TIMER_CYCLE = 1000;
|
||||
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;
|
||||
uint8_t restCookingTime;
|
||||
@ -28,14 +29,8 @@ bool timerRunning;
|
||||
bool timerStarted;
|
||||
|
||||
|
||||
void eggTimerPowerDown(void *handleArg) {
|
||||
P1DIR = 0;
|
||||
P2DIR = 0;
|
||||
P1OUT = 0;
|
||||
P2OUT = 0;
|
||||
ADC10CTL0 = 0;
|
||||
LPM4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void eggTimerStart(void *handleArg) {
|
||||
if (! timerStarted) {
|
||||
@ -62,7 +57,8 @@ void eggTimerExec(void *handleArg) {
|
||||
if (restCookingTime == 0) {
|
||||
// activate alarm
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
98
src/gpio.c
98
src/gpio.c
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* gpio.c
|
||||
*
|
||||
* Created on: 29.08.2016
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
#include <msp430g2553.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define GPIO_C
|
||||
#include "gpio.h"
|
||||
#undef GPIO_C
|
||||
|
||||
|
||||
|
||||
extern tPinCfg pinCfg[];
|
||||
|
||||
|
||||
void gpioInitPins() {
|
||||
for (tPin p = PINS_FIRST; p < PINS_END; p += 1) {
|
||||
tPinCfg pin = pinCfg[p];
|
||||
if (pin.portId == PORT1) {
|
||||
if (pin.direction == PIN_OUT) {
|
||||
P1DIR |= pin.bit;
|
||||
P1SEL &= ~pin.bit;
|
||||
P1SEL2 &= ~pin.bit;
|
||||
} else if (pin.direction == PIN_IN) {
|
||||
P1DIR &= ~pin.bit;
|
||||
P1SEL &= ~pin.bit;
|
||||
P1SEL2 &= ~pin.bit;
|
||||
P1REN &= ~pin.bit;
|
||||
} else if (pin.direction == PIN_IN_PULLUP) {
|
||||
P1DIR &= ~pin.bit;
|
||||
P1SEL &= ~pin.bit;
|
||||
P1SEL2 &= ~pin.bit;
|
||||
P1REN |= pin.bit;
|
||||
P1OUT |= pin.bit;
|
||||
}
|
||||
} else if (pin.portId == PORT2) {
|
||||
if (pin.direction == PIN_OUT) {
|
||||
P2DIR |= pin.bit;
|
||||
P2SEL &= ~pin.bit;
|
||||
P2SEL2 &= ~pin.bit;
|
||||
} else if (pin.direction == PIN_IN) {
|
||||
P2DIR &= ~pin.bit;
|
||||
P2SEL &= ~pin.bit;
|
||||
P2SEL2 &= ~pin.bit;
|
||||
P2REN &= ~pin.bit;
|
||||
} else if (pin.direction == PIN_IN_PULLUP) {
|
||||
P2DIR &= ~pin.bit;
|
||||
P2SEL &= ~pin.bit;
|
||||
P2SEL2 &= ~pin.bit;
|
||||
P2REN |= pin.bit;
|
||||
P2OUT |= pin.bit;
|
||||
}
|
||||
}
|
||||
gpioSetPin(p, pin.defaultOut);
|
||||
}
|
||||
}
|
||||
|
||||
void gpioSetPin(tPin p, tPinState v) {
|
||||
tPinCfg pin = pinCfg[p];
|
||||
if (v == HIGH) {
|
||||
if (pin.portId == PORT1) {
|
||||
P1OUT |= pin.bit;
|
||||
} else if (pin.portId == PORT2) {
|
||||
P2OUT |= pin.bit;
|
||||
}
|
||||
} else {
|
||||
if (pin.portId == PORT1) {
|
||||
P1OUT &= ~pin.bit;
|
||||
} else if (pin.portId == PORT2) {
|
||||
P2OUT &= ~pin.bit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gpioTogglePin(tPin p) {
|
||||
tPinCfg pin = pinCfg[p];
|
||||
if (pin.portId == PORT1) {
|
||||
P1OUT ^= pin.bit;
|
||||
} else if (pin.portId == PORT2) {
|
||||
P2OUT ^= pin.bit;
|
||||
}
|
||||
}
|
||||
|
||||
tPinState gpioGetPin(tPin p) {
|
||||
tPinCfg pin = pinCfg[p];
|
||||
uint16_t pinValue = 0;
|
||||
if (pin.portId == PORT1) {
|
||||
pinValue = P1IN;
|
||||
} else if (pin.portId == PORT2) {
|
||||
pinValue = P2IN;
|
||||
}
|
||||
return (pinValue & pin.bit) ? HIGH : LOW;
|
||||
}
|
66
src/gpio.h
66
src/gpio.h
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* gpio.h
|
||||
*
|
||||
* Created on: 29.08.2016
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef GPIO_H_
|
||||
#define GPIO_H_
|
||||
|
||||
|
||||
#include <msp430g2553.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
PORT1,
|
||||
PORT2
|
||||
} tPort;
|
||||
|
||||
typedef enum {
|
||||
LOW,
|
||||
HIGH,
|
||||
} tPinState;
|
||||
|
||||
typedef enum {
|
||||
PIN_OUT,
|
||||
PIN_IN,
|
||||
PIN_IN_PULLUP
|
||||
} tPinDirection;
|
||||
|
||||
typedef struct {
|
||||
tPort portId;
|
||||
uint16_t bit;
|
||||
tPinDirection direction;
|
||||
tPinState defaultOut;
|
||||
} tPinCfg;
|
||||
|
||||
|
||||
typedef enum {
|
||||
PINS_FIRST,
|
||||
SEG_A = PINS_FIRST,
|
||||
SEG_B,
|
||||
SEG_C,
|
||||
SEG_D,
|
||||
SEG_E,
|
||||
SEG_F,
|
||||
SEG_G,
|
||||
DIGIT_0,
|
||||
DIGIT_1,
|
||||
BUTTON_1,
|
||||
LED_1,
|
||||
PINS_END
|
||||
} tPin;
|
||||
|
||||
void gpioInitPins();
|
||||
void gpioSetPin(tPin p, tPinState v);
|
||||
void gpioTogglePin(tPin p);
|
||||
tPinState gpioGetPin(tPin p);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* GPIO_H_ */
|
@ -18,6 +18,7 @@ tPinCfg pinCfg[PINS_END] = {
|
||||
{PORT2, BIT2, PIN_OUT, LOW}, //G
|
||||
{PORT2, BIT0, PIN_OUT, HIGH}, //0
|
||||
{PORT1, BIT5, PIN_OUT, HIGH}, //1
|
||||
{PORT1, BIT2, PIN_OUT, HIGH}, //2
|
||||
{PORT1, BIT0, PIN_IN_PULLUP, LOW}, // BUTTON_1
|
||||
{PORT1, BIT1, PIN_OUT, LOW}, //TESTPIN1
|
||||
{PORT1, BIT1, PIN_OUT, LOW}, // LED_1
|
||||
};
|
||||
|
31
src/gpioCfg.h
Normal file
31
src/gpioCfg.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* gpioCfg.h
|
||||
*
|
||||
* Created on: 18.09.2016
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef GPIOCFG_H_
|
||||
#define GPIOCFG_H_
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
typedef enum {
|
||||
PINS_FIRST,
|
||||
SEG_A = PINS_FIRST,
|
||||
SEG_B,
|
||||
SEG_C,
|
||||
SEG_D,
|
||||
SEG_E,
|
||||
SEG_F,
|
||||
SEG_G,
|
||||
DIGIT_0,
|
||||
DIGIT_1,
|
||||
DIGIT_2,
|
||||
BUTTON_1,
|
||||
LED_1,
|
||||
PINS_END
|
||||
} tPin;
|
||||
|
||||
|
||||
#endif /* GPIOCFG_H_ */
|
13
src/main.c
13
src/main.c
@ -19,12 +19,17 @@
|
||||
#include "measure.h"
|
||||
#include "eggTimer.h"
|
||||
#include "button.h"
|
||||
#include "gpio.h"
|
||||
#include "powerDown.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
WDTCTL = WDTPW | WDTHOLD;
|
||||
|
||||
__disable_interrupt();
|
||||
|
||||
// highest possible system clock
|
||||
DCOCTL = DCO0 | DCO1 | DCO2;
|
||||
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
||||
@ -36,6 +41,8 @@ int main() {
|
||||
timeInit();
|
||||
schInit();
|
||||
|
||||
schAdd(powerDown, NULL, 1800000, 0); // default thermometer power down timeout: 30min
|
||||
|
||||
// interrupts are required for delay function in displayInit();
|
||||
__enable_interrupt();
|
||||
displayInit(NULL);
|
||||
@ -57,11 +64,7 @@ int main() {
|
||||
|
||||
while (1) {
|
||||
schExec();
|
||||
|
||||
// put it into the idle loop, it is not time critical
|
||||
// but should get as much time as possible to avoid
|
||||
// flicker
|
||||
//displayExec(NULL);
|
||||
//LPM3;
|
||||
}
|
||||
}
|
||||
|
||||
|
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;
|
||||
|
||||
ISR(TIMER0_A0, TA0_ISR) {
|
||||
LPM3_EXIT;
|
||||
timestamp++;
|
||||
schUpdate();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user