This commit is contained in:
2024-03-19 16:46:52 +01:00
parent 5615c80e8f
commit 8b2f18415d
4 changed files with 42 additions and 44 deletions

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.o *.o
firmware.* firmware.txt
firmware.elf
firmware.map

View File

@ -7,7 +7,7 @@ MCU=msp430g2553
CFLAGS=-Wall -mmcu=$(MCU) -std=gnu99 -I $(TOOLCHAIN_PREFIX)/include -O1 -g0 CFLAGS=-Wall -mmcu=$(MCU) -std=gnu99 -I $(TOOLCHAIN_PREFIX)/include -O1 -g0
# for debugging # for debugging
# CFLAGS+= -g3 -ggdb -gdwarf-2 #CFLAGS+= -g3 -ggdb -gdwarf-2
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include

View File

@ -1,5 +1,6 @@
#include "stddef.h" #include <stddef.h>
#include "stdint.h" #include <stdint.h>
#include <msp430g2553.h>
#include "buttons.h" #include "buttons.h"
#include "scheduler.h" #include "scheduler.h"
@ -8,52 +9,45 @@
#include "led.h" #include "led.h"
// TEST CODE
uint16_t counter;
static uint8_t buttonsMoveLeftPressed() { static uint8_t buttonsMoveLeftPressed() {
// ----------------------- static uint8_t last = 0;
// TEST CODE uint8_t current = (P2IN & BIT4);
//if (counter == 95) { uint8_t res = (current != 0) && (current != last);
// ledGreenToggle(); last = current;
// return 1; return res;
//}
// -----------------------
return 0;
} }
static uint8_t buttonsMoveRightPressed() { static uint8_t buttonsMoveRightPressed() {
// ----------------------- static uint8_t last = 0;
// TEST CODE uint8_t current = (P2IN & BIT0);
if (counter == 95) { uint8_t res = (current != 0) && (current != last);
ledGreenToggle(); last = current;
return 1; return res;
}
// -----------------------
return 0;
} }
static uint8_t buttonsRotateLeftPressed() { static uint8_t buttonsRotateLeftPressed() {
return 0; static uint8_t last = 0;
uint8_t current = (P2IN & BIT3);
uint8_t res = (current != 0) && (current != last);
last = current;
return res;
} }
static uint8_t buttonsRotateRightPressed() { static uint8_t buttonsRotateRightPressed() {
// ----------------------- static uint8_t last = 0;
// TEST CODE uint8_t current = (P2IN & BIT1);
if (counter == 35) { uint8_t res = (current != 0) && (current != last);
ledGreenToggle(); last = current;
return 1; return res;
} }
// -----------------------
// ----------------------- static uint8_t buttonsMoveDownPressed() {
// TEST CODE static uint8_t last = 0;
if (counter == 45) { uint8_t current = (P2IN & BIT2);
ledGreenToggle(); uint8_t res = (current != 0) && (current != last);
return 1; last = current;
} return res;
// -----------------------
return 0;
} }
void buttonsExec(void *handle) { void buttonsExec(void *handle) {
@ -62,9 +56,6 @@ void buttonsExec(void *handle) {
return; return;
} }
// TEST CODE
counter++;
uint8_t buttonPressed = 0; uint8_t buttonPressed = 0;
if (buttonsMoveLeftPressed()) { if (buttonsMoveLeftPressed()) {
@ -83,6 +74,10 @@ void buttonsExec(void *handle) {
stoneRotateRight(); stoneRotateRight();
buttonPressed = 1; buttonPressed = 1;
} }
if (buttonsMoveDownPressed()) {
stoneMoveDown();
buttonPressed = 1;
}
if (buttonPressed == 1) { if (buttonPressed == 1) {
canvasShow(); canvasShow();
@ -90,8 +85,7 @@ void buttonsExec(void *handle) {
} }
void buttonsInit() { void buttonsInit() {
// TEST CODE P2DIR &= ~(BIT0|BIT1|BIT2|BIT3|BIT4);
counter = 0;
schAdd(buttonsExec, NULL, 0, 100); schAdd(buttonsExec, NULL, 0, 100);
} }

2
game-ctrl/firmware.gdb Normal file
View File

@ -0,0 +1,2 @@
target remote localhost:2000
file firmware.elf