first success
This commit is contained in:
commit
d361e11d50
126
.cproject
Normal file
126
.cproject
Normal file
@ -0,0 +1,126 @@
|
||||
<?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.1803245296">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="dk.xpg.msp430eclipse.configuration.app.debug.1803245296" 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.1803245296" name="Debug" parent="dk.xpg.msp430eclipse.configuration.app.debug">
|
||||
<folderInfo id="dk.xpg.msp430eclipse.configuration.app.debug.1803245296." name="/" resourcePath="">
|
||||
<toolChain id="dk.xpg.msp430eclipse.toolchain.gcc.app.debug.1531619590" 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.1645518570" isAbstract="false" name="MSP430 Cross-Target" osList="all" superClass="dk.xpg.msp430eclipse.targetplatform.msp430"/>
|
||||
<builder buildPath="${workspace_loc:/TouchSwitch2}/Debug" id="dk.xpg.msp430eclipse.target.gnu.builder.519328457" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="MSP430 GNU Make Builder" superClass="dk.xpg.msp430eclipse.target.gnu.builder"/>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.compiler.gcc.266139147" 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.1547289165" 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.961192910" name="Debugging Level" superClass="dk.xpg.msp430eclipse.compiler.option.debugging.level" valueType="enumerated"/>
|
||||
<option id="dk.xpg.msp430eclipse.compiler.option.language.standard.1330784157" name="Standard" superClass="dk.xpg.msp430eclipse.compiler.option.language.standard" useByScannerDiscovery="false" value="dk.xpg.msp430eclipse.compiler.option.language.standard.gnu99" valueType="enumerated"/>
|
||||
<option id="dk.xpg.msp430eclipse.compiler.option.includes.paths.1317814193" superClass="dk.xpg.msp430eclipse.compiler.option.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/TicTacToe/hottislib}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.1155150193" name="C Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input"/>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.1230949175" name="C++ Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.assembler.gcc.974609093" name="MSP430 Assembler" superClass="dk.xpg.msp430eclipse.tool.assembler.gcc">
|
||||
<option id="dk.xpg.msp430eclipse.assembler.option.general.include.483037451" superClass="dk.xpg.msp430eclipse.assembler.option.general.include" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/TicTacToe/hottislib}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.assembler.input.669783994" name="Assembler Files" superClass="dk.xpg.msp430eclipse.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.linker.gcc.626413630" name="MSP430 Linker" superClass="dk.xpg.msp430eclipse.tool.linker.gcc">
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.linker.input.803469813" name="Object Files" superClass="dk.xpg.msp430eclipse.tool.linker.input"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.archiver.gcc.949405556" name="MSP430 Archiver" superClass="dk.xpg.msp430eclipse.tool.archiver.gcc"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="hottislib|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="hottislib"/>
|
||||
<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.194068964">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="dk.xpg.msp430eclipse.configuration.app.release.194068964" 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.194068964" name="Release" parent="dk.xpg.msp430eclipse.configuration.app.release">
|
||||
<folderInfo id="dk.xpg.msp430eclipse.configuration.app.release.194068964." name="/" resourcePath="">
|
||||
<toolChain id="dk.xpg.msp430eclipse.toolchain.gcc.app.release.86971024" 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.380819629" isAbstract="false" name="MSP430 Cross-Target" osList="all" superClass="dk.xpg.msp430eclipse.targetplatform.msp430"/>
|
||||
<builder buildPath="${workspace_loc:/TouchSwitch2}/Release" id="dk.xpg.msp430eclipse.target.gnu.builder.2031426445" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="MSP430 GNU Make Builder" superClass="dk.xpg.msp430eclipse.target.gnu.builder"/>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.compiler.gcc.822429366" 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.135723235" 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.1183049546" name="Debugging Level" superClass="dk.xpg.msp430eclipse.compiler.option.debugging.level" valueType="enumerated"/>
|
||||
<option id="dk.xpg.msp430eclipse.compiler.option.includes.paths.247408562" superClass="dk.xpg.msp430eclipse.compiler.option.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/TicTacToe/hottislib}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.743092204" name="C Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input"/>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.534769254" name="C++ Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.assembler.gcc.1808009534" name="MSP430 Assembler" superClass="dk.xpg.msp430eclipse.tool.assembler.gcc">
|
||||
<option id="dk.xpg.msp430eclipse.assembler.option.general.include.1099305810" superClass="dk.xpg.msp430eclipse.assembler.option.general.include" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/TicTacToe/hottislib}""/>
|
||||
</option>
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.assembler.input.490974509" name="Assembler Files" superClass="dk.xpg.msp430eclipse.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.linker.gcc.467046619" name="MSP430 Linker" superClass="dk.xpg.msp430eclipse.tool.linker.gcc">
|
||||
<inputType id="dk.xpg.msp430eclipse.tool.linker.input.401567459" name="Object Files" superClass="dk.xpg.msp430eclipse.tool.linker.input"/>
|
||||
</tool>
|
||||
<tool id="dk.xpg.msp430eclipse.tool.archiver.gcc.333323147" 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="TouchSwitch2.dk.xpg.msp430eclipse.project.gcc.elf.836565128" name="MSP430 Cross Target Application" projectType="dk.xpg.msp430eclipse.project.gcc.elf"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.release.194068964;dk.xpg.msp430eclipse.configuration.app.release.194068964.;dk.xpg.msp430eclipse.tool.compiler.gcc.822429366;dk.xpg.msp430eclipse.tool.compiler.gcc.input.743092204">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.release.194068964;dk.xpg.msp430eclipse.configuration.app.release.194068964.;dk.xpg.msp430eclipse.tool.compiler.gcc.822429366;dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.534769254">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.debug.1803245296;dk.xpg.msp430eclipse.configuration.app.debug.1803245296.;dk.xpg.msp430eclipse.tool.compiler.gcc.266139147;dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.1230949175">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="dk.xpg.msp430eclipse.MSP430GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="dk.xpg.msp430eclipse.configuration.app.debug.1803245296;dk.xpg.msp430eclipse.configuration.app.debug.1803245296.;dk.xpg.msp430eclipse.tool.compiler.gcc.266139147;dk.xpg.msp430eclipse.tool.compiler.gcc.input.1155150193">
|
||||
<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/
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "hottislib"]
|
||||
path = hottislib
|
||||
url = git@gitlab.com:wolutator/hottislib.git
|
27
.project
Normal file
27
.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>TicTacToe</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>
|
7
.settings/dk.xpg.msp430eclipse.prefs
Normal file
7
.settings/dk.xpg.msp430eclipse.prefs
Normal file
@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
msp430/DeviceSerialNumber=
|
||||
msp430/MSP430TARGETMCU=msp430g2553
|
||||
msp430/MSPDebugConnection=
|
||||
msp430/MSPDebugDriver=rf2500
|
||||
msp430/MSPDebugProtocol=SBW
|
||||
msp430/MSPDebugTTYDevice=
|
1
hottislib
Submodule
1
hottislib
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit d129650a6fbc77f5b5474c2b5153fa6adbbda003
|
49
src/TicTacToe.c
Normal file
49
src/TicTacToe.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* TouchSwitch2.c
|
||||
*
|
||||
* Created on: Jan 29, 2018
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
#include <msp430g2553.h>
|
||||
#include <stdint.h>
|
||||
#include <intrinsics.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "PontCoopScheduler.h"
|
||||
|
||||
#include "time.h"
|
||||
#include "fieldDef.h"
|
||||
#include "leds.h"
|
||||
#include "game.h"
|
||||
|
||||
|
||||
int main() {
|
||||
WDTCTL = WDTPW | WDTHOLD;
|
||||
|
||||
__disable_interrupt();
|
||||
|
||||
// highest possible system clock
|
||||
DCOCTL = DCO0 | DCO1 | DCO2;
|
||||
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
||||
BCSCTL2 = 0;
|
||||
BCSCTL3 = 0;
|
||||
|
||||
|
||||
timeInit();
|
||||
schInit();
|
||||
|
||||
ledsInit();
|
||||
gameInit();
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
while (1) {
|
||||
schExec();
|
||||
|
||||
tCellState *field = gameGetField();
|
||||
ledsShowField(field);
|
||||
}
|
||||
}
|
20
src/fieldDef.h
Normal file
20
src/fieldDef.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* fieldDef.h
|
||||
*
|
||||
* Created on: Apr 28, 2018
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef FIELDDEF_H_
|
||||
#define FIELDDEF_H_
|
||||
|
||||
typedef enum { csEMPTY, csCROSS, csCIRCLE } tCellState;
|
||||
|
||||
#define FIELD_SIZE 9
|
||||
#define ROW_SIZE 3
|
||||
#define COL_SIZE 3
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* FIELDDEF_H_ */
|
67
src/game.c
Normal file
67
src/game.c
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* game.c
|
||||
*
|
||||
* Created on: Apr 28, 2018
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "PontCoopScheduler.h"
|
||||
|
||||
#include "leds.h"
|
||||
#include "game.h"
|
||||
|
||||
|
||||
|
||||
tCellState field[FIELD_SIZE];
|
||||
|
||||
|
||||
|
||||
|
||||
static void setCell(uint8_t row, uint8_t col, tCellState state) {
|
||||
field[(row * ROW_SIZE) + col] = state;
|
||||
}
|
||||
|
||||
void gameMove() {
|
||||
static uint8_t row = 0;
|
||||
static uint8_t col = 0;
|
||||
|
||||
static enum { sNEXT, sCROSS, sCIRCLE } state = sCROSS;
|
||||
switch (state) {
|
||||
case sCROSS:
|
||||
setCell(row, col, csCROSS);
|
||||
state = sCIRCLE;
|
||||
break;
|
||||
case sCIRCLE:
|
||||
setCell(row, col, csCIRCLE);
|
||||
state = sNEXT;
|
||||
break;
|
||||
case sNEXT:
|
||||
setCell(row, col, csEMPTY);
|
||||
col++;
|
||||
if (col >= COL_SIZE) {
|
||||
col = 0;
|
||||
row++;
|
||||
if (row >= ROW_SIZE) {
|
||||
row = 0;
|
||||
}
|
||||
}
|
||||
state = sCROSS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gameInit() {
|
||||
for (uint8_t i = 0; i < FIELD_SIZE; i++) {
|
||||
field[i] = csEMPTY;
|
||||
}
|
||||
|
||||
schAdd(gameMove, NULL, 0, 1000);
|
||||
|
||||
}
|
||||
|
||||
tCellState* gameGetField() {
|
||||
return field;
|
||||
}
|
19
src/game.h
Normal file
19
src/game.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* game.h
|
||||
*
|
||||
* Created on: Apr 28, 2018
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef GAME_H_
|
||||
#define GAME_H_
|
||||
|
||||
#include "fieldDef.h"
|
||||
|
||||
|
||||
void gameInit();
|
||||
tCellState* gameGetField();
|
||||
|
||||
|
||||
|
||||
#endif /* GAME_H_ */
|
62
src/leds.c
Normal file
62
src/leds.c
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* leds.c
|
||||
*
|
||||
* Created on: Apr 28, 2018
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#include <msp430g2553.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "leds.h"
|
||||
|
||||
|
||||
void ledsInit() {
|
||||
ROW_OUT = 0;
|
||||
ROW_DIR |= ROW1 | ROW2 | ROW3;
|
||||
|
||||
COL_OUT = 0;
|
||||
COL_DIR |= COL1_GREEN | COL2_GREEN | COL3_GREEN |
|
||||
COL1_RED | COL2_RED | COL3_RED;
|
||||
}
|
||||
|
||||
void ledsShowField(tCellState *field) {
|
||||
for (uint8_t row = 0; row < ROW_SIZE; row++) {
|
||||
|
||||
uint8_t rowOut = 0xff;
|
||||
if (row == 0) {
|
||||
rowOut &= ~ROW1;
|
||||
} else if (row == 1) {
|
||||
rowOut &= ~ROW2;
|
||||
} else if (row == 2) {
|
||||
rowOut &= ~ROW3;
|
||||
}
|
||||
|
||||
uint8_t colOut = 0;
|
||||
for (uint8_t col = 0; col < COL_SIZE; col++) {
|
||||
uint8_t cell = field[(row * ROW_SIZE) + col];
|
||||
if (col == 0) {
|
||||
if (cell == csCIRCLE) {
|
||||
colOut |= COL1_RED;
|
||||
} else if (cell == csCROSS) {
|
||||
colOut |= COL1_GREEN;
|
||||
}
|
||||
} else if (col == 1) {
|
||||
if (cell == csCIRCLE) {
|
||||
colOut |= COL2_RED;
|
||||
} else if (cell == csCROSS) {
|
||||
colOut |= COL2_GREEN;
|
||||
}
|
||||
} else if (col == 2) {
|
||||
if (cell == csCIRCLE) {
|
||||
colOut |= COL3_RED;
|
||||
} else if (cell == csCROSS) {
|
||||
colOut |= COL3_GREEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ROW_OUT = rowOut;
|
||||
COL_OUT = colOut;
|
||||
}
|
||||
}
|
37
src/leds.h
Normal file
37
src/leds.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* leds.h
|
||||
*
|
||||
* Created on: Apr 28, 2018
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef LEDS_H_
|
||||
#define LEDS_H_
|
||||
|
||||
|
||||
#include <msp430g2553.h>
|
||||
#include <stdint.h>
|
||||
#include "fieldDef.h"
|
||||
|
||||
|
||||
#define ROW_OUT P1OUT
|
||||
#define ROW_DIR P1DIR
|
||||
#define ROW1 BIT0
|
||||
#define ROW2 BIT1
|
||||
#define ROW3 BIT2
|
||||
|
||||
#define COL_OUT P2OUT
|
||||
#define COL_DIR P2DIR
|
||||
#define COL1_RED BIT0
|
||||
#define COL2_RED BIT1
|
||||
#define COL3_RED BIT2
|
||||
#define COL1_GREEN BIT3
|
||||
#define COL2_GREEN BIT4
|
||||
#define COL3_GREEN BIT5
|
||||
|
||||
|
||||
void ledsInit();
|
||||
void ledsShowField(tCellState *field);
|
||||
|
||||
|
||||
#endif /* LEDS_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