diff --git a/lib/busvoodoo_rs232.c b/lib/busvoodoo_rs232.c index b3bdb5c..7552d22 100644 --- a/lib/busvoodoo_rs232.c +++ b/lib/busvoodoo_rs232.c @@ -24,6 +24,7 @@ #include // string utilities /* STM32 (including CM3) libraries */ +#include // interrupt utilities #include // general purpose input output library #include // real-time control clock library #include // USART utilities @@ -43,6 +44,9 @@ #define BUSVOODOO_RS232_USART 2 /**< USART peripheral */ /** @} */ +#define BUSVOODOO_RS232_RX_TIMER 2 /**< timer ID to capture RX edges */ +#define BUSVOODOO_RS232_RX_CHANNEL 4 /**< channel ID used as input capture to capture RX edges */ + /** RS-232 specific methods that will be called by the generic methods */ static const struct busvoodoo_uart_generic_specific_t busvoodoo_uart_generic_rs232 = { .usart = USART(BUSVOODOO_RS232_USART), @@ -66,6 +70,18 @@ static const struct busvoodoo_uart_generic_specific_t busvoodoo_uart_generic_rs2 .cts_port = USART_CTS_PORT(BUSVOODOO_RS232_USART), .cts_pin = USART_CTS_PIN(BUSVOODOO_RS232_USART), .cts_rcc = RCC_USART_PORT(BUSVOODOO_RS232_USART), + .timer = TIM(BUSVOODOO_RS232_RX_TIMER), + .timer_rcc = RCC_TIM(BUSVOODOO_RS232_RX_TIMER), + .timer_port = TIM_CH_PORT(BUSVOODOO_RS232_RX_TIMER, BUSVOODOO_RS232_RX_CHANNEL), + .timer_port_rcc = RCC_TIM_CH(BUSVOODOO_RS232_RX_TIMER, BUSVOODOO_RS232_RX_CHANNEL), + .timer_pin = TIM_CH_PIN(BUSVOODOO_RS232_RX_TIMER, BUSVOODOO_RS232_RX_CHANNEL), + .timer_ic = TIM_IC(BUSVOODOO_RS232_RX_CHANNEL), + .timer_ic_in_ti = TIM_IC_IN_TI(BUSVOODOO_RS232_RX_CHANNEL), + .timer_sr_ccif = TIM_SR_CCIF(BUSVOODOO_RS232_RX_CHANNEL), + .timer_sr_ccof = TIM_SR_CCOF(BUSVOODOO_RS232_RX_CHANNEL), + .timer_ccr = &TIM_CCR(BUSVOODOO_RS232_RX_TIMER, BUSVOODOO_RS232_RX_CHANNEL), + .timer_dier_ccie = TIM_DIER_CCIE(BUSVOODOO_RS232_RX_CHANNEL), + .timer_nvic_irq = NVIC_TIM_IRQ(BUSVOODOO_RS232_RX_TIMER), }; /** setup RS-232 mode