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

This document describes the SCPI command interface implemented in commands_i2c.c for I2C and FMPI2C control on the Melexis IO STM32 platform.

Overview

The commands_i2c.c file provides SCPI-like commands for initializing, deinitializing, configuring, and performing data transfers over the I2C and FMPI2C interfaces. The commands support both the main FMPI2C peripheral and a secondary I2C2 peripheral, with options for memory and direct read/write operations, timing configuration, and advanced I2C features.

Supported Commands

FMPI2C (I2C1)

Command Pattern Description
:I2C:INFO Print FMPI2C info (clock, timing, filters, etc.)
:I2C:INIT Initialize FMPI2C (pins SCL/SDA)
:I2C:DEINIT Deinitialize FMPI2C
:I2C:TimingRegister «val» Set timing register (uint32)
:I2C:TimingRegister? Get timing register
:I2C:FREQuency «freq» Set I2C frequency (e.g. 100k, 400k, 1MA)
:I2C:FastModePlus «bool» Set fast mode plus (ON/OFF, 1/0, TRUE/FALSE)
:I2C:FastModePlus? Get fast mode plus status
:I2C:AnalogFilter «bool» Set analog filter (ON/OFF, 1/0, TRUE/FALSE)
:I2C:AnalogFilter? Get analog filter status
:I2C:DigitalFilter «0-15» Set digital filter coefficient
:I2C:DigitalFilter? Get digital filter coefficient
:I2C:MemReaD «dev,mem,sz,cnt» Read memory (dev addr, mem addr, mem addr size, count)
:I2C:MemWRite «dev,mem,sz,data» Write memory (dev addr, mem addr, mem addr size, data bytes)
:I2C:ReaD «dev,cnt» Read from device (dev addr, count)
:I2C:WRite «dev,data» Write to device (dev addr, data bytes)
:I2C:EXCHange «dev,cnt,data» Write and/or read to/from device (dev addr, count, data bytes, ...)

I2C2

Command Pattern Description
:I2C2:INFO Print I2C2 info
:I2C2:INIT Initialize I2C2 (pins A2/A3)
:I2C2:DEINIT Deinitialize I2C2
:I2C2:ClockSpeed «val» Set I2C2 clock speed (Hz)
:I2C2:AddressingMode «0/1» Set addressing mode (0=7BIT, 1=10BIT)
:I2C2:DualAddressMode «bool» Set dual address mode (ON/OFF, 1/0, TRUE/FALSE)
:I2C2:GeneralCallMode «bool» Set general call mode (ON/OFF, 1/0, TRUE/FALSE)
:I2C2:NoStretchMode «bool» Set no stretch mode (ON/OFF, 1/0, TRUE/FALSE)
:I2C2:PullUpDown «0/1/2» Set GPIO pull (0=No Pull, 1=Pull-Up, 2=Pull-Down)
:I2C2:MemReaD «dev,mem,sz,cnt» Read memory (dev addr, mem addr, mem addr size, count)
:I2C2:MemWRite «dev,mem,sz,data» Write memory (dev addr, mem addr, mem addr size, data bytes)
:I2C2:ReaD «dev,cnt» Read from device (dev addr, count)
:I2C2:WRite «dev,data» Write to device (dev addr, data bytes)
:I2C2:EXCHange «dev,cnt,data» Write and/or read to/from device (dev addr, count, data bytes, ...)

Command Details

  • INFO: Prints configuration and status information for the selected I2C peripheral.
  • INIT/DEINIT: Initializes or deinitializes the I2C peripheral and its pins.
  • TimingRegister/FREQuency: Configures timing and frequency for FMPI2C.
  • FastModePlus/AnalogFilter/DigitalFilter: Configures advanced I2C features.
  • MemReaD/MemWRite: Reads/writes memory from/to a device using memory addressing.
  • ReaD/WRite/EXCHange: Reads, writes, or exchanges data with a device.
  • I2C2:ClockSpeed/AddressingMode/DualAddressMode/GeneralCallMode/NoStretchMode/PullUpDown: Configures I2C2-specific features.

Examples

Initialize FMPI2C

Command sent:

:I2C:INIT\n

Response:

(OK)>

Set I2C Frequency

Command sent:

:I2C:FREQuency 400k\n

Response:

(OK)>

Read Device Memory

Command sent:

:I2C:MemReaD 0x50,0x00,1,4\n

Response:

Data: 12 34 56 78
(OK)>

Write Device Memory

Command sent:

:I2C:MemWRite 0x50,0x00,1,ABCD\n

Response:

(OK)>

Error Example (Invalid Address)

Command sent:

:I2C:ReaD 0xZZ,4\n

Response:

ERR: invalid device address
(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 commands require specific hardware features or configurations.