Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Function

Description

Comments

uart_handler * uart_init(uint32_t port, uint32_t rx_mode, uint32_t tx_mode)

Initialize a specified UART interface

port is the UART interface (1 to 8 corresponding to the number of the UART interfaces; rx_mode defines how receivers will be performed, possible values are UART_POLLING, UART_INTERRUPT, UART_DMA; tx_mode defines how transmit will be performed; possible values are UART_POLLING, UART_INTERRUPT, UART_DMA; returns the UART interface handle or 0 in case of error

int uart_read(uart_handler * huart, uint8_t * pdata, uint16_t size, uint32_t timeout)

Receive an amount of data

huart is the UART interface handle; pdata is the pointer to data buffer; size is the amount of data to be received; timeout is the amount of ticks for timeout in polling mode; returns a number of received bytes or a negative error code

int uart_write(uart_handler * huart, uint8_t * pdata, uint16_t size, uint32_t timeout)

Send an amount of data

huart is the UART interface handle; pdata is the pointer to data buffer; size is the amount of data to be sent; timeout is the amount of ticks for timeout in polling mode; returns a number of transmitted bytes or a negative error code

HAL_StatusTypeDef uart_deinit(uart_handler * huart)

De-Initialize the UART interface

huart is the UART interface handle; returns the status of operation

...

Command

Description

Comments

uart_test <port> <baudrate> <count>

Read data from the specified UART interface at the baudrate rate and send it back to the same UART interface. The command exits if the count bytes have been received or the special charcter OEF has been detected.

...

  1. Connect the target USART3 interface to the Linux development host (eg. via a UART-to-USB adapter).

    • On the STM32H7-BSB Rev 1A board: P5.14 (TX/PB10), P5.16 (RX/PB11).;

    • On the STM32H7-BSB Rev 2A board: P5.15 (TX/PB10), P5.16 (RX/PB11).

  2. Power cycle the target board and let it boot to the FreeRTOS CLI.

  3. Generate a 1MB test file on the Linux development host:

    Code Block
    $ echo -n `</dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c1048576` > /tmp/rdata
  4. From the FreeRTOS CLI, run the following command (read a 1MB data stream at 115200):

    Code Block
    CLI> uart_test 3 115200 1048576
  5. Run the following command in a terminal window (referred to as term1 herein) on the Linux development host:

    Code Block
    $ stty raw -echo 115200 -F /dev/ttyUSB0; cat < /dev/ttyUSB0 > /tmp/utest
  6. In a second terminal window (term2) on the Linux development host run the following command:

    Code Block
    $ stty raw -echo 115200 -F /dev/ttyUSB0; cat /tmp/rdata > /dev/ttyUSB0
  7. Wait for the uart_test CLI command to complete:

    Code Block
    uart test completed.
    CLI>
  8. Terminate cat by pressing Ctrl-C on term1 terminal and verify the sent and received files are identical:

    Code Block
    ^C
    $ md5sum /tmp/rdata /tmp/utest
    05e2c95e78835af6e01397e0acecf8fc /tmp/rdata
    05e2c95e78835af6e01397e0acecf8fc /tmp/utest