diff --git a/XilinxProcessorIPLib/drivers/iic/src/xiic.h b/XilinxProcessorIPLib/drivers/iic/src/xiic.h index 6f6e51c4..bfbc543d 100644 --- a/XilinxProcessorIPLib/drivers/iic/src/xiic.h +++ b/XilinxProcessorIPLib/drivers/iic/src/xiic.h @@ -286,6 +286,10 @@ * It Fixes the CR:685759 Changes are done in the file * xiic_l.c in the function XIic_Recv. * 3.0 adk 19/12/13 Updated as per the New Tcl API's +* 3.1 adk 01/08/15 When configured as a slave return the actual number of +* bytes have been received/sent by the Master +* to the user callback (CR: 828504). Changes are made in the +* file xiic_slave.c. * * ******************************************************************************/ diff --git a/XilinxProcessorIPLib/drivers/iic/src/xiic_slave.c b/XilinxProcessorIPLib/drivers/iic/src/xiic_slave.c index f5f217d1..13494a6a 100644 --- a/XilinxProcessorIPLib/drivers/iic/src/xiic_slave.c +++ b/XilinxProcessorIPLib/drivers/iic/src/xiic_slave.c @@ -67,6 +67,9 @@ * bus. This flag is to be used by slave applications for * recovering when it has gone out of sync with the master. * CR 615004. +* 3.1 adk 01/08/15 When configured as a slave return the actual number of +* bytes have been received/sent by the Master +* to the user callback (CR: 828504). * * ****************************************************************************/ @@ -368,6 +371,7 @@ static void NotAddrAsSlaveHandler(XIic *InstancePtr) u32 CntlReg; u8 BytesToRead; u8 LoopCnt; + u32 TxFifoOcy; /* * Disable NAAS so that the condition will not continue to interrupt @@ -377,6 +381,20 @@ static void NotAddrAsSlaveHandler(XIic *InstancePtr) XIic_DisableIntr(InstancePtr->BaseAddress, XIIC_INTR_NAAS_MASK); XIic_ClearEnableIntr(InstancePtr->BaseAddress, XIIC_INTR_AAS_MASK); + /* + * In the slave transmitter case pass the actual number of + * bytes being recievd by the master to the user callback. + */ + Status = XIic_ReadReg(InstancePtr->BaseAddress, XIIC_SR_REG_OFFSET); + TxFifoOcy = XIic_ReadReg(InstancePtr->BaseAddress, XIIC_TFO_REG_OFFSET); + if (!(Status & XIIC_SR_TX_FIFO_EMPTY_MASK)) { + InstancePtr->SendByteCount = InstancePtr->Stats.SendBytes - + (TxFifoOcy+1) ; + } else { + InstancePtr->SendByteCount = InstancePtr->Stats.SendBytes; + } + + /* * Flush Tx FIFO by toggling TxFIFOResetBit. FIFO runs normally at 0 * Do this incase needed to Tx FIFO with more than expected if what @@ -404,7 +422,6 @@ static void NotAddrAsSlaveHandler(XIic *InstancePtr) } } - InstancePtr->RecvByteCount = 0; /* * Flush Rx FIFO should slave Rx had a problem, sent No ack but * still received a few bytes. Should the slave receive have disabled @@ -456,6 +473,7 @@ static void NotAddrAsSlaveHandler(XIic *InstancePtr) InstancePtr->RecvHandler(InstancePtr->RecvCallBackRef, InstancePtr->RecvByteCount); } + InstancePtr->RecvByteCount = 0; return; }