diff --git a/lib/vfd.c b/lib/vfd.c index 83b4bf2..3b56f5b 100644 --- a/lib/vfd.c +++ b/lib/vfd.c @@ -23,6 +23,8 @@ /* STM32 (including CM3) libraries */ #include // real-time control clock library #include // general purpose input output library +#include // SPI library +#include // interrupt handler #include "vfd.h" // VFD definitions @@ -254,8 +256,11 @@ static const uint8_t pict5x7[][5] = { {0x00, 0x00, 0x00, 0x00, 0x00} // nothing }; -/* the three 32 bits values to be shifted out to the VFD driver */ -static uint32_t vfd_data[3] = {0}; +/* the 32 bits values to be shifted out to the VFD driver + * split into 16 bit for SPI transfer */ +static uint32_t vfd_data[VFD_DRIVERS] = {0}; +static uint16_t vfd_spi[VFD_DRIVERS*2] = {0}; +static volatile uint8_t vfd_spi_i = 0; char vfd_digits[VFD_DIGITS] = {0}; char vfd_matrixs[VFD_MATRIX] = {0}; @@ -267,7 +272,12 @@ void vfd_digit(uint8_t nb, char c) if (!(nb to ASCII character * non ASCII characters are used for pictures */ void vfd_matrix(uint8_t nb, char c) { - if (!(nb=' ')) { // only take printable characters uint8_t i = c-' '; // get index for character if (i>16; + } + vfd_spi_i = 0; + + spi_enable(VFD_SPI); // enable SPI (the tx empty interrupt will trigger) + //while (true) { + //spi_send(VFD_SPI, vfd_spi[vfd_spi_i++]); // send first data (also enables latch) +//} + +/* gpio_clear(VFD_PORT, VFD_NLE); // do not latch data gpio_set(VFD_PORT, VFD_CLK); // clock is idle high for (uint8_t i=0; i // vector table definition #include // Cortex M3 utilities +#include // SPI library + /* own libraries */ #include "main.h" // board definitions #include "usart.h" // USART utilities @@ -69,7 +71,7 @@ int main(void) gpio_setup(); // setup main inputs/outputs usart_setup(); // setup USART (for printing) - cdcacm_setup(); // setup USB CDC ACM (for printing) + cdcacm_setup(); // setup USB CDC ACM (for printing) vfd_setup(); // setup VFD setbuf(stdout, NULL); // set standard out buffer to NULL to immediately print @@ -77,6 +79,8 @@ int main(void) printf("welcome to the STM32F1 CuVoodoo display driver\n"); + + vfd_on(); // switch on VFD vfd_test(); vfd_shift(); for (uint32_t i = 0; i < 0x800000; i++) { @@ -84,6 +88,8 @@ int main(void) } vfd_clear(); vfd_shift(); + vfd_digit(0,'0'); + vfd_shift(); bool vfd_flag = false; for (uint8_t i=0; i