I2C compile error

New to XMOS and XCore? Get started here.
Posts: 18
Joined: Thu Mar 08, 2018 4:07 pm

I2C compile error

Postby soundhound » Fri Mar 09, 2018 4:14 am

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?
User avatar
XCore Legend
Posts: 1885
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Fri Mar 09, 2018 1:44 pm


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

Who is online

Users browsing this forum: No registered users and 1 guest