busvoodoo_uart_generic.h
Go to the documentation of this file.
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <libopencm3/stm32/timer.h> // timer library
struct busvoodoo_uart_generic_specific_t {
uint32_t usart;
uint32_t usart_rcc;
uint32_t usart_rst;
bool multidrive;
uint32_t tx_port;
uint32_t tx_pin;
uint32_t tx_rcc;
void (*tx_pre)(void);
void (*tx_post)(void);
uint32_t rx_port;
uint32_t rx_pin;
uint32_t rx_rcc;
void (*rx_pre)(void);
void (*rx_post)(void);
/* hardware flow control configuration */
bool hwflowctl;
uint32_t rts_port;
uint32_t rts_pin;
uint32_t rts_rcc;
uint32_t cts_port;
uint32_t cts_pin;
uint32_t cts_rcc;
/* timer input channel capture to measure Rx edge timing */
uint32_t timer;
uint32_t timer_rcc;
uint32_t timer_port;
uint32_t timer_port_rcc;
uint32_t timer_pin;
enum tim_ic_id timer_ic;
enum tim_ic_input timer_ic_in_ti;
uint32_t timer_sr_ccif;
uint32_t timer_sr_ccof;
volatile uint32_t* timer_ccr;
uint32_t timer_dier_ccie;
uint32_t timer_nvic_irq;
};
bool busvoodoo_uart_generic_configure(const struct busvoodoo_uart_generic_specific_t* conf);
bool busvoodoo_uart_generic_setup(char** prefix, const char* line);
void busvoodoo_uart_generic_exit(void);
#define busvoodoo_uart_generic_commands_nb 6
extern const struct menu_command_t busvoodoo_uart_generic_commands[busvoodoo_uart_generic_commands_nb];
busvoodoo_uart_generic_specific_t::timer_pin
uint32_t timer_pin
pin of timer capture channel
Definition: busvoodoo_uart_generic.h:52
menu_command_t
command menu entry
Definition: menu.h:32
busvoodoo_uart_generic_specific_t::tx_post
void(* tx_post)(void)
method to be called after transmitting data
Definition: busvoodoo_uart_generic.h:33
busvoodoo_uart_generic_specific_t::timer_ic
enum tim_ic_id timer_ic
timer input capture channel
Definition: busvoodoo_uart_generic.h:53
busvoodoo_uart_generic_setup
bool busvoodoo_uart_generic_setup(char **prefix, const char *line)
setup generic UART mode
Definition: busvoodoo_uart_generic.c:98
busvoodoo_uart_generic_configure
bool busvoodoo_uart_generic_configure(const struct busvoodoo_uart_generic_specific_t *conf)
provide the generic USART with mode specific information
Definition: busvoodoo_uart_generic.c:76
busvoodoo_uart_generic_specific_t::rx_pin
uint32_t rx_pin
GPIO pin address of receive pin.
Definition: busvoodoo_uart_generic.h:35
busvoodoo_uart_generic_specific_t::timer_port
uint32_t timer_port
port of timer capture channel
Definition: busvoodoo_uart_generic.h:50
busvoodoo_uart_generic_specific_t::timer_dier_ccie
uint32_t timer_dier_ccie
timer channel capture interrupt enable
Definition: busvoodoo_uart_generic.h:58
busvoodoo_uart_generic_specific_t::timer_port_rcc
uint32_t timer_port_rcc
port RCC of timer capture channel
Definition: busvoodoo_uart_generic.h:51
busvoodoo_uart_generic_specific_t::rts_port
uint32_t rts_port
GPIO port address of request to send pin.
Definition: busvoodoo_uart_generic.h:41
busvoodoo_uart_generic_specific_t::timer_ccr
volatile uint32_t * timer_ccr
timer channel capture register
Definition: busvoodoo_uart_generic.h:57
busvoodoo_uart_generic_specific_t::timer
uint32_t timer
timer peripheral
Definition: busvoodoo_uart_generic.h:48
busvoodoo_uart_generic_specific_t::rx_pre
void(* rx_pre)(void)
method to be called before receiving data
Definition: busvoodoo_uart_generic.h:37
busvoodoo_uart_generic_specific_t::usart
uint32_t usart
USART peripheral base address.
Definition: busvoodoo_uart_generic.h:25
busvoodoo_uart_generic_specific_t::rx_rcc
uint32_t rx_rcc
GPIO RCC address of receive pin.
Definition: busvoodoo_uart_generic.h:36
busvoodoo_uart_generic_specific_t::multidrive
bool multidrive
if multiple drive modes are supported (push-pull, open-drain with internal resistors, open-drain with external resistors), or just push-pull
Definition: busvoodoo_uart_generic.h:28
busvoodoo_uart_generic_specific_t::rx_port
uint32_t rx_port
GPIO port address of receive pin.
Definition: busvoodoo_uart_generic.h:34
busvoodoo_uart_generic_specific_t::timer_rcc
uint32_t timer_rcc
timer RCC address
Definition: busvoodoo_uart_generic.h:49
busvoodoo_uart_generic_specific_t::tx_pin
uint32_t tx_pin
GPIO pin address of transmit pin.
Definition: busvoodoo_uart_generic.h:30
busvoodoo_uart_generic_specific_t::rx_post
void(* rx_post)(void)
method to be called after receiving data
Definition: busvoodoo_uart_generic.h:38
busvoodoo_uart_generic_specific_t::tx_rcc
uint32_t tx_rcc
GPIO RCC address of transmit pin.
Definition: busvoodoo_uart_generic.h:31
busvoodoo_uart_generic_specific_t
UART specific methods that will be called by the generic methods.
Definition: busvoodoo_uart_generic.h:24
busvoodoo_uart_generic_specific_t::timer_sr_ccif
uint32_t timer_sr_ccif
timer channel capture interrupt flag
Definition: busvoodoo_uart_generic.h:55
busvoodoo_uart_generic_specific_t::tx_pre
void(* tx_pre)(void)
method to be called before transmitting data
Definition: busvoodoo_uart_generic.h:32
busvoodoo_uart_generic_specific_t::rts_rcc
uint32_t rts_rcc
GPIO RCC address of request to send pin.
Definition: busvoodoo_uart_generic.h:43
busvoodoo_uart_generic_specific_t::cts_port
uint32_t cts_port
GPIO port address of clear to send pin.
Definition: busvoodoo_uart_generic.h:44
busvoodoo_uart_generic_commands_nb
#define busvoodoo_uart_generic_commands_nb
number of commands supported by the generic UART mode
Definition: busvoodoo_uart_generic.h:79
busvoodoo_uart_generic_specific_t::usart_rst
uint32_t usart_rst
USART RST address.
Definition: busvoodoo_uart_generic.h:27
busvoodoo_uart_generic_specific_t::rts_pin
uint32_t rts_pin
GPIO pin address of request to send pin.
Definition: busvoodoo_uart_generic.h:42
busvoodoo_uart_generic_specific_t::usart_rcc
uint32_t usart_rcc
USART RCC address.
Definition: busvoodoo_uart_generic.h:26
busvoodoo_uart_generic_specific_t::timer_nvic_irq
uint32_t timer_nvic_irq
timer IRQ
Definition: busvoodoo_uart_generic.h:59
busvoodoo_uart_generic_specific_t::timer_sr_ccof
uint32_t timer_sr_ccof
timer channel capture overrun flag
Definition: busvoodoo_uart_generic.h:56
busvoodoo_uart_generic_specific_t::cts_rcc
uint32_t cts_rcc
GPIO RCC address of clear to send pin.
Definition: busvoodoo_uart_generic.h:46
busvoodoo_uart_generic_exit
void busvoodoo_uart_generic_exit(void)
exit genetic UART mode
Definition: busvoodoo_uart_generic.c:287
busvoodoo_uart_generic_specific_t::hwflowctl
bool hwflowctl
if RTC/CTS hardware flow control is supported
Definition: busvoodoo_uart_generic.h:40
busvoodoo_uart_generic_specific_t::tx_port
uint32_t tx_port
GPIO port address of transmit pin.
Definition: busvoodoo_uart_generic.h:29
busvoodoo_uart_generic_specific_t::cts_pin
uint32_t cts_pin
GPIO pin address of clear to send pin.
Definition: busvoodoo_uart_generic.h:45
busvoodoo_uart_generic_commands
const struct menu_command_t busvoodoo_uart_generic_commands[busvoodoo_uart_generic_commands_nb]
commands supported by the generic UART mode
Definition: busvoodoo_uart_generic.c:1018
busvoodoo_uart_generic_specific_t::timer_ic_in_ti
enum tim_ic_input timer_ic_in_ti
timer input capture channel TIn
Definition: busvoodoo_uart_generic.h:54