Hi Neil
If you set tI2CParameters.Task_to_wake to a task name you will get a notification (task will be scheduled) each time the write has terminated, although this is not the best technique here (termination means that the final byte has completed and the stop condition has been commanded).
The driver's queue state will be TX_ACTIVE until this point ,so polling this value shows when it has completed. The value is however local to the driver but can (in an emergency) by read using:
I2CQue *ptI2CQue = (struct stI2CQue *)(que_ids[IICPortIDG2 - 1].output_buffer_control);
if ((ptI2CQue->ucState & TX_ACTIVE) != 0) {
// still transmitting...
}
[older code may use IIC instead of I2C].
I would however just use a software timer and state-event sequence like this:
task() {
static int iInitState = 0;
unsigned char VAL[4];
switch (iInitState) {
case 0:
VAL[0]=0x40;
VAL[1]=0;
VAL[2]=0x0; //set as output
fnWrite(IICPortIDG2, (unsigned char *)VAL, 3);
uTaskerMonoTimer(OWN_TASK, (DELAY_LIMIT)(0.05 * SEC), E_TIMER_NEXT_I2C_MESSAGE);
iInitState++;
break;
case 1:
VAL[0]=0x40;
VAL[1]=0x09;
VAL[2]=0x02; //set as output
fnWrite(IICPortIDG2, (unsigned char *)VAL, 3);
uTaskerMonoTimer(OWN_TASK, (DELAY_LIMIT)(0.05 * SEC), E_TIMER_NEXT_I2C_MESSAGE);
iInitState++;
break;
case 2:
VAL[0]=0x40;
VAL[1]=0x23;
VAL[2]=0x22; //set as output
fnWrite(IICPortIDG2, (unsigned char *)VAL, 3);
fnDebugMsg("I2C sequence terminated - each command sent with 50ms delay");
iInitState++;
break;
}
}
This ensures adequate delay between each message.
Regards
Mark