initial, ported from constantly failed C++ variant
This commit is contained in:
commit
35bef18ec0
100
.cproject
Normal file
100
.cproject
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
|
<cconfiguration id="dk.xpg.msp430eclipse.configuration.app.debug.1048602252">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="dk.xpg.msp430eclipse.configuration.app.debug.1048602252" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||||
|
<externalSettings/>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="dk.xpg.msp430eclipse.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=dk.xpg.msp430eclipse.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.VCErrorParser" id="dk.xpg.msp430eclipse.configuration.app.debug.1048602252" name="Debug" parent="dk.xpg.msp430eclipse.configuration.app.debug">
|
||||||
|
<folderInfo id="dk.xpg.msp430eclipse.configuration.app.debug.1048602252." name="/" resourcePath="">
|
||||||
|
<toolChain id="dk.xpg.msp430eclipse.toolchain.gcc.app.debug.1295560935" name="MSP430 GCC Toolchain" superClass="dk.xpg.msp430eclipse.toolchain.gcc.app.debug">
|
||||||
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="dk.xpg.msp430eclipse.targetplatform.msp430.1997442023" isAbstract="false" name="MSP430 Cross-Target" osList="all" superClass="dk.xpg.msp430eclipse.targetplatform.msp430"/>
|
||||||
|
<builder buildPath="${workspace_loc:/TeaThermoTimer}/Debug" id="dk.xpg.msp430eclipse.target.gnu.builder.1911415240" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="MSP430 GNU Make Builder" superClass="dk.xpg.msp430eclipse.target.gnu.builder"/>
|
||||||
|
<tool id="dk.xpg.msp430eclipse.tool.compiler.gcc.1489133124" name="MSP430 C Compiler" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc">
|
||||||
|
<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" superClass="dk.xpg.msp430eclipse.compiler.option.language.standard" value="dk.xpg.msp430eclipse.compiler.option.language.standard.gnu99" valueType="enumerated"/>
|
||||||
|
<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">
|
||||||
|
<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">
|
||||||
|
<inputType id="dk.xpg.msp430eclipse.tool.linker.input.1373967257" name="Object Files" superClass="dk.xpg.msp430eclipse.tool.linker.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="dk.xpg.msp430eclipse.tool.archiver.gcc.2115199058" name="MSP430 Archiver" superClass="dk.xpg.msp430eclipse.tool.archiver.gcc"/>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
<sourceEntries>
|
||||||
|
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||||
|
</sourceEntries>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
<cconfiguration id="dk.xpg.msp430eclipse.configuration.app.release.1716607718">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="dk.xpg.msp430eclipse.configuration.app.release.1716607718" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||||
|
<externalSettings/>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="dk.xpg.msp430eclipse.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=dk.xpg.msp430eclipse.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.VCErrorParser" id="dk.xpg.msp430eclipse.configuration.app.release.1716607718" name="Release" parent="dk.xpg.msp430eclipse.configuration.app.release">
|
||||||
|
<folderInfo id="dk.xpg.msp430eclipse.configuration.app.release.1716607718." name="/" resourcePath="">
|
||||||
|
<toolChain id="dk.xpg.msp430eclipse.toolchain.gcc.app.release.2120639002" name="MSP430 GCC Toolchain" superClass="dk.xpg.msp430eclipse.toolchain.gcc.app.release">
|
||||||
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="dk.xpg.msp430eclipse.targetplatform.msp430.1070938188" isAbstract="false" name="MSP430 Cross-Target" osList="all" superClass="dk.xpg.msp430eclipse.targetplatform.msp430"/>
|
||||||
|
<builder buildPath="${workspace_loc:/TeaThermoTimer}/Release" id="dk.xpg.msp430eclipse.target.gnu.builder.1912281183" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="MSP430 GNU Make Builder" superClass="dk.xpg.msp430eclipse.target.gnu.builder"/>
|
||||||
|
<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"/>
|
||||||
|
<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">
|
||||||
|
<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">
|
||||||
|
<inputType id="dk.xpg.msp430eclipse.tool.linker.input.570466072" name="Object Files" superClass="dk.xpg.msp430eclipse.tool.linker.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="dk.xpg.msp430eclipse.tool.archiver.gcc.1047873146" name="MSP430 Archiver" superClass="dk.xpg.msp430eclipse.tool.archiver.gcc"/>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
<sourceEntries>
|
||||||
|
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||||
|
</sourceEntries>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
</storageModule>
|
||||||
|
<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"/>
|
||||||
|
</cproject>
|
27
.project
Normal file
27
.project
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>TeaThermoTimer</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
|
<nature>dk.xpg.msp430eclipse.msp430nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
6
.settings/dk.xpg.msp430eclipse.prefs
Normal file
6
.settings/dk.xpg.msp430eclipse.prefs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
msp430/DeviceSerialNumber=
|
||||||
|
msp430/MSP430TARGETMCU=msp430g2553
|
||||||
|
msp430/MSPDebugConnection=
|
||||||
|
msp430/MSPDebugProtocol=SBW
|
||||||
|
msp430/MSPDebugTTYDevice=
|
12
docs/tea.txt
Normal file
12
docs/tea.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
P1.7 A
|
||||||
|
P1.6 B
|
||||||
|
P2.5 F
|
||||||
|
P2.4 E
|
||||||
|
P2.3 D
|
||||||
|
P2.2 G
|
||||||
|
P2.1 C
|
||||||
|
P2.0 1
|
||||||
|
P1.5 2
|
||||||
|
P1.0 T
|
||||||
|
|
||||||
|
|
60
src/PontCoopScheduler.c
Normal file
60
src/PontCoopScheduler.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void schAdd(void (*exec)(void), 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;
|
||||||
|
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();
|
||||||
|
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--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
src/PontCoopScheduler.h
Normal file
33
src/PontCoopScheduler.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* PontCoopScheduler.h
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PONTCOOPSCHEDULER_H_
|
||||||
|
#define PONTCOOPSCHEDULER_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_NUM_OF_TASKS 3
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t delay;
|
||||||
|
uint32_t period;
|
||||||
|
uint8_t run;
|
||||||
|
void (*exec)(void);
|
||||||
|
} tTask;
|
||||||
|
|
||||||
|
|
||||||
|
void schInit();
|
||||||
|
void schAdd(void (*exec)(void), uint32_t delay, uint32_t period);
|
||||||
|
void schExec();
|
||||||
|
void schUpdate();
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PONTCOOPSCHEDULER_H_ */
|
107
src/display.c
Normal file
107
src/display.c
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* display.c
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <msp430g2553.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <intrinsics.h>
|
||||||
|
|
||||||
|
#include "display.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const uint16_t INIT_CYCLE_DELAY = 200;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ALL_ID = 10,
|
||||||
|
H_ID,
|
||||||
|
I_ID,
|
||||||
|
EMPTY_ID,
|
||||||
|
} tPatternId;
|
||||||
|
|
||||||
|
const tPin ALL_PATTERN[] = { SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G, PINS_END };
|
||||||
|
const tPin H_PATTERN[] = { SEG_B, SEG_C, SEG_E, SEG_F, SEG_G, PINS_END };
|
||||||
|
const tPin I_PATTERN[] = { SEG_B, SEG_C, PINS_END };
|
||||||
|
const tPin EMPTY_PATTERN[] = { PINS_END };
|
||||||
|
const tPin NUMBER0[] = { SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, PINS_END };
|
||||||
|
const tPin NUMBER1[] = { SEG_B, SEG_C, PINS_END };
|
||||||
|
const tPin NUMBER2[] = { SEG_A, SEG_B, SEG_G, SEG_E, SEG_D, PINS_END };
|
||||||
|
const tPin NUMBER3[] = { SEG_A, SEG_B, SEG_G, SEG_C, SEG_D, PINS_END };
|
||||||
|
const tPin NUMBER4[] = { SEG_F, SEG_G, SEG_B, SEG_C, PINS_END };
|
||||||
|
const tPin NUMBER5[] = { SEG_A, SEG_F, SEG_G, SEG_C, SEG_D, PINS_END };
|
||||||
|
const tPin NUMBER6[] = { SEG_A, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G, PINS_END };
|
||||||
|
const tPin NUMBER7[] = { SEG_A, SEG_B, SEG_C, PINS_END };
|
||||||
|
const tPin NUMBER8[] = { SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G, PINS_END };
|
||||||
|
const tPin NUMBER9[] = { SEG_A, SEG_B, SEG_C, SEG_D, SEG_F, SEG_G, PINS_END };
|
||||||
|
|
||||||
|
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 };
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t digitValues[2] = { EMPTY_ID, EMPTY_ID };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void displayInit() {
|
||||||
|
for (tPin d = DIGIT_0; d <= DIGIT_1; 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(d, HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void showNumber(uint8_t n) {
|
||||||
|
const tPin *pattern = NUMBERS[10];
|
||||||
|
do {
|
||||||
|
gpioSetPin(*pattern, LOW);
|
||||||
|
pattern++;
|
||||||
|
} while (*pattern != PINS_END);
|
||||||
|
pattern = NUMBERS[n];
|
||||||
|
do {
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayExec() {
|
||||||
|
static uint8_t activeDigit = 0;
|
||||||
|
|
||||||
|
activeDigit++;
|
||||||
|
if (activeDigit == 2) {
|
||||||
|
activeDigit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tPin *digit = DIGITS;
|
||||||
|
do {
|
||||||
|
gpioSetPin(*digit, HIGH);
|
||||||
|
digit++;
|
||||||
|
} while (*digit != PINS_END);
|
||||||
|
|
||||||
|
digit = DIGITS + activeDigit;
|
||||||
|
gpioSetPin(*digit, LOW);
|
||||||
|
|
||||||
|
showNumber(digitValues[activeDigit]);
|
||||||
|
}
|
17
src/display.h
Normal file
17
src/display.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* display.h
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DISPLAY_H_
|
||||||
|
#define DISPLAY_H_
|
||||||
|
|
||||||
|
|
||||||
|
void displayInit();
|
||||||
|
void displayExec();
|
||||||
|
void displaySetValue(uint8_t v);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DISPLAY_H_ */
|
49
src/gpio.c
Normal file
49
src/gpio.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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) {
|
||||||
|
P1DIR |= pin.bit;
|
||||||
|
} else if (pin.portId == PORT2) {
|
||||||
|
P2DIR |= 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
56
src/gpio.h
Normal file
56
src/gpio.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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 struct {
|
||||||
|
tPort portId;
|
||||||
|
uint16_t bit;
|
||||||
|
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,
|
||||||
|
TESTPIN,
|
||||||
|
PINS_END
|
||||||
|
} tPin;
|
||||||
|
|
||||||
|
void gpioInitPins();
|
||||||
|
void gpioSetPin(tPin p, tPinState v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* GPIO_H_ */
|
21
src/gpioCfg.c
Normal file
21
src/gpioCfg.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* gpioCfg.c
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
tPinCfg pinCfg[PINS_END] = {
|
||||||
|
{PORT1, BIT7, LOW}, //A
|
||||||
|
{PORT1, BIT6, LOW}, //B
|
||||||
|
{PORT2, BIT1, LOW}, //C
|
||||||
|
{PORT2, BIT3, LOW}, //D
|
||||||
|
{PORT2, BIT4, LOW}, //E
|
||||||
|
{PORT2, BIT5, LOW}, //F
|
||||||
|
{PORT2, BIT2, LOW}, //G
|
||||||
|
{PORT2, BIT0, HIGH}, //0
|
||||||
|
{PORT1, BIT5, HIGH}, //1
|
||||||
|
{PORT1, BIT7, LOW}, // TESTPIN
|
||||||
|
};
|
49
src/main.c
Normal file
49
src/main.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <msp430g2553.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <intrinsics.h>
|
||||||
|
|
||||||
|
#include "gpio.h"
|
||||||
|
#include "time.h"
|
||||||
|
#include "display.h"
|
||||||
|
#include "PontCoopScheduler.h"
|
||||||
|
#include "testTask.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
WDTCTL = WDTPW | WDTHOLD;
|
||||||
|
|
||||||
|
// highest possible system clock
|
||||||
|
DCOCTL = DCO0 | DCO1 | DCO2;
|
||||||
|
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
||||||
|
BCSCTL2 = 0;
|
||||||
|
BCSCTL3 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
gpioInitPins();
|
||||||
|
timeInit();
|
||||||
|
schInit();
|
||||||
|
|
||||||
|
// interrupts are required for delay function in displayInit();
|
||||||
|
__enable_interrupt();
|
||||||
|
displayInit();
|
||||||
|
__disable_interrupt();
|
||||||
|
|
||||||
|
testTaskInit();
|
||||||
|
|
||||||
|
// schAdd(displayExec, 0, 100);
|
||||||
|
schAdd(testTaskExec, 0, 100);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
schExec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
26
src/testTask.c
Normal file
26
src/testTask.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* testTask.c
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
|
||||||
|
void testTaskInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void testTaskExec() {
|
||||||
|
static uint8_t toggle = 0;
|
||||||
|
|
||||||
|
if (toggle == 0) {
|
||||||
|
toggle = 1;
|
||||||
|
gpioSetPin(TESTPIN, HIGH);
|
||||||
|
} else {
|
||||||
|
toggle = 0;
|
||||||
|
gpioSetPin(TESTPIN, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
15
src/testTask.h
Normal file
15
src/testTask.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* testTask.h
|
||||||
|
*
|
||||||
|
* Created on: 29.08.2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TESTTASK_H_
|
||||||
|
#define TESTTASK_H_
|
||||||
|
|
||||||
|
void testTaskInit();
|
||||||
|
void testTaskExec();
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TESTTASK_H_ */
|
38
src/time.c
Normal file
38
src/time.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* time.c
|
||||||
|
*
|
||||||
|
* Created on: 20.05.2014
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <msp430g2553.h>
|
||||||
|
#include <isr_compat.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "time.h"
|
||||||
|
#include "PontCoopScheduler.h"
|
||||||
|
|
||||||
|
|
||||||
|
volatile uint32_t timestamp;
|
||||||
|
|
||||||
|
ISR(TIMER0_A0, TA0_ISR) {
|
||||||
|
timestamp++;
|
||||||
|
schUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void timeInit() {
|
||||||
|
timestamp = 0;
|
||||||
|
|
||||||
|
TACCR0 = 32;
|
||||||
|
TACCTL0 = CCIE;
|
||||||
|
TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getMillis() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ms_active_delay(uint16_t delay) {
|
||||||
|
uint32_t start = timestamp;
|
||||||
|
while (start + delay > timestamp);
|
||||||
|
}
|
19
src/time.h
Normal file
19
src/time.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* time.h
|
||||||
|
*
|
||||||
|
* Created on: 20.05.2014
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TIME_H_
|
||||||
|
#define TIME_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void timeInit();
|
||||||
|
uint32_t getMillis();
|
||||||
|
void ms_active_delay(uint16_t delay);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TIME_H_ */
|
Loading…
x
Reference in New Issue
Block a user