simpe_i2c module incompatible type for argument 1

Technical questions regarding the XTC tools and programming with XMOS.
stdefeber
Active Member
Posts: 35
Joined: Wed Dec 18, 2013 9:20 pm

simpe_i2c module incompatible type for argument 1

Post by stdefeber »

I am doing something stupid using the i2c_simple module.
See the following error :

Code: Select all

../src/audio_io.xc:64: error: incompatible type for argument 1 of `i2c_master_init'
The call is in my audio_io.xc:

Code: Select all

void audio_hw_init()
{
	// Initialise the I2C bus
	i2c_master_init( i2cPorts );
}
The protype of i2c_master_init() is in i2.h as

Code: Select all

 
void i2c_master_init(REFERENCE_PARAM(struct r_i2c,i2c));
i2cPorts is defined in audio_io.h as

extern port i2cPorts;

The declaration of i2cPorts is in my codec.xc as

Code: Select all


struct  r_i2c i2cPorts = {
  XS1_PORT_4C,
  XS1_PORT_1G
};

and the struct r_i2c is defined in i2c.h of the simple_i2c module as

Code: Select all

struct r_i2c {
    port scl;
    port sda;
};
As far as I can see this should be correct but I am not a professional SW designer.


stdefeber
Active Member
Posts: 35
Joined: Wed Dec 18, 2013 9:20 pm

Post by stdefeber »

Moving the declaration of the struct to my audio_io.xc
and therefor moving the "extern port i2cPorts" to codec.h

results in

Code: Select all

../src/audio_io.xc:51: error: conflicting types for 'i2cPorts'
In file included from ../src/audio_io.xc:23,
                 from audio_io.h:29:
codec.h:31: error: previous declaration of 'i2cPorts' was here
xmake[1]: *** [.build_Debug/src/audio_io.xc.o] Error 1
xmake: *** [bin/Debug/app_loopback_Debug.xe] Error 2

stdefeber
Active Member
Posts: 35
Joined: Wed Dec 18, 2013 9:20 pm

Post by stdefeber »

I have solved it by changing the module I use.
Instead of using the simple_i2c module, which makes use of separate ports, I use the single_port I2C
implementation which fits the port usage (4F) of the startKit.

grtz


Simon
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Looks like you are passing a struct to something that is expecting a port (or vice versa)