diff options
author | jaseg <git@jaseg.de> | 2023-12-24 15:31:51 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-12-24 15:31:51 +0100 |
commit | 2dcae5db6fdcc5c604a7bd39d5c0c4b58bbd1a5b (patch) | |
tree | e7f3c5b1afd820c34ed5ef5b0f728133cba92f9b | |
parent | 7b7b18cb148adf6a254a1f73b7fd32d68d88681c (diff) | |
download | 8seg-2dcae5db6fdcc5c604a7bd39d5c0c4b58bbd1a5b.tar.gz 8seg-2dcae5db6fdcc5c604a7bd39d5c0c4b58bbd1a5b.tar.bz2 8seg-2dcae5db6fdcc5c604a7bd39d5c0c4b58bbd1a5b.zip |
Fix some dumb bugs
-rw-r--r-- | driver_fw/.gdbinit | 4 | ||||
-rw-r--r-- | driver_fw/src/main.c | 49 |
2 files changed, 36 insertions, 17 deletions
diff --git a/driver_fw/.gdbinit b/driver_fw/.gdbinit index 652efda..a4181e4 100644 --- a/driver_fw/.gdbinit +++ b/driver_fw/.gdbinit @@ -1,6 +1,6 @@ # blackmagic-1 -# target extended-remote 192.168.27.252:2022 +target extended-remote 192.168.27.252:2022 # blackmagic-2 # target extended-remote 192.168.27.114:2022 @@ -9,7 +9,7 @@ # target extended-remote 192.168.27.207:2022 # blackmagic-4 -target extended-remote 192.168.27.153:2022 +# target extended-remote 192.168.27.153:2022 set print pretty on set print elements 512 diff --git a/driver_fw/src/main.c b/driver_fw/src/main.c index 4502784..7227a4a 100644 --- a/driver_fw/src/main.c +++ b/driver_fw/src/main.c @@ -43,11 +43,11 @@ int hex_to_int(char *hex, size_t len) { rv = rv<<4; char c = hex[len]; if ('0' <= c && c <= '9') - c -= '0'; + c = c - '0'; else if ('a' <= c && c <= 'f') - c -= 'a' + 0xa; + c = c - 'a' + 0xa; else if ('A' <= c && c <= 'F') - c -= 'A' + 0xa; + c = c - 'A' + 0xa; else c = 0; rv |= c; @@ -161,7 +161,9 @@ int main(void) { GPIOB->OSPEEDR = (3<<0) | (3<<1) | (3<<3); /* GPIOC: - * C0-C3: (testpoint) + * C0, C3: (testpoint) + * C1: Fan 2 PWM + * C2: Fan 1 PWM * C4: RJ45 LED 4 * C5: RJ45 LED 3 * C6: Fuse monitor 7 @@ -172,12 +174,14 @@ int main(void) { * C11-C15: (testpoint) */ GPIOC->MODER = - IN(0) | IN(1) | IN(2) | IN(3) | IN(9) | IN(11) | IN(12) | IN(13) | IN(14) | IN(15) | + IN(0) | OUT(1) | OUT(2) | IN(3) | IN(9) | IN(11) | IN(12) | IN(13) | IN(14) | IN(15) | OUT(4) | OUT(5) | IN(6) | IN(7) | IN(8) | AF(10); + GPIOC->OTYPER = (1<<1) | (1<<2); GPIOC->AFR[1] = AFRH(10, 2); GPIOC->OSPEEDR = (3<<10); + GPIOC->BRR = (1<<1) | (1<<2); /* Disable fans */ /* GPIOD: * D0-D6: (testpoint) @@ -187,11 +191,20 @@ int main(void) { GPIOD->MODER = IN(0) | IN(1) | IN(2) | IN(3) | IN(4) | IN(5) | IN(6) | IN(8) | IN(9); - for (int i=0; i<20; i++) { + for (int i=0; i<10; i++) { set_status_leds(LED_ON); - delay_us(500*1000); + delay_us(250*1000); set_status_leds(0); - delay_us(500*1000); + delay_us(250*1000); + } + + GPIOC->BSRR = (1<<1) | (1<<2); /* Enable fans */ + + for (int i=0; i<10; i++) { + set_status_leds(LED_ON); + delay_us(250*1000); + set_status_leds(0); + delay_us(250*1000); } TIM1->CCMR1 = (6<<TIM_CCMR1_OC2M_Pos) | TIM_CCMR1_OC2PE; @@ -249,12 +262,18 @@ int main(void) { } set_status_leds(leds); - if (USART1->ISR & USART_ISR_RXNE_RXFNE) { - rj45_rx_ctr = 100000; - if (USART1->RDR == '\n') { - if (rxp != 4*16*3) { + int isr = USART1->ISR; + if ((isr & USART_ISR_ORE) || (isr & USART_ISR_FE)) { + USART1->ICR = USART_ICR_ORECF | USART_ICR_FECF; + } + + if (isr & USART_ISR_RXNE_RXFNE) { + rj45_rx_ctr = 20000; + char c = USART1->RDR; + if (c == '\n') { + if (rxp > 2 && rxp != 4*16*3) { + control_err_ctr = 1000000; rxp = 0; - control_err_ctr = 10000000; continue; } @@ -271,12 +290,12 @@ int main(void) { } } rxp = 0; - ping_ctr = 1000000; + ping_ctr = 500000; update_tx_buf(); } else { if (rxp <= sizeof(rxbuf)) { - rxbuf[rxp] = USART1->RDR; + rxbuf[rxp] = c; rxp ++; } } |