Skip to content

Commit

Permalink
Fix ME18 USB examples hanging in GPIO0_IRQhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Scheiffler committed Oct 6, 2023
1 parent 2e9223d commit 27b2877
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Examples/MAX32690/USB_CompositeDevice_MSC_HID/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "msc.h"
#include "descriptors.h"
#include "mscmem.h"
#include "nvic_table.h"

/* **** Definitions **** */
#define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS
Expand Down Expand Up @@ -113,15 +114,25 @@ int Hid_SW_Init(void)
}

/******************************************************************************/
void HID_SW_Handler(void)
{
MXC_GPIO_Handler(MXC_GPIO_GET_IDX(hid_sw[0].port));
}

int Hid_SW_RegisterCallback(unsigned int pb, pb_callback callback)
{
if(pb != 0) {
return E_INVALID;
}

if (callback) {
// Register callback
MXC_GPIO_RegisterCallback(&hid_sw[pb], callback, (void *)pb);

// Configure and enable interrupt
MXC_GPIO_IntConfig(&hid_sw[pb], MXC_GPIO_INT_FALLING);
MXC_GPIO_EnableInt(hid_sw[pb].port, hid_sw[pb].mask);
MXC_NVIC_SetVector(MXC_GPIO_GET_IRQ(MXC_GPIO_GET_IDX(hid_sw[pb].port)), HID_SW_Handler);
NVIC_EnableIRQ(MXC_GPIO_GET_IRQ(MXC_GPIO_GET_IDX(hid_sw[pb].port)));
} else { // Disable interrupt and clear callback
MXC_GPIO_DisableInt(hid_sw[pb].port, hid_sw[pb].mask);
Expand Down
11 changes: 11 additions & 0 deletions Examples/MAX32690/USB_HIDKeyboard/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "enumerate.h"
#include "hid_kbd.h"
#include "descriptors.h"
#include "nvic_table.h"

/***** Definitions *****/
#define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS
Expand Down Expand Up @@ -99,15 +100,25 @@ int Hid_SW_Init(void)
}

/******************************************************************************/
void HID_SW_Handler(void)
{
MXC_GPIO_Handler(MXC_GPIO_GET_IDX(hid_sw[0].port));
}

int Hid_SW_RegisterCallback(unsigned int pb, pb_callback callback)
{
if(pb != 0) {
return E_INVALID;
}

if (callback) {
// Register callback
MXC_GPIO_RegisterCallback(&hid_sw[pb], callback, (void *)pb);

// Configure and enable interrupt
MXC_GPIO_IntConfig(&hid_sw[pb], MXC_GPIO_INT_FALLING);
MXC_GPIO_EnableInt(hid_sw[pb].port, hid_sw[pb].mask);
MXC_NVIC_SetVector(MXC_GPIO_GET_IRQ(MXC_GPIO_GET_IDX(hid_sw[pb].port)), HID_SW_Handler);
NVIC_EnableIRQ(MXC_GPIO_GET_IRQ(MXC_GPIO_GET_IDX(hid_sw[pb].port)));
} else { // Disable interrupt and clear callback
MXC_GPIO_DisableInt(hid_sw[pb].port, hid_sw[pb].mask);
Expand Down

0 comments on commit 27b2877

Please sign in to comment.