Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: arduino/ArduinoCore-avr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: arduino/ArduinoCore-avr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: pr_4649
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Nov 13, 2017

  1. Check for valid pin properly (fixes #4605)

    Fix for `pinMode()`, `digitalWrite()`, `digitalRead()` (issue #4605).
    Current behavior: look up pin number in `digital_pin_to_port_PGM[]` and then check if it returned `NOT_A_PIN`.  Causes undefined behavior if provided `pin` number is out of the range of `digital_pin_to_port_PGM[]`.
    Proposed behavior (from issue #4605): check if `pin` is within the valid range of `digital_pin_to_port_PGM[]`, and THEN look it up.
    
    Additionally, remove second check for `port` not being `NOT_A_PIN` (which was useful for boards where the pin numbering skips some numbers).  This can still be achieved by making `bit = digitalPinToBitMask(pin)` be 0 for invalid pins, which causes further bitwise operations such as `*reg &= ~bit;` and `*out |= bit;` to not actually modify the value of the register.  (This removal makes the operation complete a bit faster for valid pins and slower for invalid pins, which I think is a good trade; plus it saves binary size.)
    cousteaulecommandant authored and facchinm committed Nov 13, 2017
    Configuration menu
    Copy the full SHA
    e2016d5 View commit details
    Browse the repository at this point in the history
Loading