You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/02/04 08:55:10 UTC

[GitHub] kasjer commented on a change in pull request #1629: hw/mcu/nrf52: Add option to use GPIOTE port event

kasjer commented on a change in pull request #1629: hw/mcu/nrf52: Add option to use GPIOTE port event
URL: https://github.com/apache/mynewt-core/pull/1629#discussion_r253378971
 
 

 ##########
 File path: hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
 ##########
 @@ -207,17 +218,83 @@ hal_gpio_toggle(int pin)
 static void
 hal_gpio_irq_handler(void)
 {
+#if MYNEWT_VAL(MCU_GPIO_USE_PORT_EVENT)
+    NRF_GPIO_Type *nrf_gpio;
+    int pin_index;
+    int pin_state;
+    uint8_t sense_trig;
+#if NRF52840_XXAA
+    uint64_t gpio_state;
+#else
+    uint32_t gpio_state;
+#endif
+#endif
     int i;
 
     os_trace_isr_enter();
 
+#if MYNEWT_VAL(MCU_GPIO_USE_PORT_EVENT)
+    NRF_GPIOTE->EVENTS_PORT = 0;
+
+    gpio_state = NRF_P0->IN;
+#if NRF52840_XXAA
+    gpio_state |= (uint64_t)NRF_P1->IN << 32;
+#endif
+#endif
+
     for (i = 0; i < HAL_GPIO_MAX_IRQ; i++) {
+#if MYNEWT_VAL(MCU_GPIO_USE_PORT_EVENT)
+        if ((!hal_gpio_irqs[i].func) ||
+            (hal_gpio_irqs[i].sense_trig == HAL_GPIO_SENSE_TRIG_NONE)) {
+            continue;
+        }
+
+        nrf_gpio = HAL_GPIO_PORT(hal_gpio_irqs[i].pin);
+        pin_index = HAL_GPIO_INDEX(hal_gpio_irqs[i].pin);
+
+        /* Store current SENSE setting */
+        sense_trig = (nrf_gpio->PIN_CNF[pin_index] & GPIO_PIN_CNF_SENSE_Msk) >> GPIO_PIN_CNF_SENSE_Pos;
+
+        if (!sense_trig) {
+            continue;
+        }
+
+        /*
+         * A little hack... SENSE values are 0x02 for high and 0x03 for low, so
+         * bit #0 is the opposite of state which triggers interrupt.
+         */
+        pin_state = gpio_state & (1 << hal_gpio_irqs[i].pin);
 
 Review comment:
   For 52840 64 bits from gpio_state will not fit in 32 bits of pin_state

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services