UART API

This page aggregates all C++ UART-related public methods of the class CosmicSDK.

group CosmicSDK UART API

Constants and APIs related to UART operations.

Functions

uint16_t uartSetBusVoltage(uint16_t voltage_mV, bool persist = false)

Sets the UART bus voltage.

Warning

On Supernova and Pulsar host adapters, the UART interface shares the same voltage domain as I2C, SPI and GPIOs. As a result, calling this method to set the UART voltage will also affect the voltage of I2C, SPI and GPIO interfaces. This must be taken into account when more than one interfaces are used simultaneously.

Parameters:
  • voltage_mV – Voltage in millivolts to set the UART interface to. The valid values are 0 mV, and any value in the range 1200 to 3300 mV. The value 0mV deactivates the VTARG pin and turn offs the downstream devices.

  • persist – bool If true, the voltage setting will be persistent across power cycles. This ensures that any DUT connected to the UART interface (e.g. via Pulsar or Supernova) will receive power immediately upon startup, without waiting for the host to issue the voltage set command. If false, the setting will only apply to the current session.

Returns:

The status code of the operation

uint16_t uartInit(UartBaudRate baudrate, UartHwHandshake hardwareHandshake, UartParity parityMode, UartDataSize dataSize, UartStopBit stopBit)

Initialize the UART interface.

This function initializes the UART peripheral and must be called successfully before any other UART-related API is used.

Note

Parameters:
  • baudrate – UART baud rate used for both transmission (TX) and reception (RX). See UartBaudRate for supported values.

  • hardwareHandshake – Enables or disables hardware flow control (RTS/CTS), if supported by the underlying hardware. See UartHwHandshake for supported values.

  • parityMode – UART parity configuration. See UartParity for supported values.

  • dataSize – Number of data bits per UART frame. See UartDataSize for supported values.

  • stopBit – Number of stop bits per UART frame. See UartStopBit for supported values.

Return values:
  • SUCCESS – UART interphase was successfully initialized.

  • FW_INTERFACE_ALREADY_INITIALIZED – The UART interface has already been initialized.

  • FW_INVALID_PARAMETER – One or more configuration parameters are invalid or unsupported.

  • SDK_ERROR_TIMEOUT – The operation timed out.

  • SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.

uint16_t uartSetParameters(UartBaudRate baudrate, UartHwHandshake hardwareHandshake, UartParity parityMode, UartDataSize dataSize, UartStopBit stopBit)

Configure UART peripheral communication parameters.

This function updates the UART communication parameters after the UART interface has been successfully initialized using uartInit. It allows runtime reconfiguration of the UART without requiring a full deinitialization or reinitialization of the peripheral.

Note

Parameters:
  • baudrate – UART baud rate used for both transmission (TX) and reception (RX). See UartBaudRate for supported values.

  • hardwareHandshake – Enables or disables hardware flow control (RTS/CTS), if supported by the underlying hardware. See UartHwHandshake for supported values.

  • parityMode – UART parity configuration. See UartParity for supported values.

  • dataSize – Number of data bits per UART frame. See UartDataSize for supported values.

  • stopBit – Number of stop bits per UART frame. See UartStopBit for supported values.

Return values:
  • SUCCESS – UART parameters were successfully updated.

  • FW_INTERFACE_NOT_INITIALIZED – The UART interface has not been initialized.

  • FW_INVALID_PARAMETER – One or more configuration parameters are invalid or unsupported.

  • SDK_ERROR_TIMEOUT – The operation timed out.

  • SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.

uint16_t uartSendMessage(const std::vector<uint8_t> &inData)

Transmit a UART message through the host adapter device.

Requests the host adapter to send data using the currently active UART configuration (see uartInit and uartSetParameters).

Note

  • The UART interface must be successfully initialized with uartInit before calling this function.

  • If the UART interface is not initialized, this function returns FW_INTERFACE_NOT_INITIALIZED.

Parameters:

inData – Reference to the vector containing the bytes to transmit.

Return values:
  • SUCCESS – UART message were successfully sent.

  • FW_INTERFACE_NOT_INITIALIZED – The UART interface has not been initialized.

  • FW_INVALID_PARAMETER – One or more parameters are invalid or unsupported.

  • SDK_ERROR_TIMEOUT – The operation timed out.

  • SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.