I2C Events

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Events

68 Views
NXP Employee
NXP Employee
Content originally posted in LPCWare by rubensm on Sun Jan 11 08:47:57 MST 2015
Hello everybody,

Can anyone explain what does function i2c_iox_events do exactly? I want to edit this function in order to fit it according to my needs, but I don't understand the differences between I2C_EVENT_DONE, I2C_EVENT_SLAVE_RX and I2C_EVENT_SLAVE_TX. How do I have to handle these events to send or receive correctly my data as slave?

What I understand is when master resquests for data to the slave, I2C_EVENT_SLAVE_TX is active. But if I do this:
  case I2C_EVENT_SLAVE_TX:
  iox_data[0] = 0x49;//H
  iox_data[1] = 0x48;//i

  iox_xfer.txBuff = iox_data;// buffer[0];

  break;


Then, LPC11U68 only sends H. If I request for 2 bytes, what I get is HH.

The original function is:
/* Slave event handler for simulated EEPROM */
static void i2c_iox_events(I2C_ID_T id, I2C_EVENT_T event)
{
switch (event) {
case I2C_EVENT_DONE:
iox_xfer.rxBuff = &iox_data[1];
iox_xfer.rxSz = sizeof(iox_data);
iox_xfer.txBuff = (const uint8_t *) iox_data;
iox_xfer.txSz = sizeof(iox_data) + 1;
break;

case I2C_EVENT_SLAVE_RX:
iox_xfer.rxBuff = &iox_data[1];
iox_xfer.rxSz = sizeof(iox_data);
i2c_iox_update_regs(1);
break;

case I2C_EVENT_SLAVE_TX:
if (iox_xfer.txSz == 1) {
iox_xfer.txBuff = (const uint8_t *) iox_data[0];
iox_xfer.txSz = sizeof(iox_data) + 1;
}
break;
}
}


And this function is called by i2c_iox_events:
/*-------- IO Expansion slave device implementation ----------*/
/* Update IN/OUT port states to real devices */
void i2c_iox_update_regs(int ops)
{
if (ops & 1) {/* update out port */
Board_LED_Set(0, iox_data[1] & 1);
Board_LED_Set(1, iox_data[1] & 2);
Board_LED_Set(2, iox_data[1] & 4);
Board_LED_Set(3, iox_data[1] & 8);
}
}



Thank you very much for your help.

Rubén
Labels (1)
0 Kudos
1 Reply

13 Views
NXP Employee
NXP Employee
Content originally posted in LPCWare by rubensm on Fri Jan 16 04:17:20 MST 2015
It's very very very sad buy what you think is a good product but then you can neither find quality information nor anyone who can help you...

NXP: thank you very much for the all the wasted time I spent trying to decipher how the hell I can use your LPC11U68 as slave with I2C. I have had to give up the project after hours and hours of read and tryings.
0 Kudos