libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
usart.h File Reference
Include dependency graph for usart.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define USART0_BASE   0x4000C000
 
#define USART1_BASE   0x4000D000
 
#define USART2_BASE   0x4000E000
 
#define USART_DR(x)   MMIO32((x) + 0x0000)
 
#define USART_IR(x)   MMIO32((x) + 0x0004)
 
#define USART_FR(x)   MMIO32((x) + 0x0018)
 
#define USART_ILPR(x)   MMIO32((x) + 0x0020)
 
#define USART_IBRD(x)   MMIO32((x) + 0x0024)
 
#define USART_FBRD(x)   MMIO32((x) + 0x0028)
 
#define USART_LCRH(x)   MMIO32((x) + 0x002c)
 
#define USART_CTL(x)   MMIO32((x) + 0x0030)
 
#define USART_IFLS(x)   MMIO32((x) + 0x0034)
 
#define USART_IM(x)   MMIO32((x) + 0x0038)
 
#define USART_RIS(x)   MMIO32((x) + 0x003c)
 
#define USART_MIS(x)   MMIO32((x) + 0x0040)
 
#define USART_IC(x)   MMIO32((x) + 0x0044)
 
#define USART_DR_OE   (0x01 << 11)
 
#define USART_DR_BE   (0x01 << 10)
 
#define USART_DR_PE   (0x01 << 9)
 
#define USART_DR_FE   (0x01 << 8)
 
#define USART_FR_TXFE   (0x01 << 7)
 
#define USART_FR_RXFF   (0x01 << 6)
 
#define USART_FR_TXFF   (0x01 << 5)
 
#define USART_FR_RXFE   (0x01 << 4)
 
#define USART_FR_BUSY   (0x01 << 3)
 
#define USART_IM_OE   (0x01 << 10)
 
#define USART_IM_BE   (0x01 << 9)
 
#define USART_IM_PE   (0x01 << 8)
 
#define USART_IM_FE   (0x01 << 7)
 
#define USART_IM_RT   (0x01 << 6)
 
#define USART_IM_TX   (0x01 << 5)
 
#define USART_IM_RX   (0x01 << 4)
 
#define USART_IC_OE   (0x01 << 10)
 
#define USART_IC_BE   (0x01 << 9)
 
#define USART_IC_PE   (0x01 << 8)
 
#define USART_IC_FE   (0x01 << 7)
 
#define USART_IC_RT   (0x01 << 6)
 
#define USART_IC_TX   (0x01 << 5)
 
#define USART_IC_RX   (0x01 << 4)
 

Enumerations

enum  usart_stopbits { USART_STOPBITS_1 , USART_STOPBITS_1_5 , USART_STOPBITS_2 }
 
enum  usart_parity { USART_PARITY_NONE , USART_PARITY_ODD , USART_PARITY_EVEN }
 
enum  usart_mode { USART_MODE_DISABLED , USART_MODE_RX , USART_MODE_TX , USART_MODE_TX_RX }
 
enum  usart_flowcontrol { USART_FLOWCONTROL_NONE , USART_FLOWCONTROL_RTS_CTS }
 

Functions

void usart_send (uint32_t usart, uint16_t data)
 
uint16_t usart_recv (uint32_t usart)
 
bool usart_is_send_ready (uint32_t usart)
 
bool usart_is_recv_ready (uint32_t usart)
 
void usart_send_blocking (uint32_t usart, uint16_t data)
 
uint16_t usart_recv_blocking (uint32_t usart)
 
void usart_enable_rx_interrupt (uint32_t usart)
 
void usart_disable_rx_interrupt (uint32_t usart)
 
void usart_clear_rx_interrupt (uint32_t usart)
 
void usart_enable_tx_interrupt (uint32_t usart)
 
void usart_disable_tx_interrupt (uint32_t usart)
 
void usart_clear_tx_interrupt (uint32_t usart)
 
bool usart_get_interrupt_source (uint32_t usart, uint32_t flag)
 

Macro Definition Documentation

◆ USART0_BASE

#define USART0_BASE   0x4000C000

Definition at line 27 of file usart.h.

◆ USART1_BASE

#define USART1_BASE   0x4000D000

Definition at line 28 of file usart.h.

