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

This document describes the SCPI command interface implemented in commands_gpio.c for GPIO (General Purpose Input/Output) control on the Melexis IO STM32 platform.

Overview

The commands_gpio.c file provides SCPI-like commands for initializing, deinitializing, reading, and writing to GPIO pins. The commands support both board and connector pins, and allow configuration as input or output.

Supported Commands

Initialization

Command Pattern Description
:A0:GPIO:INIT:IN Init A0 as GPIO Input
:A0:GPIO:INIT:OUT Init A0 as GPIO Output
... ...
:CON:SCL:GPIO:INIT:IN Init Connector SCL as GPIO Input
:CON:SCL:GPIO:INIT:OUT Init Connector SCL as GPIO Output

Deinitialization

Command Pattern Description
:A0:GPIO:DEINIT DeInit A0 as GPIO
... ...
:CON:SCL:GPIO:DEINIT DeInit Connector SCL as GPIO

Output (Write)

Command Pattern Description
:A0:GPIO «1/0» Set A0 GPIO Output
... ...
:CON:SCL:GPIO «1/0» Set Connector SCL GPIO Output

Input (Read)

Command Pattern Description
:A0:GPIO? Read A0 GPIO Input
... ...
:CON:SCL:GPIO? Read Connector SCL GPIO Input

» Note: Replace A0, A1, A2, A3, SDA, SCL, TX, RX, MO, MI, SCK, CON:SCL, CON:SDA, CON:SCLK, CON:MO, CON:MI, CON:CS0, CON:CS1 with the desired pin name.

Command Details

  • INIT:IN/OUT: Initializes the specified pin as input or output.
  • DEINIT: Deinitializes the specified pin, returning it to analog mode.
  • GPIO «1/0»: Sets the output state of the specified pin (1 = high, 0 = low).
  • GPIO?: Reads the input state of the specified pin and prints 1 (high) or 0 (low).

Handler Function

All commands are handled by the CMD_GPIO function, which interprets the tag to determine the pin, direction, and action.

Example Usage

  • Initialize A0 as output: :A0:GPIO:INIT:OUT
  • Set A0 high: :A0:GPIO 1
  • Read A0: :A0:GPIO?
  • Deinitialize A0: :A0:GPIO:DEINIT
  • Initialize Connector SCL as input: :CON:SCL:GPIO:INIT:IN

Examples

Initialize Pin as Output

Command sent:

:A0:GPIO:INIT:OUT\n

Response:

(OK)>

Set Pin Output High

Command sent:

:A0:GPIO 1\n

Response:

(OK)>

Read Pin Input

Command sent:

:A0:GPIO?\n

Response:

A0=1
(OK)>

Deinitialize Pin

Command sent:

:A0:GPIO:DEINIT\n

Response:

(OK)>

Error Example (Invalid Pin Name)

Command sent:

:Z9:GPIO:INIT:OUT\n

Response:

ERR: unknown pin
(Some error)>

Notes

  • The command interface is extensible; new pins can be added by updating the command table.
  • Commands are case-insensitive.
  • Some connector pins are prefixed with CON:.