- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
thanks for the fast answer. I will try...
regrads,
lumpi