diff --git a/src/dmesg.c b/src/dmesg.c index f1a205b..22b9613 100644 --- a/src/dmesg.c +++ b/src/dmesg.c @@ -46,6 +46,8 @@ void codal_dmesgf(const char *format, ...) { } void codal_vdmesg(const char *format, va_list ap) { + // if (format[0] == '!') + // pin_pulse(PIN_X0, 1); char tmp[80]; codal_vsprintf(tmp, sizeof(tmp) - 1, format, ap); int len = strlen(tmp); @@ -135,4 +137,3 @@ int codal_sprintf(char *dst, unsigned dstsize, const char *format, ...) { va_end(arg); return r; } - diff --git a/stm32/rtc.c b/stm32/rtc.c index ef709cf..7aea719 100644 --- a/stm32/rtc.c +++ b/stm32/rtc.c @@ -51,7 +51,7 @@ void rtc_sync_time() { if (!ctx->needsSync) return; - pin_set(PIN_PWR_STATE, 1); + target_disable_irq(); uint16_t subsecond; uint8_t newSecond; @@ -65,6 +65,7 @@ void rtc_sync_time() { } subsecond = ctx->presc - subsecond; if (newSecond != ctx->lastSecond) { + // this branch adds ~4us int diff = 60 + BCD(newSecond, 3) - BCD(ctx->lastSecond, 3); if (diff >= 60) diff -= 60; diff --git a/stm32/uart.c b/stm32/uart.c index a2b4231..01c57b1 100644 --- a/stm32/uart.c +++ b/stm32/uart.c @@ -211,10 +211,10 @@ void uart_init() { USART_UART_Init(); } -static void check_idle(void) { - if (LL_USART_IsEnabled(USARTx)) - jd_panic(); -} +// static void check_idle(void) { +// if (LL_USART_IsEnabled(USARTx)) +// jd_panic(); +//} int uart_wait_high() { int timeout = 5000; @@ -282,10 +282,7 @@ int uart_start_tx(const void *data, uint32_t numbytes) { void uart_start_rx(void *data, uint32_t maxbytes) { // DMESG("start rx"); - check_idle(); - - exti_disable(PIN_MASK(UART_PIN)); - exti_clear(PIN_MASK(UART_PIN)); + // check_idle(); uartOwnsPin(1); LL_USART_DisableDirectionTx(USARTx); @@ -300,6 +297,9 @@ void uart_start_rx(void *data, uint32_t maxbytes) { LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_5, maxbytes); LL_USART_EnableDMAReq_RX(USARTx); LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_5); + + exti_disable(PIN_MASK(UART_PIN)); + exti_clear(PIN_MASK(UART_PIN)); } // this is only enabled for error events