|
APM:Libraries
|
Go to the source code of this file.
Classes | |
| struct | usart_state |
| struct | usart_dev |
Macros | |
| #define | USART_RX_BUF_SIZE 512 |
| #define | USART_TX_BUF_SIZE 1024 |
| #define | USART_F_RXNE 0x20 |
| #define | USART_F_TXE 0x80 |
| #define | USART_F_ORE 0x8 |
| #define | USART_MASK_IDLEIE 0x10 |
| #define | USART_MASK_RXNEIE 0x20 |
| #define | USART_MASK_TCEIE 0x40 |
| #define | USART_MASK_TXEIE 0x80 |
| #define | USART_MASK_PEIE 0x100 |
| #define | USART_MASK2_LBDIE 0x40 |
| #define | USART_MASK3_CTSIE 0x400 |
| #define | USART_MASK3_EIE 0x1 |
| #define | UART_Mode_Rx (0x0004) |
| #define | UART_Mode_Tx (0x0008) |
| #define | UART_HardwareFlowControl_None (0x0000) |
| #define | UART_HardwareFlowControl_RTS (0x0100) |
| #define | UART_HardwareFlowControl_CTS (0x0200) |
| #define | UART_HardwareFlowControl_RTS_CTS (0x0300) |
| #define | UART_Word_8b ((uint16_t)0x0000) |
| #define | UART_Word_9b ((uint16_t)0x1000) |
Typedefs | |
| typedef void(* | usart_cb) () |
| typedef struct usart_state | usart_state |
| typedef struct usart_dev | usart_dev |
Functions | |
| void | usart_init (const usart_dev *dev) |
| Initialize a serial port. More... | |
| void | usart_setup (const usart_dev *dev, uint32_t baudRate, uint16_t wordLength, uint16_t stopBits, uint16_t parity, uint16_t mode, uint16_t hardwareFlowControl) |
| Configure a serial port's baud rate. More... | |
| static void | usart_enable (const usart_dev *dev) |
| Enable a serial port. More... | |
| static uint8_t | usart_is_used (const usart_dev *dev) |
| static void | usart_disable (const usart_dev *dev) |
| Turn off a serial port. More... | |
| void | usart_foreach (void(*fn)(const usart_dev *)) |
| Call a function on each USART. More... | |
| static uint32_t | usart_txfifo_nbytes (const usart_dev *dev) |
| static uint32_t | usart_txfifo_freebytes (const usart_dev *dev) |
| static void | usart_disable_all (void) |
| Disable all serial ports. More... | |
| uint32_t | usart_tx (const usart_dev *dev, const uint8_t *buf, uint32_t len) |
| Nonblocking USART transmit. More... | |
| void | usart_putudec (const usart_dev *dev, uint32_t val) |
| Transmit an unsigned integer to the specified serial port in decimal format. More... | |
| static uint32_t | usart_putc (const usart_dev *dev, uint8_t bt) |
| Transmit one character on a serial port. More... | |
| static void | usart_putstr (const usart_dev *dev, const char *str) |
| Transmit a character string on a serial port. More... | |
| static uint8_t | usart_getc (const usart_dev *dev) |
| Read one character from a serial port. More... | |
| static uint32_t | usart_data_available (const usart_dev *dev) |
| Return the amount of data available in a serial port's RX buffer. More... | |
| static void | usart_reset_rx (const usart_dev *dev) |
| Discard the contents of a serial port's RX buffer. More... | |
| static void | usart_reset_tx (const usart_dev *dev) |
| static void | usart_set_callback (const usart_dev *dev, Handler cb) |
| void | USART1_IRQHandler (void) |
| void | USART2_IRQHandler (void) |
| void | USART3_IRQHandler (void) |
| void | USART4_IRQHandler (void) |
| void | USART5_IRQHandler (void) |
| void | USART6_IRQHandler (void) |
| void | UART4_IRQHandler (void) |
| void | UART5_IRQHandler (void) |
Variables | |
| const usart_dev *const | UARTS [] |
| const usart_dev *const | _USART1 |
| const usart_dev *const | _USART2 |
| const usart_dev *const | _USART3 |
| const usart_dev *const | _UART4 |
| const usart_dev *const | _UART5 |
| const usart_dev *const | _USART6 |
| #define UART_HardwareFlowControl_None (0x0000) |
Definition at line 78 of file usart.h.
Referenced by F4Light::UARTDriver::begin().
| #define UART_Word_8b ((uint16_t)0x0000) |
Definition at line 83 of file usart.h.
Referenced by F4Light::UARTDriver::begin().
| #define USART_F_ORE 0x8 |
Definition at line 62 of file usart.h.
Referenced by usart_rx_irq().
| #define USART_F_RXNE 0x20 |
Definition at line 60 of file usart.h.
Referenced by usart_rx_irq().
| #define USART_F_TXE 0x80 |
Definition at line 61 of file usart.h.
Referenced by usart_tx_irq().
| #define USART_MASK2_LBDIE 0x40 |
Definition at line 70 of file usart.h.
Referenced by usart_setup().
| #define USART_MASK3_CTSIE 0x400 |
Definition at line 72 of file usart.h.
Referenced by usart_setup().
| #define USART_MASK3_EIE 0x1 |
Definition at line 73 of file usart.h.
Referenced by usart_setup().
| #define USART_MASK_IDLEIE 0x10 |
Definition at line 64 of file usart.h.
Referenced by usart_setup().
| #define USART_MASK_PEIE 0x100 |
Definition at line 68 of file usart.h.
Referenced by usart_setup().
| #define USART_MASK_RXNEIE 0x20 |
Definition at line 65 of file usart.h.
Referenced by usart_rx_irq(), and usart_setup().
| #define USART_MASK_TCEIE 0x40 |
Definition at line 66 of file usart.h.
Referenced by usart_setup().
| #define USART_MASK_TXEIE 0x80 |
Definition at line 67 of file usart.h.
Referenced by usart_setup(), usart_tx(), and usart_tx_irq().
| #define USART_RX_BUF_SIZE 512 |
Definition at line 12 of file usart.h.
Referenced by usart_setup().
| #define USART_TX_BUF_SIZE 1024 |
Definition at line 16 of file usart.h.
Referenced by usart_setup(), and usart_txfifo_freebytes().
| typedef struct usart_state usart_state |
| void UART4_IRQHandler | ( | void | ) |
Referenced by USART3_IRQHandler(), and usart_set_callback().
| void UART5_IRQHandler | ( | void | ) |
Referenced by USART3_IRQHandler(), and usart_set_callback().
| void USART1_IRQHandler | ( | void | ) |
Definition at line 362 of file usart.c.
Referenced by usart_set_callback().
| void USART2_IRQHandler | ( | void | ) |
Referenced by USART1_IRQHandler(), and usart_set_callback().
| void USART3_IRQHandler | ( | void | ) |
Definition at line 376 of file usart.c.
Referenced by usart_set_callback().
| void USART4_IRQHandler | ( | void | ) |
| void USART5_IRQHandler | ( | void | ) |
| void USART6_IRQHandler | ( | void | ) |
Referenced by USART3_IRQHandler(), and usart_set_callback().
|
inlinestatic |
Return the amount of data available in a serial port's RX buffer.
| dev | Serial port to check |
Definition at line 286 of file usart.h.
Referenced by F4Light::UARTDriver::available().
|
inlinestatic |
Turn off a serial port.
| dev | Serial port to be disabled |
Definition at line 180 of file usart.h.
Referenced by F4Light::UARTDriver::begin(), F4Light::UARTDriver::end(), usart_disable_all(), and usart_setup().
|
inlinestatic |
Disable all serial ports.
Definition at line 206 of file usart.h.
Referenced by HAL_F4Light::run().
|
inlinestatic |
Enable a serial port.
USART is enabled in single buffer transmission mode, multibuffer receiver mode, 8n1.
Serial port must have a baud rate configured to work properly.
| dev | Serial port to enable. |
Definition at line 155 of file usart.h.
Referenced by F4Light::UARTDriver::begin().
| void usart_foreach | ( | void(*)(const usart_dev *) | fn | ) |
Call a function on each USART.
| fn | Function to call. |
Definition at line 163 of file usart.c.
Referenced by usart_disable(), and usart_disable_all().
|
inlinestatic |
Read one character from a serial port.
It's not safe to call this function if the serial port has no data available.
| dev | Serial port to read from |
Definition at line 277 of file usart.h.
Referenced by F4Light::UARTDriver::read().
| void usart_init | ( | const usart_dev * | dev | ) |
Initialize a serial port.
| dev | Serial port to be initialized |
Definition at line 187 of file usart.c.
Referenced by F4Light::UARTDriver::begin().
|
inlinestatic |
|
inlinestatic |
Transmit one character on a serial port.
This function blocks until the character has been successfully transmitted.
| dev | Serial port to send on. |
| byte | Byte to transmit. |
Definition at line 240 of file usart.h.
Referenced by usart_putstr(), usart_putudec(), and F4Light::UARTDriver::write().
|
inlinestatic |
| void usart_putudec | ( | const usart_dev * | dev, |
| uint32_t | val | ||
| ) |
Transmit an unsigned integer to the specified serial port in decimal format.
This function blocks until the integer's digits have been completely transmitted.
| dev | Serial port to send on |
| val | Number to print |
Definition at line 282 of file usart.c.
Referenced by usart_disable_all().
|
inlinestatic |
Discard the contents of a serial port's RX buffer.
| dev | Serial port whose buffer to empty. |
Definition at line 295 of file usart.h.
Referenced by F4Light::UARTDriver::flush().
|
inlinestatic |
Definition at line 299 of file usart.h.
Referenced by F4Light::UARTDriver::flush().
Definition at line 304 of file usart.h.
Referenced by F4Light::UARTDriver::begin(), and F4Light::UARTDriver::setCallback().
| void usart_setup | ( | const usart_dev * | dev, |
| uint32_t | baudRate, | ||
| uint16_t | wordLength, | ||
| uint16_t | stopBits, | ||
| uint16_t | parity, | ||
| uint16_t | mode, | ||
| uint16_t | hardwareFlowControl | ||
| ) |
Configure a serial port's baud rate.
| dev | Serial port to be configured |
| baudRate | Baud rate for transmit/receive. |
| wordLength | Specifies the number of data bits transmitted or received in a frame. This parameter can be a value of USART_Word_Length |
| stopBits | Specifies the number of stop bits transmitted. This parameter can be a value of USART_Stop_Bits |
| parity | Specifies the parity mode. This parameter can be a value of USART_Parity |
| mode | Specifies wether the Receive or Transmit mode is enabled or disabled. This parameter can be a value of USART_Mode |
| hardwareFlowControl | Specifies wether the hardware flow control mode is enabled or disabled. This parameter can be a value of USART_Hardware_Flow_Control |
Definition at line 199 of file usart.c.
Referenced by F4Light::UARTDriver::begin().
| uint32_t usart_tx | ( | const usart_dev * | dev, |
| const uint8_t * | buf, | ||
| uint32_t | len | ||
| ) |
Nonblocking USART transmit.
| dev | Serial port to transmit over |
| buf | Buffer to transmit |
| len | Maximum number of bytes to transmit |
Definition at line 258 of file usart.c.
Referenced by usart_disable_all(), usart_putc(), and F4Light::UARTDriver::write().
|
inlinestatic |
Definition at line 198 of file usart.h.
Referenced by F4Light::UARTDriver::txspace().
|
inlinestatic |
Definition at line 195 of file usart.h.
Referenced by F4Light::UARTDriver::tx_pending().
| const usart_dev* const _UART4 |
| const usart_dev* const _UART5 |
| const usart_dev* const _USART2 |
| const usart_dev* const _USART6 |
| const usart_dev* const UARTS[] |
Definition at line 136 of file usart.c.
Referenced by F4Light::UARTDriver::begin().
1.8.13