* 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:
parent
4e2a90e52f
commit
969f198084
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
*.o
|
*.o
|
||||||
*.elf
|
*.elf
|
||||||
|
core
|
||||||
|
8
Makefile
8
Makefile
@ -1,5 +1,11 @@
|
|||||||
CC=msp430-gcc
|
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
|
LDFLAGS=-mmcu=msp430g2553
|
||||||
|
|
||||||
blinky1.elf: main.o led.o time.o pattern.o PontCoopScheduler.o myrand.o measure.o
|
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
4
main.c
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "pattern.h"
|
#include "pattern.h"
|
||||||
|
#include "measure.h"
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@ -28,7 +29,8 @@ int main() {
|
|||||||
|
|
||||||
ledInit();
|
ledInit();
|
||||||
patternInit();
|
patternInit();
|
||||||
// ledSetMatrix(0, 1, BLUE);
|
measureInit();
|
||||||
|
// ledSetMatrix(0, 0, BLUE);
|
||||||
|
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
|
|
||||||
|
45
measure.c
45
measure.c
@ -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() {
|
void measureCollectAndProcessConversion() {
|
||||||
|
|
||||||
static uint32_t averagingSum = 0;
|
static uint32_t averagingSum = 0;
|
||||||
static uint8_t averagingCnt = 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
32
pattern.c
32
pattern.c
@ -6,8 +6,8 @@
|
|||||||
#include "myrand.h"
|
#include "myrand.h"
|
||||||
|
|
||||||
|
|
||||||
uint8_t temperature = 20;
|
uint8_t temperature = 21;
|
||||||
const uint8_t TEMPERATURE_THRESHOLD = 20;
|
const uint8_t TEMPERATURE_THRESHOLD = 25;
|
||||||
|
|
||||||
tColor lockedColor = OFF;
|
tColor lockedColor = OFF;
|
||||||
|
|
||||||
@ -35,9 +35,7 @@ void patternExec() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
void patternTestBlueExec() {
|
||||||
* BLUE
|
|
||||||
void patternExec() {
|
|
||||||
static uint8_t state = 0;
|
static uint8_t state = 0;
|
||||||
static uint8_t column = 0;
|
static uint8_t column = 0;
|
||||||
|
|
||||||
@ -48,12 +46,11 @@ void patternExec() {
|
|||||||
ledSetMatrix(1, 0, BLUE);
|
ledSetMatrix(1, 0, BLUE);
|
||||||
ledSetMatrix(2, 0, BLUE);
|
ledSetMatrix(2, 0, BLUE);
|
||||||
ledSetMatrix(3, 0, BLUE);
|
ledSetMatrix(3, 0, BLUE);
|
||||||
srand(13);
|
|
||||||
state = 1;
|
state = 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// select new column, row 1
|
// select new column, row 1
|
||||||
column = ((uint8_t) rand()) & 0x3;
|
column = 0;
|
||||||
ledSetMatrix(column, 1, BLUE);
|
ledSetMatrix(column, 1, BLUE);
|
||||||
state = 2;
|
state = 2;
|
||||||
break;
|
break;
|
||||||
@ -79,7 +76,7 @@ void patternExec() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static bool _patternChangeColor() {
|
static bool _patternChangeColor() {
|
||||||
@ -101,7 +98,20 @@ static bool _patternChangeColor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t _patternStayCnt() {
|
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() {
|
void patternExec() {
|
||||||
@ -129,7 +139,7 @@ void patternExec() {
|
|||||||
ledSetMatrix(1, baseRow, lockedColor);
|
ledSetMatrix(1, baseRow, lockedColor);
|
||||||
ledSetMatrix(2, baseRow, lockedColor);
|
ledSetMatrix(2, baseRow, lockedColor);
|
||||||
ledSetMatrix(3, baseRow, lockedColor);
|
ledSetMatrix(3, baseRow, lockedColor);
|
||||||
srand(13);
|
|
||||||
state = 1;
|
state = 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -177,7 +187,7 @@ void patternExec() {
|
|||||||
case 7:
|
case 7:
|
||||||
// same column, row 0 off
|
// same column, row 0 off
|
||||||
ledSetMatrix(column, (lockedColor == RED) ? 0 : 3, OFF);
|
ledSetMatrix(column, (lockedColor == RED) ? 0 : 3, OFF);
|
||||||
state = _patternChangeColor() ? 1 : 0;
|
state = _patternChangeColor() ? 0 : 1;
|
||||||
stay = _patternStayCnt();
|
stay = _patternStayCnt();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user