libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
usart_common_fifos.h
Go to the documentation of this file.
1/** @addtogroup usart_defines
2 */
3/*
4 * This file is part of the libopencm3 project.
5 *
6 * Copyright (C) 2019 Brian Viele <vielster@allocor.tech>
7 *
8 * This library is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef LIBOPENCM3_STM32_COMMON_USART_COMMON_FIFOS_H_
22#define LIBOPENCM3_STM32_COMMON_USART_COMMON_FIFOS_H_
23
27
28/** @addtogroup usart_registers
29@{*/
30#define USART_PRESC(usart_base) MMIO32((usart_base) + 0x2C)
31/**@}*/
32
33/** @addtogroup usart_cr1_values
34@{*/
35/** RX FIFO Full Interrupt Enable. */
36#define USART_CR1_RXFFIE BIT31
37/** TX FIFO Empty Interrupt Enable. */
38#define USART_CR1_TXFEIE BIT30
39/** FIFO Enable bit. */
40#define USART_CR1_FIFOEN BIT29
41/**@}*/
42
43/** @addtogroup usart_cr3_values
44@{*/
45/** FIFO Threshold definitions. */
46typedef enum {
56
57/** TX FIFO Threshold Configuration bits. */
58#define USART_CR3_TXFTCFG_SHIFT 29
59/** RX FIFO THreshold Interrupt Enable. */
60#define USART_CR3_RXFTIE BIT28
61/** RX FIFO Threshold Configuration bits. */
62#define USART_CR3_RXFTCFG_SHIFT 25
63/** Transmission Complete Before Guard Time Enable bit. */
64#define USART_CR3_TCBGTIE BIT24
65/** TX FIFO THreshold Interrupt Enable. */
66#define USART_CR3_TXFTIE BIT23
67/**@}*/
68
69/** @addtogroup usart_isr_values
70@{*/
71/** TX FIFO Threshold Interrupt Flag. */
72#define USART_ISR_TXFT BIT27
73/** RX FIFO Threshold Interrupt Flag. */
74#define USART_ISR_RXFT BIT26
75/** Transmission Complete before Guard Time Interrupt Flag. */
76#define USART_ISR_TCBGT BIT25
77/** RX FIFO Full Flag. */
78#define USART_ISR_RXFF BIT24
79/** TX FIFO Empty Flag. */
80#define USART_ISR_TXFE BIT23
81/** SPI Slave Underrun Flag. */
82#define USART_ISR_UDR BIT13
83/**@}*/
84
85/** @addtogroup usart_icr_values
86@{*/
87/** SPI Slave Underrun Clear Flag. */
88#define USART_ICR_UDR BIT13
89/** TX FIFO Empty Clear Flag. */
90#define USART_ICR_TXFECF BIT5
91/**@}*/
92
94
95/** @defgroup usart_file USART peripheral API
96 * @ingroup peripheral_apis
97 * @{
98 */
99/**
100 * Enable FIFOs on the specified USART.
101 * @param[in] usart Base address of USART to configure FIFOs.
102 */
103void usart_enable_fifos(uint32_t usart);
104/**
105 * Disable FIFOs on the specified USART.
106 * @param[in] usart Base address of USART to configure FIFOs.
107 */
108void usart_disable_fifos(uint32_t usart);
109/**
110 * Enable TX FIFO empty interrupt on the specified USART.
111 * @param[in] usart Base address of USART to configure FIFO interrupt.
112 */
113void usart_enable_tx_fifo_empty_interrupt(uint32_t usart);
114/**
115 * Disable TX FIFO empty interrupt on the specified USART.
116 * @param[in] usart Base address of USART to configure FIFO interrupt.
117 */
118void usart_disable_tx_fifo_empty_interrupt(uint32_t usart);
119/**
120 * Enable TX FIFO empty interrupt on the specified USART.
121 * @param[in] usart Base address of USART to configure FIFO interrupt.
122 */
124/**
125 * Disable TX FIFO empty interrupt on the specified USART.
126 * @param[in] usart Base address of USART to configure FIFO interrupt.
127 */
129/**
130 * Configure TX FIFO threshold on specified UART.
131 * @param[in] usart Base address of USART to configure FIFO.
132 * @param[in] threshold Threshold value to set for TX FIFO.
133 */
134void usart_set_tx_fifo_threshold(uint32_t usart,
135 usart_fifo_threshold_t threshold);
136/**
137 * Enable RX FIFO full interrupt on the specified USART.
138 * @param[in] usart Base address of USART to configure FIFO interrupt.
139 */
140void usart_enable_rx_fifo_full_interrupt(uint32_t usart);
141/**
142 * Disable RX FIFO full interrupt on the specified USART.
143 * @param[in] usart Base address of USART to configure FIFO interrupt.
144 */
145void usart_disable_rx_fifo_full_interrupt(uint32_t usart);
146/**
147 * Enable RX FIFO threshold interrupt on the specified USART.
148 * @param[in] usart Base address of USART to configure FIFO interrupt.
149 */
151/**
152 * Disable RX FIFO threshold interrupt on the specified USART.
153 * @param[in] usart Base address of USART to configure FIFO interrupt.
154 */
156/**
157 * Configure RX FIFO threshold on specified UART.
158 * @param[in] usart Base address of USART to configure FIFO.
159 * @param[in] threshold Threshold value to set for RX FIFO.
160 */
161void usart_set_rx_fifo_threshold(uint32_t usart,
162 usart_fifo_threshold_t threshold);
163/**@}*/
165
166#endif /* LIBOPENCM3_STM32_COMMON_USART_COMMON_FIFOS_H_ */
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
usart_fifo_threshold_t
FIFO Threshold definitions.
@ USART_FIFO_THRESH_QUARTER
@ USART_FIFO_THRESH_MASK
@ USART_FIFO_THRESH_HALF
@ USART_FIFO_THRESH_SEVENEIGTH
@ USART_FIFO_THRESH_RX_FULL
@ USART_FIFO_THRESH_TX_EMPTY
@ USART_FIFO_THRESH_EIGTH
@ USART_FIFO_THRESH_THREEQTR
void usart_disable_tx_fifo_empty_interrupt(uint32_t usart)
Disable TX FIFO empty interrupt on the specified USART.
void usart_enable_rx_fifo_full_interrupt(uint32_t usart)
Enable RX FIFO full interrupt on the specified USART.
void usart_disable_rx_fifo_threshold_interrupt(uint32_t usart)
Disable RX FIFO threshold interrupt on the specified USART.
void usart_set_tx_fifo_threshold(uint32_t usart, usart_fifo_threshold_t threshold)
Configure TX FIFO threshold on specified UART.
void usart_enable_fifos(uint32_t usart)
Enable FIFOs on the specified USART.
void usart_enable_tx_fifo_empty_interrupt(uint32_t usart)
Enable TX FIFO empty interrupt on the specified USART.
void usart_disable_fifos(uint32_t usart)
Disable FIFOs on the specified USART.
void usart_disable_tx_fifo_threshold_interrupt(uint32_t usart)
Disable TX FIFO empty interrupt on the specified USART.
void usart_disable_rx_fifo_full_interrupt(uint32_t usart)
Disable RX FIFO full interrupt on the specified USART.
void usart_set_rx_fifo_threshold(uint32_t usart, usart_fifo_threshold_t threshold)
Configure RX FIFO threshold on specified UART.
void usart_enable_tx_fifo_threshold_interrupt(uint32_t usart)
Enable TX FIFO empty interrupt on the specified USART.
void usart_enable_rx_fifo_threshold_interrupt(uint32_t usart)
Enable RX FIFO threshold interrupt on the specified USART.