idk what happand
This commit is contained in:
parent
4307102b72
commit
dfd9b3ba2f
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,8 +1,8 @@
|
|||||||
/.settings
|
/.settings
|
||||||
/Debug
|
/Debug
|
||||||
/debug
|
/debug
|
||||||
/bin
|
/bin
|
||||||
/targetConfigs
|
/targetConfigs
|
||||||
/.ccsproject
|
/.ccsproject
|
||||||
/.cproject
|
/.cproject
|
||||||
/.project
|
/.project
|
||||||
66
.vscode/c_cpp_properties.json
vendored
66
.vscode/c_cpp_properties.json
vendored
@ -1,34 +1,34 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"DEBUGDIR": "./debug",
|
"DEBUGDIR": "./debug",
|
||||||
"SRCDIR" : "./src",
|
"SRCDIR" : "./src",
|
||||||
"BINDIR" : "./bin",
|
"BINDIR" : "./bin",
|
||||||
"TI_CCSDIR" : "/home/mreenen/.local/share/ccs10/ccs",
|
"TI_CCSDIR" : "/home/mreenen/.local/share/ccs10/ccs",
|
||||||
"TI_SL_CC32xxDIR": "/home/mreenen/.local/share/ccs10/simplelink_cc32xx_sdk_4_30_00_06",
|
"TI_SL_CC32xxDIR": "/home/mreenen/.local/share/ccs10/simplelink_cc32xx_sdk_4_30_00_06",
|
||||||
"TI_INCLUDEDIR" : "${TI_SL_CC32xxDIR}/source",
|
"TI_INCLUDEDIR" : "${TI_SL_CC32xxDIR}/source",
|
||||||
"TI_XDCTOOLSDIR" : "/home/mreenen/.local/share/ccs10/xdctools_3_61_02_27_core",
|
"TI_XDCTOOLSDIR" : "/home/mreenen/.local/share/ccs10/xdctools_3_61_02_27_core",
|
||||||
"TI_KERNEL" : "${TI_SL_CC32xxDIR}/kernel/tirtos",
|
"TI_KERNEL" : "${TI_SL_CC32xxDIR}/kernel/tirtos",
|
||||||
"TI_EABI" : "${TI_KERNEL}/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/include/",
|
"TI_EABI" : "${TI_KERNEL}/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/include/",
|
||||||
"TI_CGT" : "${TI_CCSDIR}/tools/compiler/ti-cgt-arm_20.2.1.LTS/include"
|
"TI_CGT" : "${TI_CCSDIR}/tools/compiler/ti-cgt-arm_20.2.1.LTS/include"
|
||||||
},"configurations": [
|
},"configurations": [
|
||||||
{
|
{
|
||||||
"name": "TI",
|
"name": "TI",
|
||||||
"compilerPath": "/usr/bin/gcc",
|
"compilerPath": "/usr/bin/gcc",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${TI_INCLUDEDIR}",
|
"${TI_INCLUDEDIR}",
|
||||||
"${TI_INCLUDEDIR}/ti/posix/gcc",
|
"${TI_INCLUDEDIR}/ti/posix/gcc",
|
||||||
"${TI_KERNEL}/packages",
|
"${TI_KERNEL}/packages",
|
||||||
"${TI_XDCTOOLSDIR}/packages",
|
"${TI_XDCTOOLSDIR}/packages",
|
||||||
"${TI_CGT}",
|
"${TI_CGT}",
|
||||||
"${TI_EABI}"
|
"${TI_EABI}"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"DEVICE_FAMALY=CC32xx",
|
"DEVICE_FAMALY=CC32xx",
|
||||||
"DEVICE=CC3220S"
|
"DEVICE=CC3220S"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
56
.vscode/launch.json
vendored
56
.vscode/launch.json
vendored
@ -1,29 +1,29 @@
|
|||||||
{
|
{
|
||||||
// Use IntelliSense to learn about possible attributes.
|
// Use IntelliSense to learn about possible attributes.
|
||||||
// Hover to view descriptions of existing attributes.
|
// Hover to view descriptions of existing attributes.
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "gcc-9 - Build and debug active file",
|
"name": "gcc-9 - Build and debug active file",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
||||||
"args": [],
|
"args": [],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"MIMode": "gdb",
|
"MIMode": "gdb",
|
||||||
"setupCommands": [
|
"setupCommands": [
|
||||||
{
|
{
|
||||||
"description": "Enable pretty-printing for gdb",
|
"description": "Enable pretty-printing for gdb",
|
||||||
"text": "-enable-pretty-printing",
|
"text": "-enable-pretty-printing",
|
||||||
"ignoreFailures": true
|
"ignoreFailures": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"preLaunchTask": "C/C++: gcc-9 build active file",
|
"preLaunchTask": "C/C++: gcc-9 build active file",
|
||||||
"miDebuggerPath": "/usr/bin/gdb"
|
"miDebuggerPath": "/usr/bin/gdb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
42
.vscode/tasks.json
vendored
42
.vscode/tasks.json
vendored
@ -1,22 +1,22 @@
|
|||||||
{
|
{
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "cppbuild",
|
"type": "cppbuild",
|
||||||
"label": "build using make",
|
"label": "build using make",
|
||||||
"command": "/usr/bin/make",
|
"command": "/usr/bin/make",
|
||||||
"args": [ "all" ],
|
"args": [ "all" ],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
},
|
},
|
||||||
"problemMatcher": [
|
"problemMatcher": [
|
||||||
"$gcc"
|
"$gcc"
|
||||||
],
|
],
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": true
|
||||||
},
|
},
|
||||||
"detail": "Task generated by Debugger."
|
"detail": "Task generated by Debugger."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "2.0.0"
|
"version": "2.0.0"
|
||||||
}
|
}
|
||||||
88
Makefile
88
Makefile
@ -1,44 +1,44 @@
|
|||||||
CC := /usr/bin/gcc -x c
|
CC := /usr/bin/gcc -x c
|
||||||
CURDIR := $(shell pwd)
|
CURDIR := $(shell pwd)
|
||||||
|
|
||||||
DEBUGDIR := $(CURDIR)/debug
|
DEBUGDIR := $(CURDIR)/debug
|
||||||
SRCDIR := $(CURDIR)/src
|
SRCDIR := $(CURDIR)/src
|
||||||
BINDIR := $(CURDIR)/bin
|
BINDIR := $(CURDIR)/bin
|
||||||
|
|
||||||
# TI
|
# TI
|
||||||
TI_CCSDIR := /home/mreenen/.local/share/ccs10/ccs
|
TI_CCSDIR := /home/mreenen/.local/share/ccs10/ccs
|
||||||
TI_SL_CC32xxDIR := /home/mreenen/.local/share/ccs10/simplelink_cc32xx_sdk_4_30_00_06
|
TI_SL_CC32xxDIR := /home/mreenen/.local/share/ccs10/simplelink_cc32xx_sdk_4_30_00_06
|
||||||
TI_XDCTOOLSDIR := /home/mreenen/.local/share/ccs10/xdctools_3_61_02_27_core
|
TI_XDCTOOLSDIR := /home/mreenen/.local/share/ccs10/xdctools_3_61_02_27_core
|
||||||
TI_INCLUDEDIR := $(TI_SL_CC32xxDIR)/source
|
TI_INCLUDEDIR := $(TI_SL_CC32xxDIR)/source
|
||||||
TI_KERNEL := $(TI_SL_CC32xxDIR)/kernel/tirtos
|
TI_KERNEL := $(TI_SL_CC32xxDIR)/kernel/tirtos
|
||||||
TI_EABI := $(TI_KERNEL)/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/include/
|
TI_EABI := $(TI_KERNEL)/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/include/
|
||||||
TI_CGT := $(TI_CCSDIR)/tools/compiler/ti-cgt-arm_20.2.1.LTS/include
|
TI_CGT := $(TI_CCSDIR)/tools/compiler/ti-cgt-arm_20.2.1.LTS/include
|
||||||
TI_CCINCLUDES := -I"$(TI_INCLUDEDIR)" -I"$(TI_INCLUDEDIR)/ti/posix/gcc" -I"$(TI_KERNEL)/packages" -I"$(TI_XDCTOOLSDIR)/packages" -I"$(TI_CGT)" -I"$(TI_EABI)"
|
TI_CCINCLUDES := -I"$(TI_INCLUDEDIR)" -I"$(TI_INCLUDEDIR)/ti/posix/gcc" -I"$(TI_KERNEL)/packages" -I"$(TI_XDCTOOLSDIR)/packages" -I"$(TI_CGT)" -I"$(TI_EABI)"
|
||||||
|
|
||||||
# CC ARGS
|
# CC ARGS
|
||||||
CC_INCLUDES := $(TI_CCINCLUDES)
|
CC_INCLUDES := $(TI_CCINCLUDES)
|
||||||
CC_ARGS := $(CC_INCLUDES)
|
CC_ARGS := $(CC_INCLUDES)
|
||||||
|
|
||||||
OBJECTS := $(DEBUGDIR)/main.o $(DEBUGDIR)/communicatieBeheer.o $(DEBUGDIR)/noodstop.o $(DEBUGDIR)/systeemBeheer.o
|
OBJECTS := $(DEBUGDIR)/main.o $(DEBUGDIR)/communicatieBeheer.o $(DEBUGDIR)/noodstop.o $(DEBUGDIR)/systeemBeheer.o
|
||||||
|
|
||||||
dirs:
|
dirs:
|
||||||
mkdir -p $(DEBUGDIR) $(SRCDIR) $(BINDIR)
|
mkdir -p $(DEBUGDIR) $(SRCDIR) $(BINDIR)
|
||||||
|
|
||||||
# compile
|
# compile
|
||||||
main.o: src/main.c dirs
|
main.o: src/main.c dirs
|
||||||
$(CC) $(CC_ARGS) -c $(SRCDIR)/main.c -o $(DEBUGDIR)/main.o
|
$(CC) $(CC_ARGS) -c $(SRCDIR)/main.c -o $(DEBUGDIR)/main.o
|
||||||
communicatieBeheer.o: src/communicatieBeheer.c dirs
|
communicatieBeheer.o: src/communicatieBeheer.c dirs
|
||||||
$(CC) $(CC_ARGS) -c $(SRCDIR)/communicatieBeheer.c -o $(DEBUGDIR)/communicatieBeheer.o
|
$(CC) $(CC_ARGS) -c $(SRCDIR)/communicatieBeheer.c -o $(DEBUGDIR)/communicatieBeheer.o
|
||||||
noodstop.o: src/noodstop.c dirs
|
noodstop.o: src/noodstop.c dirs
|
||||||
$(CC) $(CC_ARGS) -c $(SRCDIR)/noodstop.c -o $(DEBUGDIR)/noodstop.o
|
$(CC) $(CC_ARGS) -c $(SRCDIR)/noodstop.c -o $(DEBUGDIR)/noodstop.o
|
||||||
systeemBeheer.o: src/systeemBeheer.c dirs
|
systeemBeheer.o: src/systeemBeheer.c dirs
|
||||||
$(CC) $(CC_ARGS) -c $(SRCDIR)/systeemBeheer.c -o $(DEBUGDIR)/systeemBeheer.o
|
$(CC) $(CC_ARGS) -c $(SRCDIR)/systeemBeheer.c -o $(DEBUGDIR)/systeemBeheer.o
|
||||||
|
|
||||||
# link
|
# link
|
||||||
link: main.o communicatieBeheer.o noodstop.o systeemBeheer.o
|
link: main.o communicatieBeheer.o noodstop.o systeemBeheer.o
|
||||||
$(CC) $(CC_ARGS) -o $(BINDIR)/binary $(OBJECTS)
|
$(CC) $(CC_ARGS) -o $(BINDIR)/binary $(OBJECTS)
|
||||||
|
|
||||||
all: link
|
all: link
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -p domeTimer $(DEBUGDIR)/*
|
rm -p domeTimer $(DEBUGDIR)/*
|
||||||
|
|||||||
@ -1,65 +1,65 @@
|
|||||||
/**
|
/**
|
||||||
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
|
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
|
||||||
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
|
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
|
||||||
* @cliArgs --board "/ti/boards/CC3220S_LAUNCHXL" --product "simplelink_cc32xx_sdk@4.30.00.06"
|
* @cliArgs --board "/ti/boards/CC3220S_LAUNCHXL" --product "simplelink_cc32xx_sdk@4.30.00.06"
|
||||||
* @versions {"data":"2020090214","timestamp":"2020090214","tool":"1.6.0+1543","templates":"2020090214"}
|
* @versions {"data":"2020090214","timestamp":"2020090214","tool":"1.6.0+1543","templates":"2020090214"}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import the modules used in this configuration.
|
* Import the modules used in this configuration.
|
||||||
*/
|
*/
|
||||||
const DriverLib = scripting.addModule("/ti/devices/DriverLib");
|
const DriverLib = scripting.addModule("/ti/devices/DriverLib");
|
||||||
const Board = scripting.addModule("/ti/drivers/Board");
|
const Board = scripting.addModule("/ti/drivers/Board");
|
||||||
const DMA = scripting.addModule("/ti/drivers/DMA");
|
const DMA = scripting.addModule("/ti/drivers/DMA");
|
||||||
const GPIO = scripting.addModule("/ti/drivers/GPIO", {}, false);
|
const GPIO = scripting.addModule("/ti/drivers/GPIO", {}, false);
|
||||||
const GPIO1 = GPIO.addInstance();
|
const GPIO1 = GPIO.addInstance();
|
||||||
const I2C = scripting.addModule("/ti/drivers/I2C", {}, false);
|
const I2C = scripting.addModule("/ti/drivers/I2C", {}, false);
|
||||||
const I2C1 = I2C.addInstance();
|
const I2C1 = I2C.addInstance();
|
||||||
const PWM = scripting.addModule("/ti/drivers/PWM", {}, false);
|
const PWM = scripting.addModule("/ti/drivers/PWM", {}, false);
|
||||||
const PWM1 = PWM.addInstance();
|
const PWM1 = PWM.addInstance();
|
||||||
const Power = scripting.addModule("/ti/drivers/Power");
|
const Power = scripting.addModule("/ti/drivers/Power");
|
||||||
const SPI = scripting.addModule("/ti/drivers/SPI");
|
const SPI = scripting.addModule("/ti/drivers/SPI");
|
||||||
const SPI1 = SPI.addInstance();
|
const SPI1 = SPI.addInstance();
|
||||||
const Watchdog = scripting.addModule("/ti/drivers/Watchdog");
|
const Watchdog = scripting.addModule("/ti/drivers/Watchdog");
|
||||||
const Watchdog1 = Watchdog.addInstance();
|
const Watchdog1 = Watchdog.addInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write custom configuration values to the imported modules.
|
* Write custom configuration values to the imported modules.
|
||||||
*/
|
*/
|
||||||
GPIO1.$name = "CONF_GPIO_NOODSTOP";
|
GPIO1.$name = "CONF_GPIO_NOODSTOP";
|
||||||
GPIO1.interruptTrigger = "Falling Edge";
|
GPIO1.interruptTrigger = "Falling Edge";
|
||||||
GPIO1.pull = "Pull Up";
|
GPIO1.pull = "Pull Up";
|
||||||
GPIO1.mode = "Dynamic";
|
GPIO1.mode = "Dynamic";
|
||||||
GPIO1.callbackFunction = "noodstop_noodstopISR";
|
GPIO1.callbackFunction = "noodstop_noodstopISR";
|
||||||
|
|
||||||
I2C1.$name = "CONFIG_I2C_0";
|
I2C1.$name = "CONFIG_I2C_0";
|
||||||
I2C1.$hardware = system.deviceData.board.components.LP_I2C;
|
I2C1.$hardware = system.deviceData.board.components.LP_I2C;
|
||||||
I2C1.i2c.sdaPin.$assign = "boosterpack.10";
|
I2C1.i2c.sdaPin.$assign = "boosterpack.10";
|
||||||
I2C1.i2c.sclPin.$assign = "boosterpack.9";
|
I2C1.i2c.sclPin.$assign = "boosterpack.9";
|
||||||
|
|
||||||
PWM1.$name = "CONFIG_PWM_0";
|
PWM1.$name = "CONFIG_PWM_0";
|
||||||
PWM1.$hardware = system.deviceData.board.components.LED_RED;
|
PWM1.$hardware = system.deviceData.board.components.LED_RED;
|
||||||
|
|
||||||
Power.ioRetentionShutdown = ["GRP_1"];
|
Power.ioRetentionShutdown = ["GRP_1"];
|
||||||
Power.parkPins.$name = "ti_drivers_power_PowerCC32XXPins0";
|
Power.parkPins.$name = "ti_drivers_power_PowerCC32XXPins0";
|
||||||
|
|
||||||
SPI1.$name = "CONFIG_SPI_MASTER";
|
SPI1.$name = "CONFIG_SPI_MASTER";
|
||||||
|
|
||||||
Watchdog1.$name = "CONFIG_WATCHDOG_0";
|
Watchdog1.$name = "CONFIG_WATCHDOG_0";
|
||||||
Watchdog1.watchdog.$assign = "WATCHDOG0";
|
Watchdog1.watchdog.$assign = "WATCHDOG0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
|
||||||
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
|
||||||
* re-solve from scratch.
|
* re-solve from scratch.
|
||||||
*/
|
*/
|
||||||
GPIO1.gpioPin.$suggestSolution = "boosterpack.4";
|
GPIO1.gpioPin.$suggestSolution = "boosterpack.4";
|
||||||
I2C1.i2c.$suggestSolution = "I2C0";
|
I2C1.i2c.$suggestSolution = "I2C0";
|
||||||
PWM1.timer.$suggestSolution = "Timer2";
|
PWM1.timer.$suggestSolution = "Timer2";
|
||||||
PWM1.timer.pwmPin.$suggestSolution = "boosterpack.29";
|
PWM1.timer.pwmPin.$suggestSolution = "boosterpack.29";
|
||||||
SPI1.spi.$suggestSolution = "SPI0";
|
SPI1.spi.$suggestSolution = "SPI0";
|
||||||
SPI1.spi.sclkPin.$suggestSolution = "boosterpack.7";
|
SPI1.spi.sclkPin.$suggestSolution = "boosterpack.7";
|
||||||
SPI1.spi.misoPin.$suggestSolution = "boosterpack.14";
|
SPI1.spi.misoPin.$suggestSolution = "boosterpack.14";
|
||||||
SPI1.spi.mosiPin.$suggestSolution = "boosterpack.15";
|
SPI1.spi.mosiPin.$suggestSolution = "boosterpack.15";
|
||||||
SPI1.spi.dmaRxChannel.$suggestSolution = "UDMA_CH30";
|
SPI1.spi.dmaRxChannel.$suggestSolution = "UDMA_CH30";
|
||||||
SPI1.spi.dmaTxChannel.$suggestSolution = "UDMA_CH31";
|
SPI1.spi.dmaTxChannel.$suggestSolution = "UDMA_CH31";
|
||||||
|
|||||||
224
msp430/main.c
224
msp430/main.c
@ -1,112 +1,112 @@
|
|||||||
#include <msp430.h>
|
#include <msp430.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define READBUFFER_LEN 10
|
#define READBUFFER_LEN 10
|
||||||
#define WRITEBUFFER_LEN 10
|
#define WRITEBUFFER_LEN 10
|
||||||
|
|
||||||
// this buffers store the the receved and send data
|
// this buffers store the the receved and send data
|
||||||
unsigned char ReadBuffer[READBUFFER_LEN];
|
unsigned char ReadBuffer[READBUFFER_LEN];
|
||||||
unsigned char WriteBuffer[WRITEBUFFER_LEN];
|
unsigned char WriteBuffer[WRITEBUFFER_LEN];
|
||||||
|
|
||||||
// the pointers are used to remenber the location it was on the buffer
|
// the pointers are used to remenber the location it was on the buffer
|
||||||
unsigned char *ReadBuffer_p = &ReadBuffer[0];
|
unsigned char *ReadBuffer_p = &ReadBuffer[0];
|
||||||
unsigned char *WriteBuffer_p = &WriteBuffer[0];
|
unsigned char *WriteBuffer_p = &WriteBuffer[0];
|
||||||
|
|
||||||
// if it finisched receving/sending a packet this wil become true
|
// if it finisched receving/sending a packet this wil become true
|
||||||
bool NewPacket = false;
|
bool NewPacket = false;
|
||||||
|
|
||||||
enum {SLEEP, WRITE, READ} State;
|
enum {SLEEP, WRITE, READ} State;
|
||||||
typedef enum {} PacketID_t; //TODO: add packet ids
|
typedef enum {} PacketID_t; //TODO: add packet ids
|
||||||
|
|
||||||
void Setup(void);
|
void Setup(void);
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
|
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
|
||||||
|
|
||||||
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
|
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
|
||||||
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0
|
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0
|
||||||
|
|
||||||
Setup();
|
Setup();
|
||||||
State = SLEEP;
|
State = SLEEP;
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
while(!NewPacket){
|
while(!NewPacket){
|
||||||
//TODO: add sleep mode
|
//TODO: add sleep mode
|
||||||
}
|
}
|
||||||
|
|
||||||
__disable_interrupt(); // don't want the interupt to destoy you beautiful packet
|
__disable_interrupt(); // don't want the interupt to destoy you beautiful packet
|
||||||
NewPacket = false; // recet new packet flag
|
NewPacket = false; // recet new packet flag
|
||||||
uint8_t bytesReceved = ReadBuffer_p - &ReadBuffer[0];
|
uint8_t bytesReceved = ReadBuffer_p - &ReadBuffer[0];
|
||||||
uint8_t data[READBUFFER_LEN];
|
uint8_t data[READBUFFER_LEN];
|
||||||
|
|
||||||
// copy data from the buffer used for the communication so it can receve the next packet
|
// copy data from the buffer used for the communication so it can receve the next packet
|
||||||
memcpy(&data[0], &ReadBuffer[0], bytesReceved);
|
memcpy(&data[0], &ReadBuffer[0], bytesReceved);
|
||||||
|
|
||||||
__enable_interrupt(); // data is save
|
__enable_interrupt(); // data is save
|
||||||
|
|
||||||
switch (data[0]){
|
switch (data[0]){
|
||||||
case /* packet id */:
|
case /* packet id */:
|
||||||
/* read packet */
|
/* read packet */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deze interrupt is beide voor RXIFG en TXIFG.
|
* Deze interrupt is beide voor RXIFG en TXIFG.
|
||||||
* Dus vlaggetjes bekijken om te zien wat er gebeurd
|
* Dus vlaggetjes bekijken om te zien wat er gebeurd
|
||||||
*/
|
*/
|
||||||
#pragma vector = USCIAB0TX_VECTOR
|
#pragma vector = USCIAB0TX_VECTOR
|
||||||
__interrupt void USCIAB0TX_ISR(void)
|
__interrupt void USCIAB0TX_ISR(void)
|
||||||
{
|
{
|
||||||
if(IFG2 & UCB0TXIFG && State == WRITE){
|
if(IFG2 & UCB0TXIFG && State == WRITE){
|
||||||
// Read data from I2C
|
// Read data from I2C
|
||||||
UCB0TXBUF = *WriteBuffer_p;
|
UCB0TXBUF = *WriteBuffer_p;
|
||||||
WriteBuffer_p++;
|
WriteBuffer_p++;
|
||||||
if(WriteBuffer_p > &WriteBuffer[WRITEBUFFER_LEN]){
|
if(WriteBuffer_p > &WriteBuffer[WRITEBUFFER_LEN]){
|
||||||
State = SLEEP;
|
State = SLEEP;
|
||||||
NewPacket = true;
|
NewPacket = true;
|
||||||
}
|
}
|
||||||
}else if(IFG2 & UCB0RXIFG && State == READ){
|
}else if(IFG2 & UCB0RXIFG && State == READ){
|
||||||
// Write data to I2C
|
// Write data to I2C
|
||||||
*ReadBuffer_p = UCB0RXBUF;
|
*ReadBuffer_p = UCB0RXBUF;
|
||||||
ReadBuffer_p++;
|
ReadBuffer_p++;
|
||||||
if(ReadBuffer_p > &ReadBuffer[READBUFFER_LEN]){
|
if(ReadBuffer_p > &ReadBuffer[READBUFFER_LEN]){
|
||||||
State = WRITE;
|
State = WRITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hier krijgen we de start/stop condities
|
* Hier krijgen we de start/stop condities
|
||||||
*/
|
*/
|
||||||
#pragma vector = USCIAB0RX_VECTOR
|
#pragma vector = USCIAB0RX_VECTOR
|
||||||
__interrupt void USCIAB0RX_ISR(void)
|
__interrupt void USCIAB0RX_ISR(void)
|
||||||
{
|
{
|
||||||
if(UCB0STAT & UCSTTIFG){
|
if(UCB0STAT & UCSTTIFG){
|
||||||
// start signaal ontvangen
|
// start signaal ontvangen
|
||||||
State = READ;
|
State = READ;
|
||||||
// reset pointers
|
// reset pointers
|
||||||
WriteBuffer_p = &WriteBuffer[0];
|
WriteBuffer_p = &WriteBuffer[0];
|
||||||
ReadBuffer_p = &ReadBuffer[0];
|
ReadBuffer_p = &ReadBuffer[0];
|
||||||
}else if(UCB0STAT & UCSTPIFG){
|
}else if(UCB0STAT & UCSTPIFG){
|
||||||
// stop signaal, klaar met transactie
|
// stop signaal, klaar met transactie
|
||||||
State = SLEEP;
|
State = SLEEP;
|
||||||
NewPacket = true;
|
NewPacket = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear interrupt flags
|
// Clear interrupt flags
|
||||||
UCB0STAT &= ~(UCSTPIFG + UCSTTIFG);
|
UCB0STAT &= ~(UCSTPIFG + UCSTTIFG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Setup(void){
|
void Setup(void){
|
||||||
__disable_interrupt();
|
__disable_interrupt();
|
||||||
UCB0CTL1 |= UCSWRST; // reset
|
UCB0CTL1 |= UCSWRST; // reset
|
||||||
UCB0CTL0 = UCMODE_3 + UCSYNC; // I2C Slave, synchronous mode
|
UCB0CTL0 = UCMODE_3 + UCSYNC; // I2C Slave, synchronous mode
|
||||||
UCB0I2COA = 0x48; // eigen slave adres is 048h
|
UCB0I2COA = 0x48; // eigen slave adres is 048h
|
||||||
UCB0CTL1 &= ~UCSWRST; // reset uit
|
UCB0CTL1 &= ~UCSWRST; // reset uit
|
||||||
UCB0I2CIE |= UCSTPIE + UCSTTIE; // detectie voor start en stop
|
UCB0I2CIE |= UCSTPIE + UCSTTIE; // detectie voor start en stop
|
||||||
IE2 |= UCB0RXIE | UCB0TXIE; // interrupts aan
|
IE2 |= UCB0RXIE | UCB0TXIE; // interrupts aan
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
void systeemBeheer(){
|
void systeemBeheer(){
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user