Skip to content

Commit

Permalink
fix(Boards, Examples): Fix MAX32690 GPIO Example (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Carter authored Aug 17, 2023
1 parent 79c58c7 commit c2a218b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Examples/MAX32690/GPIO/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,19 @@
/***** Globals *****/

/***** Functions *****/
void gpio_isr(void *cbdata)
{
MXC_Delay(MXC_DELAY_MSEC(100));
uint32_t flags = MXC_GPIO_GetFlags(MXC_GPIO_PORT_IN);
MXC_GPIO_ClearFlags(MXC_GPIO_PORT_IN, flags);

void gpio_callback(void *cbdata)
{
mxc_gpio_cfg_t *cfg = cbdata;
MXC_GPIO_OutToggle(cfg->port, cfg->mask);
}

void gpio_isr(void)
{
MXC_Delay(MXC_DELAY_MSEC(100)); // Debounce
MXC_GPIO_Handler(MXC_GPIO_GET_IDX(MXC_GPIO_PORT_IN));
}

int main(void)
{
mxc_gpio_cfg_t gpio_out;
Expand Down Expand Up @@ -111,10 +114,11 @@ int main(void)
gpio_interrupt.func = MXC_GPIO_FUNC_IN;
gpio_interrupt.vssel = MXC_GPIO_VSSEL_VDDIOH;
MXC_GPIO_Config(&gpio_interrupt);
MXC_GPIO_RegisterCallback(&gpio_interrupt, gpio_isr, &gpio_interrupt_status);
MXC_GPIO_RegisterCallback(&gpio_interrupt, gpio_callback, &gpio_interrupt_status);
MXC_GPIO_IntConfig(&gpio_interrupt, MXC_GPIO_INT_FALLING);
MXC_GPIO_EnableInt(gpio_interrupt.port, gpio_interrupt.mask);
NVIC_EnableIRQ(MXC_GPIO_GET_IRQ(MXC_GPIO_GET_IDX(MXC_GPIO_PORT_IN)));
MXC_NVIC_SetVector(MXC_GPIO_GET_IRQ(MXC_GPIO_GET_IDX(MXC_GPIO_PORT_IN)), gpio_isr);

/* Setup output pin. */
gpio_out.port = MXC_GPIO_PORT_OUT;
Expand Down
6 changes: 6 additions & 0 deletions Libraries/Boards/MAX32690/EvKit_V1/Source/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ __weak void GPIOWAKE_IRQHandler(void)
MXC_GPIO_Handler(MXC_GPIO_GET_IDX(MXC_GPIO4));
}

// Default handler for generic GPIO interrupts on port 2 (used by GPIO example)
__weak void GPIO2_IRQHandler(void)
{
MXC_GPIO_Handler(MXC_GPIO_GET_IDX(MXC_GPIO2));
}

/******************************************************************************/
int Board_Init(void)
{
Expand Down

0 comments on commit c2a218b

Please sign in to comment.