Loading...
Searching...
No Matches
cpu_uart.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Freie Universität Berlin
3 * 2017 OTA keys S.A.
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
21#ifndef PERIPH_CPU_UART_H
22#define PERIPH_CPU_UART_H
23
24#include <stdint.h>
25
26#include "cpu.h"
27#include "periph/cpu_dma.h"
28#include "periph/cpu_gpio.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
41
45#ifndef UART_TXBUF_SIZE
46#define UART_TXBUF_SIZE (64)
47#endif
48
49#ifndef DOXYGEN
56#define UART_INVALID_MODE (0x8000000)
57
62#define HAVE_UART_PARITY_T
63typedef enum {
65 UART_PARITY_EVEN = USART_CR1_PCE,
66 UART_PARITY_ODD = (USART_CR1_PCE | USART_CR1_PS),
76#define HAVE_UART_DATA_BITS_T
77typedef enum {
80#if defined(USART_CR1_M1)
81 UART_DATA_BITS_7 = USART_CR1_M1,
82#else
84#endif
93#define HAVE_UART_STOP_BITS_T
94typedef enum {
96 UART_STOP_BITS_2 = USART_CR2_STOP_1,
99#endif /* ndef DOXYGEN */
100
104typedef struct {
105 USART_TypeDef *dev;
106 uint32_t rcc_mask;
107 gpio_t rx_pin;
108 gpio_t tx_pin;
109#ifndef CPU_FAM_STM32F1
112#endif
113 uint8_t bus;
114 uint8_t irqn;
115#ifdef MODULE_PERIPH_UART_HW_FC
116 gpio_t cts_pin;
117 gpio_t rts_pin;
118#ifndef CPU_FAM_STM32F1
119 gpio_af_t cts_af;
120 gpio_af_t rts_af;
121#endif
122#endif
123#if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L4) || \
124 defined(CPU_FAM_STM32WB) || defined(CPU_FAM_STM32G4) || \
125 defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32U5) || \
126 defined(CPU_FAM_STM32MP1) || defined(CPU_FAM_STM32WL)
127 uart_type_t type;
128 uint32_t clk_src;
129#endif
130#ifdef MODULE_PERIPH_DMA
131 dma_t dma;
132 uint8_t dma_chan;
133#endif
135
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* PERIPH_CPU_UART_H */
DMA CPU specific definitions for the STM32 family.
GPIO CPU definitions for the STM32 family.
uart_type_t
UART hardware module types.
Definition cpu_uart.h:37
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition cpu_uart.h:39
@ STM32_USART
STM32 USART module type.
Definition cpu_uart.h:38
gpio_af_t
Override alternative GPIO mode options.
Definition periph_cpu.h:166
uart_parity_t
Definition of possible parity modes.
Definition periph_cpu.h:502
@ UART_PARITY_SPACE
space parity
Definition periph_cpu.h:507
@ UART_PARITY_NONE
no parity
Definition periph_cpu.h:503
@ UART_PARITY_EVEN
even parity
Definition periph_cpu.h:504
@ UART_PARITY_ODD
odd parity
Definition periph_cpu.h:505
@ UART_PARITY_MARK
mark parity
Definition periph_cpu.h:506
uart_stop_bits_t
Definition of possible stop bits lengths.
Definition periph_cpu.h:534
@ UART_STOP_BITS_2
2 stop bits
Definition periph_cpu.h:536
@ UART_STOP_BITS_1
1 stop bit
Definition periph_cpu.h:535
#define UART_INVALID_MODE
Invalid UART mode mask.
Definition periph_cpu.h:493
uart_data_bits_t
Definition of possible data bits lengths in a UART frame.
Definition periph_cpu.h:518
@ UART_DATA_BITS_6
6 data bits
Definition periph_cpu.h:520
@ UART_DATA_BITS_5
5 data bits
Definition periph_cpu.h:519
@ UART_DATA_BITS_7
7 data bits
Definition periph_cpu.h:521
@ UART_DATA_BITS_8
8 data bits
Definition periph_cpu.h:522
unsigned dma_t
DMA channel type.
UART device configuration.
Definition periph_cpu.h:218
gpio_af_t rx_af
alternate function for RX pin
Definition cpu_uart.h:110
uint32_t rcc_mask
bit in clock enable register
Definition cpu_uart.h:106
USART_TypeDef * dev
UART device base register address.
Definition cpu_uart.h:105
gpio_af_t tx_af
alternate function for TX pin
Definition cpu_uart.h:111