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

library to control up to 4 independent receive and transmit software UART ports (code) More...

Go to the source code of this file.

Data Structures

struct  soft_uart_rx_state
 UART receive state definition. More...
 
struct  soft_uart_tx_state
 UART transmit state definition. More...
 

Macros

#define UART_SOFT_RX_PORT0   B
 port for receive signal for UART port 0
 
#define UART_SOFT_RX_PIN0   9
 pin for receive signal for UART port 0
 
#define UART_SOFT_TX_PORT0   B
 port for transmit signal for UART port 0
 
#define UART_SOFT_TX_PIN0   8
 pin for transmit signal for UART port 0
 
#define UART_SOFT_BUFFER   128
 buffer size for receive and transmit buffers
 
#define UART_SOFT_RX_TIMER   3
 timer peripheral for receive signals
 
#define UART_SOFT_TX_TIMER   4
 timer peripheral for transmit signals
 

Functions

bool uart_soft_setup (uint32_t *rx_baudrates, uint32_t *tx_baudrates)
 setup software UART ports More...
 
uint8_t uart_soft_getbyte (uint8_t uart)
 get received byte from UART port More...
 
void TIM_ISR() UART_SOFT_RX_TIMER (void)
 timer interrupt service routine to generate UART transmit signals
 
void uart_soft_flush (uint8_t uart)
 ensure all bytes are transmitted for the UART More...
 
static void uart_soft_transmit (uint8_t uart)
 start transmitting a byte from the buffer More...
 
void uart_soft_putbyte_nonblocking (uint8_t uart, uint8_t byte)
 put byte in buffer to be transmitted on UART port More...
 
void uart_soft_putbyte_blocking (uint8_t uart, uint8_t byte)
 transmit byte on UART port More...
 
void TIM_ISR() UART_SOFT_TX_TIMER (void)
 timer interrupt service routine to sample UART receive signals
 
static void uart_soft_receive_activity (void)
 central function handling receive signal activity
 
void exti9_5_isr (void)
 GPIO interrupt service routine to detect UART receive activity.
 

Variables

static struct soft_uart_rx_stateuart_soft_rx_states [4] = {NULL}
 states of UART receive ports (up to 4)
 
static struct soft_uart_tx_stateuart_soft_tx_states [4] = {NULL}
 states of UART transmit ports (up to 4)
 
volatile bool uart_soft_received [4] = {false, false, false, false}
 if data has been received from UART port and is available to be read
 
static const uint32_t timer_flags [4] = {TIM_SR_CC1IF,TIM_SR_CC2IF,TIM_SR_CC3IF,TIM_SR_CC4IF}
 the interrupt flags for the compare units
 
static const uint32_t timer_interrupt [4] = {TIM_DIER_CC1IE,TIM_DIER_CC2IE,TIM_DIER_CC3IE,TIM_DIER_CC4IE}
 the interrupt enable for the compare units
 
static enum tim_oc_id timer_oc [4] = {TIM_OC1,TIM_OC2,TIM_OC3,TIM_OC4}
 the output compares for the compare units
 

Detailed Description

library to control up to 4 independent receive and transmit software UART ports (code)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2016
Note
peripherals used: GPIO GPIO used for the software 4 UART ports, timer timer used to sample UART signals

Definition in file uart_soft.c.

Function Documentation

§ uart_soft_flush()

void uart_soft_flush ( uint8_t  uart)

ensure all bytes are transmitted for the UART

Parameters
[in]uartUART port to flush

Definition at line 253 of file uart_soft.c.

§ uart_soft_getbyte()

uint8_t uart_soft_getbyte ( uint8_t  uart)

get received byte from UART port

Parameters
[in]uartUART receive port to read byte from
Returns
received byte (0 if no byte is available)

Definition at line 195 of file uart_soft.c.

§ uart_soft_putbyte_blocking()

void uart_soft_putbyte_blocking ( uint8_t  uart,
uint8_t  byte 
)

transmit byte on UART port

Note
blocks until all buffered byte and this byte are transmitted
Parameters
[in]uartUART port to transmit the byte from
[in]bytebyte to transmit

Definition at line 303 of file uart_soft.c.

§ uart_soft_putbyte_nonblocking()

void uart_soft_putbyte_nonblocking ( uint8_t  uart,
uint8_t  byte 
)

put byte in buffer to be transmitted on UART port

Note
blocking if buffer is full
Parameters
[in]uartUART port to transmit the byte from
[in]bytebyte to put in transmit buffer

Definition at line 290 of file uart_soft.c.

§ uart_soft_setup()

bool uart_soft_setup ( uint32_t *  rx_baudrates,
uint32_t *  tx_baudrates 
)

setup software UART ports

Parameters
[in]rx_baudratesbaud rates of the 4 UART RX ports (0 if unused)
[in]tx_baudratesbaud rates of the 4 UART TX ports (0 if unused)
Returns
is setup succeeded, else the configuration is wrong

Definition at line 115 of file uart_soft.c.

§ uart_soft_transmit()

static void uart_soft_transmit ( uint8_t  uart)
static

start transmitting a byte from the buffer

Parameters
[in]uartUART port used for transmission

Definition at line 269 of file uart_soft.c.