How to set GPIO's default's value.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Peya_4162826
Level 2
Level 2
First like received

I use api "CyU3PDeviceConfigureIOMatrix" to enable some GPIOs, while enable it, Is it high or low for these GPIO's? how to set to high while is enabling?

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello Peter,

You can configure the GPIO:

    CyU3PGpioSimpleConfig_t gpioConfig;

    /* Configure GPIO 21 as output */

    gpioConfig.outValue = CyFalse;      //This will set the initial value of the GPIO to Low. You can set initial value of GPIO using this field

    gpioConfig.driveLowEn = CyFalse;

    gpioConfig.driveHighEn = CyFalse;

    gpioConfig.inputEn = CyTrue;

    gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;

    apiRetStatus = CyU3PGpioSetSimpleConfig(21, &gpioConfig);

You can also refer to the GPIOAPP example of the SDK   Path : \Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxgpioapp

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
2 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello Peter,

You can configure the GPIO:

    CyU3PGpioSimpleConfig_t gpioConfig;

    /* Configure GPIO 21 as output */

    gpioConfig.outValue = CyFalse;      //This will set the initial value of the GPIO to Low. You can set initial value of GPIO using this field

    gpioConfig.driveLowEn = CyFalse;

    gpioConfig.driveHighEn = CyFalse;

    gpioConfig.inputEn = CyTrue;

    gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;

    apiRetStatus = CyU3PGpioSetSimpleConfig(21, &gpioConfig);

You can also refer to the GPIOAPP example of the SDK   Path : \Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxgpioapp

Regards,

Rashi

Regards,
Rashi
0 Likes
GuSc_293616
Level 3
Level 3
5 likes given First like given

or some other config options:

  • TriState

  CyU3PGpioSimpleConfig_t gpioConfigTriState;

  gpioConfigTriState.intrMode   = CY_U3P_GPIO_NO_INTR;

  gpioConfigTriState.inputEn    = CyFalse;

  gpioConfigTriState.driveLowEn = CyFalse;

  gpioConfigTriState.driveHighEn= CyFalse;

  gpioConfigTriState.outValue   = CyFalse;

  • Output (high level )

CyU3PGpioSimpleConfig_t gpioConfigOutput_On;

  gpioConfigOutput_On.outValue = CyTrue;

  gpioConfigOutput_On.driveLowEn = CyTrue;

  gpioConfigOutput_On.driveHighEn = CyTrue;

  gpioConfigOutput_On.inputEn = CyFalse;

  gpioConfigOutput_On.intrMode = CY_U3P_GPIO_NO_INTR;

  • Output (low level )

CyU3PGpioSimpleConfig_t gpioConfigOutput_Off;

  gpioConfigOutput_Off.outValue = CyFalse;

  gpioConfigOutput_Off.driveLowEn = CyTrue;

  gpioConfigOutput_Off.driveHighEn = CyTrue;

  gpioConfigOutput_Off.inputEn = CyFalse;

  gpioConfigOutput_Off.intrMode = CY_U3P_GPIO_NO_INTR;

  • Input

  CyU3PGpioSimpleConfig_t gpioConfigInput;

  gpioConfigInput.inputEn = CyTrue;

  gpioConfigInput.driveLowEn = CyFalse;

  gpioConfigInput.driveHighEn = CyFalse;

  gpioConfigInput.outValue = CyTrue; // I think it is ignored

  gpioConfigInput.intrMode = CY_U3P_GPIO_NO_INTR;

Keep in mind if you not set  CyU3PGpioSimpleConfig_t::driveLowEn and CyU3PGpioSimpleConfig_t::gpioConfigInput.driveHighEn to true for a output the pin keeps tristated!

0 Likes