User Manual Part 2

CY8CKIT-042-BLE Bluetooth® Low Energy (BLE) Pioneer Kit Guide, Doc. # 001-93731 Rev. *A 129
Advanced Topics
5. Select pin P3[5] for the I
2
C SCL and pin P3[4] for the I
2
C SDA in the Pins tab of
<Project_Name>.cydwr, as shown in Figure 6-21.
Figure 6-21. Pin Selection_USBI2C
6. Place the following code in your
main.c project file. The code will enable the PSoC 4 BLE/PRoC
BLE device to transmit and receive I
2
C data to and from the BCP application.
int main()
{
uint8 wrBuf[10]; /* I
2
C write buffer */
uint8 rdBuf[10]; /* I
2
C read buffer */
uint8 indexCntr;
uint32 byteCnt;
/* Enable the Global Interrupt */
CyGlobalIntEnable;
/* Start I
2
C 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 I
2
C master to complete a write */