Electronics > Projects, Designs, and Technical Stuff

Generic I2C GUI??

(1/2) > >>

Mario87:
Hi all,

Not sure if this is the best place to put this, but was wondering if anyone has any links to any good generic I2C GUI tools?

There is one mentioned by Renesas here that looks perfect: https://www.renesas.com/us/en/document/oth/i2c-gui-tool-user-guide

However I cannot find a download for the software itself anywhere. Looks like that works with a cheap FTDI FT232H device such as this adafruit unit: https://thepihut.com/products/adafruit-ft232h-breakout-general-purpose-usb-to-gpio-spi-i2c

Ideally looking for something like what I have shown above, a simple GUI that lets you connect to an I2C device, read / write individual bytes as well as blocks and doesn't require expensive tools, but can also interface with cheap I2C USB devices such as the Adafruit unit.

Thanks

DavidAlfa:
Neoprogrammer supports scripts, you can use a cheap CH341 and send simple i2c and SPI commands (read, write.. )

free_electron:
https://www.renesas.com/us/en/products/power-power-management/power-management-ics-pmic-and-pmus/usb-bridgev2-eval-usb-i2c-dongle
https://i2ctools.com/our-clients-customers/idt-inc/

Mario87:
Thanks to both. However, in the end I managed to find some Arduino code that mostly does the job (did all the write functionality) and then some other code that worked for reading. Put the 2 together and now I can read & write individual bytes from the Arduino serial monitor.  :-+

Full code listed below incase anyone wants to use it. Have confirmed with the logic analyser that it works as it should.

Original link for the code that can write via serial monitor: https://github.com/DinoTools/Serial-I2C-Tester

