Page 1 of 1

I2C compile error

Posted: Fri Mar 09, 2018 4:14 am
by soundhound
Just started out and am already perplexed by a the non-compilation of some trivial i2c code:

#include <i2c.h>
#include <xs1.h>
#include <xclib.h>
#include <timer.h>

//port I2C_SCL = XS1_PORT_1E; //I2C clock
//port I2C_SDA = XS1_PORT_1H; //I2C data

port p_scl = XS1_PORT_4C;
port p_sda = XS1_PORT_1G;
i2c_master_if xx;

..... for which I am rewarded with:

../src/I2C testing.xc:18:8: warning: type defaults to `int' in declaration of `i2c_master_if' [-Wimplicit-int]
static i2c_master_if xx;
^~~~~~~~~~~~~
../src/I2C testing.xc:18:22: error: parse error before "xx"
i2c_master_if xx;
^
../src/I2C testing.xc:18:22: warning: type defaults to `int' in declaration of `xx' [-Wimplicit-int]
i2c_master_if xx;
^~
../src/I2C testing.xc:18:22: warning: data definition has no type or storage class [-Wunusual-code]
i2c_master_if xx;

this makes no sense to me as xs1.h is not complained about so the declarations must be there.
the i2c module is also a dependency in the Makefile.
someone know what the issue is?

Re: I2C compile error

Posted: Fri Mar 09, 2018 1:44 pm
by mon2
https://www.xmos.com/support/appnotes/AN00156

Start with this appnote and import the posted project (zip file). Compile for your target cpu or kit. Then modify as needed.