Storing an interface reference in a structure

Technical questions regarding the XTC tools and programming with XMOS.
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Storing an interface reference in a structure

Post by babazaroni »

I would like to store a reference to an interface in a structure and use that reference to make a notification.

The specific need is when performing an i2c transmission, I would like to eventually notify the initiator that the i2c transmission has succeeded.

My attempt below resulted in: `i_i2c_tx' has resource type

typedef struct {
int address_destination;
int dest_reg;
int tx_count;
unsigned char * unsafe tx_address;
unsigned int data;
server interface i2c_msi_tx_interface ?i_i2c_tx; // error `i_i2c_tx' has resource type
} I2C_TX_ENTRY;

So, how can an interface be stored to be used later?


User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

I believe interfaces (like channels) need to have both ends (client and server) allocated by the compiler and thus should be passed into at least two tasks, declared in their respective arguments, I am not sure if the compiler could deal with a null or unallocated interface. You can use arrays of interfaces that might help you.

(Also having said that, from memory, I believe you can get away with some of an array of interfaces not all being allocated with just a compiler warning)

regards
Al
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

Post by babazaroni »

Thanks, an array of interfaces will also help with other issues. So now instead of trying to store the interface, I just need to store the index.