2020-02-17 14:07:20 +01:00
|
|
|
/** library to control up to 4 independent receive and transmit software UART ports
|
|
|
|
* @file
|
2016-10-23 17:42:55 +02:00
|
|
|
* @author King Kévin <kingkevin@cuvoodoo.info>
|
2020-06-06 14:35:55 +02:00
|
|
|
* @copyright SPDX-License-Identifier: GPL-3.0-or-later
|
2020-02-17 14:07:20 +01:00
|
|
|
* @date 2016-2020
|
2016-10-23 17:42:55 +02:00
|
|
|
* @note peripherals used: GPIO @ref uart_soft_gpio, timer @ref uart_soft_timer
|
|
|
|
*/
|
2020-11-24 15:56:00 +01:00
|
|
|
#pragma once
|
|
|
|
#error not converted for STM32F4
|
2016-10-23 17:42:55 +02:00
|
|
|
|
|
|
|
/** if data has been received from UART port and is available to be read */
|
|
|
|
extern volatile bool uart_soft_received[4];
|
|
|
|
|
|
|
|
/** setup software UART ports
|
|
|
|
* @param[in] rx_baudrates baud rates of the 4 UART RX ports (0 if unused)
|
|
|
|
* @param[in] tx_baudrates baud rates of the 4 UART TX ports (0 if unused)
|
|
|
|
* @return is setup succeeded, else the configuration is wrong
|
|
|
|
*/
|
2020-06-24 11:49:09 +02:00
|
|
|
bool uart_soft_setup(const uint32_t* rx_baudrates, const uint32_t* tx_baudrates);
|
2016-10-23 17:42:55 +02:00
|
|
|
/** get received byte from UART port
|
|
|
|
* @param[in] uart UART receive port to read byte from
|
|
|
|
* @return received byte (0 if no byte is available)
|
|
|
|
*/
|
|
|
|
uint8_t uart_soft_getbyte(uint8_t uart);
|
|
|
|
/** ensure all bytes are transmitted for the UART
|
|
|
|
* @param[in] uart UART port to flush
|
|
|
|
*/
|
|
|
|
void uart_soft_flush(uint8_t uart);
|
|
|
|
/** put byte in buffer to be transmitted on UART port
|
|
|
|
* @note blocking if buffer is full
|
|
|
|
* @param[in] uart UART port to transmit the byte from
|
|
|
|
* @param[in] byte byte to put in transmit buffer
|
|
|
|
*/
|
|
|
|
void uart_soft_putbyte_nonblocking(uint8_t uart, uint8_t byte);
|
|
|
|
/** transmit byte on UART port
|
|
|
|
* @note blocks until all buffered byte and this byte are transmitted
|
|
|
|
* @param[in] uart UART port to transmit the byte from
|
|
|
|
* @param[in] byte byte to transmit
|
|
|
|
*/
|
|
|
|
void uart_soft_putbyte_blocking(uint8_t uart, uint8_t byte);
|
|
|
|
|