我有一个基于"I2C_Slave_Using_Callbacks" 的 PSoC4 MAX 器件的 I2C 从设备项目。 它已启用"Accept Slave Address In RX FIFO" 。 但是,我的设备被主站发送的从站地址淹没了。 下面粗体字一行是将地址复制到我的 FW 缓冲区。 我本以为地址会在此之前被删除,但事实似乎并非如此。 我还有什么不明白的地方?
static void SlaveHandleDataReceive(CySCB_Type *base, cy_stc_scb_i2c_context_t *context){ /* Check whether there is space to put data */ if (context->slaveRxBufferSize > 0UL) { if (context->useRxFifo) { uint32_t level; /* Get the number of bytes to read from RX FIFO */ uint32_t numToCopy = Cy_SCB_GetRxFifoLevel(base) + 1UL; /* Get data from RX FIFO */ numToCopy = Cy_SCB_ReadArray(base, context->slaveRxBuffer, numToCopy); context->slaveRxBufferIdx += numToCopy; context->slaveRxBufferSize -= numToCopy; context->slaveRxBuffer = context->slaveRxBuffer[numToCopy]; /* Prepare to read a next chunk of data */ if (context->slaveRxBufferSize > CY_SCB_I2C_FIFO_SIZE) { level = context->slaveRxBufferSize - CY_SCB_I2C_FIFO_SIZE; level = ((level > CY_SCB_I2C_FIFO_SIZE) ? (CY_SCB_I2C_FIFO_SIZE / 2UL) : level) - 1UL; } else { SCB_I2C_CTRL(base) |= SCB_I2C_CTRL_S_NOT_READY_DATA_NACK_Msk; level = (context->slaveRxBufferSize == 0UL) ? (0UL) : (context->slaveRxBufferSize - 1UL); Cy_SCB_SetRxInterruptMask(base, CY_SCB_CLEAR_ALL_INTR_SRC); } /* Set the RX level to trigger an interrupt */ Cy_SCB_SetRxFifoLevel(base, level); } else { /* Continue the transfer: send an ACK */ SCB_I2C_S_CMD(base) |= SCB_I2C_S_CMD_S_ACK_Msk; /* Put data into the RX buffer */ context->slaveRxBuffer[context->slaveRxBufferIdx] = (uint8_t) Cy_SCB_ReadRxFifo(base); ++context->slaveRxBufferIdx; --context->slaveRxBufferSize; } } else { /* Finish a transfer: send a NACK and discard the received byte */ SCB_I2C_S_CMD(base) |= SCB_I2C_S_CMD_S_NACK_Msk; Cy_SCB_SetRxInterruptMask(base, CY_SCB_CLEAR_ALL_INTR_SRC); }} |