add VFD set and test capabilities

This commit is contained in:
King Kévin 2016-01-21 11:52:59 +01:00
parent ab273fc545
commit 515b52ec7b
3 changed files with 46 additions and 16 deletions

View File

@ -347,7 +347,6 @@ void vfd_shift(void)
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<sizeof(vfd_data)/sizeof(vfd_data[0]); i++) {
//printf("%08lx ",vfd_data[i]);
for (uint8_t b=0; b<32; b++) {
gpio_clear(VFD_PORT, VFD_CLK); // change data on low
if (vfd_data[i]&(1<<b)) { // shift the value
@ -358,11 +357,16 @@ void vfd_shift(void)
gpio_set(VFD_PORT, VFD_CLK); // signal need to be valid on high edge
}
}
//printf("\n");
gpio_set(VFD_PORT, VFD_STR); // disable HV output
gpio_set(VFD_PORT, VFD_NLE); // latch data
gpio_clear(VFD_PORT, VFD_STR); // enable HV output
gpio_clear(VFD_PORT, VFD_NLE); // stop latching data
// let the fluorescence glow up a bit
for (uint32_t i = 0; i < 0x2000; i++) {
__asm__("nop");
}
}
/* transmit each digit and dot */
@ -374,6 +378,24 @@ static void vfd_transmit(void)
}
*/
/* clear VFD display
* the data has to be transmitted separately */
void vfd_clear(void)
{
for (uint8_t i=0; i<LENGTH(vfd_data); i++) {
vfd_data[i] = 0;
}
}
/* test VFD display (light up all anodes)
* the data has to be transmitted separately */
void vfd_test(void)
{
for (uint8_t i=0; i<LENGTH(vfd_data); i++) {
vfd_data[i] = ~0;
}
}
/* setup VFD */
void vfd_setup(void)
{
@ -382,4 +404,8 @@ void vfd_setup(void)
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_NLE); // set VFD pin to 'output push-pull'
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_CLK); // set VFD pin to 'output push-pull'
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_DIN); // set VFD pin to 'output push-pull'
gpio_set(VFD_PORT, VFD_STR); // disable HV output
gpio_clear(VFD_PORT, VFD_NLE); // do not latch data
gpio_set(VFD_PORT, VFD_CLK); // clock is idle high
}

View File

@ -32,5 +32,11 @@ void vfd_digit(uint8_t nb, char c);
void vfd_matrix(uint8_t nb, char c);
/* shift out the VFD data */
void vfd_shift(void);
/* clear VFD display
* the data has to be transmitted separately */
void vfd_clear(void);
/* test VFD display (light up all anodes)
* the data has to be transmitted separately */
void vfd_test(void);
/* setup VFD */
void vfd_setup(void);

26
main.c
View File

@ -73,22 +73,24 @@ int main(void)
setbuf(stderr, NULL); // set standard error buffer to NULL to immediately print
printf("welcome to the STM32F1 CuVoodoo display driver\n");
gpio_set(VFD_PORT, VFD_STR); // disable HV output
gpio_clear(VFD_PORT, VFD_NLE); // do not latch data
gpio_set(VFD_PORT, VFD_CLK); // clock is idle high
bool vfd_transmit = false;
uint8_t digit = 0;
uint8_t matrix = 0;
char c = 0x80;
vfd_digit(digit,'0');
vfd_clear();
vfd_shift();
// let the fluorescence glow up a bit
for (uint32_t i = 0; i < 0x2000; i++) {
for (uint32_t i = 0; i < 0x800000; i++) {
__asm__("nop");
}
vfd_test();
vfd_shift();
for (uint32_t i = 0; i < 0x800000; i++) {
__asm__("nop");
}
vfd_digit(digit,'0');
vfd_shift();
while (true) {
while (usart_received) { // echo every received character
@ -107,12 +109,8 @@ int main(void)
vfd_matrix(matrix,c);
vfd_shift();
// let the fluorescence glow up a bit
for (uint32_t i = 0; i < 0x2000; i++) {
__asm__("nop");
}
matrix = (matrix+1)%12;
matrix = (matrix+1)%12;
c++;
}
__WFI(); // go to sleep