[riot-notifications] [RIOT-OS/RIOT] cpu/atmega_common: pseudomodule-based pin change interrupt implementation (#11122)

Robert Hartung notifications at github.com
Thu Jul 25 10:11:55 CEST 2019


roberthartung commented on this pull request.



> +        if (enabled_pcints & 0x1) {
+            /* re-construct mask from pin number*/
+            uint8_t pin_mask = (1 << pin_num);
+            /* get pin from mapping (assumes 8 entries per bank!) */
+            gpio_t pin = pcint_mapping[ bank * 8 + pin_num ];
+            uint8_t port_value = (_SFR_MEM8(_pin_addr( pin )));
+            uint8_t pin_value = ((port_value & pin_mask) != 0);
+            uint8_t old_state = ((pcint_state[ bank ] & pin_mask) != 0);
+            gpio_isr_ctx_pcint_t *conf = &pcint_config[ bank * 8 + pin_num ];
+            if (old_state != pin_value) {
+                if (pin_value) {
+                    pcint_state[ bank ] |= (pin_mask);
+                }
+                else {
+                    pcint_state[ bank ] &= ~(pin_mask);
+                }

In the latter case for the `!=` I agree, then we can toggle. For the initial state you can't!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11122#discussion_r307167060
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190725/c2d3deaf/attachment.htm>


More information about the notifications mailing list