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

4
.gitignore vendored

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

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

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

2
game-ctrl/firmware.gdb Normal file

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