FX3 Bootloader SDK CyFx3BootDeviceConfigureIOMatrix returns BAD_ARGUMENT while using GPIO 30,31,32 as simple GPIO

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

cross mob
Anonymous
Not applicable
        Hi, I am actually trying to use more GPIO's in my bootloader application. Now I have the problem that if I like to use GPIO 30, 31, 32 then the function CyFx3BootDeviceConfigureIOMatrix returns with BAD_ARGUMENT. the file cyfx3device.h says at the function description of CyFx3BootDeviceConfigureIOMatrix following: This API completes the IO configuration based on the user specified parameters. Any pin that is not used as part of the GPIF or serial peripheral interfaces can be used as a GPIO. These GPIO's 30..32 are the PMODE pins and I like to read the states of these pins. I also like to use GPIO20(GPIF SLRD) and GPIO53(SPI_SCK). Is there or will there be a function like in the FX3 SDK to Override GPIO pins? thanks, lumpi   
0 Likes
4 Replies
Anonymous
Not applicable

Hi,

   

These could work:

   

void myGpioOverride(uint8_t gpioId, CyBool_t simple)
{
if (gpioId>60) return;
if (simple)
{
if (gpioId<32) *(volatile uint32_t *)(0xe0051000+12) |= (1<<gpioId);
else *(volatile uint32_t *)(0xe0051000+16) |= (1<<(gpioId-32));
}
else
{
if (gpioId<32) *(volatile uint32_t *)(0xe0051000+20) |= (1<<gpioId);
else *(volatile uint32_t *)(0xe0051000+24) |= (1<<(gpioId-32));
}
}

void myGpioRestore(uint8_t gpioId)
{
if (gpioId>60) return;
if (gpioId<32)
{
*(volatile uint32_t *)(0xe0051000+12) &= ~(1<<gpioId); // simple
*(volatile uint32_t *)(0xe0051000+20) &= ~(1<<gpioId); // complex
}
else
{
*(volatile uint32_t *)(0xe0051000+16) &= ~(1<<(gpioId-32)); //simple
*(volatile uint32_t *)(0xe0051000+24) &= ~(1<<(gpioId-32)); //complex
}

   

br,

   

kalev

0 Likes
Anonymous
Not applicable

Hi Kalev,

   

thanks for your answer. The Override function returns success but when I call the "CyFx3BootGpioSetSimpleConfig" then it returns CY_FX3_BOOT_ERROR_NOT_CONFIGURED.

Have you any solution? How can I configure the GPIO's as In-/Output...?

   

Thanks,

   

lumpi

0 Likes
Anonymous
Not applicable

Hi,

   

GPIO  API source is available in SDK  "firmware\lpp_source" directory. See file "cyu3gpio.c" there. You can bypass most of argument checking instructions there. For example below is my variant of CyFx3BootGpioSetSimpleConfig. Note, you need also to include "gpio_regs.h" file from "firmware\u3p_firmware\inc" directory.

   

int myGpioSetSimpleConfig(uint8_t gpioId, CyFx3BootGpioSimpleConfig_t *cfg_p)
{
uint32_t value = 0;
#if 0
if (!glIsGpioActive)
{
return CY_U3P_ERROR_NOT_STARTED;
}

/* Check for parameter validity. */
if (!CyU3PIsGpioValid(gpioId))
{
return CY_U3P_ERROR_BAD_ARGUMENT;
}
if (cfg_p == NULL)
{
return CY_U3P_ERROR_NULL_POINTER;
}
if (cfg_p->intrMode > CY_U3P_GPIO_INTR_HIGH_LEVEL)
{
return CY_U3P_ERROR_BAD_ARGUMENT;
}

/* Validate against the IO matrix. */
if (!CyU3PIsGpioSimpleIOConfigured(gpioId))
{
return CY_U3P_ERROR_NOT_CONFIGURED;
}
#endif
if (gpioId>61 || !cfg_p ) return -1;

/* Input stage. */
if (cfg_p->inputEn)
{
value |= CY_U3P_LPP_GPIO_INPUT_EN;
}
/* Output stage. */
if (cfg_p->driveLowEn)
{
value |= CY_U3P_LPP_GPIO_DRIVE_LO_EN;
}
if (cfg_p->driveHighEn)
{
value |= CY_U3P_LPP_GPIO_DRIVE_HI_EN;
}
if (cfg_p->outValue)
{
value |= CY_U3P_LPP_GPIO_OUT_VALUE;
}

#if 0
// No need for interrupts support in Boot Loader
/* Interrupt mode. */
value |= ((cfg_p->intrMode << CY_U3P_LPP_GPIO_INTRMODE_POS) &
CY_U3P_LPP_GPIO_INTRMODE_MASK);
/* Clear any pending interrupt. */
value |= CY_U3P_LPP_GPIO_INTR;
#endif

/* Enable the GPIO. */
value |= CY_U3P_LPP_GPIO_ENABLE;

/* Write and read back from the register. */
GPIO->lpp_gpio_simple[gpioId] = value;
value = GPIO->lpp_gpio_simple[gpioId];

return 0;
}

   

br,

   

kalev

0 Likes
Anonymous
Not applicable

Hi,

   

thanks for the fast answer. I will try...

   

regrads,

   

lumpi

0 Likes