diff --git a/r_cg_serial_user.c b/r_cg_serial_user.c index b2e7287..3f66747 100644 --- a/r_cg_serial_user.c +++ b/r_cg_serial_user.c @@ -156,6 +156,42 @@ static void __near r_uart0_interrupt_send(void) static void r_uart0_callback_receiveend(void) { /* Start user code. Do not edit comment generated here */ + uint8_t c = rs485_rx_buffer[rs485_rx_index]; + + if (g_rs485_bridge_active) + { + RS485_Bridge_Push(c); + g_rs485_bridge_seq++; + rs485_rx_index = 0; + rs485_rx_length = 0; + R_UART0_Receive((uint8_t *)&rs485_rx_buffer[0], 1); + return; + } + + if (rs485_rx_index < (UART_RX_BUF_SIZE - 1)) + { + rs485_rx_index++; + rs485_rx_length = rs485_rx_index; + } + else + { + rs485_rx_done = 1; + return; + } + + if (c == '\r') + { + R_UART0_Receive((uint8_t *)&rs485_rx_buffer[rs485_rx_index], 1); + return; + } + + if (c == '\n') + { + rs485_rx_done = 1; + return; + } + + R_UART0_Receive((uint8_t *)&rs485_rx_buffer[rs485_rx_index], 1); /* End user code. Do not edit comment generated here */ } diff --git a/r_main.c b/r_main.c index 5ae54bb..899a33e 100644 --- a/r_main.c +++ b/r_main.c @@ -349,13 +349,17 @@ static app_owi_result_t do_stable_owi_read(uint8_t id, uint8_t read_len) app_owi_result_t r; if (is_long_owi_read_len(read_len)) { + app_kick_wdt(); delay_us(OWI_LONG_READ_SETTLE_US); + app_kick_wdt(); } r = app_owi_read_basic(id, (int)read_len); if ((!r.ok || r.timeout || r.read_len < read_len) && is_long_owi_read_len(read_len)) { + app_kick_wdt(); delay_us(OWI_LONG_READ_RETRY_US); + app_kick_wdt(); r = app_owi_read_basic(id, (int)read_len); }