xsim (is_pin_driving) responds with XSI_STATUS_INVALID_PIN

Technical questions regarding the XTC tools and programming with XMOS.
IgorLopez
Member++
Posts: 25
Joined: Tue Mar 11, 2014 8:16 pm

xsim (is_pin_driving) responds with XSI_STATUS_INVALID_PIN

Post by IgorLopez »

Hi,

Problem solved, I had O instead of 0 in the pin name arguments to the plugin when starting xsim.

I am debugging my I2C Slave (targeting a Startkit) with xsim and a plugin simulating the I2C Master.

The plugin_create function works as expected but when xsim calls plugin_clock and my plugin makes a check on the slave for status of the pin(s) it gets the response: XSI_STATUS_INVALID_PIN.

This is how my slave is setup pinwise:

Code: Select all

port p_scl = XS1_PORT_1F; // XOD13
port p_sda = XS1_PORT_1H; // XOD23

int main() {
  i2c_slave_callback_if i_i2c;
  par {
    i2c_slave_register_file(i_i2c);
    i2c_slave(i_i2c, p_scl, p_sda, 0x21);
  }
  return 0;
}
I am running xsim from the command line like this:
$ xsim i2cTest.xe --plugin I2CTestPlugin.so '0 XOD23 XOD13'
which is wrong. Working command line is:
$ xsim i2cTest.xe --plugin I2CTestPlugin.so '0 X0D23 X0D13'
and the package, pin arguments are properly picked up by the plugin:

Code: Select all

XsiStatus plugin_create(void **instance, XsiCallbacks *xsi, const char *arguments)
{
  ...
  char *argv[3];
  XsiStatus status = split_args(arguments, argv);
  ...
  fprintf(stdout, "plugin_create stores pin info: package=%s, sda=%s, scl=%s\n", argv[0], argv[1], argv[2]);
  s_instances[s_num_instances].package = argv[0];
  s_instances[s_num_instances].sda = argv[1];
  s_instances[s_num_instances].scl = argv[2];
  s_instances[s_num_instances].xsi = xsi;
  ...
}
The debug print statement to stdout for argv gives:
plugin_create stores pin info: package=0, sda=XOD23, scl=XOD13
Problem occurs in plugin_clock:

Code: Select all

XsiStatus plugin_clock(void *instance)
{
  ...
  XsiCallbacks *xsi      = s_instances[instance_num].xsi;
  const char *package = s_instances[instance_num].package;
  const char *sda        = s_instances[instance_num].sda;
  const char *scl         = s_instances[instance_num].scl;
  unsigned int sda_driving = 0;
  status = xsi->is_pin_driving(package, sda, &sda_driving);
where the last row gives status == XSI_STATUS_INVALID_PIN