◆ USART2_BASE

#define USART2_BASE   0x4000E000

Definition at line 29 of file usart.h.

◆ USART_CTL

#define USART_CTL (   x)    MMIO32((x) + 0x0030)

Definition at line 39 of file usart.h.

◆ USART_DR

#define USART_DR (   x)    MMIO32((x) + 0x0000)

Definition at line 32 of file usart.h.

◆ USART_DR_BE

#define USART_DR_BE   (0x01 << 10)

Definition at line 49 of file usart.h.

◆ USART_DR_FE

#define USART_DR_FE   (0x01 << 8)

Definition at line 51 of file usart.h.

◆ USART_DR_OE

#define USART_DR_OE   (0x01 << 11)

Definition at line 48 of file usart.h.

◆ USART_DR_PE

#define USART_DR_PE   (0x01 << 9)

Definition at line 50 of file usart.h.

◆ USART_FBRD

#define USART_FBRD (   x)    MMIO32((x) + 0x0028)

Definition at line 37 of file usart.h.

◆ USART_FR

#define USART_FR (   x)    MMIO32((x) + 0x0018)

Definition at line 34 of file usart.h.

◆ USART_FR_BUSY

#define USART_FR_BUSY   (0x01 << 3)

Definition at line 59 of file usart.h.

◆ USART_FR_RXFE

#define USART_FR_RXFE   (0x01 << 4)

Definition at line 58 of file usart.h.

◆ USART_FR_RXFF

#define USART_FR_RXFF   (0x01 << 6)

Definition at line 56 of file usart.h.

◆ USART_FR_TXFE

#define USART_FR_TXFE   (0x01 << 7)

Definition at line 55 of file usart.h.

◆ USART_FR_TXFF

#define USART_FR_TXFF   (0x01 << 5)

Definition at line 57 of file usart.h.

◆ USART_IBRD

#define USART_IBRD (   x)    MMIO32((x) + 0x0024)

Definition at line 36 of file usart.h.

◆ USART_IC

#define USART_IC (   x)    MMIO32((x) + 0x0044)

Definition at line 44 of file usart.h.

◆ USART_IC_BE

#define USART_IC_BE   (0x01 << 9)

Definition at line 76 of file usart.h.

◆ USART_IC_FE

#define USART_IC_FE   (0x01 << 7)

Definition at line 78 of file usart.h.

◆ USART_IC_OE

#define USART_IC_OE   (0x01 << 10)

Definition at line 75 of file usart.h.

◆ USART_IC_PE

#define USART_IC_PE   (0x01 << 8)

Definition at line 77 of file usart.h.

◆ USART_IC_RT

#define USART_IC_RT   (0x01 << 6)

Definition at line 79 of file usart.h.

◆ USART_IC_RX

#define USART_IC_RX   (0x01 << 4)

Definition at line 81 of file usart.h.

◆ USART_IC_TX

#define USART_IC_TX   (0x01 << 5)

Definition at line 80 of file usart.h.

◆ USART_IFLS

#define USART_IFLS (   x)    MMIO32((x) + 0x0034)

Definition at line 40 of file usart.h.

◆ USART_ILPR

#define USART_ILPR (   x)    MMIO32((x) + 0x0020)

Definition at line 35 of file usart.h.

◆ USART_IM

#define USART_IM (   x)    MMIO32((x) + 0x0038)

Definition at line 41 of file usart.h.

◆ USART_IM_BE

#define USART_IM_BE   (0x01 << 9)

Definition at line 65 of file usart.h.

◆ USART_IM_FE

#define USART_IM_FE   (0x01 << 7)

Definition at line 67 of file usart.h.

◆ USART_IM_OE

#define USART_IM_OE   (0x01 << 10)

Definition at line 64 of file usart.h.

◆ USART_IM_PE

#define USART_IM_PE   (0x01 << 8)

Definition at line 66 of file usart.h.

◆ USART_IM_RT

#define USART_IM_RT   (0x01 << 6)

Definition at line 68 of file usart.h.

◆ USART_IM_RX

#define USART_IM_RX   (0x01 << 4)

Definition at line 70 of file usart.h.

◆ USART_IM_TX

