Merge pull request #261 from MacGyverNL/fix_interrupts

Fix interrupts for device with multiple I/O Ports
This commit is contained in:
hathach authored and GitHub committed 2019-05-06 10:10:02 +07:00
commit effaaa6ef3
1 file changed
+8 -2
+8 -2
View File
@@ -30,6 +30,12 @@
#define NUMBER_OF_GPIO_TE 4
#endif
#ifdef GPIOTE_CONFIG_PORT_Msk
#define GPIOTE_CONFIG_PORT_PIN_Msk (GPIOTE_CONFIG_PORT_Msk | GPIOTE_CONFIG_PSEL_Msk)
#else
#define GPIOTE_CONFIG_PORT_PIN_Msk GPIOTE_CONFIG_PSEL_Msk
#endif
static voidFuncPtr callbacksInt[NUMBER_OF_GPIO_TE];
static bool callbackDeferred[NUMBER_OF_GPIO_TE];
static int8_t channelMap[NUMBER_OF_GPIO_TE];
@@ -95,8 +101,8 @@ int attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
callbacksInt[ch] = callback;
callbackDeferred[ch] = deferred;
NRF_GPIOTE->CONFIG[ch] &= ~(GPIOTE_CONFIG_PSEL_Msk | GPIOTE_CONFIG_POLARITY_Msk);
NRF_GPIOTE->CONFIG[ch] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PSEL_Msk) |
NRF_GPIOTE->CONFIG[ch] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk);
NRF_GPIOTE->CONFIG[ch] |= ((pin << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) |
((polarity << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk);
NRF_GPIOTE->CONFIG[ch] |= GPIOTE_CONFIG_MODE_Event;