* add readme with comments on debugging

* add optional CFLAGS in Makefile for debugging
* fix _patternChangeColor function in pattern.c
* add debug variant for measure exec function
This commit is contained in:
Wolfgang Hottgenroth 2019-02-09 17:54:18 +01:00
parent 4e2a90e52f
commit 969f198084
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
7 changed files with 77 additions and 28 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
*.o
*.elf
core

View File

@ -1,5 +1,11 @@
CC=msp430-gcc
CFLAGS=-O3 -g0 -Wall -mmcu=msp430g2553 -std=gnu99 -I hottislib
# regular
CFLAGS=-Wall -mmcu=msp430g2553 -std=gnu99 -I hottislib -O3 -g0
# for debugging
# CFLAGS=-Wall -mmcu=msp430g2553 -std=gnu99 -I hottislib -g3 -ggdb -gdwarf-2
LDFLAGS=-mmcu=msp430g2553
blinky1.elf: main.o led.o time.o pattern.o PontCoopScheduler.o myrand.o measure.o

@ -1 +1 @@
Subproject commit d129650a6fbc77f5b5474c2b5153fa6adbbda003
Subproject commit 8c7413c09b39e46916fc112e49005cbe7e798487

4
main.c
View File

@ -9,6 +9,7 @@
#include "led.h"
#include "pattern.h"
#include "measure.h"
int main() {
@ -28,7 +29,8 @@ int main() {
ledInit();
patternInit();
// ledSetMatrix(0, 1, BLUE);
measureInit();
// ledSetMatrix(0, 0, BLUE);
__enable_interrupt();

View File

@ -28,20 +28,8 @@ const uint8_t AVERAGING_CYCLES = 50;
void measureInit() {
ADC10CTL0 = SREF1 | ADC10SHT_3 | ADC10SR | REFOUT | REFON | REF2_5V | ADC10ON;
ADC10CTL1 = INCH_3;
ADC10AE0 = BIT3;
}
void measureCollectAndProcessConversion();
void measureStartConversion(void *handleArg) {
ADC10CTL0 |= ENC | ADC10SC;
schAdd(measureCollectAndProcessConversion, NULL, MEASURE_FETCH_RESULT_DELAY, 0);
}
void measureCollectAndProcessConversion() {
static uint32_t averagingSum = 0;
static uint8_t averagingCnt = 0;
@ -81,4 +69,35 @@ void measureCollectAndProcessConversion() {
}
}
void measureTestExec() {
static uint8_t t = 0;
static int8_t dir = 1;
if (t == 0) {
dir = 1;
}
if (t == 50) {
dir = -1;
}
t += dir;
patternSetTemperature(t);
}
void measureInit() {
ADC10CTL0 = SREF1 | ADC10SHT_3 | ADC10SR | REFOUT | REFON | REF2_5V | ADC10ON;
ADC10CTL1 = INCH_0;
ADC10AE0 = BIT0;
// schAdd(measureStartConversion, NULL, 0, 100);
schAdd(measureTestExec, NULL, 0, 1000);
}
void measureStartConversion() {
ADC10CTL0 |= ENC | ADC10SC;
schAdd(measureCollectAndProcessConversion, NULL, MEASURE_FETCH_RESULT_DELAY, 0);
}

View File

@ -6,8 +6,8 @@
#include "myrand.h"
uint8_t temperature = 20;
const uint8_t TEMPERATURE_THRESHOLD = 20;
uint8_t temperature = 21;
const uint8_t TEMPERATURE_THRESHOLD = 25;
tColor lockedColor = OFF;
@ -35,9 +35,7 @@ void patternExec() {
}
*/
/*
* BLUE
void patternExec() {
void patternTestBlueExec() {
static uint8_t state = 0;
static uint8_t column = 0;
@ -48,12 +46,11 @@ void patternExec() {
ledSetMatrix(1, 0, BLUE);
ledSetMatrix(2, 0, BLUE);
ledSetMatrix(3, 0, BLUE);
srand(13);
state = 1;
break;
case 1:
// select new column, row 1
column = ((uint8_t) rand()) & 0x3;
column = 0;
ledSetMatrix(column, 1, BLUE);
state = 2;
break;
@ -79,7 +76,7 @@ void patternExec() {
break;
}
}
*/
static bool _patternChangeColor() {
@ -101,7 +98,20 @@ static bool _patternChangeColor() {
}
uint8_t _patternStayCnt() {
return temperature;
uint8_t s = 0;
if (temperature < TEMPERATURE_THRESHOLD) {
s = TEMPERATURE_THRESHOLD - temperature;
} else if (temperature > (TEMPERATURE_THRESHOLD * 2)) {
s = 0;
} else {
s = (TEMPERATURE_THRESHOLD * 2) - temperature;
}
if (s == 0) {
s = 1;
}
return s;
}
void patternExec() {
@ -129,7 +139,7 @@ void patternExec() {
ledSetMatrix(1, baseRow, lockedColor);
ledSetMatrix(2, baseRow, lockedColor);
ledSetMatrix(3, baseRow, lockedColor);
srand(13);
state = 1;
break;
case 1:
@ -177,7 +187,7 @@ void patternExec() {
case 7:
// same column, row 0 off
ledSetMatrix(column, (lockedColor == RED) ? 0 : 3, OFF);
state = _patternChangeColor() ? 1 : 0;
state = _patternChangeColor() ? 0 : 1;
stay = _patternStayCnt();
break;
default:

12
readme.md Normal file
View File

@ -0,0 +1,12 @@
Build:
* make all
Flash:
* make upload
Debugger:
* enable debugging in Makefile
* mspdebug rf2500 gdb
* ddd --debugger msp430-gdb
* for every code change upload using Makefile and restart both mspdebug and ddd (or fine a way to reset the both)