BV RS485: add timer for baud rate detection
This commit is contained in:
parent
6b8255c5d9
commit
1fe300335d
|
@ -24,6 +24,7 @@
|
|||
#include <string.h> // string utilities
|
||||
|
||||
/* STM32 (including CM3) libraries */
|
||||
#include <libopencm3/cm3/nvic.h> // interrupt utilities
|
||||
#include <libopencm3/stm32/gpio.h> // general purpose input output library
|
||||
#include <libopencm3/stm32/rcc.h> // real-time control clock library
|
||||
#include <libopencm3/stm32/usart.h> // USART utilities
|
||||
|
@ -67,6 +68,9 @@ static void busvoodoo_rs485_receive_disable(void)
|
|||
gpio_set(GPIO(BUSVOODOO_RS485_RE_PORT), GPIO(BUSVOODOO_RS485_RE_PIN)); // set high to disable RS-485 transceiver receiver
|
||||
}
|
||||
|
||||
#define BUSVOODOO_RS485_RX_TIMER 2 /**< timer ID to capture RX edges */
|
||||
#define BUSVOODOO_RS485_RX_CHANNEL 4 /**< channel ID used as input capture to capture RX edges */
|
||||
|
||||
/** RS-485 specific methods that will be called by the generic methods */
|
||||
static const struct busvoodoo_uart_generic_specific_t busvoodoo_uart_generic_rs485 = {
|
||||
.usart = USART(BUSVOODOO_RS485_USART),
|
||||
|
@ -90,6 +94,18 @@ static const struct busvoodoo_uart_generic_specific_t busvoodoo_uart_generic_rs4
|
|||
.cts_port = 0,
|
||||
.cts_pin = 0,
|
||||
.cts_rcc = 0,
|
||||
.timer = TIM(BUSVOODOO_RS485_RX_TIMER),
|
||||
.timer_rcc = RCC_TIM(BUSVOODOO_RS485_RX_TIMER),
|
||||
.timer_port = TIM_CH_PORT(BUSVOODOO_RS485_RX_TIMER, BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_port_rcc = RCC_TIM_CH(BUSVOODOO_RS485_RX_TIMER, BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_pin = TIM_CH_PIN(BUSVOODOO_RS485_RX_TIMER, BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_ic = TIM_IC(BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_ic_in_ti = TIM_IC_IN_TI(BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_sr_ccif = TIM_SR_CCIF(BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_sr_ccof = TIM_SR_CCOF(BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_ccr = &TIM_CCR(BUSVOODOO_RS485_RX_TIMER, BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_dier_ccie = TIM_DIER_CCIE(BUSVOODOO_RS485_RX_CHANNEL),
|
||||
.timer_nvic_irq = NVIC_TIM_IRQ(BUSVOODOO_RS485_RX_TIMER),
|
||||
};
|
||||
|
||||
/** setup RS-485 mode
|
||||
|
|
Loading…
Reference in New Issue