UART API¶
Defines
-
K_NUM_UARTS
YOTTA_CFG_HARDWARE_UART_COUNT¶ KubOS-HAL UART Interface.
- Author
- kubos.co Number of UART interfaces available. Derived from value in target.json
"config": { "hardware": { "uart": { "count": 2 } } }
-
K_UART_CONSOLE
YOTTA_CFG_HARDWARE_CONSOLE_UART¶ Uart interface used for console output.
"config": { "hardware": { "console": { "uart": "K_UART1" } } }
-
K_UART_CONSOLE_BAUDRATE
YOTTA_CFG_HARDWARE_CONSOLE_BAUDRATE¶ Baudrate used for console output.
"config": { "hardware": { "console": { "baudrate": "115200" } } }
Enums
-
enum
KUARTNum
¶ Available UART interfaces.
Values:
Functions
-
KUARTStatus
k_uart_init
(KUARTNum uart, KUARTConf *conf)¶ Setup and enable UART interface.
- Return
- KUARTStatus UART_OK if OK, failure otherwise
- Parameters
uart
: UART interface to initializeconf
: config values to initialize with
-
void
k_uart_terminate
(KUARTNum uart)¶ Terminates UART interface.
- Parameters
uart
: UART interface to terminate
-
void
k_uart_console_init
(void)¶ Setup and enable console UART interface.
-
int
k_uart_read
(KUARTNum uart, char *ptr, int len)¶ Interrupt driven function for reading data from a UART interface.
This function reads from a queue which is filled up via the UART interrupt handler.
- Return
- int number of characters read or -1 to indicate a null UART handle
- Parameters
uart
: UART interface to read fromptr
: buffer to read data intolen
: length of data to read
-
int
k_uart_write
(KUARTNum uart, char *ptr, int len)¶ Interrupt driven function for writing data to a UART interface.
This function writes data into a queue which is then written out in the interrupt handler.
- Return
- int number of characters written or -1 to indicate a null UART handle
- Parameters
uart
: UART interface to write toptr
: buffer to write data fromlen
: length of data to write
-
KUARTStatus
k_uart_write_immediate
(KUARTNum uart, char c)¶ Write data directly to a UART interface.
- Return
- KUARTStatus UART_OK if success, otherwise failure
- Parameters
uart
: UART interface to write toc
: character to write
-
KUARTStatus
k_uart_write_immediate_str
(KUARTNum uart, uint8_t *ptr, uint8_t len)¶ Write data directly to a UART interface.
- Return
- KUARTStatus UART_OK if success, otherwise failure
- Parameters
uart
: UART interface to write toptr
: buffer to write data fromlen
: length of data to write
-
int
k_uart_rx_queue_len
(KUARTNum uart)¶ Returns the number of characters currently in the UART rx queue.
- Return
- int length of UART’s rx_queue
- Parameters
uart
: UART interface number or -1 to indicate a null UART handle or -2 to indicate a null rx queue pointer
-
void
k_uart_rx_queue_push
(KUARTNum uart, char c, void *task_woken)¶ Pushes a character into the UART rx queue.
- Parameters
uart
: UART interface numberc
: character to pushtask_woken
: used by FreeRTOS to determine task blocking
-
int
k_uart_rx_pin
(KUARTNum uart)¶ Returns rx pin for specified UART interface.
- Return
- int rx pin
- Parameters
uart
: UART interface number
-
int
k_uart_tx_pin
(KUARTNum uart)¶ Returns tx pin for specified UART interface.
- Return
- int tx pin
- Parameters
uart
: UART interface number
-
KUART *
kprv_uart_get
(KUARTNum uart)¶ Returns UART data structure for specified interface.
- Return
- KUART* pointer to UART data structure
- Parameters
uart
: UART interface number
-
KUARTStatus
kprv_uart_dev_init
(KUARTNum uart)¶ Performs low-level UART hardware initialization.
- Return
- KUARTStatus UART_OK if OK, failure otherwise
- Parameters
uart
: UART interface to initialize
-
struct
KUARTConf
¶ - #include <uart.h>
Uart configuration structure.
Public Members
-
const char *
dev_path
¶ The path of the UART bus.
-
uint32_t
baud_rate
¶ The buad rate of the UART bus.
- Warning
- For the MSP430F5 microcontroller, the speed of the SPI bus can only be defined as a factor of the peripheral clock to which it’s connected (SMCLK for MSP430F5 SPI buses). For example, SMCLK_speed / 2. To make things easier, this speed field will take a normal baud rate number and then it will automatically be converted to the nearest available system speed without exceeding the original value.
-
KWordLen
word_len
¶ The number of data bits in each transmit/receive of the UART bus.
Can be 7-, 8-, or 9-bits, as specified by the KWordLen enumerator
-
KStopBits
stop_bits
¶ The number of stop bits at the end of each transmit/receive of the UART bus.
Can be 1 or 2 bits, as specified by the KStopBits enumerator
-
KParity
parity
¶ The presence and state of the parity bit in each transmit/receive of the UART bus.
Can be none, odd, or even, as specified by the KParity enumerator
-
uint8_t
rx_queue_len
¶ The size of the queue for incoming messages.
-
uint8_t
tx_queue_len
¶ The size of the queue for outgoing messages.
-
const char *
-
struct
KUART
¶ - #include <uart.h>
Uart interface data structure.
Public Members
-
int
dev
¶ UART device number.
-
csp_queue_handle_t
rx_queue
¶ Queue filled with received UART data.
-
csp_queue_handle_t
tx_queue
¶ Queue filled with data to be sent.
-
int