grantkbrown wrote on Wednesday, October 22, 2008:
Hi List
I have the following function that is designed to send a message via the FreeRTOS message system to my I2C module.
It then waits until the message has been processed and then retrieves the results.
My question is,
Is this the best way in which to do this or is there a better more efficient way in which to achieve the above function.
void Load_Current_I2C_GPO_Register(void)
{
I2C_CmdMsg TheMsgStruct;
I2C_CmdMsg *TheMsgPtr;
TheMsgStruct.I2C_Status = I2C_DoCmd; // set the command status
TheMsgPtr = &TheMsgStruct; // create a pointer to the message structure
if (xQueueSendToBack( TheI2C_Queue, ( void * ) TheMsgPtr, ( portTickType ) 10 )!= pdPASS)
SPI_DtaMessage->I2C_Status = I2C_CmdError;// message did not get posted
else
{ // the message was posted successfully
// wait until the I2C command has been processed
while(TheMsgStruct.I2C_Status == I2C_DoCmd);
// Load the new GPO register data from the message structure
GPO_0_Byte = TheMsgStruct.Byte_1;
GPO_1_Byte = TheMsgStruct.Byte_1;
SPI_DtaMessage->I2C_Status = I2C_CmdDone;
}
}
Kind Regards
Grant Brown