Specifications
CY8CKIT-042 PSoC 4 Pioneer Kit Guide, Doc. # 001-86371 Rev. *D 79
Advanced Topics
Figure 6-24. Pin Selection
6. Place the following code in your main.c project file. The code will enable the PSoC 4 device to
transmit and receive I2C data to and from the BCP application.
int main()
{
uint8 wrBuf[10]; /* I2C write buffer */
uint8 rdBuf[10]; /* I2C read buffer */
uint8 indexCntr;
uint32 byteCnt;
/* Enable the Global Interrupt */
CyGlobalIntEnable;
/* Start I2C Slave operation */
I2C_Start();
/* Initialize write buffer */
I2C_I2CSlaveInitWriteBuf((uint8 *) wrBuf, 10);
/* Initialize read buffer */
I2C_I2CSlaveInitReadBuf((uint8 *) rdBuf, 10);
for(;;) /* Loop forever */
{
/* Wait for I2C master to complete a write */