EZ-USB FX3 Technical Reference Manual, Document Number: 001-76074 Rev. *F 195
Low Performance Peripherals (LPP)
/* Init the GPIO module */
gpioClock.fastClkDiv = 2;
gpioClock.slowClkDiv = 0;
gpioClock.simpleDiv = CY_U3P_GPIO_SIMPLE_DIV_BY_2;
gpioClock.clkSrc = CY_U3P_SYS_CLK;
gpioClock.halfDiv = 0;
apiRetStatus = CyU3PGpioInit(&gpioClock, NULL);
The CyU3PGpioSetSimpleConfig API configures a simple GPIO. The code for configuring GPIO[45] is as follows. GPIO[45] is
configured as input, and interrupt is enabled for both edges of GPIO[45].
/* Configure GPIO 45 as input with interrupt enabled for both edges */
gpioConfig.outValue = CyTrue;
gpioConfig.inputEn = CyTrue;
gpioConfig.driveLowEn = CyFalse;
gpioConfig.driveHighEn = CyFalse;
gpioConfig.intrMode = CY_U3P_GPIO_INTR_BOTH_EDGE;
CyU3PGpioSetSimpleConfig(45, &gpioConfig);
GPIO[21] needs to be overridden, as this pin is associated with the GPIF II control signal. The
CyU3PDeviceConfigureIOMatrix call cannot select the I/O as a GPIO, as it is part of the GPIF II I/Os. An override API call
must be made with caution, as this will change the functionality of the pin. If the I/O line is used as part of GPIF II and is
connected to an external device, then the line will no longer behave as a GPIF II I/O. Here the CTL4 line is not used by the
GPIF II block, so it is safe to override.
CyU3PDeviceGpioOverride (21, CyTrue);
GPIO[21] can be configured as an output using the following code. No interrupt is enabled
corresponding to this I/O change.
gpioConfig.outValue = CyFalse;
gpioConfig.driveLowEn = CyTrue;
gpioConfig.driveHighEn = CyTrue;
gpioConfig.inputEn = CyFalse;
gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;
CyU3PGpioSetSimpleConfig(21, &gpioConfig);
Use the followingcode to get the status of GPIO[45].
/* Get the status of the pin */
CyU3PGpioGetValue (45, &gpioValue);
Use the following code to set the value of GPIO[21].
/* Set the GPIO 21 to high */
CyU3PGpioSetValue (21, CyTrue);
GPIO[21] can be driven low by changing the second parameter of the CyU3PGpioSetValue API.
/* Set the GPIO 21 to low */
CyU3PGpioSetValue (21, CyFalse);