CuVoodoo STM32F1 firmware template
Data Structures | Macros | Enumerations | Functions | Variables
busvoodoo_uart_generic.c File Reference

BusVoodoo generic UART mode (code) More...

Go to the source code of this file.

Data Structures

struct  uart_configuration_t
 the possible properties of a UART configuration (to be updated with every character) More...
 

Macros

#define BUSVOODOO_UART_TIMER_USE_INTERRUPT_TABLE   false
 set if the timer ISR should be set in the interrupt table instead of the vector table More...
 

Enumerations

enum  busvoodoo_uart_generic_setting_t {
  BUSVOODOO_UART_SETTING_NONE, BUSVOODOO_UART_SETTING_BAUDRATE, BUSVOODOO_UART_SETTING_DATABITS, BUSVOODOO_UART_SETTING_PARITY,
  BUSVOODOO_UART_SETTING_STOPBITS, BUSVOODOO_UART_SETTING_HWFLOWCTL, BUSVOODOO_UART_SETTING_DRIVE, BUSVOODOO_UART_SETTING_DONE
}
 mode setup stage
 

Functions

bool busvoodoo_uart_generic_configure (const struct busvoodoo_uart_generic_specific_t *conf)
 provide the generic USART with mode specific information More...
 
bool busvoodoo_uart_generic_setup (char **prefix, const char *line)
 setup generic UART mode More...
 
void busvoodoo_uart_generic_exit (void)
 exit genetic UART mode
 
static void busvoodoo_uart_generic_write (uint8_t value)
 write to UART More...
 
static void busvoodoo_uart_generic_read (void)
 read from UART
 
static bool busvoodoo_uart_generic_action (const char *action, uint32_t repetition, bool perform)
 perform UART action More...
 
static void busvoodoo_uart_generic_command_actions (void *argument)
 command to perform actions More...
 
static void busvoodoo_uart_generic_command_transmit (void *argument)
 command to transmit a string More...
 
static void busvoodoo_uart_generic_command_receive (void *argument)
 command to receive data More...
 
static void busvoodoo_uart_generic_command_transceive (void *argument)
 command to transmit and receive data More...
 
static void busvoodoo_uart_generic_command_error (void *argument)
 command to verify incoming transmission for error More...
 
static void uart_configuration_reset (struct uart_configuration_t *configuration)
 reset all matching values of UART configuration More...
 
void TIM_ISR (2)
 timer ISR to measure edge timing
 
static void busvoodoo_uart_generic_command_detect (void *argument)
 command to auto-detect incoming UART configuration (baud rate, data bits, parity) More...
 

Variables

static const struct busvoodoo_uart_generic_specific_tbusvoodoo_uart_generic_specific = NULL
 the USART mode specific information
 
static enum busvoodoo_uart_generic_setting_t busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_NONE
 current mode setup stage
 
static uint32_t busvoodoo_uart_generic_baudrate = 115200
 UART baud rate (in bps)
 
static uint8_t busvoodoo_uart_generic_databits = 8
 UART data bits.
 
static enum usart_enhanced_parity_t busvoodoo_uart_generic_parity = USART_ENHANCED_PARITY_NONE
 UART parity setting.
 
static uint32_t busvoodoo_uart_generic_stopbits = USART_STOPBITS_1
 UART stop bits setting.
 
static bool busvoodoo_uart_generic_hwflowctl = false
 UART hardware flow control setting (true = with hardware flow control, false = without hardware flow control.
 
static bool busvoodoo_uart_generic_drive = true
 pin drive mode (true = push-pull, false = open-drain)
 
static bool busvoodoo_uart_generic_pullup = false
 if embedded pull-up resistors are used
 
volatile bool pulse_flag = false
 set when a small pulse time is detected
 
volatile uint32_t pulse_duration = UINT32_MAX
 smallest pulse duration measured
 
const struct menu_command_t busvoodoo_uart_generic_commands [busvoodoo_uart_generic_commands_nb]
 commands supported by the generic UART mode
 

Detailed Description

BusVoodoo generic UART mode (code)

Note
this only contains the common UART methods and should be supplied with mode specific methods and information
Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2018

Definition in file busvoodoo_uart_generic.c.

Macro Definition Documentation

◆ BUSVOODOO_UART_TIMER_USE_INTERRUPT_TABLE

#define BUSVOODOO_UART_TIMER_USE_INTERRUPT_TABLE   false

set if the timer ISR should be set in the interrupt table instead of the vector table

Note
the vector table is faster, but doesn't allow to change the ISR
Warning
for the BusVoodoo UART (using USART3) and RS-232/RS-485 (using USART2) the RX is on TIM2_CH4 (remapped for USART3)

Definition at line 74 of file busvoodoo_uart_generic.c.

Function Documentation

◆ busvoodoo_uart_generic_action()

static bool busvoodoo_uart_generic_action ( const char *  action,
uint32_t  repetition,
bool  perform 
)
static

perform UART action

Parameters
[in]actionaction to perform
[in]repetitionhow many times to perform the action
[in]performthe action (true) or just check it (false)
Returns
true if the action has been performed, false if it is malformed

Definition at line 382 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_command_actions()

static void busvoodoo_uart_generic_command_actions ( void *  argument)
static

command to perform actions

Parameters
[in]argumentactions to perform

Definition at line 482 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_command_detect()

static void busvoodoo_uart_generic_command_detect ( void *  argument)
static

command to auto-detect incoming UART configuration (baud rate, data bits, parity)

Parameters
[in]argumentargument not required
Remarks
uses timer input capture for the baud rate, and guess checking for the data bits and parity

the possible UART configurations

Note
since the first valid configuration will be chosen, order in decreasing probability of being valid and decreasing probability or getting invalidated

Definition at line 732 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_command_error()

static void busvoodoo_uart_generic_command_error ( void *  argument)
static

command to verify incoming transmission for error

Parameters
[in]argumentargument not required

Definition at line 657 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_command_receive()

static void busvoodoo_uart_generic_command_receive ( void *  argument)
static

command to receive data

Parameters
[in]argumentin which format to display

Definition at line 553 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_command_transceive()

static void busvoodoo_uart_generic_command_transceive ( void *  argument)
static

command to transmit and receive data

Parameters
[in]argumentno argument required

Definition at line 597 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_command_transmit()

static void busvoodoo_uart_generic_command_transmit ( void *  argument)
static

command to transmit a string

Parameters
[in]argumentstring to transmit (CR+LF when none provided)

Definition at line 518 of file busvoodoo_uart_generic.c.

◆ 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

Parameters
[in]confUSART mode specific information
Returns
if configuration is valid

Definition at line 76 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_setup()

bool busvoodoo_uart_generic_setup ( char **  prefix,
const char *  line 
)

setup generic UART mode

Parameters
[out]prefixterminal prompt prefix
[in]lineterminal prompt line to configure mode
Returns
if setup is complete
Note
run busvoodoo_uart_generic_configure before

Definition at line 98 of file busvoodoo_uart_generic.c.

◆ busvoodoo_uart_generic_write()

static void busvoodoo_uart_generic_write ( uint8_t  value)
static

write to UART

Parameters
[in]valuevalue to write

Definition at line 309 of file busvoodoo_uart_generic.c.

◆ uart_configuration_reset()

static void uart_configuration_reset ( struct uart_configuration_t configuration)
static

reset all matching values of UART configuration

Parameters
[out]configurationUART configuration to reset

Definition at line 681 of file busvoodoo_uart_generic.c.