Hi,
I am trying to figure out this line in the example given below from the I2C_LDD help page. I am refering to the Master mode, without interrupt mode example. (I have extracted only the relevant portion of the code)
the variable is initialised as follows
uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U}; /* Initialization of output data buffer */
Error = I2C2_MasterSendBlock(MyI2CPtr, OutData, 4U, LDD_I2C_SEND_STOP); /* Send OutData (4 bytes) on the I2C bus and generates a stop condition to end transmission */
while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */
I2C2_Main(MyI2CPtr);
}
The contents of the Events.c file is as follows
extern volatile bool DataTransmittedFlg;
void I2C3_OnSlaveBlockSent(LDD_TUserData *UserDataPtr)
{
DataTransmittedFlg = TRUE; /* Set DataTransmittedFlg flag */
}
extern volatile bool DataReceivedFlg;
void I2C3_OnSlaveBlockReceived(LDD_TUserData *UserDataPtr)
{
DataReceivedFlg = TRUE; /* Set DataReceivedFlg flag */
}
I have the following queries...
1.The text bold is what I am unable to understand, is 0x00U, 0x01U... the register addresses or data for the I2C slave device ??
2. what is 4U meant for ??
3. The while loop never quits, as the BlockSentEvent is not fired and DataTransmittedFlg remains FALSE.
I am trying to connect to a MCP23016 (address=1) with a MKL26Z64VFT4 mcu (via I2C1). For this I would like to send the following parameters.
Mode=Master
Slave Address=1
Register Address=0
GPIO1=0xFE
GPIO2=0x00
So how can do this using the I2C_LDD device driver ?? In my test program I am doing this (again only relevant portions are shown, if required I could post more info)
OutData[0]=0; //GP0 address
OutData[1]=0xFF; //GP0 set as input
OutData[2]=0; //GP2 set as output
Error = I2C2_MasterSendBlock(MyI2CPtr, OutData,3U, LDD_I2C_SEND_STOP);
while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */
I2C2_Main(MyI2CPtr);
}
With a scope I can see the SDA pin pulsing, but no pulsing on SCL line is observed. Also the while loop is never quit as the BlockSentEvent does not get fired.
thanks
a