|
PebbleOS
|
Serial port driver interface. More...
Modules | |
| nRF5 | |
| nRF5 UARTE device definition. | |
| POSIX | |
| UART on the host: the terminal, a TCP port or a serial device. | |
| QEMU | |
| QEMU UART device definition. | |
| SF32LB | |
| SF32LB UART device definition. | |
Data Structures | |
| struct | UARTRXErrorFlags |
| Receive error flags. More... | |
| union | UARTRXErrorFlags.__unnamed29__ |
| struct | UARTRXErrorFlags.__unnamed29__.__unnamed31__ |
Typedefs | |
| typedef const struct UARTDevice | UARTDevice |
| UART device, defined per SoC. | |
| typedef void(* | UARTRXInterruptHandler) (UARTDevice *dev, uint8_t data, const UARTRXErrorFlags *err_flags) |
| Receive interrupt handler, called from the UART ISR for each received byte. | |
| typedef void(* | UARTTXInterruptHandler) (UARTDevice *dev) |
| Transmit interrupt handler, called from the UART ISR when a byte can be sent. | |
Functions | |
| void | uart_init (UARTDevice *dev) |
| Initialize the device for receive and transmit. | |
| void | uart_init_open_drain (UARTDevice *dev) |
| Initialize the device with open-drain instead of push-pull pins. | |
| void | uart_init_tx_only (UARTDevice *dev) |
| Initialize the device for transmit only. | |
| void | uart_init_rx_only (UARTDevice *dev) |
| Initialize the device for receive only. | |
| void | uart_deinit (UARTDevice *dev) |
| Deinitialize the device. | |
| void | uart_set_baud_rate (UARTDevice *dev, uint32_t baud_rate) |
| Set the baud rate. | |
| void | uart_set_rx_interrupt_handler (UARTDevice *dev, UARTRXInterruptHandler irq_handler) |
| Set the receive interrupt handler. | |
| void | uart_set_tx_interrupt_handler (UARTDevice *dev, UARTTXInterruptHandler irq_handler) |
| Set the transmit interrupt handler. | |
| void | uart_set_rx_interrupt_enabled (UARTDevice *dev, bool enabled) |
| Enable or disable the receive interrupt. | |
| void | uart_set_tx_interrupt_enabled (UARTDevice *dev, bool enabled) |
| Enable or disable the transmit interrupt. | |
| void | uart_write_byte (UARTDevice *dev, uint8_t data) |
| Write a byte. | |
| uint8_t | uart_read_byte (UARTDevice *dev) |
| Read a byte. | |
| void | uart_start_rx_dma (UARTDevice *dev, void *buffer, uint32_t length) |
| Start receiving into a circular DMA buffer. | |
| void | uart_stop_rx_dma (UARTDevice *dev) |
| Stop receiving through DMA. | |
| void | uart_clear_rx_dma_buffer (UARTDevice *dev) |
| Discard data pending in the receive DMA buffer. | |
| bool | uart_is_rx_ready (UARTDevice *dev) |
| Check whether a received byte is ready to be read. | |
| bool | uart_has_rx_overrun (UARTDevice *dev) |
| Check for a receive overrun. | |
| bool | uart_has_rx_framing_error (UARTDevice *dev) |
| Check for a framing error. | |
| bool | uart_is_tx_ready (UARTDevice *dev) |
| Check whether a byte can be written. | |
| bool | uart_is_tx_complete (UARTDevice *dev) |
| Check whether the last byte has been fully sent. | |
| void | uart_wait_for_tx_complete (UARTDevice *dev) |
| Wait until the last byte has been fully sent. | |
| UARTRXErrorFlags | uart_has_errored_out (UARTDevice *dev) |
| Get the pending receive errors. | |
| void | uart_clear_all_interrupt_flags (UARTDevice *dev) |
| Clear all interrupt flags. | |
Serial port driver interface.
Devices are defined by the board, with a SoC-specific UARTDevice. Received bytes are delivered to an RX handler from the UART interrupt, also when receiving through DMA.
| struct UARTRXErrorFlags |
Receive error flags.
| Data Fields | ||
|---|---|---|
| union UARTRXErrorFlags.__unnamed29__ | __unnamed__ | |
| union UARTRXErrorFlags.__unnamed29__ |
| Data Fields | ||
|---|---|---|
| struct UARTRXErrorFlags.__unnamed29__.__unnamed31__ | __unnamed__ | |
| uint8_t | error_mask | All flags as a bit mask; non-zero if any error occurred. |
| struct UARTRXErrorFlags.__unnamed29__.__unnamed31__ |
| typedef const struct UARTDevice UARTDevice |
UART device, defined per SoC.
| typedef void(* UARTRXInterruptHandler) (UARTDevice *dev, uint8_t data, const UARTRXErrorFlags *err_flags) |
Receive interrupt handler, called from the UART ISR for each received byte.
| dev | Device. |
| data | Received byte. |
| err_flags | Errors detected with this byte. |
| typedef void(* UARTTXInterruptHandler) (UARTDevice *dev) |
Transmit interrupt handler, called from the UART ISR when a byte can be sent.
| dev | Device. |
| void uart_clear_all_interrupt_flags | ( | UARTDevice * | dev | ) |
Clear all interrupt flags.
| dev | Device. |
| void uart_clear_rx_dma_buffer | ( | UARTDevice * | dev | ) |
Discard data pending in the receive DMA buffer.
| dev | Device. |
| void uart_deinit | ( | UARTDevice * | dev | ) |
Deinitialize the device.
| dev | Device. |
| UARTRXErrorFlags uart_has_errored_out | ( | UARTDevice * | dev | ) |
Get the pending receive errors.
| dev | Device. |
error_mask is non-zero if an error occurred. | bool uart_has_rx_framing_error | ( | UARTDevice * | dev | ) |
Check for a framing error.
Check before reading the received byte, as reading clears the flag.
| dev | Device. |
| bool uart_has_rx_overrun | ( | UARTDevice * | dev | ) |
Check for a receive overrun.
Check before reading the received byte, as reading clears the flag.
| dev | Device. |
| void uart_init | ( | UARTDevice * | dev | ) |
Initialize the device for receive and transmit.
| dev | Device. |
| void uart_init_open_drain | ( | UARTDevice * | dev | ) |
Initialize the device with open-drain instead of push-pull pins.
Not supported on all SoCs.
| dev | Device. |
| void uart_init_rx_only | ( | UARTDevice * | dev | ) |
Initialize the device for receive only.
| dev | Device. |
| void uart_init_tx_only | ( | UARTDevice * | dev | ) |
Initialize the device for transmit only.
| dev | Device. |
| bool uart_is_rx_ready | ( | UARTDevice * | dev | ) |
Check whether a received byte is ready to be read.
| dev | Device. |
| bool uart_is_tx_complete | ( | UARTDevice * | dev | ) |
Check whether the last byte has been fully sent.
| dev | Device. |
| bool uart_is_tx_ready | ( | UARTDevice * | dev | ) |
Check whether a byte can be written.
| dev | Device. |
| uint8_t uart_read_byte | ( | UARTDevice * | dev | ) |
Read a byte.
Clears the framing and overrun error flags.
| dev | Device. |
| void uart_set_baud_rate | ( | UARTDevice * | dev, |
| uint32_t | baud_rate | ||
| ) |
Set the baud rate.
| dev | Device. |
| baud_rate | Baud rate in bits per second. |
| void uart_set_rx_interrupt_enabled | ( | UARTDevice * | dev, |
| bool | enabled | ||
| ) |
Enable or disable the receive interrupt.
| dev | Device. |
| enabled | true to enable. |
| void uart_set_rx_interrupt_handler | ( | UARTDevice * | dev, |
| UARTRXInterruptHandler | irq_handler | ||
| ) |
Set the receive interrupt handler.
| dev | Device. |
| irq_handler | Handler, called from the ISR for each received byte. |
| void uart_set_tx_interrupt_enabled | ( | UARTDevice * | dev, |
| bool | enabled | ||
| ) |
Enable or disable the transmit interrupt.
| dev | Device. |
| enabled | true to enable. |
| void uart_set_tx_interrupt_handler | ( | UARTDevice * | dev, |
| UARTTXInterruptHandler | irq_handler | ||
| ) |
Set the transmit interrupt handler.
| dev | Device. |
| irq_handler | Handler, called from the ISR when a byte can be sent. |
| void uart_start_rx_dma | ( | UARTDevice * | dev, |
| void * | buffer, | ||
| uint32_t | length | ||
| ) |
Start receiving into a circular DMA buffer.
The device must have DMA configured. Received bytes are still delivered to the receive handler. Some SoCs require buffer and length to be aligned to the data cache line.
| dev | Device. |
| buffer | DMA buffer. |
| length | Size of buffer in bytes. |
| void uart_stop_rx_dma | ( | UARTDevice * | dev | ) |
Stop receiving through DMA.
| dev | Device. |
| void uart_wait_for_tx_complete | ( | UARTDevice * | dev | ) |
Wait until the last byte has been fully sent.
| dev | Device. |
| void uart_write_byte | ( | UARTDevice * | dev, |
| uint8_t | data | ||
| ) |
Write a byte.
Blocks until the transmit buffer has room.
| dev | Device. |
| data | Byte to write. |