37#include "mcu_periph/uart_arch.h" 
   46#ifndef UART_THREAD_STACK_SIZE 
   47#define UART_THREAD_STACK_SIZE 512 
   60#define SERIAL_INIT_NULL { NULL, NULL, NULL, NULL, NULL, 0, 0 } 
   74  p->rx_buf[
p->rx_insert_idx] = c;
 
   76  if (temp != 
p->rx_extract_idx) {
 
   77    p->rx_insert_idx = temp;  
 
   93  while (
p->tx_insert_idx != 
p->tx_extract_idx) {
 
   94#if USE_UART_SOFT_FLOW_CONTROL 
   95    if (init_struct->cts_port != 0) {
 
   97      while (
gpio_get(init_struct->cts_port, init_struct->cts_pin) == 1) ;
 
   99    uint8_t data = 
p->tx_buf[
p->tx_extract_idx];
 
  105    if (init_struct->cts_port != 0) {
 
  111    if (
p->tx_insert_idx > 
p->tx_extract_idx) {
 
  116      if(
p->tx_insert_idx > 0) {
 
  120    p->tx_extract_idx = 
p->tx_insert_idx;
 
  124  p->tx_running = 
false;
 
  130#define UART1_BAUD SERIAL_DEFAULT_BITRATE 
  135#define USE_UART1_TX TRUE 
  138#define USE_UART1_RX TRUE 
  146#define UART1_CR2 USART_CR2_STOP1_BITS 
  201#if USE_UART1_TX && defined UART1_GPIO_PORT_TX 
  204#if USE_UART1_RX && defined UART1_GPIO_PORT_RX 
  235#define UART2_BAUD SERIAL_DEFAULT_BITRATE 
  240#define USE_UART2_TX TRUE 
  243#define USE_UART2_RX TRUE 
  248#ifndef UART2_HW_FLOW_CONTROL 
  249#define UART2_HW_FLOW_CONTROL FALSE 
  252#if UART2_HW_FLOW_CONTROL && defined(UART2_CR3) 
  253#warning "UART2_CR3 reset to your value, HW flow control not enabled! You may want to set USART_CR3_CTSE | USART_CR3_RTSE yourself." 
  261#define UART2_CR2 USART_CR2_STOP1_BITS 
  265#if UART2_HW_FLOW_CONTROL 
  266#define UART2_CR3 USART_CR3_CTSE | USART_CR3_RTSE 
  320#if USE_UART2_TX && defined UART2_GPIO_PORT_TX 
  323#if USE_UART2_RX && defined UART2_GPIO_PORT_RX 
  353#define UART3_BAUD SERIAL_DEFAULT_BITRATE 
  358#define USE_UART3_TX TRUE 
  361#define USE_UART3_RX TRUE 
  369#define UART3_CR2 USART_CR2_STOP1_BITS 
  424#if USE_UART3_TX && defined UART3_GPIO_PORT_TX 
  427#if USE_UART3_RX && defined UART3_GPIO_PORT_RX 
  457#define UART4_BAUD SERIAL_DEFAULT_BITRATE 
  462#define USE_UART4_TX TRUE 
  465#define USE_UART4_RX TRUE 
  473#define UART4_CR2 USART_CR2_STOP1_BITS 
  528#if USE_UART4_TX && defined UART4_GPIO_PORT_TX 
  531#if USE_UART4_RX && defined UART4_GPIO_PORT_RX 
  561#define UART5_BAUD SERIAL_DEFAULT_BITRATE 
  566#define USE_UART5_TX TRUE 
  569#define USE_UART5_RX TRUE 
  577#define UART5_CR2 USART_CR2_STOP1_BITS 
  632#if USE_UART5_TX && defined UART5_GPIO_PORT_TX 
  635#if USE_UART5_RX && defined UART5_GPIO_PORT_RX 
  665#define UART6_BAUD SERIAL_DEFAULT_BITRATE 
  670#define USE_UART6_TX TRUE 
  673#define USE_UART6_RX TRUE 
  681#define UART6_CR2 USART_CR2_STOP1_BITS 
  736#if USE_UART6_TX && defined UART6_GPIO_PORT_TX 
  739#if USE_UART6_RX && defined UART6_GPIO_PORT_RX 
  763#if defined UART6_GPIO_CTS && defined UART6_GPIO_PORT_CTS 
  774#define UART7_BAUD SERIAL_DEFAULT_BITRATE 
  779#define USE_UART7_TX TRUE 
  782#define USE_UART7_RX TRUE 
  790#define UART7_CR2 USART_CR2_STOP1_BITS 
  845#if USE_UART7_TX && defined UART7_GPIO_PORT_TX 
  848#if USE_UART7_RX && defined UART7_GPIO_PORT_RX 
  878#define UART8_BAUD SERIAL_DEFAULT_BITRATE 
  883#define USE_UART8_TX TRUE 
  886#define USE_UART8_RX TRUE 
  894#define UART8_CR2 USART_CR2_STOP1_BITS 
  949#if USE_UART8_TX && defined UART8_GPIO_PORT_TX 
  952#if USE_UART8_RX && defined UART8_GPIO_PORT_RX 
 1013#if defined(STM32H7XX) 
 1014#define __USART_CR1_M USART_CR1_M0 
 1015#elif defined(STM32F7XX) 
 1016#define __USART_CR1_M USART_CR1_M_0 
 1017#elif defined(STM32F1XX) || defined (STM32F3XX) || defined(STM32F4XX) 
 1018#define __USART_CR1_M USART_CR1_M 
 1020#error Unsupported board 
 1065#if defined(STM32F7XX) || defined(STM32H7XX) 
 1093  int space = 
p->tx_extract_idx - 
p->tx_insert_idx - 1;
 
 1115    if (temp == 
p->tx_extract_idx) {
 
 1119    p->tx_buf[
p->tx_insert_idx] = data;
 
 1120    p->tx_insert_idx = temp;
 
 1127    p->tx_buf[
p->tx_insert_idx] = data;
 
 1153  for (i = 0; i < len; i++) {
 
 1154    p->tx_buf[
p->tx_insert_idx] = data[i];
 
#define UART4_GPIO_PORT_RX
#define UART1_GPIO_PORT_TX
#define UART6_GPIO_PORT_RX
#define UART2_GPIO_PORT_RX
#define UART1_GPIO_PORT_RX
#define UART6_GPIO_PORT_TX
#define UART4_GPIO_PORT_TX
#define UART3_GPIO_PORT_TX
#define UART3_GPIO_PORT_RX
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
static THD_WORKING_AREA(wa_thd_spi1, SPI_THREAD_STACK_SIZE)
static MUTEX_DECL(sys_time_mtx)
#define UART8_GPIO_PORT_RX
#define UART7_GPIO_PORT_RX
#define UART8_GPIO_PORT_TX
#define UART2_GPIO_PORT_TX
UART2 (with optional flow control activated by default)
#define UART1_GPIO_AF
UART defines.
#define UART6_GPIO_PORT_CTS
#define UART5_GPIO_PORT_TX
#define UART5_GPIO_PORT_RX
Some architecture independent helper functions for GPIOs.
void uart_put_byte(struct uart_periph *periph, long fd, uint8_t data)
void uart_periph_set_bits_stop_parity(struct uart_periph *periph, uint8_t bits, uint8_t stop, uint8_t parity)
uint8_t uart_getch(struct uart_periph *p)
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud)
#define UART_TX_BUFFER_SIZE
#define UART_RX_BUFFER_SIZE
#define UART7_GPIO_PORT_TX
UART7 (Modem with optional flow control disabled by default)
void uart_periph_set_mode(struct uart_periph *p, bool tx_enabled, bool rx_enabled, bool hw_flow_control)
void WEAK uart_send_message(struct uart_periph *p, long fd)
void uart_periph_init(struct uart_periph *p)
void WEAK uart_put_buffer(struct uart_periph *p, long fd, const uint8_t *data, uint16_t len)
void WEAK uart_periph_invert_data_logic(struct uart_periph *p, bool invert_rx, bool invert_tx)
int WEAK uart_check_free_space(struct uart_periph *p, long *fd, uint16_t len)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
static SEMAPHORE_DECL(we_ukf_sem, 0)