Original link for the code that can read via serial monitor (it's the accepted the answer to the question original asked on Stack Exchange): https://arduino.stackexchange.com/questions/60940/arduino-i2c-register-read


--- Code: ---/**
 * Test I2C device by using a serial interface.
 *
 * Copyright (c) 2015 PhiBo (DinoTools)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 */
#include <Wire.h>

#define SERIAL_PORT Serial

uint8_t slave_addr = 0x01;
uint8_t data[128];
uint8_t data_length = 0;

void clearSerial()
{
  while(SERIAL_PORT.available() > 0) {
    SERIAL_PORT.read();
  }
}

void readAddress()
{
  uint8_t c;
  int tmp = 0;
  SERIAL_PORT.println("Enter slave address as decimal value(1-127) and press the Enter-Key");
  SERIAL_PORT.print("Slave address: ");
  while (true) {
    if(SERIAL_PORT.available() == 0) {
      continue;
    }
    c = SERIAL_PORT.read();
    if(isDigit(c)) {
      tmp = tmp * 10 + (c - '0');
      SERIAL_PORT.write(c);
    } else if (c == 27) {
      return;
    } else if (isControl(c)) {
      break;
    }
  }
  SERIAL_PORT.println();
  clearSerial();
  if (tmp > 0 && tmp < 128) {
    slave_addr = tmp;
  } else {
    SERIAL_PORT.println("Only values in the range 1-127 are allowed");
    SERIAL_PORT.println("Press any key to continue");
    waitSerial();
  }
}

bool readData()
{
  // Data
  uint8_t tmp_data[128];
  // Length
  uint8_t tmp_data_length = 0;
  // data octet
  uint8_t pos_data = 0;
  // nibble to process
  uint8_t lower = 0;
  // character read from serial
  uint8_t c;

  SERIAL_PORT.println("Enter data or register as hex string");
  SERIAL_PORT.print("Data / Register: ");
 
  while(true) {
    if (SERIAL_PORT.available() > 0) {
      c = SERIAL_PORT.read();
     
      if (c == 27) {
        return false;
      } else if (isControl(c)) {
        break;
      } else if (!isHexadecimalDigit(c)) {
        continue;
      }
     
      SERIAL_PORT.write(c);

      if(isLowerCase(c)) {
        // lower case characters
        c -= 87;
      } else if(isUpperCase(c)) {
        // upper case characters
        c -= 55;
      } else if(isDigit(c)){
        // numbers
        c -= 48;
      }
      if(lower == 0) {
        // process first nibble
        c = c << 4;
        pos_data = c;
        lower = 1;
      } else {
        // process second nibble
        pos_data |= c;
        tmp_data[tmp_data_length++] = pos_data;
        lower = 0;
      }
    }
  }
  SERIAL_PORT.println();
  if (lower == 1) {
    SERIAL_PORT.println("Data incomplete.");
    SERIAL_PORT.println("Press any key to continue");
    waitSerial();
    return false;
  }
  memcpy(data, tmp_data, tmp_data_length);
  data_length = tmp_data_length;
  return true;
}

void sendI2C(uint8_t *data, uint8_t len) {
  uint8_t i;
  SERIAL_PORT.print("Sending data '");
  for(i = 0; i < len; i++) {
    if (data[i] < 16) {
      SERIAL_PORT.print("0");
    }
    SERIAL_PORT.print(data[i], HEX);
  }
  SERIAL_PORT.print("' to ");
  SERIAL_PORT.println(slave_addr);
 
  Wire.beginTransmission(slave_addr);
  Wire.write(data, len);
  Wire.endTransmission();
}

void readI2C(uint8_t *data, uint8_t len) {

   Wire.beginTransmission(slave_addr); 
   Wire.write(data, len);  // set register for read
   Wire.endTransmission(false); // false to not release the line

   Wire.requestFrom(slave_addr,1); // request bytes from register XY
   byte buff[1];   
   Wire.readBytes(buff, 1);
   SERIAL_PORT.print("Reading data '");
   for (int i = 0; i < 1; i++) {
     if (buff[i] < 8) {
      SERIAL_PORT.print("0");
    }
     Serial.println(buff[i], HEX);
   }
}

void waitSerial()
{
  clearSerial();
  while (SERIAL_PORT.available() == 0);
}

void setup(){
    Wire.begin();
    SERIAL_PORT.begin(9600);
}

void loop(){
  uint8_t c;
  uint8_t i;
  SERIAL_PORT.println();
  SERIAL_PORT.println("Serial to I2C");
  SERIAL_PORT.println("=============");
  SERIAL_PORT.print("Slave Address: ");
  SERIAL_PORT.println(slave_addr);
  SERIAL_PORT.print("Data: ");
  for(i=0; i < data_length; i++) {
    if(i % 8 == 0 && i != 0) {
      SERIAL_PORT.println();
      SERIAL_PORT.print("      ");
    }
    if(data[i] < 16) {
      SERIAL_PORT.print('0');
    }
    SERIAL_PORT.print(data[i], HEX);
  }
  SERIAL_PORT.println();
  SERIAL_PORT.println("-------------");
  SERIAL_PORT.println("a = Set slave address");
  SERIAL_PORT.println("d = Set data to send or register to read");
  SERIAL_PORT.println("s = Send data");
  SERIAL_PORT.println("r = Read register");
  // SERIAL_PORT.println("w = Read and send data");
  SERIAL_PORT.println();
  SERIAL_PORT.print("Action: ");
  clearSerial();
  waitSerial();
  c = SERIAL_PORT.read();
  SERIAL_PORT.println();
  switch(c) {
    case 'a':
      readAddress();
      break;
    case 'd':
      readData();
      break;
    case 's':
      sendI2C(data, data_length);
      break;
    case 'w':
      if(readData()) {
        sendI2C(data, data_length); 
      }
      break;
      case 'r':
      readI2C(data, data_length);
      break;
  }
}
--- End code ---

tooki:
I'm using https://engsta.net/download/i2c-scripting-tool/ with a cp2112 board from AliExpress. (I paid $3 for mine in August, but they seem to have jumped to $10 now.)

Silicon Labs also has demo software for it (including source code). It can control all the features, but is harder to use and doesn't support scripting.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod