Skip to content

Commit effaaa6

Browse files
authored
Merge pull request #261 from MacGyverNL/fix_interrupts
Fix interrupts for device with multiple I/O Ports
2 parents 200b3aa + 7f03236 commit effaaa6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cores/nRF5/WInterrupts.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#define NUMBER_OF_GPIO_TE 4
3131
#endif
3232

33+
#ifdef GPIOTE_CONFIG_PORT_Msk
34+
#define GPIOTE_CONFIG_PORT_PIN_Msk (GPIOTE_CONFIG_PORT_Msk | GPIOTE_CONFIG_PSEL_Msk)
35+
#else
36+
#define GPIOTE_CONFIG_PORT_PIN_Msk GPIOTE_CONFIG_PSEL_Msk
37+
#endif
38+
3339
static voidFuncPtr callbacksInt[NUMBER_OF_GPIO_TE];
3440
static bool callbackDeferred[NUMBER_OF_GPIO_TE];
3541
static int8_t channelMap[NUMBER_OF_GPIO_TE];
@@ -95,8 +101,8 @@ int attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
95101
callbacksInt[ch] = callback;
96102
callbackDeferred[ch] = deferred;
97103

98-
NRF_GPIOTE->CONFIG[ch] &= ~(GPIOTE_CONFIG_PSEL_Msk | GPIOTE_CONFIG_POLARITY_Msk);
99-
NRF_GPIOTE->CONFIG[ch] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PSEL_Msk) |
104+
NRF_GPIOTE->CONFIG[ch] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk);
105+
NRF_GPIOTE->CONFIG[ch] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
100106
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk);
101107

102108
NRF_GPIOTE->CONFIG[ch] |= GPIOTE_CONFIG_MODE_Event;

0 commit comments

Comments
 (0)