UART_Open Function

Header: #include <applibs/uart.h>

Opens and configures a UART, and returns a file descriptor to use for subsequent calls.

int UART_Open(UART_Id uartId, const UART_Config * uartConfig);

Parameters

  • uartId The ID of the UART to open.

  • uartConfig A pointer to a UART_Config struct that defines the configuration of the UART. Call UART_InitConfig to get a UART_Config with default settings.

Errors

Returns -1 if an error is encountered and sets errno to the error value.

  • EACCES: access to UART_Id is not permitted as the uartId is not listed in the Uart field of the application manifest.

  • ENODEV: the uartId is invalid.

  • EINVAL: the uartConfig represents an invalid configuration.

  • EBUSY: the uartId is already open.

  • EFAULT: the uartConfig is NULL.

Any other errno may also be specified; such errors aren't deterministic and the same behavior might not be retained through system updates.

Return value

Returns the file descriptor of the UART if it was opened successfully, or -1 for failure, in which case errno is set to the error value.

Application manifest requirements

To access individual UARTs, your application must identify them in the Uart field of the application manifest.