prepare display

This commit is contained in:
Wolfgang Hottgenroth 2024-03-22 18:38:30 +01:00
parent 10a09e3ad3
commit a32ef8fa5b
7 changed files with 73 additions and 5 deletions

View File

@ -11,7 +11,7 @@ CFLAGS=-Wall -mmcu=$(MCU) -std=gnu99 -I $(TOOLCHAIN_PREFIX)/include -O1 -g0
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include
$(ARTIFACT).elf: main.o spi.o scheduler.o canvas.o shapes.o game.o buttons.o myrand.o
$(ARTIFACT).elf: main.o spi.o scheduler.o canvas.o shapes.o game.o buttons.o myrand.o display.o
$(CC) -o $@ $(LDFLAGS) $^
$(OBJDUMP) -D $(ARTIFACT).elf > $(ARTIFACT).txt

50
game-ctrl/display.c Normal file
View File

@ -0,0 +1,50 @@
#include <stdint.h>
#include "display.h"
#include "spi.h"
uint16_t score;
void displayInit() {
score = 0;
spiSendBegin(e_SPI_DISPLAY);
// display test off
spiSendOctet(0x0f);
spiSendOctet(0x01);
// BCD decode for all digits
spiSendOctet(0x09);
spiSendOctet(0xff);
// scan limit to digits 0-3
spiSendOctet(0x0b);
spiSendOctet(0x03);
// intensity
spiSendOctet(0x0a);
spiSendOctet(0x0f);
// normal operation
spiSendOctet(0x0C);
spiSendOctet(0x01);
spiSendEnd(e_SPI_DISPLAY);
}
void displaySetScore(uint16_t v) {
score = v;
spiSendBegin(e_SPI_DISPLAY);
spiSendOctet(0x01);
spiSendOctet(0x07);
spiSendEnd(e_SPI_DISPLAY);
}

13
game-ctrl/display.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
#include <stdint.h>
void displayInit();
void displaySetScore(uint16_t v);
#endif // _DISPLAY_H_

View File

@ -6,6 +6,7 @@
#include "shapes.h"
#include "canvas.h"
#include "../rgb-driver/colors.h"
#include "display.h"
#define GAME_CYCLE_TIME 100
@ -116,6 +117,8 @@ void gameExec(void *handle) {
}
}
}
displaySetScore(7);
}
void gameInit() {

View File

@ -11,6 +11,7 @@
#include "shapes.h"
#include "myrand.h"
#include "spi.h"
#include "display.h"
int main() {
@ -27,6 +28,7 @@ int main() {
schInit();
spiInit();
displayInit();
myRandInit();
canvasInit();

View File

@ -2,8 +2,8 @@
#include "spi.h"
void spiInit() {
// SPI in master mode
UCB0CTL0 = UCMST;
// SPI in master mode, most significant bit first
UCB0CTL0 = UCMST | UCMSB;
// SPI timing config
UCB0CTL1 = UCSSEL_3;
// Faster than 8 ends up in strange communication errors

View File

@ -122,8 +122,8 @@ init:
mov.w #OUTMOD_7,&TA1CCTL2
;; spi configuration
;; USCI B to slave mode
mov.b #UCSYNC|UCMODE_2, &UCB0CTL0
;; USCI B to slave mode, enable STE and most significant bit first
mov.b #UCSYNC|UCMODE_2|UCMSB, &UCB0CTL0
mov.b #0x00, &UCB0CTL1
;; make sure the isr will not immediately start