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

Robert Hartung notifications at github.com
Wed Jul 24 10:44:59 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);
+                }

The idea is *not* to toggle the bit, but to set the bit correctly to 1 or 0. Using your syntax does not work here!

-- 
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_r306694677
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190724/484cee9b/attachment-0001.htm>


More information about the notifications mailing list