#define USART_IM_TX   (0x01 << 5)

Definition at line 69 of file usart.h.

◆ USART_IR

#define USART_IR (   x)    MMIO32((x) + 0x0004)

Definition at line 33 of file usart.h.

◆ USART_LCRH

#define USART_LCRH (   x)    MMIO32((x) + 0x002c)

Definition at line 38 of file usart.h.

◆ USART_MIS

#define USART_MIS (   x)    MMIO32((x) + 0x0040)

Definition at line 43 of file usart.h.

◆ USART_RIS

#define USART_RIS (   x)    MMIO32((x) + 0x003c)

Definition at line 42 of file usart.h.

Enumeration Type Documentation

◆ usart_flowcontrol

Enumerator
USART_FLOWCONTROL_NONE 
USART_FLOWCONTROL_RTS_CTS 

Definition at line 103 of file usart.h.

◆ usart_mode

enum usart_mode
Enumerator
USART_MODE_DISABLED 
USART_MODE_RX 
USART_MODE_TX 
USART_MODE_TX_RX 

Definition at line 96 of file usart.h.

◆ usart_parity

Enumerator
USART_PARITY_NONE 
USART_PARITY_ODD 
USART_PARITY_EVEN 

Definition at line 90 of file usart.h.

◆ usart_stopbits

Enumerator
USART_STOPBITS_1 
USART_STOPBITS_1_5 
USART_STOPBITS_2 

Definition at line 84 of file usart.h.

Function Documentation

◆ usart_clear_rx_interrupt()

void usart_clear_rx_interrupt ( uint32_t  usart)

Definition at line 75 of file usart.c.

References USART_IC, and USART_IC_RX.

◆ usart_clear_tx_interrupt()

void usart_clear_tx_interrupt ( uint32_t  usart)

Definition at line 80 of file usart.c.

References USART_IC, and USART_IC_TX.

◆ usart_disable_rx_interrupt()

void usart_disable_rx_interrupt ( uint32_t  usart)

Definition at line 65 of file usart.c.

References USART_IM.

◆ usart_disable_tx_interrupt()

void usart_disable_tx_interrupt ( uint32_t  usart)

Definition at line 70 of file usart.c.

References USART_IM.

◆ usart_enable_rx_interrupt()

void usart_enable_rx_interrupt ( uint32_t  usart)

Definition at line 55 of file usart.c.

References USART_IM, and USART_IM_RX.

◆ usart_enable_tx_interrupt()

void usart_enable_tx_interrupt ( uint32_t  usart)

Definition at line 60 of file usart.c.

References USART_IM, and USART_IM_TX.

◆ usart_get_interrupt_source()

bool usart_get_interrupt_source ( uint32_t  usart,
uint32_t  flag 
)

Definition at line 85 of file usart.c.

References USART_RIS.

◆ usart_is_recv_ready()

bool usart_is_recv_ready ( uint32_t  usart)

Definition at line 39 of file usart.c.

References USART_FR, and USART_FR_RXFE.

Referenced by usart_recv_blocking().

Here is the caller graph for this function:

◆ usart_is_send_ready()

bool usart_is_send_ready ( uint32_t  usart)

Definition at line 44 of file usart.c.

References USART_FR, and USART_FR_BUSY.

Referenced by usart_send_blocking().

Here is the caller graph for this function:

◆ usart_recv()

uint16_t usart_recv ( uint32_t  usart)

Definition at line 28 of file usart.c.

References USART_DR.

Referenced by usart_recv_blocking().

Here is the caller graph for this function:

◆ usart_recv_blocking()

uint16_t usart_recv_blocking ( uint32_t  usart)

Definition at line 49 of file usart.c.

References usart_is_recv_ready(), and usart_recv().

Here is the call graph for this function:

◆ usart_send()

void usart_send ( uint32_t  usart,
uint16_t  data 
)

Definition at line 23 of file usart.c.

References USART_DR.

Referenced by usart_send_blocking().

Here is the caller graph for this function:

◆ usart_send_blocking()

void usart_send_blocking ( uint32_t  usart,
uint16_t  data 
)

Definition at line 33 of file usart.c.

References usart_is_send_ready(), and usart_send().

Here is the call graph for this function: