diff options
43 files changed, 667 insertions, 146 deletions
diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..d5d337d --- /dev/null +++ b/.codespellrc @@ -0,0 +1,8 @@ +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = hart,pullrequest +builtin = clear +check-filenames = +check-hidden = +skip = ./.git,./firmwares/arduinoISP,./firmwares/wifishield,./bootloaders diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..03600dd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml new file mode 100644 index 0000000..cfffb75 --- /dev/null +++ b/.github/workflows/check-arduino.yml @@ -0,0 +1,27 @@ +name: Check Arduino + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + compliance: specification + # Always use this setting for official repositories. Remove for 3rd party projects. + official: true + project-type: platform diff --git a/.github/workflows/compile-platform-examples.yml b/.github/workflows/compile-platform-examples.yml new file mode 100644 index 0000000..8e8f5b5 --- /dev/null +++ b/.github/workflows/compile-platform-examples.yml @@ -0,0 +1,206 @@ +name: Compile Examples + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-platform-examples.ya?ml" + - "cores/**" + - "libraries/**" + - "variants/**" + - "boards.txt" + - "platform.txt" + pull_request: + paths: + - ".github/workflows/compile-platform-examples.ya?ml" + - "cores/**" + - "libraries/**" + - "variants/**" + - "boards.txt" + - "platform.txt" + workflow_dispatch: + repository_dispatch: + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:avr:yun + serial: true + softwareserial: true + - fqbn: arduino:avr:uno + serial: true + softwareserial: true + - fqbn: arduino:avr:diecimila:cpu=atmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:diecimila:cpu=atmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:nano:cpu=atmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:nano:cpu=atmega328old + serial: true + softwareserial: true + - fqbn: arduino:avr:nano:cpu=atmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:mega:cpu=atmega2560 + serial: true + softwareserial: true + - fqbn: arduino:avr:mega:cpu=atmega1280 + serial: true + softwareserial: true + - fqbn: arduino:avr:megaADK + serial: true + softwareserial: true + - fqbn: arduino:avr:leonardo + serial: true + softwareserial: true + - fqbn: arduino:avr:leonardoeth + serial: true + softwareserial: true + - fqbn: arduino:avr:micro + serial: true + softwareserial: true + - fqbn: arduino:avr:esplora + serial: true + softwareserial: true + - fqbn: arduino:avr:mini:cpu=atmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:mini:cpu=atmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:ethernet + serial: true + softwareserial: true + - fqbn: arduino:avr:fio + serial: true + softwareserial: true + - fqbn: arduino:avr:bt:cpu=atmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:bt:cpu=atmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:LilyPadUSB + serial: true + softwareserial: true + - fqbn: arduino:avr:lilypad:cpu=atmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:lilypad:cpu=atmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:pro:cpu=16MHzatmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:pro:cpu=8MHzatmega328 + serial: true + softwareserial: true + - fqbn: arduino:avr:pro:cpu=16MHzatmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:pro:cpu=8MHzatmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:atmegang:cpu=atmega168 + serial: true + softwareserial: true + - fqbn: arduino:avr:atmegang:cpu=atmega8 + serial: true + softwareserial: false + - fqbn: arduino:avr:robotControl + serial: true + softwareserial: false + - fqbn: arduino:avr:robotMotor + serial: true + softwareserial: false + - fqbn: arduino:avr:gemma + serial: false + softwareserial: false + - fqbn: arduino:avr:circuitplay32u4cat + serial: true + softwareserial: true + - fqbn: arduino:avr:yunmini + serial: true + softwareserial: true + - fqbn: arduino:avr:chiwawa + serial: true + softwareserial: true + - fqbn: arduino:avr:one + serial: true + softwareserial: true + - fqbn: arduino:avr:unowifi + serial: true + softwareserial: true + + # Make board type-specific customizations to the matrix jobs + include: + - board: + # Boards with Serial interface + serial: true + # Compile these sketches in addition to the ones compiled for all boards + serial-sketch-paths: | + - libraries/EEPROM/examples/eeprom_crc + - libraries/EEPROM/examples/eeprom_get + - libraries/EEPROM/examples/eeprom_put + - libraries/EEPROM/examples/eeprom_read + - libraries/SPI + - libraries/Wire + - board: + serial: false + serial-sketch-paths: "" + - board: + # Boards compatible with the SoftwareSerial library + softwareserial: true + softwareserial-sketch-paths: | + - libraries/SoftwareSerial + - board: + softwareserial: false + softwareserial-sketch-paths: "" + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: | + # Use Boards Manager to install the latest release of the platform to get the toolchain. + - name: arduino:avr + # Overwrite the Boards Manager installation with the platform from the repository. + - source-path: ./ + name: arduino:avr + sketch-paths: | + # Compile these sketches for all boards + - libraries/EEPROM/examples/eeprom_clear + - libraries/EEPROM/examples/eeprom_iteration + - libraries/EEPROM/examples/eeprom_update + - libraries/EEPROM/examples/eeprom_write + # Board-specific sketches + ${{ matrix.serial-sketch-paths }} + ${{ matrix.softwareserial-sketch-paths }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..652be5d --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.yml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..01bee87 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,22 @@ +name: Spell Check + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Spell check + uses: codespell-project/actions-codespell@master @@ -1,4 +1,4 @@ -# See: http://code.google.com/p/arduino/wiki/Platforms +# See: https://arduino.github.io/arduino-cli/latest/platform-specification/ menu.cpu=Processor @@ -15,8 +15,19 @@ yun.vid.2=0x2A03 yun.pid.2=0x0041 yun.vid.3=0x2A03 yun.pid.3=0x8041 +yun.upload_port.0.vid=0x2341 +yun.upload_port.0.pid=0x0041 +yun.upload_port.1.vid=0x2341 +yun.upload_port.1.pid=0x8041 +yun.upload_port.2.vid=0x2A03 +yun.upload_port.2.pid=0x0041 +yun.upload_port.3.vid=0x2A03 +yun.upload_port.3.pid=0x8041 +yun.upload_port.4.board=yun yun.upload.tool=avrdude +yun.upload.tool.default=avrdude +yun.upload.tool.network=arduino_ota yun.upload.protocol=avr109 yun.upload.maximum_size=28672 yun.upload.maximum_data_size=2560 @@ -26,6 +37,7 @@ yun.upload.use_1200bps_touch=true yun.upload.wait_for_upload_port=true yun.bootloader.tool=avrdude +yun.bootloader.tool.default=avrdude yun.bootloader.low_fuses=0xff yun.bootloader.high_fuses=0xd8 yun.bootloader.extended_fuses=0xfb @@ -55,8 +67,19 @@ leonardo.vid.2=0x2A03 leonardo.pid.2=0x0036 leonardo.vid.3=0x2A03 leonardo.pid.3=0x8036 +leonardo.upload_port.0.vid=0x2341 +leonardo.upload_port.0.pid=0x0036 +leonardo.upload_port.1.vid=0x2341 +leonardo.upload_port.1.pid=0x8036 +leonardo.upload_port.2.vid=0x2A03 +leonardo.upload_port.2.pid=0x0036 +leonardo.upload_port.3.vid=0x2A03 +leonardo.upload_port.3.pid=0x8036 +leonardo.upload_port.4.board=leonardo leonardo.upload.tool=avrdude +leonardo.upload.tool.default=avrdude +leonardo.upload.tool.network=arduino_ota leonardo.upload.protocol=avr109 leonardo.upload.maximum_size=28672 leonardo.upload.maximum_data_size=2560 @@ -66,6 +89,7 @@ leonardo.upload.use_1200bps_touch=true leonardo.upload.wait_for_upload_port=true leonardo.bootloader.tool=avrdude +leonardo.bootloader.tool.default=avrdude leonardo.bootloader.low_fuses=0xff leonardo.bootloader.high_fuses=0xd8 leonardo.bootloader.extended_fuses=0xcb @@ -90,8 +114,15 @@ leonardoeth.vid.0=0x2a03 leonardoeth.pid.0=0x0040 leonardoeth.vid.1=0x2a03 leonardoeth.pid.1=0x8040 +leonardoeth.upload_port.0.vid=0x2a03 +leonardoeth.upload_port.0.pid=0x0040 +leonardoeth.upload_port.1.vid=0x2a03 +leonardoeth.upload_port.1.pid=0x8040 +leonardoeth.upload_port.2.board=leonardoeth leonardoeth.upload.tool=avrdude +leonardoeth.upload.tool.default=avrdude +leonardoeth.upload.tool.network=arduino_ota leonardoeth.upload.protocol=avr109 leonardoeth.upload.maximum_size=28672 leonardoeth.upload.maximum_data_size=2560 @@ -101,6 +132,7 @@ leonardoeth.upload.use_1200bps_touch=true leonardoeth.upload.wait_for_upload_port=true leonardoeth.bootloader.tool=avrdude +leonardoeth.bootloader.tool.default=avrdude leonardoeth.bootloader.low_fuses=0xff leonardoeth.bootloader.high_fuses=0xd8 leonardoeth.bootloader.extended_fuses=0xcb @@ -134,8 +166,23 @@ micro.vid.4=0x2341 micro.pid.4=0x0237 micro.vid.5=0x2341 micro.pid.5=0x8237 +micro.upload_port.0.vid=0x2341 +micro.upload_port.0.pid=0x0037 +micro.upload_port.1.vid=0x2341 +micro.upload_port.1.pid=0x8037 +micro.upload_port.2.vid=0x2A03 +micro.upload_port.2.pid=0x0037 +micro.upload_port.3.vid=0x2A03 +micro.upload_port.3.pid=0x8037 +micro.upload_port.4.vid=0x2341 +micro.upload_port.4.pid=0x0237 +micro.upload_port.5.vid=0x2341 +micro.upload_port.5.pid=0x8237 +micro.upload_port.6.board=micro micro.upload.tool=avrdude +micro.upload.tool.default=avrdude +micro.upload.tool.network=arduino_ota micro.upload.protocol=avr109 micro.upload.maximum_size=28672 micro.upload.maximum_data_size=2560 @@ -145,6 +192,7 @@ micro.upload.use_1200bps_touch=true micro.upload.wait_for_upload_port=true micro.bootloader.tool=avrdude +micro.bootloader.tool.default=avrdude micro.bootloader.low_fuses=0xff micro.bootloader.high_fuses=0xd8 micro.bootloader.extended_fuses=0xcb @@ -173,8 +221,19 @@ esplora.vid.2=0x2A03 esplora.pid.2=0x003C esplora.vid.3=0x2A03 esplora.pid.3=0x803C +esplora.upload_port.0.vid=0x2341 +esplora.upload_port.0.pid=0x003C +esplora.upload_port.1.vid=0x2341 +esplora.upload_port.1.pid=0x803C +esplora.upload_port.2.vid=0x2A03 +esplora.upload_port.2.pid=0x003C +esplora.upload_port.3.vid=0x2A03 +esplora.upload_port.3.pid=0x803C +esplora.upload_port.4.board=esplora esplora.upload.tool=avrdude +esplora.upload.tool.default=avrdude +esplora.upload.tool.network=arduino_ota esplora.upload.protocol=avr109 esplora.upload.maximum_size=28672 esplora.upload.maximum_data_size=2560 @@ -184,6 +243,7 @@ esplora.upload.use_1200bps_touch=true esplora.upload.wait_for_upload_port=true esplora.bootloader.tool=avrdude +esplora.bootloader.tool.default=avrdude esplora.bootloader.low_fuses=0xff esplora.bootloader.high_fuses=0xd8 esplora.bootloader.extended_fuses=0xcb @@ -208,8 +268,15 @@ LilyPadUSB.vid.0=0x1B4F LilyPadUSB.pid.0=0x9207 LilyPadUSB.vid.1=0x1B4F LilyPadUSB.pid.1=0x9208 +LilyPadUSB.upload_port.0.vid=0x1B4F +LilyPadUSB.upload_port.0.pid=0x9207 +LilyPadUSB.upload_port.1.vid=0x1B4F +LilyPadUSB.upload_port.1.pid=0x9208 +LilyPadUSB.upload_port.2.board=LilyPadUSB LilyPadUSB.upload.tool=avrdude +LilyPadUSB.upload.tool.default=avrdude +LilyPadUSB.upload.tool.network=arduino_ota LilyPadUSB.upload.protocol=avr109 LilyPadUSB.upload.maximum_size=28672 LilyPadUSB.upload.maximum_data_size=2560 @@ -219,6 +286,7 @@ LilyPadUSB.upload.use_1200bps_touch=true LilyPadUSB.upload.wait_for_upload_port=true LilyPadUSB.bootloader.tool=avrdude +LilyPadUSB.bootloader.tool.default=avrdude LilyPadUSB.bootloader.low_fuses=0xff LilyPadUSB.bootloader.high_fuses=0xd8 LilyPadUSB.bootloader.extended_fuses=0xce @@ -247,8 +315,19 @@ robotControl.vid.2=0x2A03 robotControl.pid.2=0x0038 robotControl.vid.3=0x2A03 robotControl.pid.3=0x8038 +robotControl.upload_port.0.vid=0x2341 +robotControl.upload_port.0.pid=0x0038 +robotControl.upload_port.1.vid=0x2341 +robotControl.upload_port.1.pid=0x8038 +robotControl.upload_port.2.vid=0x2A03 +robotControl.upload_port.2.pid=0x0038 +robotControl.upload_port.3.vid=0x2A03 +robotControl.upload_port.3.pid=0x8038 +robotControl.upload_port.4.board=robotControl robotControl.upload.tool=avrdude +robotControl.upload.tool.default=avrdude +robotControl.upload.tool.network=arduino_ota robotControl.upload.protocol=avr109 robotControl.upload.maximum_size=28672 robotControl.upload.maximum_data_size=2560 @@ -258,6 +337,7 @@ robotControl.upload.use_1200bps_touch=true robotControl.upload.wait_for_upload_port=true robotControl.bootloader.tool=avrdude +robotControl.bootloader.tool.default=avrdude robotControl.bootloader.low_fuses=0xff robotControl.bootloader.high_fuses=0xd8 robotControl.bootloader.extended_fuses=0xcb @@ -286,8 +366,19 @@ robotMotor.vid.2=0x2A03 robotMotor.pid.2=0x0039 robotMotor.vid.3=0x2A03 robotMotor.pid.3=0x8039 +robotMotor.upload_port.0.vid=0x2341 +robotMotor.upload_port.0.pid=0x0039 +robotMotor.upload_port.1.vid=0x2341 +robotMotor.upload_port.1.pid=0x8039 +robotMotor.upload_port.2.vid=0x2A03 +robotMotor.upload_port.2.pid=0x0039 +robotMotor.upload_port.3.vid=0x2A03 +robotMotor.upload_port.3.pid=0x8039 +robotMotor.upload_port.4.board=robotMotor robotMotor.upload.tool=avrdude +robotMotor.upload.tool.default=avrdude +robotMotor.upload.tool.network=arduino_ota robotMotor.upload.protocol=avr109 robotMotor.upload.maximum_size=28672 robotMotor.upload.maximum_data_size=2560 @@ -297,6 +388,7 @@ robotMotor.upload.use_1200bps_touch=true robotMotor.upload.wait_for_upload_port=true robotMotor.bootloader.tool=avrdude +robotMotor.bootloader.tool.default=avrdude robotMotor.bootloader.low_fuses=0xff robotMotor.bootloader.high_fuses=0xd8 robotMotor.bootloader.extended_fuses=0xcb @@ -325,6 +417,7 @@ circuitplay32u4cat.bootloader.file=caterina/Caterina-Circuitplay32u4.hex circuitplay32u4cat.bootloader.unlock_bits=0x3F circuitplay32u4cat.bootloader.lock_bits=0x2F circuitplay32u4cat.bootloader.tool=avrdude +circuitplay32u4cat.bootloader.tool.default=avrdude circuitplay32u4cat.build.mcu=atmega32u4 circuitplay32u4cat.build.f_cpu=8000000L circuitplay32u4cat.build.vid=0x045E @@ -342,8 +435,13 @@ circuitplay32u4cat.upload.disable_flushing=true circuitplay32u4cat.upload.use_1200bps_touch=true circuitplay32u4cat.upload.wait_for_upload_port=true circuitplay32u4cat.upload.tool=avrdude +circuitplay32u4cat.upload.tool.default=avrdude +circuitplay32u4cat.upload.tool.network=arduino_ota circuitplay32u4cat.vid.0=0x239A circuitplay32u4cat.pid.0=0x8011 +circuitplay32u4cat.upload_port.0.vid=0x239A +circuitplay32u4cat.upload_port.0.pid=0x8011 +circuitplay32u4cat.upload_port.1.board=circuitplay32u4cat ############################################################## @@ -354,8 +452,15 @@ yunmini.vid.0=0x2a03 yunmini.pid.0=0x0050 yunmini.vid.1=0x2a03 yunmini.pid.1=0x8050 +yunmini.upload_port.0.vid=0x2a03 +yunmini.upload_port.0.pid=0x0050 +yunmini.upload_port.1.vid=0x2a03 +yunmini.upload_port.1.pid=0x8050 +yunmini.upload_port.2.board=yunmini yunmini.upload.tool=avrdude +yunmini.upload.tool.default=avrdude +yunmini.upload.tool.network=arduino_ota yunmini.upload.protocol=avr109 yunmini.upload.maximum_size=28672 yunmini.upload.maximum_data_size=2560 @@ -365,6 +470,7 @@ yunmini.upload.use_1200bps_touch=true yunmini.upload.wait_for_upload_port=true yunmini.bootloader.tool=avrdude +yunmini.bootloader.tool.default=avrdude yunmini.bootloader.low_fuses=0xff yunmini.bootloader.high_fuses=0xd8 yunmini.bootloader.extended_fuses=0xfb @@ -391,8 +497,15 @@ chiwawa.vid.0=0x2a03 chiwawa.pid.0=0x0056 chiwawa.vid.1=0x2a03 chiwawa.pid.1=0x8056 +chiwawa.upload_port.0.vid=0x2a03 +chiwawa.upload_port.0.pid=0x0056 +chiwawa.upload_port.1.vid=0x2a03 +chiwawa.upload_port.1.pid=0x8056 +chiwawa.upload_port.2.board=chiwawa chiwawa.upload.tool=avrdude +chiwawa.upload.tool.default=avrdude +chiwawa.upload.tool.network=arduino_ota chiwawa.upload.protocol=avr109 chiwawa.upload.maximum_size=28672 chiwawa.upload.maximum_data_size=2560 @@ -402,6 +515,7 @@ chiwawa.upload.use_1200bps_touch=true chiwawa.upload.wait_for_upload_port=true chiwawa.bootloader.tool=avrdude +chiwawa.bootloader.tool.default=avrdude chiwawa.bootloader.low_fuses=0xff chiwawa.bootloader.high_fuses=0xd8 chiwawa.bootloader.extended_fuses=0xfb @@ -428,8 +542,15 @@ one.vid.0=0x2a03 one.pid.0=0x0001 one.vid.1=0x2a03 one.pid.1=0x8001 +one.upload_port.0.vid=0x2a03 +one.upload_port.0.pid=0x0001 +one.upload_port.1.vid=0x2a03 +one.upload_port.1.pid=0x8001 +one.upload_port.2.board=one one.upload.tool=avrdude +one.upload.tool.default=avrdude +one.upload.tool.network=arduino_ota one.upload.protocol=avr109 one.upload.maximum_size=28672 one.upload.maximum_data_size=2560 @@ -439,6 +560,7 @@ one.upload.use_1200bps_touch=true one.upload.wait_for_upload_port=true one.bootloader.tool=avrdude +one.bootloader.tool.default=avrdude one.bootloader.low_fuses=0xff one.bootloader.high_fuses=0xd8 one.bootloader.extended_fuses=0xfb diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index e99d503..561127f 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -219,7 +219,7 @@ void HardwareSerial::flush() _tx_udr_empty_irq(); } // If we get here, nothing is queued anymore (DRIE is disabled) and - // the hardware finished tranmission (TXC is set). + // the hardware finished transmission (TXC is set). } size_t HardwareSerial::write(uint8_t c) diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 17000c2..6ff29d0 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -32,7 +32,7 @@ // using a ring buffer (I think), in which head is the index of the location // to which to write the next incoming character and tail is the index of the // location from which to read. -// NOTE: a "power of 2" buffer size is reccomended to dramatically +// NOTE: a "power of 2" buffer size is recommended to dramatically // optimize all the modulo operations for ring buffers. // WARNING: When buffer sizes are increased to > 256, the buffer index // variables are automatically increased in size, but the extra diff --git a/cores/arduino/HardwareSerial_private.h b/cores/arduino/HardwareSerial_private.h index 761a5e5..2e23cec 100644 --- a/cores/arduino/HardwareSerial_private.h +++ b/cores/arduino/HardwareSerial_private.h @@ -63,7 +63,7 @@ #endif #endif // !defined TXC0 -// Check at compiletime that it is really ok to use the bit positions of +// Check at compile time that it is really ok to use the bit positions of // UART0 for the other UARTs as well, in case these values ever get // changed for future hardware. #if defined(TXC1) && (TXC1 != TXC0 || RXEN1 != RXEN0 || RXCIE1 != RXCIE0 || \ diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index 058a2ab..0097cc1 100644 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -59,7 +59,7 @@ class Print } // default to zero, meaning "a single write may block" - // should be overriden by subclasses with buffering + // should be overridden by subclasses with buffering virtual int availableForWrite() { return 0; } size_t print(const __FlashStringHelper *); diff --git a/cores/arduino/Stream.h b/cores/arduino/Stream.h index 8e950c7..21a247a 100644 --- a/cores/arduino/Stream.h +++ b/cores/arduino/Stream.h @@ -25,7 +25,7 @@ #include <inttypes.h> #include "Print.h" -// compatability macros for testing +// compatibility macros for testing /* #define getInt() parseInt() #define getInt(ignore) parseInt(ignore) diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index 47221b8..1ad268c 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -32,7 +32,7 @@ typedef unsigned long u32; #include "Arduino.h" -// This definitions is usefull if you want to reduce the EP_SIZE to 16 +// This definitions is useful if you want to reduce the EP_SIZE to 16 // at the moment only 64 and 16 as EP_SIZE for all EPs are supported except the control endpoint #ifndef USB_EP_SIZE #define USB_EP_SIZE 64 diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index 77709c3..2cf4cd7 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -95,7 +95,7 @@ public: // returns true on success, false on failure (in which case, the string // is left unchanged). if the argument is null or invalid, the - // concatenation is considered unsucessful. + // concatenation is considered unsuccessful. unsigned char concat(const String &str); unsigned char concat(const char *cstr); unsigned char concat(char c); @@ -152,7 +152,7 @@ public: unsigned char startsWith(const String &prefix, unsigned int offset) const; unsigned char endsWith(const String &suffix) const; - // character acccess + // character access char charAt(unsigned int index) const; void setCharAt(unsigned int index, char c); char operator [] (unsigned int index) const; diff --git a/cores/arduino/abi.cpp b/cores/arduino/abi.cpp index 8d719b8..6e1b0f8 100644 --- a/cores/arduino/abi.cpp +++ b/cores/arduino/abi.cpp @@ -21,15 +21,16 @@ extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); +namespace std { + [[gnu::weak, noreturn]] void terminate() { + abort(); + } +} + void __cxa_pure_virtual(void) { - // We might want to write some diagnostics to uart in this case - //std::terminate(); - abort(); + std::terminate(); } void __cxa_deleted_virtual(void) { - // We might want to write some diagnostics to uart in this case - //std::terminate(); - abort(); + std::terminate(); } - diff --git a/cores/arduino/new b/cores/arduino/new index aa8ecb5..8cf2103 100644 --- a/cores/arduino/new +++ b/cores/arduino/new @@ -1,5 +1,66 @@ /* -this header is for compatibility with standard c++ header names -so that #include<new> works as expected + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "new.h" + +#ifndef NEW_H +#define NEW_H + +#include <stdlib.h> + +namespace std { + struct nothrow_t {}; + extern const nothrow_t nothrow; + + // These are not actually implemented, to prevent overhead and + // complexity. They are still declared to allow implementing + // them in user code if needed. + typedef void (*new_handler)(); + new_handler set_new_handler(new_handler new_p) noexcept; + new_handler get_new_handler() noexcept; + + // This is normally declared in various headers that we do not have + // available, so just define it here. We could also use ::size_t + // below, but then anyone including <new> can no longer assume + // std::size_t is available. + using size_t = ::size_t; +} // namespace std + +[[gnu::weak]] void * operator new(std::size_t size); +[[gnu::weak]] void * operator new[](std::size_t size); + +[[gnu::weak]] void * operator new(std::size_t size, const std::nothrow_t tag) noexcept; +[[gnu::weak]] void * operator new[](std::size_t size, const std::nothrow_t& tag) noexcept; + +void * operator new(std::size_t size, void *place) noexcept; +void * operator new[](std::size_t size, void *place) noexcept; + +[[gnu::weak]] void operator delete(void * ptr) noexcept; +[[gnu::weak]] void operator delete[](void * ptr) noexcept; + +#if __cplusplus >= 201402L +[[gnu::weak]] void operator delete(void* ptr, std::size_t size) noexcept; +[[gnu::weak]] void operator delete[](void * ptr, std::size_t size) noexcept; +#endif // __cplusplus >= 201402L + +[[gnu::weak]] void operator delete(void* ptr, const std::nothrow_t& tag) noexcept; +[[gnu::weak]] void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept; + +void operator delete(void* ptr, void* place) noexcept; +void operator delete[](void* ptr, void* place) noexcept; + +#endif + diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp index fc30cf8..7ca4931 100644 --- a/cores/arduino/new.cpp +++ b/cores/arduino/new.cpp @@ -16,26 +16,102 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdlib.h> +#include "new.h" -void *operator new(size_t size) { - return malloc(size); +// The C++ spec dictates that allocation failure should cause the +// (non-nothrow version of the) operator new to throw an exception. +// Since we expect to have exceptions disabled, it would be more +// appropriate (and probably standards-compliant) to terminate instead. +// Historically failure causes null to be returned, but this define +// allows switching to more robust terminating behaviour (that might +// become the default at some point in the future). Note that any code +// that wants null to be returned can (and should) use the nothrow +// versions of the new statement anyway and is unaffected by this. +// #define NEW_TERMINATES_ON_FAILURE + +namespace std { + // Defined in abi.cpp + void terminate(); + + const nothrow_t nothrow; } -void *operator new[](size_t size) { +static void * new_helper(std::size_t size) { + // Even zero-sized allocations should return a unique pointer, but + // malloc does not guarantee this + if (size == 0) + size = 1; return malloc(size); } -void * operator new(size_t size, void * ptr) noexcept { - (void)size; - return ptr; +void * operator new(std::size_t size) { + void *res = new_helper(size); +#if defined(NEW_TERMINATES_ON_FAILURE) + if (!res) + std::terminate(); +#endif + return res; +} +void * operator new[](std::size_t size) { + return operator new(size); } -void operator delete(void * ptr) { - free(ptr); +void * operator new(std::size_t size, const std::nothrow_t tag) noexcept { +#if defined(NEW_TERMINATES_ON_FAILURE) + // Cannot call throwing operator new as standard suggests, so call + // new_helper directly then + return new_helper(size); +#else + return operator new(size); +#endif +} +void * operator new[](std::size_t size, const std::nothrow_t& tag) noexcept { +#if defined(NEW_TERMINATES_ON_FAILURE) + // Cannot call throwing operator new[] as standard suggests, so call + // malloc directly then + return new_helper(size); +#else + return operator new[](size); +#endif +} + +void * operator new(std::size_t size, void *place) noexcept { + // Nothing to do + (void)size; // unused + return place; +} +void * operator new[](std::size_t size, void *place) noexcept { + return operator new(size, place); } -void operator delete[](void * ptr) { +void operator delete(void * ptr) noexcept { free(ptr); } +void operator delete[](void * ptr) noexcept { + operator delete(ptr); +} +#if __cplusplus >= 201402L +void operator delete(void* ptr, std::size_t size) noexcept { + operator delete(ptr); +} +void operator delete[](void * ptr, std::size_t size) noexcept { + operator delete[](ptr); +} +#endif // __cplusplus >= 201402L + +void operator delete(void* ptr, const std::nothrow_t& tag) noexcept { + operator delete(ptr); +} +void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept { + operator delete[](ptr); +} + +void operator delete(void* ptr, void* place) noexcept { + (void)ptr; (void)place; // unused + // Nothing to do +} +void operator delete[](void* ptr, void* place) noexcept { + (void)ptr; (void)place; // unused + // Nothing to do +} diff --git a/cores/arduino/new.h b/cores/arduino/new.h index 763f5cc..d529853 100644 --- a/cores/arduino/new.h +++ b/cores/arduino/new.h @@ -1,31 +1,3 @@ -/* - Copyright (c) 2014 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef NEW_H -#define NEW_H - -#include <stdlib.h> - -void * operator new(size_t size); -void * operator new[](size_t size); -void * operator new(size_t size, void * ptr) noexcept; -void operator delete(void * ptr); -void operator delete[](void * ptr); - -#endif - +// This file originally used a non-standard name for this Arduino core +// only, so still expose the old new.h name for compatibility. +#include "new" diff --git a/cores/arduino/wiring.c b/cores/arduino/wiring.c index 9727135..8caf455 100644 --- a/cores/arduino/wiring.c +++ b/cores/arduino/wiring.c @@ -125,7 +125,7 @@ void delayMicroseconds(unsigned int us) // 2 microseconds) gives delays longer than desired. //delay_us(us); #if F_CPU >= 24000000L - // for the 24 MHz clock for the aventurous ones, trying to overclock + // for the 24 MHz clock for the adventurous ones trying to overclock // zero delay fix if (!us) return; // = 3 cycles, (4 when true) @@ -135,9 +135,9 @@ void delayMicroseconds(unsigned int us) // delay requested. us *= 6; // x6 us, = 7 cycles - // account for the time taken in the preceeding commands. + // account for the time taken in the preceding commands. // we just burned 22 (24) cycles above, remove 5, (5*4=20) - // us is at least 6 so we can substract 5 + // us is at least 6 so we can subtract 5 us -= 5; //=2 cycles #elif F_CPU >= 20000000L @@ -157,9 +157,9 @@ void delayMicroseconds(unsigned int us) // delay requested. us = (us << 2) + us; // x5 us, = 7 cycles - // account for the time taken in the preceeding commands. + // account for the time taken in the preceding commands. // we just burned 26 (28) cycles above, remove 7, (7*4=28) - // us is at least 10 so we can substract 7 + // us is at least 10 so we can subtract 7 us -= 7; // 2 cycles #elif F_CPU >= 16000000L @@ -174,9 +174,9 @@ void delayMicroseconds(unsigned int us) // delay requested. us <<= 2; // x4 us, = 4 cycles - // account for the time taken in the preceeding commands. + // account for the time taken in the preceding commands. // we just burned 19 (21) cycles above, remove 5, (5*4=20) - // us is at least 8 so we can substract 5 + // us is at least 8 so we can subtract 5 us -= 5; // = 2 cycles, #elif F_CPU >= 12000000L @@ -191,9 +191,9 @@ void delayMicroseconds(unsigned int us) // delay requested. us = (us << 1) + us; // x3 us, = 5 cycles - // account for the time taken in the preceeding commands. + // account for the time taken in the preceding commands. // we just burned 20 (22) cycles above, remove 5, (5*4=20) - // us is at least 6 so we can substract 5 + // us is at least 6 so we can subtract 5 us -= 5; //2 cycles #elif F_CPU >= 8000000L @@ -208,9 +208,9 @@ void delayMicroseconds(unsigned int us) // delay requested. us <<= 1; //x2 us, = 2 cycles - // account for the time taken in the preceeding commands. + // account for the time taken in the preceding commands. // we just burned 17 (19) cycles above, remove 4, (4*4=16) - // us is at least 6 so we can substract 4 + // us is at least 6 so we can subtract 4 us -= 4; // = 2 cycles #else @@ -218,9 +218,9 @@ void delayMicroseconds(unsigned int us) // the overhead of the function calls is 14 (16) cycles if (us <= 16) return; //= 3 cycles, (4 when true) - if (us <= 25) return; //= 3 cycles, (4 when true), (must be at least 25 if we want to substract 22) + if (us <= 25) return; //= 3 cycles, (4 when true), (must be at least 25 if we want to subtract 22) - // compensate for the time taken by the preceeding and next commands (about 22 cycles) + // compensate for the time taken by the preceding and next commands (about 22 cycles) us -= 22; // = 2 cycles // the following loop takes 4 microseconds (4 cycles) // per iteration, so execute it us/4 times diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index e237d6d..0de64f7 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -37,7 +37,6 @@ void analogReference(uint8_t mode) int analogRead(uint8_t pin) { - uint8_t low, high; #if defined(analogPinToChannel) #if defined(__AVR_ATmega32U4__) @@ -74,27 +73,20 @@ int analogRead(uint8_t pin) // without a delay, we seem to read from the wrong channel //delay(1); -#if defined(ADCSRA) && defined(ADCL) +#if defined(ADCSRA) && defined(ADC) // start the conversion sbi(ADCSRA, ADSC); // ADSC is cleared when the conversion finishes while (bit_is_set(ADCSRA, ADSC)); - // we have to read ADCL first; doing so locks both ADCL - // and ADCH until ADCH is read. reading ADCL second would - // cause the results of each conversion to be discarded, - // as ADCL and ADCH would be locked when it completed. - low = ADCL; - high = ADCH; + // ADC macro takes care of reading ADC register. + // avr-gcc implements the proper reading order: ADCL is read first. + return ADC; #else // we dont have an ADC, return 0 - low = 0; - high = 0; + return 0; #endif - - // combine the two bytes - return (high << 8) | low; } // Right now, PWM output only works on the pins with diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index 27a62fc..432a150 100644 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -67,7 +67,7 @@ void pinMode(uint8_t pin, uint8_t mode) // // Mark Sproul: // - Removed inline. Save 170 bytes on atmega1280 -// - changed to a switch statment; added 32 bytes but much easier to read and maintain. +// - changed to a switch statement; added 32 bytes but much easier to read and maintain. // - Added more #ifdefs, now compiles for atmega645 // //static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline)); diff --git a/libraries/EEPROM/README.md b/libraries/EEPROM/README.md index a624136..9ca761d 100644 --- a/libraries/EEPROM/README.md +++ b/libraries/EEPROM/README.md @@ -53,7 +53,7 @@ This function does not return any value. This function will retrieve any object from the EEPROM. Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to read. -This function returns a reference to the `object` passed in. It does not need to be used and is only returned for conveience. +This function returns a reference to the `object` passed in. It does not need to be used and is only returned for convenience. #### **`EEPROM.put( address, object )`** [[_example_]](examples/eeprom_put/eeprom_put.ino) @@ -62,7 +62,7 @@ Two parameters are needed to call this function. The first is an `int` containin This function uses the _update_ method to write its data, and therefore only rewrites changed cells. -This function returns a reference to the `object` passed in. It does not need to be used and is only returned for conveience. +This function returns a reference to the `object` passed in. It does not need to be used and is only returned for convenience. #### **Subscript operator: `EEPROM[address]`** [[_example_]](examples/eeprom_crc/eeprom_crc.ino) @@ -136,4 +136,4 @@ This is useful for STL objects, custom iteration and C++11 style ranged for loop This function returns an `EEPtr` pointing at the location after the last EEPROM cell. Used with `begin()` to provide custom iteration. -**Note:** The `EEPtr` returned is invalid as it is out of range. Infact the hardware causes wrapping of the address (overflow) and `EEPROM.end()` actually references the first EEPROM cell. +**Note:** The `EEPtr` returned is invalid as it is out of range. In fact the hardware causes wrapping of the address (overflow) and `EEPROM.end()` actually references the first EEPROM cell. diff --git a/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino index 8b5121c..3fed10f 100644 --- a/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino +++ b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino @@ -18,9 +18,9 @@ void setup() { Iterate through each byte of the EEPROM storage. Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. + - Arduino Duemilanove: 512 B EEPROM storage. + - Arduino Uno: 1 kB EEPROM storage. + - Arduino Mega: 4 kB EEPROM storage. Rather than hard-coding the length, you should use the pre-provided length function. This will make your code portable to all AVR processors. diff --git a/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino b/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino index 3673b47..b5d68be 100644 --- a/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino +++ b/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino @@ -54,4 +54,4 @@ void setup() { } //End of setup function. -void loop() {}
\ No newline at end of file +void loop() {} diff --git a/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino b/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino index a8a3510..d465035 100644 --- a/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino +++ b/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino @@ -33,9 +33,9 @@ void loop() { Advance to the next address, when at the end restart at the beginning. Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. + - Arduino Duemilanove: 512 B EEPROM storage. + - Arduino Uno: 1 kB EEPROM storage. + - Arduino Mega: 4 kB EEPROM storage. Rather than hard-coding the length, you should use the pre-provided length function. This will make your code portable to all AVR processors. diff --git a/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino b/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino index 5e3db5b..f5b0c0c 100644 --- a/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino +++ b/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino @@ -17,7 +17,7 @@ int address = 0; void setup() { - /** EMpty setup **/ + /** Empty setup **/ } void loop() { @@ -48,9 +48,9 @@ void loop() { Advance to the next address, when at the end restart at the beginning. Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. + - Arduino Duemilanove: 512 B EEPROM storage. + - Arduino Uno: 1 kB EEPROM storage. + - Arduino Mega: 4 kB EEPROM storage. Rather than hard-coding the length, you should use the pre-provided length function. This will make your code portable to all AVR processors. diff --git a/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino b/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino index f9bea64..64e835c 100644 --- a/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino +++ b/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino @@ -36,9 +36,9 @@ void loop() { Advance to the next address, when at the end restart at the beginning. Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. + - Arduino Duemilanove: 512 B EEPROM storage. + - Arduino Uno: 1 kB EEPROM storage. + - Arduino Mega: 4 kB EEPROM storage. Rather than hard-coding the length, you should use the pre-provided length function. This will make your code portable to all AVR processors. diff --git a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino index df73ade..1b8ad70 100644 --- a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino +++ b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino @@ -43,7 +43,7 @@ void setup() { // start the SPI library: SPI.begin(); - // initalize the data ready and chip select pins: + // initialize the data ready and chip select pins: pinMode(dataReadyPin, INPUT); pinMode(chipSelectPin, OUTPUT); @@ -140,4 +140,3 @@ void writeRegister(byte thisRegister, byte thisValue) { // take the chip select high to de-select: digitalWrite(chipSelectPin, HIGH); } - diff --git a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino index 8719058..39e5bf9 100644 --- a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino +++ b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino @@ -14,7 +14,7 @@ The circuit: * All A pins of AD5206 connected to +5V * All B pins of AD5206 connected to ground - * An LED and a 220-ohm resisor in series connected from each W pin to ground + * An LED and a 220-ohm resistor in series connected from each W pin to ground * CS - to digital pin 10 (SS pin) * SDI - to digital pin 11 (MOSI pin) * CLK - to digital pin 13 (SCK pin) @@ -27,7 +27,7 @@ */ -// inslude the SPI library: +// include the SPI library: #include <SPI.h> @@ -64,7 +64,7 @@ void digitalPotWrite(int address, int value) { // take the SS pin low to select the chip: digitalWrite(slaveSelectPin, LOW); delay(100); - // send in the address and value via SPI: + // send in the address and value via SPI: SPI.transfer(address); SPI.transfer(value); delay(100); diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index 5206a09..1e37079 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -106,7 +106,7 @@ private: // slowest (128 == 2 ^^ 7, so clock_div = 6). uint8_t clockDiv; - // When the clock is known at compiletime, use this if-then-else + // When the clock is known at compile time, use this if-then-else // cascade, which the compiler knows how to completely optimize // away. When clock is not known, use a loop instead, which generates // shorter code. diff --git a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino index 61ce88c..061bb70 100644 --- a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino +++ b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino @@ -1,5 +1,5 @@ /* - Software serial multple serial test + Software serial multiple serial test Receives from the hardware serial, sends to software serial. Receives from software serial, sends to hardware serial. @@ -52,4 +52,3 @@ void loop() { // run over and over mySerial.write(Serial.read()); } } - diff --git a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino index 8d7f93e..d8c064b 100644 --- a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino +++ b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino @@ -1,5 +1,5 @@ /* - Software serial multple serial test + Software serial multiple serial test Receives from the two software serial ports, sends to the hardware serial port. @@ -56,7 +56,7 @@ void setup() { } void loop() { - // By default, the last intialized port is listening. + // By default, the last initialized port is listening. // when you want to listen on a port, explicitly select it: portOne.listen(); Serial.println("Data from port one:"); @@ -83,9 +83,3 @@ void loop() { // blank line to separate data from the two ports: Serial.println(); } - - - - - - diff --git a/libraries/SoftwareSerial/src/SoftwareSerial.cpp b/libraries/SoftwareSerial/src/SoftwareSerial.cpp index 3163d7a..5a387ab 100644 --- a/libraries/SoftwareSerial/src/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/src/SoftwareSerial.cpp @@ -409,7 +409,7 @@ int SoftwareSerial::available() if (!isListening())
return 0;
- return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
+ return ((unsigned int)(_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head)) % _SS_MAX_RX_BUFF;
}
size_t SoftwareSerial::write(uint8_t b)
diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino index 4d0a68f..aeb1a9c 100644 --- a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino +++ b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino @@ -3,7 +3,7 @@ // and James Tichenor <http://www.jamestichenor.net> // Demonstrates use of the Wire library reading data from the -// Devantech Utrasonic Rangers SFR08 and SFR10 +// Devantech Ultrasonic Rangers SFR08 and SFR10 // Created 29 April 2006 @@ -13,8 +13,8 @@ #include <Wire.h> void setup() { - Wire.begin(); // join i2c bus (address optional for master) - Serial.begin(9600); // start serial communication at 9600bps + Wire.begin(); // join I2C bus (address optional for master) + Serial.begin(9600); // start serial communication at 9600 bps } int reading = 0; @@ -23,7 +23,7 @@ void loop() { // step 1: instruct sensor to read echoes Wire.beginTransmission(112); // transmit to device #112 (0x70) // the address specified in the datasheet is 224 (0xE0) - // but i2c adressing uses the high 7 bits so it's 112 + // but I2C addressing uses the high 7 bits so it's 112 Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) // use 0x51 for centimeters diff --git a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino index dd40a25..b5da366 100644 --- a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino +++ b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino @@ -13,7 +13,7 @@ #include <Wire.h> void setup() { - Wire.begin(); // join i2c bus (address optional for master) + Wire.begin(); // join I2C bus (address optional for master) } byte val = 0; @@ -31,4 +31,3 @@ void loop() { } delay(500); } - diff --git a/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino b/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino index 3febbf4..295edf7 100644 --- a/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino +++ b/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino @@ -5,7 +5,7 @@ // This program (or code that looks like it) // can be found in many places. // For example on the Arduino.cc forum. -// The original author is not know. +// The original author is not known. // Version 2, Juni 2012, Using Arduino 1.0.1 // Adapted to be as simple as possible by Arduino.cc user Krodal // Version 3, Feb 26 2013 @@ -33,7 +33,7 @@ void setup() { Wire.begin(); Serial.begin(9600); - while (!Serial); // Leonardo: wait for serial monitor + while (!Serial); // Leonardo: wait for Serial Monitor Serial.println("\nI2C Scanner"); } @@ -44,7 +44,7 @@ void loop() { for (byte address = 1; address < 127; ++address) { // The i2c_scanner uses the return value of - // the Write.endTransmisstion to see if + // the Wire.endTransmission to see if // a device did acknowledge to the address. Wire.beginTransmission(address); byte error = Wire.endTransmission(); diff --git a/libraries/Wire/examples/master_reader/master_reader.ino b/libraries/Wire/examples/master_reader/master_reader.ino index ecab72a..e27cac3 100644 --- a/libraries/Wire/examples/master_reader/master_reader.ino +++ b/libraries/Wire/examples/master_reader/master_reader.ino @@ -13,7 +13,7 @@ #include <Wire.h> void setup() { - Wire.begin(); // join i2c bus (address optional for master) + Wire.begin(); // join I2C bus (address optional for master) Serial.begin(9600); // start serial for output } diff --git a/libraries/Wire/examples/master_writer/master_writer.ino b/libraries/Wire/examples/master_writer/master_writer.ino index 5cbea11..7a17668 100644 --- a/libraries/Wire/examples/master_writer/master_writer.ino +++ b/libraries/Wire/examples/master_writer/master_writer.ino @@ -13,7 +13,7 @@ #include <Wire.h> void setup() { - Wire.begin(); // join i2c bus (address optional for master) + Wire.begin(); // join I2C bus (address optional for master) } byte x = 0; diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/libraries/Wire/examples/slave_receiver/slave_receiver.ino index 8051d53..9b3f814 100644 --- a/libraries/Wire/examples/slave_receiver/slave_receiver.ino +++ b/libraries/Wire/examples/slave_receiver/slave_receiver.ino @@ -13,7 +13,7 @@ #include <Wire.h> void setup() { - Wire.begin(8); // join i2c bus with address #8 + Wire.begin(8); // join I2C bus with address #8 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output } diff --git a/libraries/Wire/examples/slave_sender/slave_sender.ino b/libraries/Wire/examples/slave_sender/slave_sender.ino index d2e72bb..6e2ed49 100644 --- a/libraries/Wire/examples/slave_sender/slave_sender.ino +++ b/libraries/Wire/examples/slave_sender/slave_sender.ino @@ -13,7 +13,7 @@ #include <Wire.h> void setup() { - Wire.begin(8); // join i2c bus with address #8 + Wire.begin(8); // join I2C bus with address #8 Wire.onRequest(requestEvent); // register event } diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index c407776..001d924 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -100,7 +100,7 @@ void TwoWire::setClock(uint32_t clock) * when `clearWireTimeoutFlag()` or `setWireTimeoutUs()` is called. * * Note that this timeout can also trigger while waiting for clock stretching or waiting for a second master - * to complete its transaction. So make sure to adapt the timeout to accomodate for those cases if needed. + * to complete its transaction. So make sure to adapt the timeout to accommodate for those cases if needed. * A typical timeout would be 25ms (which is the maximum clock stretching allowed by the SMBus protocol), * but (much) shorter values will usually also work. * @@ -120,7 +120,7 @@ void TwoWire::setWireTimeout(uint32_t timeout, bool reset_with_timeout){ /*** * Returns the TWI timeout flag. * - * @return true if timeout has occured since the flag was last cleared. + * @return true if timeout has occurred since the flag was last cleared. */ bool TwoWire::getWireTimeoutFlag(void){ return(twi_manageTimeoutFlag(false)); diff --git a/libraries/Wire/src/utility/twi.c b/libraries/Wire/src/utility/twi.c index e8a41a2..e09a33c 100644 --- a/libraries/Wire/src/utility/twi.c +++ b/libraries/Wire/src/utility/twi.c @@ -175,7 +175,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen } twi_state = TWI_MRX; twi_sendStop = sendStop; - // reset error state (0xFF.. no error occured) + // reset error state (0xFF.. no error occurred) twi_error = 0xFF; // initialize buffer iteration vars @@ -183,7 +183,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen twi_masterBufferLength = length-1; // This is not intuitive, read on... // On receive, the previously configured ACK/NACK setting is transmitted in // response to the received byte before the interrupt is signalled. - // Therefor we must actually set NACK when the _next_ to last byte is + // Therefore we must actually set NACK when the _next_ to last byte is // received, causing that NACK to be sent in response to receiving the last // expected byte of data. @@ -269,7 +269,7 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait } twi_state = TWI_MTX; twi_sendStop = sendStop; - // reset error state (0xFF.. no error occured) + // reset error state (0xFF.. no error occurred) twi_error = 0xFF; // initialize buffer iteration vars @@ -294,7 +294,7 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait // We need to remove ourselves from the repeated start state before we enable interrupts, // since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning // up. Also, don't enable the START interrupt. There may be one pending from the - // repeated start that we sent outselves, and that would really confuse things. + // repeated start that we sent ourselves, and that would really confuse things. twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR startMicros = micros(); do { @@ -411,7 +411,7 @@ void twi_stop(void) // send stop condition TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO); - // wait for stop condition to be exectued on bus + // wait for stop condition to be executed on bus // TWINT is not set after a stop condition! // We cannot use micros() from an ISR, so approximate the timeout with cycle-counted delays const uint8_t us_per_loop = 8; @@ -490,7 +490,7 @@ void twi_handleTimeout(bool reset){ * Desc returns true if twi has seen a timeout * optionally clears the timeout flag * Input clear_flag: true if we should reset the hardware - * Output none + * Output the value of twi_timed_out_flag when the function was called */ bool twi_manageTimeoutFlag(bool clear_flag){ bool flag = twi_timed_out_flag; diff --git a/platform.txt b/platform.txt index 93eef8e..345b979 100644 --- a/platform.txt +++ b/platform.txt @@ -3,7 +3,7 @@ # ------------------------------ # # For more info: -# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification +# https://arduino.github.io/arduino-cli/latest/platform-specification/ name=XInput AVR Boards version=1.0.2 @@ -89,6 +89,12 @@ recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} preproc.macros.flags=-w -x c++ -E -CC recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}" +# Required discoveries and monitors +# --------------------------------- +pluggable_discovery.required.0=builtin:serial-discovery +pluggable_discovery.required.1=builtin:mdns-discovery +pluggable_monitor.required.serial=builtin:serial-monitor + # AVR Uploader/Programmers tools # ------------------------------ @@ -96,8 +102,6 @@ tools.avrdude.path={runtime.tools.avrdude.path} tools.avrdude.cmd.path={path}/bin/avrdude tools.avrdude.config.path={path}/etc/avrdude.conf -tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA - tools.avrdude.upload.params.verbose=-v tools.avrdude.upload.params.quiet=-q -q # tools.avrdude.upload.verify is needed for backwards compatibility with IDE 1.6.8 or older, IDE 1.6.9 or newer overrides this value @@ -122,7 +126,12 @@ tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verb tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu} -tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port {upload.network.port} -sketch "{build.path}/{build.project_name}.hex" -upload {upload.network.endpoint_upload} -sync {upload.network.endpoint_sync} -reset {upload.network.endpoint_reset} -sync_exp {upload.network.sync_return} +# the following rule is deprecated by pluggable discovery +tools.avrdude.upload.network_pattern="{tools.arduino_ota.cmd}" -address {serial.port} -port {upload.network.port} -sketch "{build.path}/{build.project_name}.hex" -upload {upload.network.endpoint_upload} -sync {upload.network.endpoint_sync} -reset {upload.network.endpoint_reset} -sync_exp {upload.network.sync_return} + +# arduino ota +tools.arduino_ota.cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.arduino_ota.upload.pattern="{cmd}" -address {upload.port.address} -port {upload.port.properties.port} -sketch "{build.path}/{build.project_name}.hex" -upload {upload.port.properties.endpoint_upload} -sync {upload.port.properties.endpoint_sync} -reset {upload.port.properties.endpoint_reset} -sync_exp {upload.port.properties.sync_return} # USB Default Flags # Default blank usb manufacturer will be filled in at compile time |