MelexisIO SCPI Commands
Loading...
Searching...
No Matches
UART SCPI Commands

This document describes the SCPI command interface implemented in commands_uart.c for UART (Universal Asynchronous Receiver/Transmitter) control on the Melexis IO STM32 platform.

Overview

The commands_uart.c file provides SCPI-like commands for initializing, deinitializing, configuring, and performing data transfers over UART3 and UART4. The commands support baud rate, word length, stop bits, parity, oversampling, and read/write/exchange operations.

Supported Commands

Information

Command Pattern Description
:UART3:INFO Get UART3 settings
:UART4:INFO Get UART4 settings

Initialization/Deinitialization

Command Pattern Description
:UART3:INIT Initialize UART3 TX0/RX0
:UART4:INIT Initialize UART4 TXA0/RXA1
:UART3:DEINIT Deinitialize UART3
:UART4:DEINIT Deinitialize UART4

UART3 Configuration

Command Pattern Description
:UART3:BaudRate «val» Set UART3 baud rate (e.g. 9600, 115200)
:UART3:BaudRate? Get UART3 baud rate
:UART3:WordLength «0/1» Set UART3 word length (0=8bit, 1=9bit)
:UART3:WordLength? Get UART3 word length
:UART3:StopBit «1/2» Set UART3 stop bit
:UART3:StopBit? Get UART3 stop bit
:UART3:Parity «0/1/2» Set UART3 parity (0=None, 1=Odd, 2=Even)
:UART3:Parity? Get UART3 parity
:UART3:OverSampling «on/off» Set UART3 oversampling (on=16, off=8)
:UART3:OverSampling? Get UART3 oversampling

UART4 Configuration

Command Pattern Description
:UART4:BaudRate «val» Set UART4 baud rate
:UART4:BaudRate? Get UART4 baud rate
:UART4:WordLength «0/1» Set UART4 word length (0=8bit, 1=9bit)
:UART4:WordLength? Get UART4 word length
:UART4:StopBit «1/2» Set UART4 stop bit
:UART4:StopBit? Get UART4 stop bit
:UART4:Parity «0/1/2» Set UART4 parity (0=None, 1=Odd, 2=Even)
:UART4:Parity? Get UART4 parity
:UART4:OverSampling «on/off» Set UART4 oversampling (on=16, off=8)
:UART4:OverSampling? Get UART4 oversampling

UART Data Transfer

Command Pattern Description
:UART3:ReaD «count» Read data from UART3 (1-255 bytes)
:UART3:WRite «data,...» Write data to UART3 (up to 256 bytes)
:UART3:EXCHange «data,...» Write then read from UART3
:UART4:ReaD «count» Read data from UART4 (1-255 bytes)
:UART4:WRite «data,...» Write data to UART4 (up to 256 bytes)
:UART4:EXCHange «data,...» Write then read from UART4

Command Details

  • INFO: Prints current UART settings (baud rate, word length, stop bits, parity, oversampling).
  • INIT/DEINIT: Initializes or deinitializes UART3/UART4 and their associated pins.
  • BaudRate/WordLength/StopBit/Parity/OverSampling: Configures or queries UART parameters.
  • ReaD/WRite/EXCHange: Reads, writes, or exchanges data with the UART peripheral.

Examples

Initialize UART3

Command sent:

:UART3:INIT\n

Response:

(OK)>

Set UART3 Baud Rate

Command sent:

:UART3:BaudRate 115200\n

Response:

(OK)>

Query UART3 Baud Rate

Command sent:

:UART3:BaudRate?\n

Response:

BaudRate=115200
(OK)>

Write Data to UART3

Command sent:

:UART3:WRite Hello\n

Response:

(OK)>

Read Data from UART3

Command sent:

:UART3:ReaD 5\n

Response:

Data: 48 65 6C 6C 6F
(OK)>

Error Example (Invalid Baud Rate)

Command sent:

:UART3:BaudRate 123\n

Response:

ERR: invalid baud rate
(Some error)>

Notes

  • Commands are case-insensitive.
  • The command interface is extensible; new features can be added by updating the command table and implementing the corresponding handler logic.
  • Some advanced features (e.g., timeout, last bit) are present as comments and can be enabled as needed.