I want to use GPIO to simulate I2C, as we all know, SDA is bidirectional IO. How can i configure this GPIO?
additionally, I using CYUSB3014.
Please check the I2C GPIO example in the firmware examples folder in the sdk installed location.
Gokul Prasath N
Thanks for reply. I know those examples in SDK installed folder. Those examples use FX3API to configure I2C. I don't want to use this API to configure I2C. I want to use GPIO 50 and GPIO 51 to simulate I2C and write all I2C functions myself.SDA is bidirectional IO. How can i configure this GPIO? The following code is configure of SCL, which is unidirectional. outValue is true and inputEn is false. How to configure SDA? This GPIO is bidirectional.
/*Configure GPIO 50 as output(I2C_CLOCK). */gpioConfig.outValue = CyTrue;gpioConfig.inputEn = CyFalse;gpioConfig.driveLowEn = CyTrue;gpioConfig.driveHighEn = CyTrue;gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;apiRetStatus = CyU3PGpioSetSimpleConfig(FX3_I2C_CLK, &gpioConfig);
I dont think cypress allows both input and output are configured to a same GPIO pin. It is recommended not to use. You may try like having two sda pins one for i/p and other for o/p(May work).
According I2C specification, both SDA and SCL are actually open-drain bidirectional lines.
gpioConfig.inputEn=CyTrue; //read signal value from pin (not from output register)
gpioConfig.driveLowEn=CyTrue; //if output value=0 then drive this value to pin, i.e. pull pin low
gpioConfig.driveHighEn=CyFalse; //if output value=1 then do not drive this value to pin, i.e. tri-state pin
Hi, Gokul and Kalev
Thanks for replies and suggestions.