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