I am using a reference design adapted for XU208. Everything works fine, but I want to add one feature and I have a problem.
I need to periodically (say every 100-200ms) read data from one I2C device, do some very simple math and send the result to a second I2C device.
So I wrote in customdefines.h:
Code: Select all
void myadd_task(void);
#define USER_MAIN_CORES on tile[0]: myadd_task();
Code: Select all
on tile [0] : struct r_i2c r_i2c = {PORT_I2C}; // port is defined in .xn file
...
void AudioHwInit(chanend ?c_codec) {
timer t;
unsigned time;
int i;
char ddt[3];
/* Init the i2c module */
i2c_shared_master_init(r_i2c);
ddt[0]=0x4E;
i2c_shared_master_write_reg(r_i2c, 0x18, 0, ddt, 1); // Init 1st I2C device
ddt[0]=0x17;
i2c_shared_master_write_reg(r_i2c, 0x20, 0, ddt, 1); // Init 2nd I2C device
...
}
...
void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec,
unsigned dsdMode, unsigned samRes_DAC, unsigned samRes_ADC) {
char ddt[3];
...
ddt[0]=dsdMode;
i2c_shared_master_write_reg(r_i2c, 0x20, 1, ddt, 1); // Set 2nd I2C device Mode
...
}
....
....
void myadd_task(void){
timer t;
unsigned time;
char ddt[3];
while(1){
t :> time;
t when timerafter(time + (10000*2)) :> void;
i2c_shared_master_read_reg(r_i2c, 0x18, 3, ddt, 2); // <<<<<<<<<< Error
// here will be calculations
i2c_shared_master_write_reg(r_i2c, 0x20, 20, ddt, 2); // <<<<<<<<< Error
}
}
}
Code: Select all
W:/wrk/snd/X200/module_usb_audio/main.xc:555:5: error: use of `r_i2c' violates parallel usage rules
par
^~~
../src/extensions/audiohw.xc:280:40: note: object used here
i2c_shared_master_read_reg(r_i2c, 0x18, 1, ddt, 2);
^~~~~
../src/extensions/audiohw.xc:205:28: note: object used here
i2c_shared_master_init(r_i2c);
Help me please!