UART: use pre/post rx in baud rate detection
This commit is contained in:
parent
1cb08356ec
commit
ae3621faba
|
@ -738,12 +738,14 @@ static void busvoodoo_uart_generic_command_detect(void* argument)
|
|||
}
|
||||
printf("the more traffic is incoming, the better the detection\n");
|
||||
printf("press any key to exit\n");
|
||||
|
||||
// setup USART to receive character
|
||||
uint8_t uart_databits = 8; // start with 8 bits since this is the most common case (i.e. no additional parity bit is used)
|
||||
usart_set_baudrate(busvoodoo_uart_generic_specific->usart, 1200); // configure UART to pre-selected baud rate
|
||||
usart_set_databits(busvoodoo_uart_generic_specific->usart, uart_databits); // configure UART to pre-selected data-bits
|
||||
usart_set_stopbits(busvoodoo_uart_generic_specific->usart, USART_STOPBITS_1); // 1 stop-bits also complies to 2 stop-bits
|
||||
usart_set_parity(busvoodoo_uart_generic_specific->usart, USART_PARITY_NONE); // get the raw data since we will do the parity check ourselves
|
||||
|
||||
// setup timer to generate/measure signal timing
|
||||
if ((busvoodoo_uart_generic_specific->timer_port != busvoodoo_uart_generic_specific->rx_port) || (busvoodoo_uart_generic_specific->timer_pin != busvoodoo_uart_generic_specific->rx_pin)) {
|
||||
rcc_periph_clock_enable(busvoodoo_uart_generic_specific->timer_port_rcc); // enable clock for GPIO peripheral
|
||||
|
@ -782,6 +784,11 @@ static void busvoodoo_uart_generic_command_detect(void* argument)
|
|||
pulse_duration = UINT32_MAX; // reset pulse duration
|
||||
timer_enable_counter(busvoodoo_uart_generic_specific->timer); // enable timer
|
||||
|
||||
// switch on RX
|
||||
if (busvoodoo_uart_generic_specific->rx_pre) {
|
||||
(*busvoodoo_uart_generic_specific->rx_pre)();
|
||||
}
|
||||
|
||||
bool reset_state = true; // flag to know if we need to reset the states
|
||||
uint8_t rx_errors; // number of UART receive errors received
|
||||
bool wait_for_idle = false; // flag to wait for an IDLE frame
|
||||
|
@ -961,6 +968,11 @@ static void busvoodoo_uart_generic_command_detect(void* argument)
|
|||
user_input_get(); // clear input used to interrupt previous loop
|
||||
printf("\n");
|
||||
|
||||
// switch off RX
|
||||
if (busvoodoo_uart_generic_specific->rx_post) {
|
||||
(*busvoodoo_uart_generic_specific->rx_post)();
|
||||
}
|
||||
|
||||
// stop timer
|
||||
timer_disable_counter(busvoodoo_uart_generic_specific->timer); // disable timer
|
||||
#if defined(BUSVOODOO_UART_TIMER_USE_INTERRUPT_TABLE) && BUSVOODOO_UART_TIMER_USE_INTERRUPT_TABLE
|
||||
|
|
Loading…
Reference in New Issue