From 7a5791e976ec79107078fa654a8067ec4f1a0587 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 13 Aug 2017 15:48:48 +0200 Subject: Board rev 0.3 working --- fw/main.c | 57 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'fw') diff --git a/fw/main.c b/fw/main.c index 2e7b56e..73e7280 100644 --- a/fw/main.c +++ b/fw/main.c @@ -32,6 +32,11 @@ void strobe_leds(void) { GPIOA->BSRR = GPIO_BSRR_BR_9; } +#define SR_COMM 0x0002 +#define SR_ERROR 0x0004 +#define SR_ID 0x0008 +#define SR_ILED_HIGH 0x0080 +#define SR_ILED_LOW 0x0040 int main(void) { RCC->CR |= RCC_CR_HSEON; while (!(RCC->CR&RCC_CR_HSERDY)); @@ -77,27 +82,55 @@ int main(void) { SPI1->CR1 = SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE | SPI_CR1_SSM | SPI_CR1_SSI | SPI_CR1_SPE | (0<BSRR = GPIO_BSRR_BR_6; + int aval = 0x0000; + GPIOA->BSRR = GPIO_BSRR_BR_6; /* OE */ int j = 0; - int bval = 0x4000; + int ctr = 0; + int q = 0; + int bval = 0x400; while (42) { for (int i=0; i<8; i++) { - spi_send(val); - spi_send(val); + spi_send(1<<(ctr&3)); + spi_send(1<<((ctr>>1)&3)); strobe_leds(); - spi_send(0x0200 | bval | (0xff^(1<