I have several GPIO interrupts that need to share the same GPIO port as the Card Detect GPIO pin I am using for the sdcard.
In fsl_sdmmc_host.c, card detect has a GPIO interrupt handler defined. It uses variables scoped only to fsl_sdmmc_host.c.
What is the recommendation to add additional GPIO interrupts and keep the CD interrupt handler? I didn't want to have to make substantial changes to the SDK component, but I don't see many other options.
Solved! Go to Solution.
Here is what I ended up doing, although modifying the SDK code isn't desirable.
I have my project specific interrupt handlers defined in a local header file. For the Card Detect handler included in the SDK, I had to comment out the provided code and create a separate function that I call from my own handler.
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
extern "C"
{
#endif
void GPIO1_Combined_0_15_IRQHandler()
{
if (GPIO_PortGetInterruptFlags(GPIO1) & (1U << ENCODER0_GPIO_PIN_A))
{
GPIO_PortClearInterruptFlags(GPIO1, 1U << ENCODER0_GPIO_PIN_A);
// do something
}
else if (SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS() & (1U << BOARD_USDHC_CD_GPIO_PIN))
{
CD_Handler();
}
}
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
}
#endif
Here is the modified handler I put in the SDK:
// void SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_HANDLER(void)
// {
// if (SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS() & (1U << BOARD_USDHC_CD_GPIO_PIN))
// {
// SDMMCHOST_NofiyCardInsertStatus((SDMMCHOST_CARD_DETECT_GPIO_STATUS() == SDMMCHOST_CARD_INSERT_CD_LEVEL),
// ((sdmmhostcard_usr_param_t *)s_usdhcHandle.userData)->cd);
// }
// /* Clear interrupt flag.*/
// SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS_CLEAR(~0U);
// SDMMCEVENT_Notify(kSDMMCEVENT_CardDetect);
// }
void CD_Handler(void)
{
SDMMCHOST_NofiyCardInsertStatus((SDMMCHOST_CARD_DETECT_GPIO_STATUS() == SDMMCHOST_CARD_INSERT_CD_LEVEL), ((sdmmhostcard_usr_param_t*) s_usdhcHandle.userData)->cd);
/* Clear interrupt flag.*/
SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS_CLEAR(~0U);
SDMMCEVENT_Notify(kSDMMCEVENT_CardDetect);
}
Here is what I ended up doing, although modifying the SDK code isn't desirable.
I have my project specific interrupt handlers defined in a local header file. For the Card Detect handler included in the SDK, I had to comment out the provided code and create a separate function that I call from my own handler.
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
extern "C"
{
#endif
void GPIO1_Combined_0_15_IRQHandler()
{
if (GPIO_PortGetInterruptFlags(GPIO1) & (1U << ENCODER0_GPIO_PIN_A))
{
GPIO_PortClearInterruptFlags(GPIO1, 1U << ENCODER0_GPIO_PIN_A);
// do something
}
else if (SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS() & (1U << BOARD_USDHC_CD_GPIO_PIN))
{
CD_Handler();
}
}
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
}
#endif
Here is the modified handler I put in the SDK:
// void SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_HANDLER(void)
// {
// if (SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS() & (1U << BOARD_USDHC_CD_GPIO_PIN))
// {
// SDMMCHOST_NofiyCardInsertStatus((SDMMCHOST_CARD_DETECT_GPIO_STATUS() == SDMMCHOST_CARD_INSERT_CD_LEVEL),
// ((sdmmhostcard_usr_param_t *)s_usdhcHandle.userData)->cd);
// }
// /* Clear interrupt flag.*/
// SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS_CLEAR(~0U);
// SDMMCEVENT_Notify(kSDMMCEVENT_CardDetect);
// }
void CD_Handler(void)
{
SDMMCHOST_NofiyCardInsertStatus((SDMMCHOST_CARD_DETECT_GPIO_STATUS() == SDMMCHOST_CARD_INSERT_CD_LEVEL), ((sdmmhostcard_usr_param_t*) s_usdhcHandle.userData)->cd);
/* Clear interrupt flag.*/
SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS_CLEAR(~0U);
SDMMCEVENT_Notify(kSDMMCEVENT_CardDetect);
}
Hello,
Yes, as mentioned you have to differentiate the pin by the interrupt status Flag, as you did.
Have a nice day,
Regards
Soledad