├── .codespellignore ├── .codespellrc ├── .gitattributes ├── .github ├── issue_template.md ├── pull_request_template.md └── workflows │ ├── README.md │ ├── linter.yaml │ ├── linux.yaml │ ├── macos.yaml │ ├── spelling.yaml │ └── windows.yaml ├── .gitignore ├── .markdown-lint.json ├── .rspec ├── .rubocop.yml ├── .yardopts ├── CHANGELOG.md ├── CONTRIBUTING.md ├── CPPLINT.cfg ├── Gemfile ├── LICENSE ├── README.md ├── REFERENCE.md ├── SampleProjects ├── BusIO │ ├── .arduino-ci.yml │ ├── .gitignore │ ├── Gemfile │ ├── README.md │ ├── examples │ │ └── spi_readwrite │ │ │ └── spi_readwrite.ino │ ├── library.properties │ ├── src │ │ └── BusIO.h │ └── test │ │ └── busio.cpp ├── DependOnSomething │ ├── library.properties │ ├── src │ │ ├── YesDeps.cpp │ │ └── YesDeps.h │ └── test │ │ └── null.cpp ├── DoSomething │ ├── .arduino-ci.yaml │ ├── .gitignore │ ├── .travis.yml │ ├── Gemfile │ ├── LICENSE │ ├── README.md │ ├── do-something.cpp │ ├── do-something.h │ ├── examples │ │ └── DoSomethingExample │ │ │ └── DoSomethingExample.ino │ ├── library.properties │ └── test │ │ ├── README.md │ │ ├── bad-errormessages.cpp │ │ ├── bad-null.cpp │ │ ├── good-assert.cpp │ │ ├── good-library.cpp │ │ └── good-null.cpp ├── ExcludeSomething │ ├── .arduino-ci.yml │ ├── README.md │ ├── library.properties │ ├── src │ │ ├── exclude-something.cpp │ │ ├── exclude-something.h │ │ └── excludeThis │ │ │ ├── exclude-this.cpp │ │ │ └── exclude-this.h │ └── test │ │ └── null.cpp ├── NetworkLib │ ├── .arduino-ci.yml │ ├── .gitignore │ ├── Gemfile │ ├── README.md │ ├── examples │ │ └── EthernetExample │ │ │ └── EthernetExample.ino │ ├── library.properties │ ├── scripts │ │ └── install.sh │ ├── src │ │ ├── NetworkLib.cpp │ │ └── NetworkLib.h │ └── test │ │ ├── client.cpp │ │ └── test.cpp ├── OnePointFiveDummy │ ├── NoBase.cpp │ ├── NoBase.h │ ├── README.md │ ├── library.properties │ ├── src │ │ ├── YesSrc.cpp │ │ ├── YesSrc.h │ │ └── subdir │ │ │ ├── YesSubdir.cpp │ │ │ └── YesSubdir.h │ ├── test │ │ └── null.cpp │ └── utility │ │ ├── ImNotHere.cpp │ │ └── ImNotHere.h ├── OnePointFiveMalformed │ ├── README.md │ ├── YesBase.cpp │ ├── YesBase.h │ ├── src │ │ ├── ImNotHere.cpp │ │ └── ImNotHere.h │ └── utility │ │ ├── YesUtil.cpp │ │ └── YesUtil.h ├── OnePointOhDummy │ ├── README.md │ ├── YesBase.cpp │ ├── YesBase.h │ ├── src │ │ ├── ImNotHere.cpp │ │ └── ImNotHere.h │ ├── test │ │ └── null.cpp │ └── utility │ │ ├── YesUtil.cpp │ │ └── YesUtil.h ├── README.md ├── SharedLibrary │ ├── .arduino-ci.yml │ ├── .gitignore │ ├── Gemfile │ ├── README.md │ ├── library.properties │ ├── src │ │ ├── SharedLibrary.cpp │ │ └── SharedLibrary.h │ ├── test.sh │ └── test │ │ └── test.cpp └── TestSomething │ ├── .arduino-ci.yml │ ├── .gitignore │ ├── Gemfile │ ├── README.md │ ├── examples │ ├── .arduino-ci.yml │ └── TestSomethingExample │ │ ├── .arduino-ci.yml │ │ └── TestSomethingExample.ino │ ├── library.properties │ ├── src │ ├── test-something.cpp │ └── test-something.h │ └── test │ ├── atomic.cpp │ ├── clientServer.cpp │ ├── debounce.cpp │ ├── defines.cpp │ ├── deviceusingbytes.cpp │ ├── eeprom.cpp │ ├── fibonacciClock.h │ ├── fibonacciclock.cpp │ ├── godmode.cpp │ ├── interrupts.cpp │ ├── library.cpp │ ├── math.cpp │ ├── null.cpp │ ├── observabledatastream.cpp │ ├── outputRegister.cpp │ ├── pinhistory.cpp │ ├── queue.cpp │ ├── serial.cpp │ ├── setup_and_teardown.cpp │ ├── softwareserial.cpp │ ├── stdlib.cpp │ ├── stream.cpp │ ├── table.cpp │ ├── trig.cpp │ ├── wcharacter.cpp │ ├── wdt.cpp │ ├── wire.cpp │ └── wstring.cpp ├── arduino_ci.gemspec ├── bin ├── console └── setup ├── cpp ├── .gitignore ├── arduino │ ├── Arduino.cpp │ ├── Arduino.h │ ├── ArduinoDefines.h │ ├── AvrMath.h │ ├── Client.h │ ├── EEPROM.h │ ├── Godmode.cpp │ ├── Godmode.h │ ├── HardwareSerial.h │ ├── IPAddress.h │ ├── MockEventQueue.h │ ├── PinHistory.h │ ├── Print.h │ ├── Printable.h │ ├── SPI.h │ ├── Server.h │ ├── SoftwareSerial.h │ ├── Stream.h │ ├── Udp.h │ ├── WCharacter.h │ ├── WString.h │ ├── Wire.h │ ├── avr │ │ ├── CPPLINT.cfg │ │ ├── README.md │ │ ├── common.h │ │ ├── fuse.h │ │ ├── interrupt.h │ │ ├── io.h │ │ ├── io1200.h │ │ ├── io2313.h │ │ ├── io2323.h │ │ ├── io2333.h │ │ ├── io2343.h │ │ ├── io43u32x.h │ │ ├── io43u35x.h │ │ ├── io4414.h │ │ ├── io4433.h │ │ ├── io4434.h │ │ ├── io76c711.h │ │ ├── io8515.h │ │ ├── io8534.h │ │ ├── io8535.h │ │ ├── io86r401.h │ │ ├── io90pwm1.h │ │ ├── io90pwm161.h │ │ ├── io90pwm216.h │ │ ├── io90pwm2b.h │ │ ├── io90pwm316.h │ │ ├── io90pwm3b.h │ │ ├── io90pwm81.h │ │ ├── io90pwmx.h │ │ ├── io90scr100.h │ │ ├── ioa5272.h │ │ ├── ioa5505.h │ │ ├── ioa5702m322.h │ │ ├── ioa5782.h │ │ ├── ioa5790.h │ │ ├── ioa5790n.h │ │ ├── ioa5791.h │ │ ├── ioa5795.h │ │ ├── ioa5831.h │ │ ├── ioa6285.h │ │ ├── ioa6286.h │ │ ├── ioa6289.h │ │ ├── ioa6612c.h │ │ ├── ioa6613c.h │ │ ├── ioa6614q.h │ │ ├── ioa6616c.h │ │ ├── ioa6617c.h │ │ ├── ioa664251.h │ │ ├── ioa8210.h │ │ ├── ioa8510.h │ │ ├── ioat94k.h │ │ ├── iocan128.h │ │ ├── iocan32.h │ │ ├── iocan64.h │ │ ├── iocanxx.h │ │ ├── iom103.h │ │ ├── iom128.h │ │ ├── iom1280.h │ │ ├── iom1281.h │ │ ├── iom1284.h │ │ ├── iom1284p.h │ │ ├── iom1284rfr2.h │ │ ├── iom128a.h │ │ ├── iom128rfa1.h │ │ ├── iom128rfr2.h │ │ ├── iom16.h │ │ ├── iom161.h │ │ ├── iom162.h │ │ ├── iom163.h │ │ ├── iom164.h │ │ ├── iom164a.h │ │ ├── iom164p.h │ │ ├── iom164pa.h │ │ ├── iom165.h │ │ ├── iom165a.h │ │ ├── iom165p.h │ │ ├── iom165pa.h │ │ ├── iom168.h │ │ ├── iom168a.h │ │ ├── iom168p.h │ │ ├── iom168pa.h │ │ ├── iom168pb.h │ │ ├── iom169.h │ │ ├── iom169a.h │ │ ├── iom169p.h │ │ ├── iom169pa.h │ │ ├── iom16a.h │ │ ├── iom16hva.h │ │ ├── iom16hva2.h │ │ ├── iom16hvb.h │ │ ├── iom16hvbrevb.h │ │ ├── iom16m1.h │ │ ├── iom16u2.h │ │ ├── iom16u4.h │ │ ├── iom2560.h │ │ ├── iom2561.h │ │ ├── iom2564rfr2.h │ │ ├── iom256rfr2.h │ │ ├── iom3000.h │ │ ├── iom32.h │ │ ├── iom323.h │ │ ├── iom324a.h │ │ ├── iom324p.h │ │ ├── iom324pa.h │ │ ├── iom325.h │ │ ├── iom3250.h │ │ ├── iom3250a.h │ │ ├── iom3250p.h │ │ ├── iom3250pa.h │ │ ├── iom325a.h │ │ ├── iom325p.h │ │ ├── iom325pa.h │ │ ├── iom328.h │ │ ├── iom328p.h │ │ ├── iom329.h │ │ ├── iom3290.h │ │ ├── iom3290a.h │ │ ├── iom3290pa.h │ │ ├── iom329a.h │ │ ├── iom329p.h │ │ ├── iom329pa.h │ │ ├── iom32a.h │ │ ├── iom32c1.h │ │ ├── iom32hvb.h │ │ ├── iom32hvbrevb.h │ │ ├── iom32m1.h │ │ ├── iom32u2.h │ │ ├── iom32u4.h │ │ ├── iom32u6.h │ │ ├── iom406.h │ │ ├── iom48.h │ │ ├── iom48a.h │ │ ├── iom48p.h │ │ ├── iom48pa.h │ │ ├── iom48pb.h │ │ ├── iom64.h │ │ ├── iom640.h │ │ ├── iom644.h │ │ ├── iom644a.h │ │ ├── iom644p.h │ │ ├── iom644pa.h │ │ ├── iom644rfr2.h │ │ ├── iom645.h │ │ ├── iom6450.h │ │ ├── iom6450a.h │ │ ├── iom6450p.h │ │ ├── iom645a.h │ │ ├── iom645p.h │ │ ├── iom649.h │ │ ├── iom6490.h │ │ ├── iom6490a.h │ │ ├── iom6490p.h │ │ ├── iom649a.h │ │ ├── iom649p.h │ │ ├── iom64a.h │ │ ├── iom64c1.h │ │ ├── iom64hve.h │ │ ├── iom64hve2.h │ │ ├── iom64m1.h │ │ ├── iom64rfr2.h │ │ ├── iom8.h │ │ ├── iom8515.h │ │ ├── iom8535.h │ │ ├── iom88.h │ │ ├── iom88a.h │ │ ├── iom88p.h │ │ ├── iom88pa.h │ │ ├── iom88pb.h │ │ ├── iom8a.h │ │ ├── iom8hva.h │ │ ├── iom8u2.h │ │ ├── iomx8.h │ │ ├── iomxx0_1.h │ │ ├── iomxx4.h │ │ ├── iomxxhva.h │ │ ├── iotn10.h │ │ ├── iotn11.h │ │ ├── iotn12.h │ │ ├── iotn13.h │ │ ├── iotn13a.h │ │ ├── iotn15.h │ │ ├── iotn1634.h │ │ ├── iotn167.h │ │ ├── iotn20.h │ │ ├── iotn22.h │ │ ├── iotn2313.h │ │ ├── iotn2313a.h │ │ ├── iotn24.h │ │ ├── iotn24a.h │ │ ├── iotn25.h │ │ ├── iotn26.h │ │ ├── iotn261.h │ │ ├── iotn261a.h │ │ ├── iotn28.h │ │ ├── iotn4.h │ │ ├── iotn40.h │ │ ├── iotn4313.h │ │ ├── iotn43u.h │ │ ├── iotn44.h │ │ ├── iotn441.h │ │ ├── iotn44a.h │ │ ├── iotn45.h │ │ ├── iotn461.h │ │ ├── iotn461a.h │ │ ├── iotn48.h │ │ ├── iotn5.h │ │ ├── iotn828.h │ │ ├── iotn84.h │ │ ├── iotn841.h │ │ ├── iotn84a.h │ │ ├── iotn85.h │ │ ├── iotn861.h │ │ ├── iotn861a.h │ │ ├── iotn87.h │ │ ├── iotn88.h │ │ ├── iotn9.h │ │ ├── iotnx4.h │ │ ├── iotnx5.h │ │ ├── iotnx61.h │ │ ├── iousb1286.h │ │ ├── iousb1287.h │ │ ├── iousb162.h │ │ ├── iousb646.h │ │ ├── iousb647.h │ │ ├── iousb82.h │ │ ├── iousbxx2.h │ │ ├── iousbxx6_7.h │ │ ├── iox128a1.h │ │ ├── iox128a1u.h │ │ ├── iox128a3.h │ │ ├── iox128a3u.h │ │ ├── iox128a4u.h │ │ ├── iox128b1.h │ │ ├── iox128b3.h │ │ ├── iox128c3.h │ │ ├── iox128d3.h │ │ ├── iox128d4.h │ │ ├── iox16a4.h │ │ ├── iox16a4u.h │ │ ├── iox16c4.h │ │ ├── iox16d4.h │ │ ├── iox16e5.h │ │ ├── iox192a3.h │ │ ├── iox192a3u.h │ │ ├── iox192c3.h │ │ ├── iox192d3.h │ │ ├── iox256a3.h │ │ ├── iox256a3b.h │ │ ├── iox256a3bu.h │ │ ├── iox256a3u.h │ │ ├── iox256c3.h │ │ ├── iox256d3.h │ │ ├── iox32a4.h │ │ ├── iox32a4u.h │ │ ├── iox32c3.h │ │ ├── iox32c4.h │ │ ├── iox32d3.h │ │ ├── iox32d4.h │ │ ├── iox32e5.h │ │ ├── iox384c3.h │ │ ├── iox384d3.h │ │ ├── iox64a1.h │ │ ├── iox64a1u.h │ │ ├── iox64a3.h │ │ ├── iox64a3u.h │ │ ├── iox64a4u.h │ │ ├── iox64b1.h │ │ ├── iox64b3.h │ │ ├── iox64c3.h │ │ ├── iox64d3.h │ │ ├── iox64d4.h │ │ ├── iox8e5.h │ │ ├── lock.h │ │ ├── pgmspace.h │ │ ├── portpins.h │ │ ├── version.h │ │ ├── wdt.h │ │ └── xmega.h │ ├── binary.h │ ├── ci │ │ ├── DeviceUsingBytes.h │ │ ├── ObservableDataStream.h │ │ ├── README.md │ │ ├── StreamTape.h │ │ └── Table.h │ ├── stdlib.cpp │ ├── stdlib.h │ └── util │ │ └── atomic.h └── unittest │ ├── ArduinoUnitTests.cpp │ ├── ArduinoUnitTests.h │ ├── Assertion.h │ ├── Compare.h │ └── OstreamHelpers.h ├── exe ├── arduino_ci.rb ├── arduino_ci_remote.rb ├── arduino_library_location.rb └── ensure_arduino_installation.rb ├── lib ├── arduino_ci.rb └── arduino_ci │ ├── arduino_backend.rb │ ├── arduino_downloader.rb │ ├── arduino_downloader_linux.rb │ ├── arduino_downloader_osx.rb │ ├── arduino_downloader_windows.rb │ ├── arduino_installation.rb │ ├── ci_config.rb │ ├── cpp_library.rb │ ├── host.rb │ ├── library_properties.rb │ ├── logger.rb │ └── version.rb ├── misc └── default.yml ├── release-new-version.sh └── spec ├── BadSketch └── BadSketch.ino ├── FakeSketch └── FakeSketch.ino ├── arduino_backend_spec.rb ├── arduino_ci_spec.rb ├── arduino_downloader_spec.rb ├── arduino_installation_spec.rb ├── ci_config_spec.rb ├── cpp_library_spec.rb ├── fake_lib_dir.rb ├── fake_library └── test │ ├── mars.cpp │ ├── sam-squamsh.cpp │ └── yes-good.cpp ├── host_spec.rb ├── library_properties_spec.rb ├── properties ├── example.library.properties ├── extra_blank_line.library.properties ├── just_equals.library.properties ├── no_equals.library.properties ├── no_key.library.properties └── no_value.library.properties ├── spec_helper.rb ├── testsomething_unittests_spec.rb └── yaml ├── o1.yaml ├── o2.yaml └── override1 └── .arduino-ci.yml /.codespellignore: -------------------------------------------------------------------------------- 1 | aci 2 | ba 3 | flem 4 | -------------------------------------------------------------------------------- /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | skip = ./cpp/arduino/avr/* 3 | ignore-words=.codespellignore -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/en/github/using-git/configuring-git-to-handle-line-endings 2 | # https://git-scm.com/docs/gitattributes 3 | # https://git-scm.com/docs/git-config 4 | # https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/ 5 | 6 | # Configure this repository to use Git's type detection algorithm to guess 7 | # whether a file is text or binary. Text files will have line endings converted 8 | # as if you had set 9 | # eol=native 10 | # That is, on Windows text files will have CRLF line endings in your working 11 | # directory while on Linux and macOS your text files will have LF line endings 12 | # in your working directory. In either case, they will have LF line endings in 13 | # the Git repository itself. 14 | 15 | # Set the default behavior, in case people don't have core.autocrlf set. 16 | * text=auto eol=lf 17 | 18 | # Explicitly declare text files you want to always be normalized and converted 19 | # to native line endings on checkout. Git would likely get these right, but 20 | # we can be sure by adding them here. 21 | *.ino text diff=cpp 22 | *.c text diff=c 23 | *.cc text diff=cpp 24 | *.cxx text diff=cpp 25 | *.cpp text diff=cpp 26 | *.c++ text diff=cpp 27 | *.hpp text diff=cpp 28 | *.h text diff=c 29 | *.h++ text diff=cpp 30 | *.hh text diff=cpp 31 | 32 | *.md text 33 | *.yaml text 34 | *.yml text 35 | 36 | 37 | # Denote all files that are truly binary and should not be modified. 38 | # Even if we don't have any of these, they make a good example. 39 | *.png binary 40 | *.jpg binary 41 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | ## System 2 | 3 | 4 | 5 | - OS: _(Travis/OSX/Linux/Windows)_ 6 | - `ruby -v`: 7 | - `bundle -v`: 8 | - `bundle info arduino_ci`: 9 | - `g++ -v`: 10 | - Arduino IDE version: 11 | - `java -version`: 12 | - URL of failing Travis CI job: 13 | - URL of your Arduino project: 14 | 15 | 16 | ## (Issue Summary / Feature Request) 17 | 18 | 19 | ## Arduino or Unit Test Code, Illustrating the Problem 20 | 21 | 22 | ## Arduino Architecture(s) Affected 23 | 24 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Highlights from `CHANGELOG.md` 2 | 3 | * See CHANGELOG.md for more 4 | 5 | 10 | -------------------------------------------------------------------------------- /.github/workflows/README.md: -------------------------------------------------------------------------------- 1 | ## Note to `arduino_ci` users 2 | 3 | In this project, we define a workflow for each target platform. **If you're looking for an example you can copy from, take only `linux.yaml`.** 4 | 5 | 6 | ### Long version 7 | 8 | The reason that all platforms are tested in _this_ project is to ensure that, as a framework, `arduino_ci` will run properly on any developer's personal workstation (regardless of OS). 9 | 10 | For testing an individual Arduino library in the context of GitHub, [Linux is the cheapest option](https://docs.github.com/en/free-pro-team@latest/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions) and should produce results identical to the other OSes. 11 | -------------------------------------------------------------------------------- /.github/workflows/linter.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Lint Code Base 3 | 4 | on: 5 | push: 6 | branches-ignore: [master, main] 7 | # Remove the line above to run when pushing to master 8 | pull_request: 9 | branches: [master, main] 10 | 11 | jobs: 12 | build: 13 | name: Lint Code Base 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout Code 18 | uses: actions/checkout@v3 19 | with: 20 | # Full git history is needed to get a proper list of changed files within `super-linter` 21 | fetch-depth: 0 22 | 23 | - name: Lint Code Base 24 | uses: github/super-linter/slim@v4 25 | env: 26 | VALIDATE_ALL_CODEBASE: true 27 | FILTER_REGEX_EXCLUDE: ./cpp/arduino/avr/* 28 | DEFAULT_BRANCH: master 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | VALIDATE_CPP: true 31 | VALIDATE_MARKDOWN: true 32 | VALIDATE_YAML: true 33 | LINTER_RULES_PATH: / 34 | MARKDOWN_CONFIG_FILE: /.markdown-lint.json 35 | -------------------------------------------------------------------------------- /.github/workflows/linux.yaml: -------------------------------------------------------------------------------- 1 | # This is the name of the workflow, visible on GitHub UI 2 | name: linux 3 | 4 | on: [push, pull_request] 5 | 6 | jobs: 7 | "BusIO_with_dependencies": 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: ruby/setup-ruby@v1 12 | with: 13 | ruby-version: 2.6 14 | - name: Check usage - Test BusIO from scratch 15 | run: | 16 | g++ -v 17 | cd SampleProjects/BusIO 18 | bundle install 19 | bundle exec ensure_arduino_installation.rb 20 | bundle exec arduino_ci.rb 21 | 22 | "rubocop": 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v3 26 | - uses: ruby/setup-ruby@v1 27 | with: 28 | ruby-version: 2.6 29 | - name: Check style 30 | run: | 31 | g++ -v 32 | bundle install 33 | bundle exec rubocop --version 34 | bundle exec rubocop -D . 35 | 36 | "rspec-linux": 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v3 40 | - uses: ruby/setup-ruby@v1 41 | with: 42 | ruby-version: 2.6 43 | - name: Check functionality 44 | run: | 45 | g++ -v 46 | bundle install 47 | bundle exec rspec 48 | 49 | "TestSomething": 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v3 53 | - uses: ruby/setup-ruby@v1 54 | with: 55 | ruby-version: 2.6 56 | - name: Check usage - TestSomething 57 | run: | 58 | g++ -v 59 | bundle install 60 | cd SampleProjects/TestSomething 61 | bundle install 62 | bundle exec arduino_ci.rb --help 63 | bundle exec arduino_ci.rb 64 | 65 | NetworkLib: 66 | runs-on: ubuntu-latest 67 | steps: 68 | - uses: actions/checkout@v3 69 | - uses: ruby/setup-ruby@v1 70 | with: 71 | ruby-version: 2.6 72 | - name: Check usage - Test NetworkLib from scratch 73 | run: | 74 | g++ -v 75 | cd SampleProjects/NetworkLib 76 | bundle install 77 | bundle exec ensure_arduino_installation.rb 78 | sh ./scripts/install.sh 79 | bundle exec arduino_ci.rb 80 | 81 | SharedLibrary: 82 | runs-on: ubuntu-latest 83 | steps: 84 | - uses: actions/checkout@v3 85 | - uses: ruby/setup-ruby@v1 86 | with: 87 | ruby-version: 2.6 88 | - name: Check usage - Test SharedLibrary should fail 89 | run: ./SampleProjects/SharedLibrary/test.sh 90 | -------------------------------------------------------------------------------- /.github/workflows/macos.yaml: -------------------------------------------------------------------------------- 1 | # This is the name of the workflow, visible on GitHub UI 2 | name: macos 3 | 4 | on: [push, pull_request] 5 | 6 | jobs: 7 | "rubocop": 8 | runs-on: macos-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: ruby/setup-ruby@v1 12 | with: 13 | ruby-version: 2.6 14 | - name: Check style 15 | run: | 16 | g++ -v 17 | bundle install 18 | bundle exec rubocop --version 19 | bundle exec rubocop -D . 20 | 21 | "rspec-macos": 22 | runs-on: macos-latest 23 | steps: 24 | - uses: actions/checkout@v3 25 | - uses: ruby/setup-ruby@v1 26 | with: 27 | ruby-version: 2.6 28 | - name: Check functionality 29 | run: | 30 | g++ -v 31 | bundle install 32 | bundle exec rspec 33 | 34 | "TestSomething": 35 | runs-on: macos-latest 36 | steps: 37 | - uses: actions/checkout@v3 38 | - uses: ruby/setup-ruby@v1 39 | with: 40 | ruby-version: 2.6 41 | - name: Check usage - TestSomething 42 | run: | 43 | g++ -v 44 | bundle install 45 | cd SampleProjects/TestSomething 46 | bundle install 47 | bundle exec arduino_ci.rb --help 48 | bundle exec arduino_ci.rb 49 | 50 | NetworkLib: 51 | runs-on: macos-latest 52 | steps: 53 | - uses: actions/checkout@v3 54 | - uses: ruby/setup-ruby@v1 55 | with: 56 | ruby-version: 2.6 57 | - name: Check usage - Test NetworkLib from scratch 58 | run: | 59 | g++ -v 60 | cd SampleProjects/NetworkLib 61 | bundle install 62 | bundle exec ensure_arduino_installation.rb 63 | sh ./scripts/install.sh 64 | bundle exec arduino_ci.rb 65 | 66 | SharedLibrary: 67 | runs-on: macos-latest 68 | steps: 69 | - uses: actions/checkout@v3 70 | - uses: ruby/setup-ruby@v1 71 | with: 72 | ruby-version: 2.6 73 | - name: Check usage - Test SharedLibrary should fail 74 | run: ./SampleProjects/SharedLibrary/test.sh 75 | -------------------------------------------------------------------------------- /.github/workflows/spelling.yaml: -------------------------------------------------------------------------------- 1 | # This is the name of the workflow, visible on GitHub UI 2 | name: Check Spelling 3 | 4 | on: 5 | push: 6 | branches-ignore: [master, main] 7 | # Remove the line above to run when pushing to master 8 | pull_request: 9 | branches: [master, main] 10 | 11 | jobs: 12 | build: 13 | name: Check Spelling 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout Code 18 | uses: actions/checkout@v3 19 | with: 20 | # Full git history is needed to get a proper list of changed files within `super-linter` 21 | fetch-depth: 0 22 | 23 | - name: Check Spelling 24 | uses: codespell-project/actions-codespell@v1.0 25 | with: 26 | check_filenames: true 27 | -------------------------------------------------------------------------------- /.github/workflows/windows.yaml: -------------------------------------------------------------------------------- 1 | # This is the name of the workflow, visible on GitHub UI 2 | name: windows 3 | 4 | on: [push, pull_request] 5 | 6 | jobs: 7 | "rubocop": 8 | runs-on: windows-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: ruby/setup-ruby@v1 12 | with: 13 | ruby-version: 2.6 14 | - name: Check style 15 | run: | 16 | g++ -v 17 | bundle install 18 | bundle exec rubocop --version 19 | bundle exec rubocop -D . --except Layout/EndOfLine 20 | 21 | "rspec-windows": 22 | runs-on: windows-latest 23 | steps: 24 | - uses: actions/checkout@v3 25 | - uses: ruby/setup-ruby@v1 26 | with: 27 | ruby-version: 2.6 28 | - name: Check functionality 29 | run: | 30 | g++ -v 31 | bundle install 32 | bundle exec rspec 33 | 34 | TestSomething: 35 | runs-on: windows-latest 36 | steps: 37 | - uses: actions/checkout@v3 38 | - uses: ruby/setup-ruby@v1 39 | with: 40 | ruby-version: 2.6 41 | - name: Check usage - TestSomething 42 | run: | 43 | g++ -v 44 | bundle install 45 | cd SampleProjects/TestSomething 46 | bundle install 47 | bundle exec arduino_ci.rb --help 48 | bundle exec arduino_ci.rb 49 | 50 | NetworkLib: 51 | runs-on: windows-latest 52 | steps: 53 | - uses: actions/checkout@v3 54 | - uses: ruby/setup-ruby@v1 55 | with: 56 | ruby-version: 2.6 57 | - name: Check usage - Test NetworkLib from scratch 58 | run: | 59 | g++ -v 60 | cd SampleProjects/NetworkLib 61 | bundle install 62 | bundle exec ensure_arduino_installation.rb 63 | bash -x ./scripts/install.sh 64 | bundle exec arduino_ci.rb 65 | 66 | SharedLibrary: 67 | runs-on: windows-latest 68 | steps: 69 | - uses: actions/checkout@v3 70 | - uses: ruby/setup-ruby@v1 71 | with: 72 | ruby-version: 2.6 73 | - name: Check usage - Test SharedLibrary should fail 74 | run: ./SampleProjects/SharedLibrary/test.sh 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | vendor 10 | *.gem 11 | .arduino_ci 12 | 13 | # rspec failure tracking 14 | .rspec_status 15 | 16 | # C++ stuff 17 | *.bin 18 | *.bin.dSYM 19 | *.so 20 | *.so.dSYM 21 | .vscode 22 | -------------------------------------------------------------------------------- /.markdown-lint.json: -------------------------------------------------------------------------------- 1 | { 2 | "blanks-around-fences": false, 3 | "blanks-around-headings": false, 4 | "blanks-around-lists": false, 5 | "commands-show-output": false, 6 | "first-line-h1": false, 7 | "header-increment": false, 8 | "line_length": { 9 | "line_length": 600 10 | }, 11 | "no-bare-urls": false, 12 | "no-duplicate-heading": false, 13 | "no-multiple-blanks": { 14 | "maximum": 2 15 | }, 16 | "single-h1": false, 17 | "ul-indent": { 18 | "indent": 4 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | TargetRubyVersion: 2.5 3 | NewCops: enable 4 | SuggestExtensions: false 5 | Exclude: 6 | - '*.gemspec' 7 | - 'spec/*.rb' 8 | - '**/generated_parser/*' 9 | - './vendor/**/*' 10 | - 'SampleProjects/**/vendor/**/*' 11 | 12 | # TODO: stuff I actually want to fix 13 | Style/RescueStandardError: 14 | Enabled: false 15 | 16 | Security/Open: 17 | Enabled: false 18 | 19 | Style/FrozenStringLiteralComment: 20 | Enabled: false 21 | 22 | # broken :( https://github.com/rubocop-hq/rubocop/issues/9144 23 | Style/StringConcatenation: 24 | Enabled: false 25 | 26 | # Ruins git diffs 27 | Style/AccessorGrouping: 28 | Enabled: false 29 | 30 | # Ruins keeping the upper half of the conditional smaller 31 | Style/NegatedIfElseCondition: 32 | Enabled: false 33 | 34 | # affects calling style? 35 | Style/OptionalBooleanParameter: 36 | Enabled: false 37 | 38 | # Extra lines for readability 39 | Layout/EmptyLinesAroundClassBody: 40 | Enabled: false 41 | 42 | Layout/EmptyLinesAroundMethodBody: 43 | Enabled: false 44 | 45 | Layout/EmptyLinesAroundModuleBody: 46 | Enabled: false 47 | 48 | # This can add clarity 49 | Style/CommentedKeyword: 50 | Enabled: false 51 | 52 | # Configuration parameters: AllowForAlignment. 53 | Layout/ExtraSpacing: 54 | Enabled: false 55 | 56 | Layout/EndOfLine: 57 | EnforcedStyle: lf 58 | 59 | Layout/EndAlignment: 60 | EnforcedStyleAlignWith: start_of_line 61 | 62 | Layout/CaseIndentation: 63 | EnforcedStyle: end 64 | 65 | Layout/LineLength: 66 | Enabled: true 67 | Max: 130 68 | 69 | # Configuration parameters: CountComments. 70 | Metrics/ClassLength: 71 | Enabled: false 72 | 73 | Metrics/AbcSize: 74 | Enabled: false 75 | 76 | Metrics/MethodLength: 77 | Enabled: false 78 | 79 | Metrics/BlockLength: 80 | Enabled: false 81 | 82 | # Configuration parameters: CountKeywordArgs. 83 | Metrics/ParameterLists: 84 | Max: 7 85 | 86 | Style/BlockComments: 87 | Enabled: false 88 | 89 | Style/ColonMethodCall: 90 | Enabled: false 91 | 92 | # if you find "a == 3" readable and "3 == a" 'unreadable', do not contribute to this project. 93 | Style/YodaCondition: 94 | Enabled: false 95 | 96 | # Configuration parameters: EnforcedStyle, SupportedStyles. 97 | Style/FormatString: 98 | Enabled: false 99 | 100 | # Offense count: 1 101 | Metrics/CyclomaticComplexity: 102 | Enabled: false 103 | Max: 11 104 | 105 | # Offense count: 1 106 | Metrics/PerceivedComplexity: 107 | Enabled: false 108 | Max: 14 109 | 110 | # Cop supports --auto-correct. 111 | Style/RedundantSelf: 112 | Enabled: false 113 | 114 | # because apostrophes 115 | Style/StringLiterals: 116 | Enabled: false 117 | 118 | Style/TrailingCommaInArrayLiteral: 119 | Enabled: false 120 | 121 | Style/TrailingCommaInHashLiteral: 122 | Enabled: false 123 | 124 | Style/SymbolArray: 125 | Enabled: false 126 | 127 | # because if the robot can comment better than me then 128 | # it might as well learn to write the code for me 129 | Style/CommentAnnotation: 130 | Enabled: false 131 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | lib/arduino_ci.rb lib/**/*.rb 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the ArduinoCI gem 2 | 3 | ArduinoCI uses a very standard GitHub workflow. 4 | 5 | 1. Fork the repository on github 6 | 2. Make your desired changes on top of the latest `master` branch, document them in [CHANGELOG.md](CHANGELOG.md) 7 | 3. Push to your personal fork 8 | 4. Open a pull request 9 | * If you are submitting code, use `master` as the base branch 10 | * If you are submitting broken unit tests (illustrating a bug that should be fixed), use `tdd` as the base branch. 11 | 12 | Pull requests will trigger a CI job. The following two commands will be expected to pass (so you may want to run them locally before opening the pull request): 13 | 14 | * `bundle exec rubocop -D .` - code style tests 15 | * `bundle exec rspec` - functional tests 16 | * `bundle exec rspec spec/some_file_spec.rb` - functional tests for just some file 17 | 18 | If you do not already have a working ruby development environment set up, run the following commands: 19 | 20 | ```shell 21 | # One of the following 22 | apt-get install ruby ruby-dev # For Debian/Ubuntu 23 | dnf install ruby ruby-devel # For Fedora/newer Centos/RHEL 24 | yum install ruby ruby-devel # For older Centos/RHEL 25 | 26 | # All below 27 | gem install bundler 28 | gem install rspec 29 | # Now you are ready to install dependencies with bundle (as described in the 30 | # README file) and to run unit tests. 31 | ``` 32 | 33 | Be prepared to write tests to accompany any code you would like to see merged. 34 | See `SampleProjects/TestSomething/test/*.cpp` for the existing tests (run by rspec). 35 | 36 | 37 | ## Convenience Features 38 | 39 | To speed up testing by targeting only the files you're working on, you can set several environment variables that `bundle exec rspec` will respond to: 40 | 41 | * `ARDUINO_CI_SKIP_RUBY_RSPEC_TESTS`: if set, this will skip all tests against ruby code (useful if you are not changing Ruby code). 42 | * `ARDUINO_CI_SKIP_CPP_RSPEC_TESTS`: if set, this will skip all tests against the `TestSomething` sample project (useful if you are not changing C++ code). 43 | * `ARDUINO_CI_SELECT_CPP_TESTS=`: if set, this will skip all C++ unit tests whose filenames don't match the provided glob (executed in the tests directory) 44 | 45 | Example usage: 46 | 47 | ```shell 48 | ARDUINO_CI_SKIP_RUBY_RSPEC_TESTS=1 bundle exec rspec 49 | ``` 50 | 51 | 52 | ## Packaging the Gem 53 | 54 | * Merge pull request with new features 55 | * Execute `release-new-version.sh` with the appropriate argument (e.g. `--increment-patch`), which does the following: 56 | * `git stash save` (at least before the gem build step, but easiest here). 57 | * `git pull --rebase` 58 | * Update the sections of `CHANGELOG.md` by running `bundle exec keepachangelog_manager.rb --increment-patch` 59 | * Bump the version in lib/arduino_ci/version.rb and change it in README.md (since rubydoc.info doesn't always redirect to the latest version) 60 | * `git add README.md CHANGELOG.md lib/arduino_ci/version.rb` 61 | * `git commit -m "vVERSION bump"` 62 | * `git tag -a vVERSION -m "Released version VERSION"` 63 | * `gem build arduino_ci.gemspec` 64 | * `git stash pop` 65 | * `gem push arduino_ci-VERSION.gem` 66 | * `git push upstream` 67 | * `git push upstream --tags` 68 | * Visit http://www.rubydoc.info/gems/arduino_ci/VERSION to initiate the doc generation process 69 | -------------------------------------------------------------------------------- /CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | filter=-build/header_guard, -build/include, -build/include_order, -build/include_subdir, -build/include_what_you_use, -build/namespaces, -legal/copyright, -readability/alt_tokens, -readability/braces, -readability/casting, -readability/fn_size, -readability/inheritance, -readability/todo, -runtime/arrays, -runtime/explicit, -runtime/int, -runtime/printf, -runtime/references, -whitespace 3 | linelength=120 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } 4 | 5 | # Specify your gem's dependencies in arduino_ci.gemspec 6 | gemspec 7 | 8 | gem "bundler", "> 1.15", require: false, group: :test 9 | gem "irb", "~> 1.3.5", require: false 10 | gem "keepachangelog_manager", "~> 0.0.2", require: false, group: :test 11 | gem "rspec", "~> 3.0", require: false, group: :test 12 | gem 'rubocop', '~>1.5.0', require: false, group: :test 13 | gem 'simplecov', require: false, group: :test 14 | gem 'yard', '~>0.9.11', require: false, group: :test 15 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | unittest: 2 | platforms: 3 | - mega2560 4 | libraries: 5 | - "Adafruit_BusIO" 6 | 7 | compile: 8 | platforms: 9 | - mega2560 10 | libraries: 11 | - "Adafruit_BusIO" 12 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle -------------------------------------------------------------------------------- /SampleProjects/BusIO/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'arduino_ci', path: '../../' 3 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/README.md: -------------------------------------------------------------------------------- 1 | # BusIO 2 | 3 | This is an example of a library that depends on Adafruit BusIO. 4 | It is provided to help reproduce #192 and #352. 5 | 6 | This example specifies a dependency in `library.properties`, which 7 | exercises the `arduino_ci.rb` CI runner in a way that the other 8 | SampleProjects currently do not. 9 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/examples/spi_readwrite/spi_readwrite.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define SPIDEVICE_CS 10 4 | Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS); 5 | 6 | 7 | void setup() { 8 | while (!Serial) { delay(10); } 9 | Serial.begin(115200); 10 | Serial.println("SPI device read and write test"); 11 | 12 | if (!spi_dev.begin()) { 13 | Serial.println("Could not initialize SPI device"); 14 | while (1); 15 | } 16 | 17 | uint8_t buffer[32]; 18 | 19 | // Try to read 32 bytes 20 | spi_dev.read(buffer, 32); 21 | Serial.print("Read: "); 22 | for (uint8_t i=0; i<32; i++) { 23 | Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", "); 24 | } 25 | Serial.println(); 26 | 27 | // read a register by writing first, then reading 28 | buffer[0] = 0x8F; // we'll reuse the same buffer 29 | spi_dev.write_then_read(buffer, 1, buffer, 2, false); 30 | Serial.print("Write then Read: "); 31 | for (uint8_t i=0; i<2; i++) { 32 | Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", "); 33 | } 34 | Serial.println(); 35 | } 36 | 37 | void loop() { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/library.properties: -------------------------------------------------------------------------------- 1 | name=BusIO 2 | version=0.1.0 3 | author=James Foster 4 | maintainer=James Foster 5 | sentence=Sample BusIO library to validate import of Adafruit BusIO 6 | paragraph=Sample BusIO library to validate import of Adafruit BusIO 7 | category=Other 8 | url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/BusIO 9 | architectures=avr,esp8266 10 | includes=BusIO.h 11 | depends=Adafruit BusIO 12 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/src/BusIO.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class BusIO { 5 | public: 6 | BusIO() {} 7 | ~BusIO() {} 8 | int answer() { return 42; } 9 | }; 10 | -------------------------------------------------------------------------------- /SampleProjects/BusIO/test/busio.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | bundle config --local path vendor/bundle 3 | bundle install 4 | bundle exec arduino_ci.rb --skip-examples-compilation 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | unittest(busio_answer) { 12 | // token test 13 | BusIO busIO; 14 | assertEqual(42, busIO.answer()); 15 | } 16 | 17 | unittest_main() 18 | -------------------------------------------------------------------------------- /SampleProjects/DependOnSomething/library.properties: -------------------------------------------------------------------------------- 1 | depends=OnePointOhDummy,OnePointFiveDummy 2 | -------------------------------------------------------------------------------- /SampleProjects/DependOnSomething/src/YesDeps.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/DependOnSomething/src/YesDeps.cpp -------------------------------------------------------------------------------- /SampleProjects/DependOnSomething/src/YesDeps.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/DependOnSomething/src/YesDeps.h -------------------------------------------------------------------------------- /SampleProjects/DependOnSomething/test/null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(nothing) 4 | { 5 | } 6 | 7 | unittest_main() 8 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/.arduino-ci.yaml: -------------------------------------------------------------------------------- 1 | compile: 2 | libraries: ~ 3 | platforms: 4 | - uno 5 | - due 6 | - leonardo 7 | 8 | unittest: 9 | libraries: ~ 10 | platforms: 11 | - uno 12 | - due 13 | - leonardo 14 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | vendor 10 | *.gem 11 | 12 | # rspec failure tracking 13 | .rspec_status 14 | 15 | # C++ stuff 16 | *.bin 17 | *.bin.dSYM 18 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: ruby 3 | script: 4 | - bundle install 5 | - bundle exec arduino_ci.rb 6 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'arduino_ci', path: '../../' 3 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/README.md: -------------------------------------------------------------------------------- 1 | # Arduino CI and Unit Tests HOWTO 2 | 3 | This project is a template for a CI-enabled (and unit testable) Arduino project of your own. 4 | 5 | 6 | ### Features 7 | 8 | * Travis CI 9 | * Unit tests 10 | * Development workflow matches CI workflow 11 | 12 | # Where The Magic Happens 13 | 14 | Here is the minimal set of files that you will need to adapt to your own project: 15 | 16 | 17 | ### `Gemfile` Ruby gem configuration 18 | 19 | ```ruby 20 | source 'https://rubygems.org' 21 | gem 'arduino_ci' 22 | ``` 23 | 24 | You'll need this to get access to the functionality. 25 | 26 | > This is different from the `Gemfile` that's included in this directory! That's for purposes of testing the ruby gem that also lives in this repository. So "do as I say, not as I do", in this case. 27 | 28 | 29 | ### `.travis.yml` Travis CI configuration 30 | 31 | At a minimum, you will need the following lines in your file: 32 | 33 | ```yaml 34 | language: ruby 35 | script: 36 | - bundle install 37 | - bundle exec arduino_ci.rb 38 | ``` 39 | 40 | This will install the necessary ruby gem, and run it. There are no command line arguments as of this writing, because all configuration is provided by... 41 | 42 | ### `.arduino-ci.yaml` ArduinoCI configuration 43 | 44 | This file controls all aspects of building and unit testing. The (relatively-complete) defaults can be found [in the base project](../../misc/default.yml). 45 | 46 | The most relevant sections for most projects will be as follows: 47 | 48 | ```yaml 49 | compile: 50 | libraries: ~ 51 | platforms: 52 | - uno 53 | - due 54 | - leonardo 55 | 56 | unittest: 57 | libraries: ~ 58 | platforms: 59 | - uno 60 | - due 61 | - leonardo 62 | ``` 63 | 64 | This does nothing but specify a list of what platforms should run each set of tests. The platforms themselves can also be defined and/or extended in the yaml file. For example, `esp8266` as shown here: 65 | 66 | ```yaml 67 | platforms: 68 | esp8266: 69 | board: esp8266:esp8266:huzzah 70 | package: esp8266:esp8266 71 | gcc: 72 | features: 73 | defines: 74 | warnings: 75 | flags: 76 | ``` 77 | 78 | Of course, this wouldn't work by itself -- the Arduino IDE would have to know how to install the package via the board manager. So there's a section for packages too: 79 | 80 | ```yaml 81 | packages: 82 | esp8266:esp8266: 83 | url: http://arduino.esp8266.com/stable/package_esp8266com_index.json 84 | ``` 85 | 86 | ### Unit tests in `test/` 87 | 88 | All `.cpp` files in the `test/` directory are assumed to contain unit tests. Each and every one will be compiled and executed on its own. 89 | 90 | The most basic unit test file is as follows: 91 | 92 | ```C++ 93 | #include 94 | #include "../do-something.h" 95 | 96 | unittest(your_test_name) 97 | { 98 | assertEqual(4, doSomething()); 99 | } 100 | 101 | unittest_main() 102 | ``` 103 | 104 | This test defines one `unittest` (a macro provided by `ArduinoUnitTests.h`), called `your_test_name`, which makes some assertions on the target library. The `int main` section is boilerplate. 105 | 106 | 107 | # Credits 108 | 109 | This Arduino example was created in January 2018 by Ian Katz . 110 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/do-something.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "do-something.h" 3 | int doSomething(void) { 4 | millis(); // this line is only here to test that we're able to refer to the builtins 5 | return 4; 6 | }; 7 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/do-something.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | int doSomething(void); 4 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/examples/DoSomethingExample/DoSomethingExample.ino: -------------------------------------------------------------------------------- 1 | #include 2 | // if it seems bare, that's because it's only meant to 3 | // demonstrate compilation -- that references work 4 | void setup() { 5 | } 6 | 7 | void loop() { 8 | doSomething(); 9 | } 10 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/library.properties: -------------------------------------------------------------------------------- 1 | name=DoSomething 2 | version=0.1.0 3 | author=Ian Katz 4 | maintainer=Ian Katz 5 | sentence=Arduino CI unit test example 6 | paragraph=A skeleton library demonstrating CI and unit tests 7 | category=Other 8 | url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/DoSomething 9 | architectures=avr 10 | includes=do-something.h 11 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/test/README.md: -------------------------------------------------------------------------------- 1 | ## Purpose 2 | 3 | These files are designed to test the testing framework (the Ruby gem) itself, library installation and compilation. (Feature tests for C++ unittest/arduino code belong in `../TestSomething/test/`.) 4 | 5 | ## Naming convention 6 | 7 | Files in this directory are given names that either contains "bad" (if it is expected to fail) or "good" (if it is expected to pass). This provides a signal to `rspec` for how the code is expected to perform (see `spec/cpp_library_spec.rb`). 8 | 9 | When writing your own tests you should not follow this ("bad" and "good") naming convention. You should write all your tests expecting them to pass (relying on this `DoSomething` test to ensure that failures are actually noticed!). 10 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/test/bad-errormessages.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | #pragma once 5 | 6 | 7 | 8 | unittest(check_that_assertion_error_messages_are_comprehensible) 9 | { 10 | assertEqual(1, 2); 11 | assertNotEqual(2, 2); 12 | assertComparativeEquivalent(1, 2); 13 | assertComparativeNotEquivalent(2, 2); 14 | assertLess(2, 1); 15 | assertMore(1, 2); 16 | assertLessOrEqual(2, 1); 17 | assertMoreOrEqual(1, 2); 18 | assertTrue(false); 19 | assertFalse(true); 20 | assertNull(3); 21 | assertNotNull(NULL); 22 | 23 | assertEqualFloat(1.2, 1.0, 0.01); 24 | assertNotEqualFloat(1.0, 1.02, 0.1); 25 | assertInfinity(42); 26 | assertNotInfinity(INFINITY); 27 | assertNAN(42); 28 | assertNotNAN(0.0/0.0); 29 | } 30 | 31 | unittest_main() 32 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/test/bad-null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(pretend_equal_things_arent) 4 | { 5 | int x = 3; 6 | int y = 3; 7 | assertNotEqual(x, y); 8 | } 9 | 10 | unittest_main() 11 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/test/good-assert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../do-something.h" 3 | 4 | class NonOrderedType { 5 | public: 6 | int x; // ehh why not 7 | NonOrderedType(int some_x) : x(some_x) {} 8 | 9 | bool operator==(const NonOrderedType &that) const { 10 | return that.x == x; 11 | } 12 | 13 | bool operator!=(const NonOrderedType &that) const { 14 | return that.x != x; 15 | } 16 | }; 17 | inline std::ostream& operator << ( std::ostream& out, const NonOrderedType& n ) { 18 | out << "NonOrderedType(" << n.x << ")"; 19 | return out; 20 | } 21 | 22 | 23 | unittest(assert_equal_without_total_ordering) 24 | { 25 | NonOrderedType a(3); 26 | NonOrderedType b(3); 27 | NonOrderedType c(4); 28 | 29 | assertEqual(a, b); 30 | assertEqual(a, a); 31 | assertNotEqual(a, c); 32 | 33 | } 34 | 35 | unittest(float_assertions) 36 | { 37 | assertEqualFloat(1.0, 1.02, 0.1); 38 | assertNotEqualFloat(1.2, 1.0, 0.01); 39 | 40 | assertInfinity(exp(800)); 41 | assertInfinity(1.0/0.0); 42 | assertNotInfinity(42); 43 | 44 | assertNAN(INFINITY - INFINITY); 45 | assertNAN(0.0/0.0); 46 | assertNotNAN(42); 47 | 48 | assertComparativeEquivalent(exp(800), INFINITY); 49 | assertComparativeEquivalent(0.0/0.0, INFINITY - INFINITY); 50 | assertComparativeNotEquivalent(INFINITY, -INFINITY); 51 | 52 | assertLess(0, INFINITY); 53 | assertLess(-INFINITY, 0); 54 | assertLess(-INFINITY, INFINITY); 55 | } 56 | 57 | unittest_main() 58 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/test/good-library.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../do-something.h" 3 | 4 | unittest(library_does_something) 5 | { 6 | assertEqual(4, doSomething()); 7 | } 8 | 9 | unittest_main() 10 | -------------------------------------------------------------------------------- /SampleProjects/DoSomething/test/good-null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(equality_as_vars) 4 | { 5 | int x = 3; 6 | int y = 3; 7 | int z = 3; 8 | assertEqual(x, y); 9 | assertEqual(x, z); 10 | } 11 | 12 | unittest(equality_as_values) 13 | { 14 | assertEqual(1, 1); 15 | assertEqual(4, 4); 16 | } 17 | 18 | unittest(nothing) 19 | { 20 | } 21 | 22 | unittest_main() 23 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | unittest: 2 | exclude_dirs: 3 | - src/excludeThis 4 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/README.md: -------------------------------------------------------------------------------- 1 | # ExcludeSomething 2 | 3 | This example exists to test directory-exclusion code of ArduinoCI 4 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/library.properties: -------------------------------------------------------------------------------- 1 | name=ExcludeSomething 2 | version=0.1.0 3 | author=Ian Katz 4 | maintainer=Ian Katz 5 | sentence=Arduino CI unit test example 6 | paragraph=A skeleton library demonstrating file exclusion 7 | category=Other 8 | url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/ExcludeSomething 9 | architectures=avr,esp8266 10 | includes=do-something.h 11 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/src/exclude-something.cpp: -------------------------------------------------------------------------------- 1 | #include "exclude-something.h" 2 | int excludeSomething(void) { 3 | return -1; 4 | }; 5 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/src/exclude-something.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | int excludeSomething(void); 4 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/src/excludeThis/exclude-this.cpp: -------------------------------------------------------------------------------- 1 | This file intentionally contains syntactically incorrect code 2 | to break unit test compilation. If arduino_ci is working 3 | properly, it should exclude this file (as per .arduino-ci.yml 4 | configuration) and unit test compilation should succeed. 5 | 6 | ~!@#$%^&*() 7 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/src/excludeThis/exclude-this.h: -------------------------------------------------------------------------------- 1 | This file intentionally contains syntactically incorrect code 2 | to break unit test compilation. If arduino_ci is working 3 | properly, it should exclude this file (as per .arduino-ci.yml 4 | configuration) and unit test compilation should succeed. 5 | 6 | ~!@#$%^&*() 7 | -------------------------------------------------------------------------------- /SampleProjects/ExcludeSomething/test/null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(nothing) 4 | { 5 | } 6 | 7 | unittest_main() 8 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | unittest: 2 | platforms: 3 | - mega2560 4 | libraries: 5 | - "Ethernet" 6 | 7 | compile: 8 | platforms: 9 | - mega2560 10 | libraries: 11 | - "Ethernet" 12 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'arduino_ci', path: '../../' 3 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/README.md: -------------------------------------------------------------------------------- 1 | # NetworkLib 2 | 3 | This is an example of a library that depends on Ethernet. 4 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/examples/EthernetExample/EthernetExample.ino: -------------------------------------------------------------------------------- 1 | #include 2 | // if it seems bare, that's because it's only meant to 3 | // demonstrate compilation -- that references work 4 | void setup() {} 5 | 6 | void loop() {} 7 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/library.properties: -------------------------------------------------------------------------------- 1 | name=NetworkLib 2 | version=0.1.0 3 | author=James Foster 4 | maintainer=James Foster 5 | sentence=Sample Ethernet library to validate Client/Server mocks 6 | paragraph=Sample Ethernet library to validate Client/Server mocks 7 | category=Other 8 | url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/Ethernet 9 | architectures=avr,esp8266 10 | includes=NetworkLib.h 11 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # if we don't have an Ethernet library already (say, in new install or for an automated test), 4 | # then get the custom one we want to use for testing 5 | cd $(bundle exec arduino_library_location.rb) 6 | if [ ! -d ./Ethernet ] ; then 7 | git clone --depth 1 https://github.com/Arduino-CI/Ethernet.git 8 | fi 9 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/src/NetworkLib.cpp: -------------------------------------------------------------------------------- 1 | #include "Ethernet.h" 2 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/src/NetworkLib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/test/client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // test for including without 3 | #include 4 | 5 | unittest(test) { assertTrue(true); } 6 | 7 | unittest_main() 8 | -------------------------------------------------------------------------------- /SampleProjects/NetworkLib/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | cd SampleProjects/NetworkLib 3 | bundle config --local path vendor/bundle 4 | bundle install 5 | bundle exec arduino_ci.rb --skip-examples-compilation 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | unittest(test) { assertEqual(EthernetNoHardware, Ethernet.hardwareStatus()); } 13 | 14 | unittest_main() 15 | -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/NoBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/NoBase.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/NoBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/NoBase.h -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/README.md: -------------------------------------------------------------------------------- 1 | This project resembles a "1.5 spec" library: it has `library.properties` and a `src/` directory that will be scanned recursively. `utility/`, if present, will be ignored. 2 | -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/library.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/library.properties -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/src/YesSrc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/src/YesSrc.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/src/YesSrc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/src/YesSrc.h -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/src/subdir/YesSubdir.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/src/subdir/YesSubdir.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/src/subdir/YesSubdir.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/src/subdir/YesSubdir.h -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/test/null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(nothing) 4 | { 5 | } 6 | 7 | unittest_main() 8 | -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/utility/ImNotHere.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/utility/ImNotHere.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveDummy/utility/ImNotHere.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveDummy/utility/ImNotHere.h -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/README.md: -------------------------------------------------------------------------------- 1 | This project lacks a `library.properties` and so should be treated as a "1.0 spec" library -- the base and `utility` directories will be scanned for code, non-recursively. `src/`, if present, will be ignored. 2 | -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/YesBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveMalformed/YesBase.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/YesBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveMalformed/YesBase.h -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/src/ImNotHere.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveMalformed/src/ImNotHere.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/src/ImNotHere.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveMalformed/src/ImNotHere.h -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/utility/YesUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveMalformed/utility/YesUtil.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointFiveMalformed/utility/YesUtil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointFiveMalformed/utility/YesUtil.h -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/README.md: -------------------------------------------------------------------------------- 1 | This project should resemble "1.0 spec" library -- the base and `utility` directories will be scanned for code, non-recursively. `src/`, if present, will be ignored. 2 | -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/YesBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointOhDummy/YesBase.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/YesBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointOhDummy/YesBase.h -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/src/ImNotHere.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointOhDummy/src/ImNotHere.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/src/ImNotHere.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointOhDummy/src/ImNotHere.h -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/test/null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(nothing) 4 | { 5 | } 6 | 7 | unittest_main() 8 | -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/utility/YesUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointOhDummy/utility/YesUtil.cpp -------------------------------------------------------------------------------- /SampleProjects/OnePointOhDummy/utility/YesUtil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/SampleProjects/OnePointOhDummy/utility/YesUtil.h -------------------------------------------------------------------------------- /SampleProjects/README.md: -------------------------------------------------------------------------------- 1 | Arduino Sample Projects 2 | ======================= 3 | 4 | This directory contains projects that are intended solely for testing the various features of this gem -- to test the testing framework itself. The RSpec tests refer specifically to these projects, and as a result _some are explicitly designed to fail_. 5 | 6 | > **If you are a first-time `arduino_ci` user an are looking for an example to copy from, see [the `Arduino-CI/Blink` repository](https://github.com/Arduino-CI/Blink) instead.** 7 | 8 | * "TestSomething" contains a minimal library, but tests for all the C++ compilation feature-mocks of arduino_ci. 9 | * "DoSomething" is a simple test of the testing framework (arduino_ci) itself to verify that passes and failures are properly identified and reported. Because of this, it includes test files that are expected to fail -- they are prefixed with "bad-". 10 | * "OnePointOhDummy" is a non-functional library meant to test file inclusion logic on libraries conforming to the "1.0" specification 11 | * "OnePointFiveMalformed" is a non-functional library meant to test file inclusion logic on libraries that attempt to conform to the ["1.5" specification](https://arduino.github.io/arduino-cli/latest/library-specification/) but fail to include a `src` directory 12 | * "OnePointFiveDummy" is a non-functional library meant to test file inclusion logic on libraries conforming to the ["1.5" specification](https://arduino.github.io/arduino-cli/latest/library-specification/) 13 | * "DependOnSomething" is a non-functional library meant to test file inclusion logic with dependencies 14 | * "ExcludeSomething" is a non-functional library meant to test directory exclusion logic 15 | * "NetworkLib" tests the Ethernet library 16 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | unittest: 2 | platforms: 3 | - mega2560 4 | 5 | compile: 6 | platforms: 7 | - mega2560 8 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'arduino_ci', path: '../../' 3 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/README.md: -------------------------------------------------------------------------------- 1 | # SharedLibrary 2 | 3 | This is an example of a shared library with a compile error (see https://github.com/Arduino-CI/arduino_ci/issues/325). 4 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/library.properties: -------------------------------------------------------------------------------- 1 | name=SharedLibrary 2 | version=0.1.0 3 | author=James Foster 4 | maintainer=James Foster 5 | sentence=Sample shared library to validate that we catch compile errors 6 | paragraph=Sample shared library to validate that we catch compile errors 7 | category=Other 8 | url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/SharedLibrary 9 | architectures=avr,esp8266 10 | includes=SharedLibrary.h 11 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/src/SharedLibrary.cpp: -------------------------------------------------------------------------------- 1 | #include "SharedLibrary.h" 2 | 3 | int main() { 4 | return foo; // 'foo' was not declared in this scope 5 | } 6 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/src/SharedLibrary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/test.sh: -------------------------------------------------------------------------------- 1 | g++ -v 2 | cd SampleProjects/SharedLibrary 3 | bundle install 4 | bundle exec ensure_arduino_installation.rb 5 | bundle exec arduino_ci.rb --skip-examples-compilation 6 | if [ $? -ne 1 ]; then 7 | exit 1 8 | fi 9 | exit 0 10 | -------------------------------------------------------------------------------- /SampleProjects/SharedLibrary/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | cd SampleProjects/SharedLibrary 3 | bundle config --local path vendor/bundle 4 | bundle install 5 | bundle exec arduino_ci.rb --skip-examples-compilation 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | unittest(test) { assertEqual(true, true); } 12 | 13 | unittest_main() 14 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | platforms: 2 | uno: 3 | board: arduino:avr:uno 4 | package: arduino:avr 5 | gcc: 6 | features: 7 | defines: 8 | - __AVR__ 9 | - __AVR_ATmega328P__ 10 | - ARDUINO_ARCH_AVR 11 | - ARDUINO_AVR_UNO 12 | warnings: 13 | - no-unknown-attributes 14 | flags: 15 | 16 | unittest: 17 | platforms: 18 | - uno 19 | - due 20 | 21 | compile: 22 | platforms: 23 | - uno 24 | - due 25 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | vendor 10 | *.gem 11 | 12 | # rspec failure tracking 13 | .rspec_status 14 | 15 | # C++ stuff 16 | *.bin 17 | *.bin.dSYM 18 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'arduino_ci', path: '../../' 3 | gem "irb", "~> 1.3.5", require: false 4 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/README.md: -------------------------------------------------------------------------------- 1 | # TestSomething 2 | 3 | 4 | All the tests of our mocked `Arduino.h` implementation live here. 5 | 6 | This example project is tightly coupled to the tests of the Arduino CI module itself. In that sense, each of the individual test files will be illustrative of the testing strategy and capabilities of the core library itself. 7 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/examples/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | compile: 2 | platforms: 3 | - uno 4 | - due 5 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/examples/TestSomethingExample/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | compile: 2 | platforms: 3 | - uno 4 | - due 5 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/examples/TestSomethingExample/TestSomethingExample.ino: -------------------------------------------------------------------------------- 1 | #include 2 | // if it seems bare, that's because it's only meant to 3 | // demonstrate compilation -- that references work 4 | void setup() { 5 | int *p = nullptr; 6 | } 7 | 8 | void loop() { 9 | testSomething(); 10 | } 11 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/library.properties: -------------------------------------------------------------------------------- 1 | name=TestSomething 2 | version=0.1.0 3 | author=Ian Katz 4 | maintainer=Ian Katz 5 | sentence=Arduino CI unit test example 6 | paragraph=A skeleton library demonstrating CI and unit tests 7 | category=Other 8 | url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/TestSomething 9 | architectures=avr,esp8266 10 | includes=test-something.h 11 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/src/test-something.cpp: -------------------------------------------------------------------------------- 1 | #include "test-something.h" 2 | int testSomething(void) { 3 | millis(); // this line is only here to test that we're able to refer to the builtins 4 | return 4; 5 | }; 6 | 7 | int* aNullPointer(void) { 8 | int* ret = nullptr; 9 | return ret; 10 | } 11 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/src/test-something.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | int testSomething(void); 4 | int *aNullPointer(void); 5 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/atomic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | unittest(atomic) 7 | { 8 | // The macros don't do anything on the host platform, just make sure 9 | // they compile without error. 10 | 11 | int a = 1; 12 | int b = 2; 13 | 14 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { 15 | a += b; 16 | b++; 17 | } 18 | 19 | ATOMIC_BLOCK(ATOMIC_FORCEON) { 20 | a += b; 21 | b++; 22 | } 23 | 24 | NONATOMIC_BLOCK(NONATOMIC_RESTORESTATE) { 25 | a += b; 26 | b++; 27 | } 28 | 29 | NONATOMIC_BLOCK(NONATOMIC_FORCEOFF) { 30 | a += b; 31 | b++; 32 | } 33 | 34 | assertEqual(a, 15); 35 | assertEqual(b, 6); 36 | } 37 | 38 | 39 | unittest_main() 40 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/defines.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | unittest(binary) 5 | { 6 | assertEqual(1, B1); 7 | assertEqual(10, B1010); 8 | assertEqual(100, B1100100); 9 | } 10 | 11 | #ifdef __AVR__ 12 | #define DDRE _SFR_IO8(0x02) 13 | 14 | unittest(SFR_IO8) 15 | { 16 | // in normal arduino code, you can do this. in arduino_ci, you might get an 17 | // error like: cannot take the address of an rvalue of type 'int' 18 | // 19 | // this tests that directly 20 | auto foo = &DDRE; // avoid compiler warning by using the result of an expression 21 | } 22 | 23 | unittest(read_write) 24 | { 25 | _SFR_IO8(1) = 0x11; 26 | _SFR_IO8(2) = 0x22; 27 | assertEqual((int) 0x11, (int) _SFR_IO8(1)); 28 | assertEqual((int) 0x22, (int) _SFR_IO8(2)); 29 | assertEqual((int) 0x2211, (int) _SFR_IO16(1)); 30 | } 31 | #endif 32 | 33 | unittest_main() 34 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/deviceusingbytes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // DeviceUsingBytes extends DataStreamObserver, 7 | // so we will be able to attach this class to an 8 | // ObservableDataStream object, of which the pin 9 | // history (soft-serial) and HardwareSerial 10 | // objects are. 11 | class FakeHayesModem : public DeviceUsingBytes { 12 | public: 13 | String mLast; 14 | bool mMatchedInput; 15 | 16 | FakeHayesModem() : DeviceUsingBytes() { 17 | mLast = ""; 18 | mMatchedInput = false; 19 | addResponseLine("AT", "OK"); 20 | addResponseLine("ATV1", "NO CARRIER"); 21 | } 22 | 23 | virtual ~FakeHayesModem() {} 24 | 25 | virtual void onMatchInput(String output) { 26 | mLast = output; 27 | mMatchedInput = true; 28 | } 29 | }; 30 | 31 | GodmodeState* state = GODMODE(); 32 | 33 | unittest_setup() 34 | { 35 | state->reset(); 36 | } 37 | 38 | unittest(modem_hardware) 39 | { 40 | String cmd = "AT\n"; 41 | 42 | FakeHayesModem m; 43 | m.attach(&Serial); 44 | assertEqual(0, Serial.available()); 45 | assertFalse(m.mMatchedInput); 46 | assertEqual("", m.mMessage); 47 | 48 | for (int i = 0; i < cmd.length(); ++i) { 49 | assertEqual(i, m.mMessage.length()); // before we write, length should equal i 50 | Serial.write(cmd[i]); 51 | } 52 | assertEqual(0, m.mMessage.length()); // should have matched and reset 53 | 54 | assertEqual("", state->serialPort[0].dataIn); 55 | assertEqual("AT\n", state->serialPort[0].dataOut); 56 | 57 | assureTrue(m.mMatchedInput); 58 | //assertEqual(3, Serial.available()); 59 | assertEqual("OK\n", m.mLast); 60 | } 61 | 62 | unittest(modem_software) 63 | { 64 | bool bigEndian = false; 65 | bool flipLogic = false; 66 | SoftwareSerial ss(1, 2, flipLogic); 67 | ss.listen(); 68 | 69 | String cmd = "AT\n"; 70 | 71 | FakeHayesModem m; 72 | m.attach(&state->digitalPin[2]); 73 | assertEqual(0, ss.available()); 74 | assertFalse(m.mMatchedInput); 75 | assertEqual("", m.mMessage); 76 | 77 | for (int i = 0; i < cmd.length(); ++i) { 78 | assertEqual(i, m.mMessage.length()); // before we write, length should equal i 79 | assertEqual(cmd.substr(0, i), state->digitalPin[2].toAscii(1, bigEndian)); 80 | assertEqual(cmd.substr(0, i), m.mMessage); 81 | ss.write(cmd[i]); 82 | } 83 | assertEqual(0, m.mMessage.length()); // should have matched and reset 84 | 85 | assertEqual("", state->digitalPin[1].incomingToAscii(1, bigEndian)); 86 | assertEqual("AT\n", state->digitalPin[2].toAscii(1, bigEndian)); 87 | 88 | 89 | assureTrue(m.mMatchedInput); 90 | //assertEqual(3, Serial.available()); 91 | assertEqual("OK\n", m.mLast); 92 | } 93 | 94 | unittest_main() 95 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/eeprom.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // Only run EEPROM tests if there is hardware support! 6 | #if defined(EEPROM_SIZE) 7 | #include 8 | 9 | GodmodeState* state = GODMODE(); 10 | 11 | unittest_setup() 12 | { 13 | state->reset(); 14 | } 15 | 16 | unittest(length) 17 | { 18 | assertEqual(EEPROM_SIZE, EEPROM.length()); 19 | } 20 | 21 | unittest(firstRead) 22 | { 23 | uint8_t a = EEPROM.read(0); 24 | assertEqual(255, a); 25 | } 26 | 27 | unittest(writeRead) 28 | { 29 | EEPROM.write(0, 24); 30 | uint8_t a = EEPROM.read(0); 31 | assertEqual(24, a); 32 | 33 | EEPROM.write(0, 128); 34 | a = EEPROM.read(0); 35 | assertEqual(128, a); 36 | 37 | EEPROM.write(0, 255); 38 | a = EEPROM.read(0); 39 | assertEqual(255, a); 40 | 41 | int addr = EEPROM_SIZE / 2; 42 | EEPROM.write(addr, 63); 43 | a = EEPROM.read(addr); 44 | assertEqual(63, a); 45 | 46 | addr = EEPROM_SIZE - 1; 47 | EEPROM.write(addr, 188); 48 | a = EEPROM.read(addr); 49 | assertEqual(188, a); 50 | } 51 | 52 | unittest(updateWrite) 53 | { 54 | EEPROM.write(1, 14); 55 | EEPROM.update(1, 22); 56 | uint8_t a = EEPROM.read(1); 57 | assertEqual(22, a); 58 | } 59 | 60 | unittest(putGet) 61 | { 62 | const float f1 = 0.025f; 63 | float f2 = 0.0f; 64 | EEPROM.put(5, f1); 65 | assertEqual(0.0f, f2); 66 | EEPROM.get(5, f2); 67 | assertEqual(0.025f, f2); 68 | } 69 | 70 | unittest(array) 71 | { 72 | int val = 10; 73 | EEPROM[2] = val; 74 | uint8_t a = EEPROM[2]; 75 | assertEqual(10, a); 76 | } 77 | 78 | #endif 79 | 80 | unittest_main() 81 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/fibonacciClock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // fibbonacci clock 4 | unsigned long lastFakeMicros = 1; 5 | unsigned long fakeMicros = 0; 6 | 7 | void resetFibClock() { 8 | lastFakeMicros = 1; 9 | fakeMicros = 0; 10 | } 11 | 12 | unsigned long fibMicros() { 13 | unsigned long ret = lastFakeMicros + fakeMicros; 14 | lastFakeMicros = fakeMicros; 15 | fakeMicros = ret; 16 | return ret; 17 | } 18 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/fibonacciclock.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "fibonacciClock.h" 4 | 5 | unittest(my_fib_clock) 6 | { 7 | resetFibClock(); 8 | assertEqual(1, fibMicros()); 9 | assertEqual(1, fibMicros()); 10 | assertEqual(2, fibMicros()); 11 | assertEqual(3, fibMicros()); 12 | assertEqual(5, fibMicros()); 13 | assertEqual(8, fibMicros()); 14 | assertEqual(13, fibMicros()); 15 | assertEqual(21, fibMicros()); 16 | 17 | // and again 18 | resetFibClock(); 19 | assertEqual(1, fibMicros()); 20 | assertEqual(1, fibMicros()); 21 | assertEqual(2, fibMicros()); 22 | } 23 | 24 | 25 | unittest_main() 26 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/interrupts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void myInterruptHandler() { 5 | } 6 | 7 | unittest(interrupts) 8 | { 9 | // these are meaningless for testing; just call the routine directly. 10 | // make sure our mocks work though 11 | attachInterrupt(2, myInterruptHandler, CHANGE); 12 | detachInterrupt(2); 13 | } 14 | 15 | unittest(interrupt_attachment) { 16 | GodmodeState *state = GODMODE(); 17 | state->reset(); 18 | assertFalse(state->interrupt[0].attached); 19 | attachInterrupt(0, (void (*)(void))0, 3); 20 | assertTrue(state->interrupt[0].attached); 21 | assertEqual(state->interrupt[0].mode, 3); 22 | detachInterrupt(0); 23 | assertFalse(state->interrupt[0].attached); 24 | } 25 | 26 | 27 | 28 | unittest_main() 29 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/library.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../src/test-something.h" 3 | 4 | unittest(library_tests_something) 5 | { 6 | assertEqual(4, testSomething()); 7 | } 8 | 9 | unittest(library_returns_nullptr) 10 | { 11 | assertEqual(nullptr, aNullPointer()); 12 | } 13 | 14 | unittest_main() 15 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/math.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | unittest(abs) 5 | { 6 | assertEqual(1, abs(1)); 7 | assertEqual(1, abs(-1)); 8 | assertEqual(1.0, abs(1.0)); 9 | assertEqual(1.0, abs(-1.0)); 10 | } 11 | 12 | unittest(constrain) 13 | { 14 | assertEqual(3, constrain(1, 3, 5)); 15 | assertEqual(5, constrain(9, 3, 5)); 16 | assertEqual(2.0, constrain(1, 2.0, 5)); 17 | assertEqual(6.0, constrain(1.3, 6.0, 9)); 18 | } 19 | 20 | unittest(map) 21 | { 22 | assertEqual(30, map(3, 0, 10, 0, 100)); 23 | assertEqual(30, map(20, 0, 50, 50, 0)); 24 | assertEqual(-4, map(26, 0, 50, 100, -100)); 25 | } 26 | 27 | unittest(max) 28 | { 29 | assertEqual(4, max(3, 4)); 30 | assertEqual(5, max(3.0, 5)); 31 | assertEqual(6.0, max(-4, 6.0)); 32 | assertEqual(7.0, max(5.0, 7.0)); 33 | } 34 | 35 | unittest(min) 36 | { 37 | assertEqual(3, min(3, 4)); 38 | assertEqual(3.0, min(3.0, 5)); 39 | assertEqual(-4, min(-4, 6.0)); 40 | assertEqual(5.0, min(5.0, 7.0)); 41 | } 42 | 43 | unittest(pow) 44 | { 45 | assertEqual(4.0, pow(2, 2)); 46 | assertEqual(4.0, pow(2.0, 2.0)); 47 | assertEqual(0.125, pow(2, -3)); 48 | assertLess(1.41420, pow(2, 0.5)); 49 | assertMore(1.41422, pow(2, 0.5)); 50 | } 51 | 52 | unittest(sq) 53 | { 54 | assertEqual(9, sq(3)); 55 | assertEqual(9.0, sq(3.0)); 56 | assertEqual(9, sq(-3)); 57 | assertEqual(9.0, sq(-3.0)); 58 | assertEqual(0.25, sq(0.5)); 59 | assertEqual(0.25, sq(-0.5)); 60 | } 61 | 62 | unittest(sqrt) 63 | { 64 | assertEqual(3, sqrt(9)); 65 | assertEqual(3.0, sqrt(9.0)); 66 | } 67 | 68 | 69 | unittest_main() 70 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/null.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unittest(equality_as_vars) 4 | { 5 | int x = 3; 6 | int y = 3; 7 | int z = 3; 8 | assertEqual(x, y); 9 | assertEqual(x, z); 10 | } 11 | 12 | unittest(equality_as_values) 13 | { 14 | assertEqual(1, 1); 15 | assertEqual(4, 4); 16 | } 17 | 18 | unittest(nothing) 19 | { 20 | } 21 | 22 | unittest(nullpointer) 23 | { 24 | int* myPointer = NULL; 25 | int **notNullPointer = &myPointer; 26 | 27 | assertNull(myPointer); 28 | assertNull(nullptr); 29 | assertEqual(myPointer, nullptr); 30 | assertNotEqual(nullptr, notNullPointer); 31 | assertNotNull(notNullPointer); 32 | } 33 | 34 | unittest(nullpointer_equal) 35 | { 36 | int* myPointer = NULL; 37 | int **notNullPointer = &myPointer; 38 | assertEqual(nullptr, myPointer); 39 | assertNotEqual(nullptr, notNullPointer); 40 | 41 | assertLessOrEqual(nullptr, myPointer); 42 | assertMoreOrEqual(myPointer, nullptr); 43 | assertLessOrEqual(nullptr, notNullPointer); 44 | assertMoreOrEqual(notNullPointer, nullptr); 45 | assertLessOrEqual(myPointer, nullptr); 46 | assertMoreOrEqual(notNullPointer, nullptr); 47 | assertLess(nullptr, notNullPointer); 48 | assertMore(notNullPointer, nullptr); 49 | } 50 | 51 | unittest_main() 52 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/observabledatastream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | class Source : public ObservableDataStream { 6 | public: 7 | Source() : ObservableDataStream() {} 8 | 9 | // expose protected functions 10 | void doBit(bool val) { advertiseBit(val); } 11 | void doByte(unsigned char val) { advertiseByte(val); } 12 | }; 13 | 14 | class Sink : public DataStreamObserver { 15 | public: 16 | bool lastBit; 17 | unsigned char lastByte; 18 | 19 | Sink() : DataStreamObserver(false, false) {} 20 | 21 | virtual String observerName() const { return "Sink"; } 22 | virtual void onBit(bool val) { lastBit = val; } 23 | virtual void onByte(unsigned char val) { lastByte = val; } 24 | }; 25 | 26 | class BitpackSink : public DataStreamObserver { 27 | public: 28 | bool lastBit; 29 | unsigned char lastByte; 30 | 31 | BitpackSink() : DataStreamObserver(true, true) {} 32 | 33 | virtual String observerName() const { return "BitpackSink"; } 34 | virtual void onBit(bool val) { lastBit = val; } 35 | virtual void onByte(unsigned char val) { lastByte = val; } 36 | }; 37 | 38 | unittest(attach_sink_to_src) 39 | { 40 | Source src = Source(); 41 | Sink dst = Sink(); 42 | 43 | dst.lastByte = 'z'; 44 | src.addObserver("foo", &dst); 45 | src.doByte('a'); 46 | assertEqual('a', dst.lastByte); 47 | src.removeObserver("foo"); 48 | src.doByte('b'); 49 | assertEqual('a', dst.lastByte); 50 | } 51 | 52 | unittest(attach_src_to_sink) 53 | { 54 | Source src = Source(); 55 | Sink dst = Sink(); 56 | 57 | dst.attach(&src); 58 | src.doByte('f'); 59 | assertEqual('f', dst.lastByte); 60 | } 61 | 62 | // 01010100 T if bigendian 63 | unittest(bitpack) 64 | { 65 | Source src = Source(); 66 | Sink dst = Sink(); 67 | BitpackSink bst = BitpackSink(); 68 | 69 | bool message[8] = {0, 1, 0, 1, 0, 1, 0, 0}; 70 | 71 | bst.lastByte = 'f'; 72 | dst.lastByte = 'f'; 73 | bst.attach(&src); 74 | dst.attach(&src); 75 | 76 | for (int i = 0; i < 8; ++i) { 77 | src.doBit(message[i]); 78 | assertEqual(message[i], bst.lastBit); 79 | assertEqual(message[i], dst.lastBit); 80 | } 81 | 82 | assertEqual('f', dst.lastByte); // not doing bitpacking 83 | assertEqual('T', bst.lastByte); // should have formed a binary T char by now 84 | assertNotEqual('*', bst.lastByte); // backwards endianness 85 | } 86 | 87 | // 01010100 T if bigendian 88 | unittest(from_pinhistory) 89 | { 90 | GodmodeState* state = GODMODE(); 91 | state->reset(); 92 | 93 | BitpackSink bst = BitpackSink(); 94 | bst.attach(&state->digitalPin[2]); 95 | bst.lastByte = 'f'; 96 | 97 | bool message[8] = {0, 1, 0, 1, 0, 1, 0, 0}; 98 | for (int i = 0; i < 8; ++i) { 99 | digitalWrite(2, message[i]); 100 | assertEqual(message[i], bst.lastBit); 101 | } 102 | 103 | assertEqual('T', bst.lastByte); // should have formed a binary T char by now 104 | assertNotEqual('*', bst.lastByte); // backwards endianness 105 | } 106 | 107 | unittest_main() 108 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/outputRegister.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // added to fix https://github.com/Arduino-CI/arduino_ci/issues/193 5 | // https://github.com/arduino-libraries/Ethernet/blob/master/src/utility/w5100.h#L337 6 | 7 | #if defined(__AVR__) 8 | unittest(portOutputRegister) 9 | { 10 | uint8_t ss_pin = 12; 11 | uint8_t ss_port = digitalPinToPort(ss_pin); 12 | assertEqual(12, ss_port); 13 | uint8_t *ss_pin_reg = portOutputRegister(ss_port); 14 | assertEqual(GODMODE()->pMmapPort(ss_port), ss_pin_reg); 15 | uint8_t ss_pin_mask = digitalPinToBitMask(ss_pin); 16 | assertEqual(1, ss_pin_mask); 17 | 18 | assertEqual((int) 1, (int) *ss_pin_reg); // verify initial value 19 | *(ss_pin_reg) &= ~ss_pin_mask; // set SS 20 | assertEqual((int) 0, (int) *ss_pin_reg); // verify value 21 | *(ss_pin_reg) |= ss_pin_mask; // clear SS 22 | assertEqual((int) 1, (int) *ss_pin_reg); // verify value 23 | } 24 | 25 | unittest(portInputRegister) 26 | { 27 | uint8_t ss_pin = 12; 28 | uint8_t ss_port = digitalPinToPort(ss_pin); 29 | assertEqual(12, ss_port); 30 | uint8_t *ss_pin_reg = portInputRegister(ss_port); 31 | assertEqual(GODMODE()->pMmapPort(ss_port), ss_pin_reg); 32 | uint8_t ss_pin_mask = digitalPinToBitMask(ss_pin); 33 | assertEqual(1, ss_pin_mask); 34 | 35 | assertEqual((int) 1, (int) *ss_pin_reg); // verify initial value 36 | *(ss_pin_reg) &= ~ss_pin_mask; // set SS 37 | assertEqual((int) 0, (int) *ss_pin_reg); // verify value 38 | *(ss_pin_reg) |= ss_pin_mask; // clear SS 39 | assertEqual((int) 1, (int) *ss_pin_reg); // verify value 40 | } 41 | #endif 42 | 43 | unittest_main() 44 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/queue.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "fibonacciClock.h" 4 | 5 | unittest(basic_queue_dequeue_and_size) 6 | { 7 | MockEventQueue q; 8 | int data[5] = {11, 22, 33, 44, 55}; 9 | 10 | assertTrue(q.empty()); 11 | 12 | for (int i = 0; i < 5; ++i) { 13 | assertEqual(i, q.size()); 14 | q.push(data[i]); 15 | assertEqual(data[i], q.backData()); 16 | assertEqual(0, q.backTime()); // we didn't provide a function, so it should default to 0 17 | assertEqual(i + 1, q.size()); 18 | } 19 | 20 | for (int i = 0; i < 5; ++i) { 21 | assertEqual(5 - i, q.size()); 22 | assertEqual(data[i], q.frontData()); 23 | q.pop(); 24 | assertEqual(5 - i - 1, q.size()); 25 | } 26 | 27 | assertTrue(q.empty()); 28 | } 29 | 30 | unittest(copy_constructor) 31 | { 32 | MockEventQueue q; 33 | int data[5] = {11, 22, 33, 44, 55}; 34 | for (int i = 0; i < 5; ++i) q.push(data[i]); 35 | 36 | MockEventQueue q2(q); 37 | 38 | for (int i = 0; i < 5; ++i) { 39 | assertEqual(5 - i, q2.size()); 40 | assertEqual(data[i], q2.frontData()); 41 | q2.pop(); 42 | assertEqual(5 - i - 1, q2.size()); 43 | } 44 | 45 | for (int i = 0; i < 5; ++i) { 46 | assertEqual(5 - i, q.size()); 47 | assertEqual(data[i], q.frontData()); 48 | q.pop(); 49 | assertEqual(5 - i - 1, q.size()); 50 | } 51 | } 52 | 53 | unittest(boundaries) 54 | { 55 | MockEventQueue q; 56 | int data[2] = {11, 22}; 57 | for (int i = 0; i < 2; ++i) q.push(data[i]); 58 | 59 | assertEqual(2, q.size()); 60 | q.pop(); 61 | assertEqual(1, q.size()); 62 | q.pop(); 63 | assertEqual(0, q.size()); 64 | q.pop(); 65 | assertEqual(0, q.size()); 66 | 67 | } 68 | 69 | unittest(timed_events) 70 | { 71 | MockEventQueue q; 72 | int data[7] = {4, 50, 600, 8555, 9000, 9001, 1000000000}; 73 | for (int i = 0; i < 7; ++i) { 74 | q.push(data[i], data[i]); 75 | assertEqual(data[i], q.backData()); 76 | assertEqual(data[i], q.backTime()); 77 | } 78 | 79 | for (int i = 0; i < 7; ++i) { 80 | assertEqual(data[i], q.frontData()); 81 | assertEqual(data[i], q.frontTime()); 82 | q.pop(); 83 | } 84 | 85 | } 86 | 87 | unittest(clocked_events) 88 | { 89 | resetFibClock(); 90 | MockEventQueue q(fibMicros); 91 | int data[7] = {1, 1, 2, 3, 5, 8, 13}; //eureka 92 | for (int i = 0; i < 7; ++i) { 93 | q.push(data[i]); 94 | assertEqual(data[i], q.backData()); 95 | assertEqual(data[i], q.backTime()); 96 | } 97 | 98 | for (int i = 0; i < 7; ++i) { 99 | assertEqual(data[i], q.frontData()); 100 | assertEqual(data[i], q.frontTime()); 101 | q.pop(); 102 | } 103 | 104 | } 105 | 106 | unittest_main() 107 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/serial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if defined(HAVE_HWSERIAL0) 5 | #define HAVE_SERIAL true 6 | #else 7 | #define HAVE_SERIAL false 8 | #endif 9 | 10 | bool have_serial_ports = HAVE_SERIAL; 11 | 12 | unittest(serial_ports) 13 | { 14 | assertTrue(have_serial_ports); 15 | } 16 | 17 | #ifdef HAVE_HWSERIAL0 18 | 19 | unittest(reading_writing_serial) 20 | { 21 | GodmodeState* state = GODMODE(); 22 | state->serialPort[0].dataIn = ""; 23 | state->serialPort[0].dataOut = ""; 24 | assertEqual(-1, Serial.peek()); 25 | assertEqual("", state->serialPort[0].dataIn); 26 | assertEqual("", state->serialPort[0].dataOut); 27 | 28 | state->serialPort[0].dataIn = "a"; 29 | assertEqual('a', Serial.peek()); 30 | assertEqual("a", state->serialPort[0].dataIn); 31 | assertEqual("", state->serialPort[0].dataOut); 32 | 33 | assertEqual('a', Serial.read()); 34 | assertEqual("", state->serialPort[0].dataIn); 35 | assertEqual("", state->serialPort[0].dataOut); 36 | 37 | Serial.write('b'); 38 | assertEqual("", state->serialPort[0].dataIn); 39 | assertEqual("b", state->serialPort[0].dataOut); 40 | 41 | Serial.print("cdefg"); 42 | assertEqual("", state->serialPort[0].dataIn); 43 | assertEqual("bcdefg", state->serialPort[0].dataOut); 44 | } 45 | 46 | unittest(all_serial_writes) 47 | { 48 | GodmodeState* state = GODMODE(); 49 | state->serialPort[0].dataIn = ""; 50 | state->serialPort[0].dataOut = ""; 51 | 52 | char str[4] = "xyz"; 53 | Serial.write(reinterpret_cast(str ), 3); 54 | Serial.print((int)1); 55 | Serial.print((long)2); 56 | Serial.print((double)3.4); 57 | Serial.print((char)'a'); 58 | Serial.print("b"); 59 | assertEqual("xyz123.4000000000ab", state->serialPort[0].dataOut); 60 | } 61 | 62 | #endif 63 | 64 | unittest_main() 65 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/setup_and_teardown.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class LcdInterface { 5 | public: 6 | virtual void print(const char *) = 0; 7 | }; 8 | 9 | class MockLcd : public LcdInterface { 10 | public: 11 | String s; 12 | void print(const char* c) 13 | { 14 | s = String(c); 15 | } 16 | }; 17 | 18 | class Calculator { 19 | private: 20 | LcdInterface *m_lcd; 21 | 22 | public: 23 | Calculator(LcdInterface* lcd) { 24 | m_lcd = lcd; 25 | } 26 | 27 | ~Calculator() { 28 | m_lcd = 0; 29 | } 30 | 31 | int add(int a, int b) 32 | { 33 | int result = a + b; 34 | char buf[40]; 35 | sprintf(buf, "%d + %d = %d", a, b, result); 36 | m_lcd->print(buf); 37 | return result; 38 | } 39 | }; 40 | 41 | 42 | // This is a typical test where using setup (and teardown) would be useful 43 | // to set up the "external" lcd dependency that the calculator uses indirectly 44 | // but it is not something that is related to the functionality that is tested. 45 | 46 | MockLcd* lcd_p; 47 | Calculator* c; 48 | 49 | unittest_setup() 50 | { 51 | lcd_p = new MockLcd(); 52 | c = new Calculator(lcd_p); 53 | } 54 | 55 | unittest_teardown() 56 | { 57 | delete c; 58 | delete lcd_p; 59 | } 60 | 61 | 62 | // When you want to test that the calculator actually prints the calculations, 63 | // then that should be done in the arrange part of the actual test (by setting 64 | // up an mock lcd class that keeps a list of all messages printed). 65 | 66 | unittest(add) 67 | { 68 | int result = c->add(11, 22); 69 | assertEqual(33, result); 70 | assertEqual("11 + 22 = 33", lcd_p->s); 71 | } 72 | 73 | unittest(add_again) 74 | { 75 | int result = c->add(33, 44); 76 | assertEqual(77, result); 77 | assertEqual("33 + 44 = 77", lcd_p->s); 78 | } 79 | 80 | unittest_main() 81 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/softwareserial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | bool bigEndian = false; 5 | bool flipLogic = false; 6 | 7 | unittest(software_input_output) 8 | { 9 | GodmodeState* state = GODMODE(); 10 | state->reset(); 11 | 12 | SoftwareSerial ss(1, 2, flipLogic); 13 | 14 | assertEqual(-1, ss.peek()); 15 | 16 | state->digitalPin[1].fromAscii("Holy crap ", bigEndian); 17 | state->digitalPin[1].fromAscii("this took a lot of prep work", bigEndian); 18 | 19 | assertFalse(ss.isListening()); 20 | assertEqual(-1, ss.peek()); 21 | 22 | ss.listen(); 23 | assertTrue(ss.isListening()); 24 | assertEqual(38, ss.available()); 25 | assertEqual('H', ss.peek()); 26 | assertEqual('H', ss.read()); 27 | assertEqual('o', ss.read()); 28 | assertEqual('l', ss.read()); 29 | assertEqual('y', ss.read()); 30 | 31 | ss.write('b'); 32 | ss.write('A'); 33 | ss.write('r'); 34 | assertEqual("bAr", state->digitalPin[2].toAscii(1, bigEndian)); 35 | } 36 | 37 | unittest(print) { 38 | GodmodeState* state = GODMODE(); 39 | state->reset(); 40 | 41 | SoftwareSerial ss(1, 2, flipLogic); 42 | ss.listen(); 43 | ss.print(1.3, 2); 44 | assertEqual("1.30", state->digitalPin[2].toAscii(1, bigEndian)); 45 | } 46 | 47 | unittest_main() 48 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/stdlib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define ARRAY_SIZEOF(a) ( sizeof(a) / sizeof((a)[0]) ) 7 | 8 | unittest(library_tests_itoa) 9 | { 10 | char buf[32]; 11 | struct { 12 | int value; 13 | const char *expected; 14 | int base; 15 | } table[] = { 16 | { 54325, "1101010000110101", 2 }, 17 | { 54325, "54325", 10 }, 18 | { 54325, "D435", 16 }, 19 | { 493, "755", 8 }, 20 | { -1, "-1", 10 }, 21 | { 32767, "32767", 10}, 22 | { 32767, "7FFF", 16}, 23 | { 65535, "65535", 10}, 24 | { 65535, "FFFF", 16}, 25 | { 2147483647, "2147483647", 10}, 26 | { 2147483647, "7FFFFFFF", 16}, 27 | }; 28 | 29 | for (int i = 0; i < ARRAY_SIZEOF(table); i++) { 30 | itoa(table[i].value, buf, table[i].base); 31 | for (int j = 0; j < strlen(buf); ++j) { 32 | buf[j] = toupper(buf[j]); 33 | } 34 | assertEqual(table[i].expected, buf); 35 | } 36 | 37 | // While only bases 2, 8, 10 and 16 are of real interest, let's test that all 38 | // bases at least produce expected output for a few test points simple to test. 39 | for (int base = 2; base <= 16; base++) { 40 | itoa(0, buf, base); 41 | assertEqual("0", buf); 42 | itoa(1, buf, base); 43 | assertEqual("1", buf); 44 | itoa(base, buf, base); 45 | assertEqual("10", buf); 46 | } 47 | 48 | } 49 | 50 | unittest(library_tests_dtostrf) 51 | { 52 | float num = 123.456; 53 | char buffer[10]; 54 | dtostrf(num, 7, 3, buffer); 55 | assertEqual(strncmp(buffer, "123.456", sizeof(buffer)), 0); 56 | } 57 | 58 | unittest_main() 59 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/stream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | unittest(stream_construction) 5 | { 6 | String data = ""; 7 | unsigned long micros = 100; 8 | 9 | Stream s; 10 | s.mGodmodeDataIn = &data; 11 | s.mGodmodeMicrosDelay = µs; 12 | 13 | assertEqual(0, s.available()); 14 | data = "abcd"; 15 | assertEqual(4, s.available()); 16 | assertEqual('a', s.peek()); 17 | assertEqual('a', s.read()); 18 | assertEqual("bcd", s.readString()); 19 | assertEqual("", s.readString()); 20 | 21 | } 22 | 23 | 24 | unittest(stream_find) 25 | { 26 | String data = ""; 27 | unsigned long micros = 100; 28 | 29 | Stream s; 30 | s.mGodmodeDataIn = &data; 31 | s.mGodmodeMicrosDelay = µs; 32 | 33 | data = "abcdefghijkl"; 34 | assertEqual('a', s.peek()); 35 | assertEqual(true, s.find('f')); 36 | assertEqual('f', s.peek()); 37 | assertEqual("fghijkl", s.readString()); 38 | data = "fghijkl"; 39 | assertEqual(false, s.findUntil("k", "j")); 40 | assertEqual('j', s.peek()); 41 | } 42 | 43 | unittest(stream_parse) 44 | { 45 | String data = ""; 46 | unsigned long micros = 100; 47 | 48 | Stream s; 49 | s.mGodmodeDataIn = &data; 50 | s.mGodmodeMicrosDelay = µs; 51 | 52 | long l; 53 | float f; 54 | data = "abcdefghijkl-123-456abcd"; 55 | l = s.parseInt(); 56 | assertEqual(-123, l); 57 | assertEqual('-', data[0]); 58 | l = s.parseInt(); 59 | assertEqual(-456, l); 60 | l = s.parseInt(); 61 | assertEqual(0, l); 62 | 63 | data = "abc123.456-345.322"; 64 | f = s.parseFloat(); 65 | assertLess(123.456 - f, 0.0001); 66 | assertEqual('-', data[0]); 67 | f = s.parseFloat(); 68 | assertLess(-345.322 - f, 0.0001); 69 | 70 | } 71 | 72 | unittest(readStringUntil) { 73 | String data = ""; 74 | unsigned long micros = 100; 75 | data = "abc:def"; 76 | 77 | Stream s; 78 | s.mGodmodeDataIn = &data; 79 | s.mGodmodeMicrosDelay = µs; 80 | // result should not include delimiter 81 | assertEqual("abc", s.readStringUntil(':')); 82 | assertEqual("def", s.readStringUntil(':')); 83 | } 84 | unittest_main() 85 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/table.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // for testing a work function 6 | // note swapped args because as "isMatch", it's "firstArg, key" 7 | bool isSubstr(String firstArg, String haystack) { 8 | return strstr(haystack.c_str(), firstArg.c_str()); 9 | } 10 | 11 | // for testing a work function 12 | int results[5]; 13 | void setResult2(int k, int v) { 14 | results[k] = v; 15 | } 16 | void setResult3(long l, int k, int v) { 17 | results[k] = v + l; 18 | } 19 | 20 | 21 | unittest(basic_table) { 22 | ArduinoCITable t; 23 | assertTrue(t.empty()); 24 | 25 | int data[5] = {11, 22, 33, 44, 55}; 26 | 27 | for (int i = 0; i < 5; ++i) { 28 | assertEqual(i, t.size()); 29 | assertTrue(t.add(String(data[i]), data[i])); 30 | assertEqual(i + 1, t.size()); 31 | } 32 | 33 | assertTrue(t.has("44")); 34 | assertFalse(t.has("66")); 35 | assertEqual(44, t.get("44")); 36 | 37 | assertEqual("33", t.getMatchingKey(String("3"), isSubstr)); 38 | 39 | for (int i = 0; i < 5; ++i) { 40 | assertEqual(5 - i, t.size()); 41 | assertTrue(t.remove(String(data[i]))); 42 | assertFalse(t.has(String(data[i]))); 43 | assertEqual(4 - i, t.size()); 44 | } 45 | 46 | } 47 | 48 | unittest(clear) { 49 | ArduinoCITable t1; 50 | int data[5] = {11, 22, 33, 44, 55}; 51 | 52 | for (int i = 0; i < 5; ++i) { 53 | t1.add(String(data[i]), data[i]); 54 | } 55 | 56 | assertEqual(5, t1.size()); 57 | t1.clear(); 58 | assertEqual(0, t1.size()); 59 | } 60 | 61 | unittest(copy_construction) { 62 | ArduinoCITable t1; 63 | int data[5] = {11, 22, 33, 44, 55}; 64 | 65 | for (int i = 0; i < 5; ++i) { 66 | t1.add(String(data[i]), data[i]); 67 | } 68 | 69 | ArduinoCITable t2 = t1; 70 | t1.clear(); 71 | assertEqual(0, t1.size()); 72 | assertEqual(5, t2.size()); 73 | 74 | for (int i = 0; i < 5; ++i) { 75 | assertTrue(t2.has(String(data[i]))); 76 | assertTrue(t2.remove(String(data[i]))); 77 | assertFalse(t2.has(String(data[i]))); 78 | } 79 | assertEqual(0, t2.size()); 80 | } 81 | 82 | unittest(iteration_no_arg) { 83 | ArduinoCITable t; 84 | for (int i = 0; i < 5; ++i) { 85 | results[i] = 0; 86 | t.add(i, 11 * (i + 1)); 87 | } 88 | 89 | t.iterate(&setResult2); 90 | 91 | for (int i = 0; i < 5; ++i) assertEqual(11 * (i + 1), results[i]); 92 | } 93 | 94 | unittest(iteration_one_arg) { 95 | ArduinoCITable t; 96 | for (int i = 0; i < 5; ++i) { 97 | results[i] = 0; 98 | t.add(i, 11 * (i + 1)); 99 | } 100 | 101 | long offset = 9; 102 | t.iterate(&setResult3, offset); 103 | 104 | for (int i = 0; i < 5; ++i) assertEqual(11 * (i + 1), results[i] - offset); 105 | } 106 | 107 | unittest_main() 108 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/trig.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | unittest(floor) 5 | { 6 | assertEqual(1, floor(1.9)); 7 | assertEqual(1, floor(1)); 8 | assertEqual(1, floor(1.0)); 9 | assertEqual(1, floor(1.9999999)); 10 | } 11 | 12 | unittest(cos) 13 | { 14 | assertEqual(1.0, cos(0)); 15 | assertLess(-0.01, cos(3.141 / 2)); 16 | assertMore(0.01, cos(3.141 / 2)); 17 | assertMore(-0.99, cos(PI)); 18 | assertLess(-1.01, cos(PI)); 19 | assertLess(-0.01, cos(radians(90))); 20 | assertMore(0.01, cos(radians(90))); 21 | } 22 | 23 | unittest_main() 24 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/wcharacter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | unittest(isAlpha) 5 | { 6 | assertTrue(isAlpha('a')); 7 | assertFalse(isAlpha('3')); 8 | } 9 | 10 | unittest(isAlphaNumeric) 11 | { 12 | assertTrue(isAlphaNumeric('a')); 13 | assertTrue(isAlphaNumeric('3')); 14 | assertFalse(isAlphaNumeric('!')); 15 | } 16 | 17 | unittest(isAscii) 18 | { 19 | assertTrue(isAscii('a')); 20 | assertTrue(isAscii('3')); 21 | assertTrue(isAscii('!')); 22 | assertFalse(isAlpha((int)0xAF)); 23 | } 24 | 25 | unittest(isControl) 26 | { 27 | assertFalse(isControl(' ')); 28 | assertTrue(isControl((int)0x03)); 29 | } 30 | 31 | unittest(isDigit) 32 | { 33 | assertFalse(isDigit(' ')); 34 | assertTrue(isDigit('2')); 35 | } 36 | 37 | unittest(isGraph) 38 | { 39 | assertFalse(isGraph(' ')); 40 | assertTrue(isGraph('2')); 41 | } 42 | 43 | unittest(isHexadecimalDigit) 44 | { 45 | assertTrue(isHexadecimalDigit('0')); 46 | assertTrue(isHexadecimalDigit('a')); 47 | assertTrue(isHexadecimalDigit('A')); 48 | assertFalse(isHexadecimalDigit('G')); 49 | assertFalse(isHexadecimalDigit('!')); 50 | } 51 | 52 | unittest(isLowerCase) 53 | { 54 | assertFalse(isLowerCase('A')); 55 | assertTrue(isLowerCase('a')); 56 | } 57 | 58 | unittest(isPrintable) 59 | { 60 | assertFalse(isPrintable((int)0x03)); 61 | assertTrue(isPrintable('a')); 62 | } 63 | 64 | unittest(isPunct) 65 | { 66 | assertFalse(isPunct('a')); 67 | assertTrue(isPunct('!')); 68 | } 69 | 70 | unittest(isSpace) 71 | { 72 | assertFalse(isSpace('a')); 73 | assertTrue(isSpace(' ')); 74 | } 75 | 76 | unittest(isUpperCase) 77 | { 78 | assertFalse(isUpperCase('a')); 79 | assertTrue(isUpperCase('A')); 80 | } 81 | 82 | unittest(isWhitespace) 83 | { 84 | assertTrue(isWhitespace(' ')); 85 | assertTrue(isWhitespace('\r')); 86 | assertTrue(isWhitespace('\f')); 87 | assertTrue(isWhitespace('\t')); 88 | assertTrue(isWhitespace('\v')); 89 | assertTrue(isWhitespace('\n')); 90 | assertFalse(isWhitespace('j')); 91 | } 92 | 93 | unittest_main() 94 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/wdt.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | unittest(wdt) { 6 | wdt_disable(); 7 | wdt_enable(WDTO_8S); 8 | wdt_reset(); 9 | assertTrue(true); 10 | } 11 | 12 | unittest_main() 13 | -------------------------------------------------------------------------------- /SampleProjects/TestSomething/test/wire.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using std::deque; 5 | 6 | unittest(wire_init) { 7 | Wire.resetMocks(); 8 | assertFalse(Wire.didBegin()); 9 | Wire.begin(); 10 | assertTrue(Wire.didBegin()); 11 | Wire.resetMocks(); 12 | assertFalse(Wire.didBegin()); 13 | } 14 | 15 | unittest(begin_write_end) { 16 | Wire.resetMocks(); 17 | 18 | const uint8_t randomSlaveAddr = 14; 19 | const uint8_t randomData[] = { 0x07, 0x0E }; 20 | 21 | // master write buffer should be empty 22 | deque* mosi = Wire.getMosi(randomSlaveAddr); 23 | assertEqual(0, mosi->size()); 24 | 25 | // write some random data to random slave 26 | 27 | Wire.begin(); 28 | Wire.beginTransmission(randomSlaveAddr); 29 | Wire.write(randomData[0]); 30 | Wire.write(randomData[1]); 31 | Wire.endTransmission(); 32 | 33 | // check master write buffer values 34 | assertEqual(2, mosi->size()); 35 | assertEqual(randomData[0], mosi->front()); 36 | mosi->pop_front(); 37 | assertEqual(randomData[1], mosi->front()); 38 | mosi->pop_front(); 39 | assertEqual(0, mosi->size()); 40 | } 41 | 42 | unittest(readTwo_writeOne) { 43 | Wire.resetMocks(); 44 | 45 | Wire.begin(); 46 | deque* miso; 47 | // place some values on random slaves' read buffers 48 | const int randomSlaveAddr = 19, anotherRandomSlave = 34, yetAnotherSlave = 47; 49 | const uint8_t randomData[] = { 0x07, 0x0E }, moreRandomData[] = { 1, 4, 7 }; 50 | miso = Wire.getMiso(randomSlaveAddr); 51 | miso->push_back(randomData[0]); 52 | miso->push_back(randomData[1]); 53 | miso = Wire.getMiso(anotherRandomSlave); 54 | miso->push_back(moreRandomData[0]); 55 | miso->push_back(moreRandomData[1]); 56 | miso->push_back(moreRandomData[2]); 57 | 58 | // check read buffers and read-related functions 59 | // request more data than is in input buffer 60 | assertEqual(0, Wire.requestFrom(randomSlaveAddr, 3)); 61 | // normal use cases 62 | assertEqual(2, Wire.requestFrom(randomSlaveAddr, 2)); 63 | assertEqual(2, Wire.available()); 64 | assertEqual(randomData[0], Wire.read()); 65 | assertEqual(1, Wire.available()); 66 | assertEqual(randomData[1], Wire.read()); 67 | assertEqual(0, Wire.available()); 68 | assertEqual(3, Wire.requestFrom(anotherRandomSlave, 3)); 69 | assertEqual(3, Wire.available()); 70 | assertEqual(moreRandomData[0], Wire.read()); 71 | assertEqual(2, Wire.available()); 72 | assertEqual(moreRandomData[1], Wire.read()); 73 | assertEqual(1, Wire.available()); 74 | assertEqual(moreRandomData[2], Wire.read()); 75 | assertEqual(0, Wire.available()); 76 | 77 | // write some arbitrary values to a third slave 78 | Wire.beginTransmission(yetAnotherSlave); 79 | for (int i = 1; i < 4; i++) { 80 | Wire.write(i * 2); 81 | } 82 | Wire.endTransmission(); 83 | 84 | // check master write buffer 85 | deque* mosi = Wire.getMosi(yetAnotherSlave); 86 | const uint8_t expectedValues[] = { 2, 4, 6 }; 87 | 88 | assertEqual(3, mosi->size()); 89 | assertEqual(expectedValues[0], mosi->front()); 90 | mosi->pop_front(); 91 | assertEqual(2, mosi->size()); 92 | assertEqual(expectedValues[1], mosi->front()); 93 | mosi->pop_front(); 94 | assertEqual(1, mosi->size()); 95 | assertEqual(expectedValues[2], mosi->front()); 96 | mosi->pop_front(); 97 | assertEqual(0, mosi->size()); 98 | } 99 | 100 | unittest_main() 101 | -------------------------------------------------------------------------------- /arduino_ci.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path("../lib", __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require "arduino_ci/version" 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "arduino_ci" 8 | spec.version = ArduinoCI::VERSION 9 | spec.licenses = ['Apache-2.0'] 10 | spec.authors = ["Ian Katz"] 11 | spec.email = ["arduino.continuous.integration@gmail.com"] 12 | 13 | spec.summary = "Tools for building and unit testing Arduino libraries" 14 | spec.description = spec.description 15 | spec.homepage = "http://github.com/Arduino-CI/arduino_ci" 16 | 17 | spec.bindir = "exe" 18 | rejection_regex = %r{^(test|spec|features)/} 19 | libfiles = Dir['lib/**/*.*'].reject { |f| f.match(rejection_regex) } 20 | binfiles = Dir[File.join(spec.bindir, '/**/*.*')].reject { |f| f.match(rejection_regex) } 21 | cppfiles = Dir['cpp/**/*.*'] 22 | miscfiles = Dir['misc/**/*.*'] 23 | spec.files = ['README.md', 'REFERENCE.md', '.yardopts'] + libfiles + binfiles + cppfiles + miscfiles 24 | 25 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 26 | spec.require_paths = ["lib"] 27 | 28 | spec.add_dependency "os", "~> 1.0" 29 | spec.add_dependency "rubyzip", "~> 1.2" 30 | end 31 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "arduino_ci" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start(__FILE__) 15 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /cpp/.gitignore: -------------------------------------------------------------------------------- 1 | *.gch 2 | *.gch-* 3 | -------------------------------------------------------------------------------- /cpp/arduino/Arduino.cpp: -------------------------------------------------------------------------------- 1 | #include "Godmode.h" 2 | 3 | -------------------------------------------------------------------------------- /cpp/arduino/Arduino.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | Mock Arduino.h library. 4 | 5 | Where possible, variable names from the Arduino library are used to avoid conflicts 6 | 7 | */ 8 | 9 | // signal to the developer that we are in an arduino_ci mocked environment 10 | #define ARDUINO_CI_COMPILATION_MOCKS 11 | 12 | 13 | // Chars and strings 14 | 15 | #include "ArduinoDefines.h" 16 | 17 | #include "IPAddress.h" 18 | #include "WCharacter.h" 19 | #include "WString.h" 20 | #include "Print.h" 21 | #include "Stream.h" 22 | #include "HardwareSerial.h" 23 | 24 | typedef bool boolean; 25 | typedef uint8_t byte; 26 | 27 | #include "binary.h" 28 | 29 | // Math and Trig 30 | #include "AvrMath.h" 31 | 32 | #include "Godmode.h" 33 | 34 | 35 | // Bits and Bytes 36 | #define bit(b) (1UL << (b)) 37 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 38 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 39 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) 40 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 41 | #define highByte(w) ((uint8_t) ((w) >> 8)) 42 | #define lowByte(w) ((uint8_t) ((w) & 0xff)) 43 | 44 | // using #define for these makes it impossible for other code to use as function 45 | // names! 46 | inline void yield() { _NOP(); } 47 | inline void interrupts() { _NOP(); } 48 | inline void noInterrupts() { _NOP(); } 49 | 50 | // TODO: correctly establish this per-board! 51 | #define F_CPU 1000000UL 52 | #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) 53 | #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) 54 | #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) 55 | 56 | typedef unsigned int word; 57 | 58 | #define _BV(bit) (1 << (bit)) 59 | 60 | // Get the bit location within the hardware port of the given virtual pin. 61 | // This comes from the pins_*.c file for the active board configuration. 62 | 63 | #define analogInPinToBit(P) (P) 64 | #define digitalPinToInterrupt(P) (P) 65 | 66 | // uint16_t makeWord(uint16_t w); 67 | // uint16_t makeWord(byte h, byte l); 68 | inline unsigned int makeWord(unsigned int w) { return w; } 69 | inline unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } 70 | 71 | #define word(...) makeWord(__VA_ARGS__) 72 | -------------------------------------------------------------------------------- /cpp/arduino/ArduinoDefines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define HIGH 0x1 6 | #define LOW 0x0 7 | 8 | #define INPUT 0x0 9 | #define OUTPUT 0x1 10 | #define INPUT_PULLUP 0x2 11 | 12 | #define PI 3.1415926535897932384626433832795 13 | #define HALF_PI 1.5707963267948966192313216916398 14 | #define TWO_PI 6.283185307179586476925286766559 15 | #define DEG_TO_RAD 0.017453292519943295769236907684886 16 | #define RAD_TO_DEG 57.295779513082320876798154814105 17 | #define EULER 2.718281828459045235360287471352 18 | 19 | #define SERIAL 0x0 20 | #define DISPLAY 0x1 21 | 22 | #define LSBFIRST 0 23 | #define MSBFIRST 1 24 | 25 | #define CHANGE 1 26 | #define FALLING 2 27 | #define RISING 3 28 | 29 | #if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) 30 | #define DEFAULT 0 31 | #define EXTERNAL 1 32 | #define INTERNAL1V1 2 33 | #define INTERNAL INTERNAL1V1 34 | #elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) 35 | #define DEFAULT 0 36 | #define EXTERNAL 4 37 | #define INTERNAL1V1 8 38 | #define INTERNAL INTERNAL1V1 39 | #define INTERNAL2V56 9 40 | #define INTERNAL2V56_EXTCAP 13 41 | #else 42 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) 43 | #define INTERNAL1V1 2 44 | #define INTERNAL2V56 3 45 | #else 46 | #define INTERNAL 3 47 | #endif 48 | #define DEFAULT 1 49 | #define EXTERNAL 0 50 | #endif 51 | 52 | #define NOT_A_PIN 0 53 | #define NOT_A_PORT 0 54 | 55 | #define NOT_AN_INTERRUPT -1 56 | 57 | #ifdef ARDUINO_MAIN 58 | #define PA 1 59 | #define PB 2 60 | #define PC 3 61 | #define PD 4 62 | #define PE 5 63 | #define PF 6 64 | #define PG 7 65 | #define PH 8 66 | #define PJ 10 67 | #define PK 11 68 | #define PL 12 69 | #endif 70 | 71 | #define NOT_ON_TIMER 0 72 | #define TIMER0A 1 73 | #define TIMER0B 2 74 | #define TIMER1A 3 75 | #define TIMER1B 4 76 | #define TIMER1C 5 77 | #define TIMER2 6 78 | #define TIMER2A 7 79 | #define TIMER2B 8 80 | 81 | #define TIMER3A 9 82 | #define TIMER3B 10 83 | #define TIMER3C 11 84 | #define TIMER4A 12 85 | #define TIMER4B 13 86 | #define TIMER4C 14 87 | #define TIMER4D 15 88 | #define TIMER5A 16 89 | #define TIMER5B 17 90 | #define TIMER5C 18 91 | 92 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega4809__) || defined(__SAM3X8E__) || defined(__SAMD21G18A__) 93 | // Verified on these platforms, see https://github.com/Arduino-CI/arduino_ci/pull/341#issuecomment-1368118880 94 | #define LED_BUILTIN 13 95 | 96 | #define A0 14 97 | #define A1 15 98 | #define A2 16 99 | #define A3 17 100 | #define A4 18 101 | #define A5 19 102 | #define A6 20 103 | #define A7 21 104 | #define A8 22 105 | #define A9 23 106 | #define A10 24 107 | #define A11 25 108 | 109 | #endif 110 | 111 | // Arduino defines this 112 | #define _NOP() do { 0; } while (0) 113 | -------------------------------------------------------------------------------- /cpp/arduino/Client.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Client : public Stream { 7 | public: 8 | Client() { 9 | // The Stream mock defines a String buffer but never puts anything in it! 10 | if (!mGodmodeDataIn) { 11 | mGodmodeDataIn = new String; 12 | } 13 | } 14 | Client(const Client &client) { // copy constructor 15 | if (this != &client) { // not a self-assignment 16 | if (mGodmodeDataIn && 17 | client.mGodmodeDataIn) { // replace what we previously had 18 | delete mGodmodeDataIn; // get rid of previous value 19 | mGodmodeDataIn = new String(client.mGodmodeDataIn->c_str()); 20 | } 21 | } 22 | } 23 | Client &operator=(const Client &client) { // copy assignment operator 24 | if (this != &client) { // not a self-assignment 25 | if (mGodmodeDataIn && 26 | client.mGodmodeDataIn) { // replace what we previously had 27 | delete mGodmodeDataIn; // get rid of previous value 28 | mGodmodeDataIn = new String(client.mGodmodeDataIn->c_str()); 29 | } 30 | } 31 | return *this; 32 | } 33 | ~Client() { 34 | if (mGodmodeDataIn) { 35 | delete mGodmodeDataIn; 36 | mGodmodeDataIn = nullptr; 37 | } 38 | } 39 | virtual size_t write(uint8_t value) { 40 | mGodmodeDataIn->concat(value); 41 | return 1; 42 | } 43 | 44 | protected: 45 | uint8_t *rawIPAddress(IPAddress &addr) { return addr.raw_address(); } 46 | }; 47 | -------------------------------------------------------------------------------- /cpp/arduino/EEPROM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // Does the current board have EEPROM? 8 | #ifndef EEPROM_SIZE 9 | // In lieu of an "EEPROM.h not found" error for unsupported boards 10 | #error "EEPROM library not available for your board" 11 | #endif 12 | 13 | class EEPROMClass { 14 | private: 15 | GodmodeState* state; 16 | public: 17 | // constructor 18 | EEPROMClass() { 19 | state = GODMODE(); 20 | } 21 | // array subscript operator 22 | uint8_t &operator[](const int index) { 23 | assert(index < EEPROM_SIZE); 24 | return state->eeprom[index]; 25 | } 26 | 27 | uint8_t read(const int index) { 28 | assert(index < EEPROM_SIZE); 29 | return state->eeprom[index]; 30 | } 31 | 32 | void write(const int index, const uint8_t value) { 33 | assert(index < EEPROM_SIZE); 34 | state->eeprom[index] = value; 35 | } 36 | 37 | void update(const int index, const uint8_t value) { 38 | assert(index < EEPROM_SIZE); 39 | state->eeprom[index] = value; 40 | } 41 | 42 | uint16_t length() { return EEPROM_SIZE; } 43 | 44 | // read any object 45 | template T &get(const int index, T &object) { 46 | uint8_t *ptr = (uint8_t *)&object; 47 | for (int i = 0; i < sizeof(T); ++i) { 48 | *ptr++ = read(index + i); 49 | } 50 | return object; 51 | } 52 | 53 | // write any object 54 | template const T &put(const int index, T &object) { 55 | const uint8_t *ptr = (const uint8_t *)&object; 56 | for (int i = 0; i < sizeof(T); ++i) { 57 | write(index + i, *ptr++); 58 | } 59 | return object; 60 | } 61 | }; 62 | 63 | // global available in Godmode.cpp 64 | extern EEPROMClass EEPROM; 65 | -------------------------------------------------------------------------------- /cpp/arduino/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#include 4 | #include "ci/StreamTape.h" 5 | 6 | // definitions needed for Serial.begin's config arg 7 | #define SERIAL_5N1 0x00 8 | #define SERIAL_6N1 0x02 9 | #define SERIAL_7N1 0x04 10 | #define SERIAL_8N1 0x06 11 | #define SERIAL_5N2 0x08 12 | #define SERIAL_6N2 0x0A 13 | #define SERIAL_7N2 0x0C 14 | #define SERIAL_8N2 0x0E 15 | #define SERIAL_5E1 0x20 16 | #define SERIAL_6E1 0x22 17 | #define SERIAL_7E1 0x24 18 | #define SERIAL_8E1 0x26 19 | #define SERIAL_5E2 0x28 20 | #define SERIAL_6E2 0x2A 21 | #define SERIAL_7E2 0x2C 22 | #define SERIAL_8E2 0x2E 23 | #define SERIAL_5O1 0x30 24 | #define SERIAL_6O1 0x32 25 | #define SERIAL_7O1 0x34 26 | #define SERIAL_8O1 0x36 27 | #define SERIAL_5O2 0x38 28 | #define SERIAL_6O2 0x3A 29 | #define SERIAL_7O2 0x3C 30 | #define SERIAL_8O2 0x3E 31 | 32 | class HardwareSerial : public StreamTape 33 | { 34 | public: 35 | HardwareSerial(String* dataIn, String* dataOut, unsigned long* delay): StreamTape(dataIn, dataOut, delay) {} 36 | 37 | void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } 38 | void begin(unsigned long baud, uint8_t config) { 39 | *mGodmodeMicrosDelay = 1000000 / baud; 40 | } 41 | void end() {} 42 | 43 | // support "if (Serial1) {}" sorts of things 44 | operator bool() { return true; } 45 | }; 46 | 47 | #if NUM_SERIAL_PORTS >= 1 48 | extern HardwareSerial Serial; 49 | #define HAVE_HWSERIAL0 50 | #endif 51 | #if NUM_SERIAL_PORTS >= 2 52 | extern HardwareSerial Serial1; 53 | #define HAVE_HWSERIAL1 54 | #endif 55 | #if NUM_SERIAL_PORTS >= 3 56 | extern HardwareSerial Serial2; 57 | #define HAVE_HWSERIAL2 58 | #endif 59 | #if NUM_SERIAL_PORTS >= 4 60 | extern HardwareSerial Serial3; 61 | #define HAVE_HWSERIAL3 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /cpp/arduino/IPAddress.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class IPAddress { 6 | private: 7 | union { 8 | uint8_t bytes[4]; 9 | uint32_t dword; 10 | operator uint8_t *() const { return (uint8_t *)bytes; } 11 | } _address; 12 | 13 | public: 14 | // Constructors 15 | IPAddress() : IPAddress(0, 0, 0, 0) {} 16 | IPAddress(uint8_t octet1, uint8_t octet2, uint8_t octet3, uint8_t octet4) { 17 | _address.bytes[0] = octet1; 18 | _address.bytes[1] = octet2; 19 | _address.bytes[2] = octet3; 20 | _address.bytes[3] = octet4; 21 | } 22 | IPAddress(uint32_t dword) { _address.dword = dword; } 23 | IPAddress(const uint8_t bytes[]) { 24 | _address.bytes[0] = bytes[0]; 25 | _address.bytes[1] = bytes[1]; 26 | _address.bytes[2] = bytes[2]; 27 | _address.bytes[3] = bytes[3]; 28 | } 29 | IPAddress(unsigned long dword) { _address.dword = (uint32_t)dword; } 30 | 31 | // Accessors 32 | uint32_t asWord() const { return _address.dword; } 33 | uint8_t *raw_address() { return _address.bytes; } 34 | 35 | // Comparisons 36 | bool operator==(const IPAddress &rhs) const { 37 | return _address.dword == rhs.asWord(); 38 | } 39 | 40 | bool operator!=(const IPAddress &rhs) const { 41 | return _address.dword != rhs.asWord(); 42 | } 43 | 44 | // Indexing 45 | uint8_t operator[](int index) const { return _address.bytes[index]; } 46 | uint8_t &operator[](int index) { return _address.bytes[index]; } 47 | 48 | // Conversions 49 | operator uint32_t() const { return _address.dword; }; 50 | 51 | friend class EthernetClass; 52 | friend class UDP; 53 | friend class Client; 54 | friend class Server; 55 | friend class DhcpClass; 56 | friend class DNSClient; 57 | }; 58 | 59 | const IPAddress INADDR_NONE(0, 0, 0, 0); 60 | -------------------------------------------------------------------------------- /cpp/arduino/MockEventQueue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class MockEventQueue { 5 | public: 6 | struct Event { 7 | T data; 8 | unsigned long micros; 9 | 10 | Event() : data(T()), micros(0) {} 11 | Event(const T &d, unsigned long const t) : data(d), micros(t) { } 12 | }; 13 | 14 | private: 15 | struct Node { 16 | Event event; 17 | Node* next; 18 | 19 | Node(const Event &e, Node* n) : event(e), next(n) { } 20 | }; 21 | 22 | Node* mFront; 23 | Node* mBack; 24 | unsigned long mSize; 25 | T mNil; 26 | unsigned long (*mGetMicros)(void); 27 | 28 | void init(unsigned long (*getMicros)(void)) { 29 | mFront = mBack = nullptr; 30 | mSize = 0; 31 | mGetMicros = getMicros; 32 | } 33 | 34 | public: 35 | MockEventQueue(unsigned long (*getMicros)(void)): mNil() { init(getMicros); } 36 | MockEventQueue(): mNil() { init(nullptr); } 37 | 38 | MockEventQueue(const MockEventQueue& q) { 39 | init(q.mGetMicros); 40 | for (Node* n = q.mFront; n; n = n->next) push(n->event); 41 | } 42 | 43 | void setMicrosRetriever(unsigned long (*getMicros)(void)) { mGetMicros = getMicros; } 44 | 45 | inline unsigned long size() const { return mSize; } 46 | inline bool empty() const { return 0 == mSize; } 47 | inline Event front() const { return empty() ? Event(mNil, 0) : mFront->event; } 48 | inline Event back() const { return empty() ? Event(mNil, 0) : mBack->event; } 49 | inline T frontData() const { return front().data; } 50 | inline T backData() const { return back().data; } 51 | inline unsigned long frontTime() const { return front().micros; } 52 | inline unsigned long backTime() const { return back().micros; } 53 | 54 | 55 | // fully formed event 56 | bool push(const Event& e) { 57 | Node *n = new Node(e, nullptr); 58 | if (n == nullptr) return false; 59 | mBack = (mFront == nullptr ? mFront : mBack->next) = n; 60 | return ++mSize; 61 | } 62 | 63 | // fully specified event 64 | bool push(const T& v, unsigned long const time) { 65 | Event e = {v, time}; 66 | return push(e); 67 | } 68 | 69 | // event needing timestamp 70 | bool push(const T& v) { 71 | unsigned long micros = mGetMicros == nullptr ? 0 : mGetMicros(); 72 | return push(v, micros); 73 | } 74 | 75 | void pop() { 76 | if (empty()) return; 77 | Node* n = mFront; 78 | mFront = mFront->next; 79 | delete n; 80 | if (--mSize == 0) mBack = nullptr; 81 | } 82 | 83 | void clear() { while (!empty()) pop(); } 84 | 85 | ~MockEventQueue() { clear(); } 86 | }; 87 | -------------------------------------------------------------------------------- /cpp/arduino/Print.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Printable.h" 7 | #include "WString.h" 8 | 9 | #define DEC 10 10 | #define HEX 16 11 | #define OCT 8 12 | #ifdef BIN 13 | #undef BIN 14 | #endif 15 | #define BIN 2 16 | 17 | class Print 18 | { 19 | private: 20 | int write_error; 21 | protected: 22 | void setWriteError(int err = 1) { write_error = err; } 23 | public: 24 | Print() : write_error(0) {} 25 | 26 | int getWriteError() { return write_error; } 27 | void clearWriteError() { setWriteError(0); } 28 | virtual int availableForWrite() { return 0; } 29 | 30 | virtual size_t write(uint8_t) = 0; 31 | size_t write(const char *str) { return str == NULL ? 0 : write((const uint8_t *)str, String(str).length()); } 32 | 33 | virtual size_t write(const uint8_t *buffer, size_t size) { 34 | size_t n; 35 | for (n = 0; size && write(*buffer++) && ++n; --size); 36 | return n; 37 | } 38 | 39 | size_t write(const char *buffer, size_t size) { return write((const uint8_t *)buffer, size); } 40 | 41 | size_t print(const String &s) { return write(s.c_str(), s.length()); } 42 | size_t print(const __FlashStringHelper *str) { return print(reinterpret_cast(str)); } 43 | size_t print(const char* str) { return print(String(str)); } 44 | size_t print(char c) { return print(String(c)); } 45 | size_t print(unsigned char b, int base = DEC) { return print(String(b, base)); } 46 | size_t print(int n, int base = DEC) { return print(String(n, base)); } 47 | size_t print(unsigned int n, int base = DEC) { return print(String(n, base)); } 48 | size_t print(long n, int base = DEC) { return print(String(n, base)); } 49 | size_t print(unsigned long n, int base = DEC) { return print(String(n, base)); } 50 | size_t print(double n, int base = DEC) { return print(String(n, base)); } 51 | size_t print(const Printable& x) { return x.printTo(*this); } 52 | 53 | size_t println(void) { return print("\r\n"); } 54 | size_t println(const String &s) { return print(s) + println(); } 55 | size_t println(const __FlashStringHelper *str) { return println(reinterpret_cast(str)); } 56 | size_t println(const char* c) { return println(String(c)); } 57 | size_t println(char c) { return println(String(c)); } 58 | size_t println(unsigned char b, int base = DEC) { return println(String(b, base)); } 59 | size_t println(int num, int base = DEC) { return println(String(num, base)); } 60 | size_t println(unsigned int num, int base = DEC) { return println(String(num, base)); } 61 | size_t println(long num, int base = DEC) { return println(String(num, base)); } 62 | size_t println(unsigned long num, int base = DEC) { return println(String(num, base)); } 63 | size_t println(double num, int base = DEC) { return println(String(num, base)); } 64 | size_t println(const Printable& x) { return print(x) + println(); } 65 | 66 | virtual void flush() { } 67 | 68 | }; 69 | -------------------------------------------------------------------------------- /cpp/arduino/Printable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Print; 4 | 5 | class Printable { 6 | public: 7 | virtual size_t printTo(Print &p) const = 0; 8 | }; 9 | -------------------------------------------------------------------------------- /cpp/arduino/Server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Server : public Print {}; 6 | -------------------------------------------------------------------------------- /cpp/arduino/SoftwareSerial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Print.h" 3 | #include "Stream.h" 4 | #include "Godmode.h" 5 | 6 | // definitions needed for Serial.begin's config arg 7 | 8 | class SoftwareSerial : public Stream 9 | { 10 | private: 11 | int mPinIn; 12 | int mPinOut; 13 | bool mIsListening; 14 | GodmodeState* mState; 15 | unsigned long mOffset; // bits to offset stream 16 | bool bigEndian; 17 | 18 | public: 19 | // @TODO this is public for now to avoid a compiler warning 20 | bool mInvertLogic; // @TODO not sure how to implement yet 21 | 22 | SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool invertLogic = false) { 23 | mPinIn = receivePin; 24 | mPinOut = transmitPin; 25 | mIsListening = invertLogic; 26 | mIsListening = false; 27 | mOffset = 0; // godmode starts with 1 bit in the queue 28 | mState = GODMODE(); 29 | bigEndian = false; // this is how serial works 30 | } 31 | 32 | ~SoftwareSerial() {}; 33 | 34 | void setGodmodeOffset(unsigned long offset) { 35 | mOffset = offset; 36 | } 37 | 38 | bool listen() { return mIsListening = true; } 39 | bool isListening() { return mIsListening; } 40 | bool stopListening() { 41 | bool ret = mIsListening; 42 | mIsListening = false; 43 | return ret; 44 | } 45 | void begin(long speed) { listen(); } 46 | void end() { stopListening(); } 47 | bool overflow() { return false; } 48 | 49 | int peek() { 50 | if (!isListening()) return -1; 51 | String input = mState->digitalPin[mPinIn].incomingToAscii(mOffset, bigEndian); 52 | if (input.empty()) return -1; 53 | return input[0]; 54 | } 55 | 56 | virtual int read() { 57 | if (!isListening()) return -1; 58 | String input = mState->digitalPin[mPinIn].incomingToAscii(mOffset, bigEndian); 59 | if (input.empty()) return -1; 60 | int ret = input[0]; 61 | for (int i = 0; i < 8; ++i) digitalRead(mPinIn); 62 | return ret; 63 | } 64 | 65 | //using Print::write; 66 | 67 | virtual size_t write(uint8_t byte) { 68 | mState->digitalPin[mPinOut].outgoingFromAscii(String((char)byte), bigEndian); 69 | return 1; 70 | } 71 | 72 | virtual int available() { return mState->digitalPin[mPinIn].incomingToAscii(mOffset, bigEndian).length(); } 73 | virtual void flush() {} 74 | operator bool() { return true; } 75 | 76 | static inline void handle_interrupt() {}; 77 | 78 | }; 79 | 80 | 81 | -------------------------------------------------------------------------------- /cpp/arduino/Udp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class UDP : public Stream { 7 | protected: 8 | uint8_t *rawIPAddress(IPAddress &addr) { return addr.raw_address(); }; 9 | 10 | public: 11 | UDP() { 12 | // The Stream mock defines a String buffer but never puts anything in it! 13 | if (!mGodmodeDataIn) { 14 | mGodmodeDataIn = new String; 15 | } 16 | } 17 | ~UDP() { 18 | if (mGodmodeDataIn) { 19 | delete mGodmodeDataIn; 20 | mGodmodeDataIn = nullptr; 21 | } 22 | } 23 | virtual size_t write(uint8_t value) { 24 | mGodmodeDataIn->concat(value); 25 | return 1; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /cpp/arduino/WCharacter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | inline bool isAlpha(int c) { 4 | unsigned int data[16] = { 5 | 0x0000, 0x0000, 0x0000, 0x0000, 6 | 0xfffe, 0x07ff, 0xfffe, 0x07ff, 7 | 0x0000, 0x0000, 0x0000, 0x0000, 8 | 0xffff, 0xff7f, 0xffff, 0xff7f }; 9 | return data[c / 16] & (1 << (c % 16)); 10 | } 11 | 12 | inline bool isDigit(int c) { 13 | return '0' <= c && c <= '9'; 14 | } 15 | 16 | inline bool isAlphaNumeric(unsigned char c) { 17 | return isAlpha(c) || isDigit(c); 18 | } 19 | 20 | inline bool isAscii(int c) { 21 | return ((unsigned char)(c)) <= 0x7f; 22 | } 23 | 24 | inline bool isControl(int c) { 25 | unsigned int data[16] = { 26 | 0xffff, 0xffff, 0x0000, 0x0000, 27 | 0x0000, 0x0000, 0x0000, 0x8000, 28 | 0x0000, 0x0000, 0x0000, 0x0000, 29 | 0x0000, 0x0000, 0x0000, 0x0000 }; 30 | return data[c / 16] & (1 << (c % 16)); 31 | } 32 | 33 | inline bool isGraph(int c) { 34 | unsigned int data[16] = { 35 | 0x0000, 0x0000, 0xfffe, 0xffff, 36 | 0xffff, 0xffff, 0xffff, 0x7fff, 37 | 0x0000, 0x0000, 0xfffe, 0xffff, 38 | 0xffff, 0xffff, 0xffff, 0xffff }; 39 | return data[c / 16] & (1 << (c % 16)); 40 | } 41 | 42 | inline bool isHexadecimalDigit(int c) { 43 | unsigned int data[16] = { 44 | 0x0000, 0x0000, 0x0000, 0x03ff, 45 | 0x007e, 0x0000, 0x007e, 0x0000, 46 | 0x0000, 0x0000, 0x0000, 0x0000, 47 | 0x0000, 0x0000, 0x0000, 0x0000 }; 48 | return data[c / 16] & (1 << (c % 16)); 49 | } 50 | 51 | inline bool isLowerCase(int c) { 52 | unsigned int data[16] = { 53 | 0x0000, 0x0000, 0x0000, 0x0000, 54 | 0x0000, 0x0000, 0xfffe, 0x07ff, 55 | 0x0000, 0x0000, 0x0000, 0x0000, 56 | 0x0000, 0x8000, 0xffff, 0xff7f }; 57 | return data[c / 16] & (1 << (c % 16)); 58 | } 59 | 60 | inline bool isPrintable(int c) { 61 | unsigned int data[16] = { 62 | 0x0000, 0x0000, 0xffff, 0xffff, 63 | 0xffff, 0xffff, 0xffff, 0x7fff, 64 | 0x0000, 0x0000, 0xffff, 0xffff, 65 | 0xffff, 0xffff, 0xffff, 0xffff }; 66 | return data[c / 16] & (1 << (c % 16)); 67 | } 68 | 69 | inline bool isPunct(int c) { 70 | unsigned int data[16] = { 71 | 0x0000, 0x0000, 0xfffe, 0xfc00, 72 | 0x0001, 0xf800, 0x0001, 0x7800, 73 | 0x0000, 0x0000, 0xfffe, 0xffff, 74 | 0x0000, 0x0080, 0x0000, 0x0080 }; 75 | return data[c / 16] & (1 << (c % 16)); 76 | } 77 | 78 | inline bool isSpace(int c) { 79 | unsigned int data[16] = { 80 | 0x3e00, 0x0000, 0x0001, 0x0000, 81 | 0x0000, 0x0000, 0x0000, 0x0000, 82 | 0x0000, 0x0000, 0x0001, 0x0000, 83 | 0x0000, 0x0000, 0x0000, 0x0000 }; 84 | return data[c / 16] & (1 << (c % 16)); 85 | } 86 | 87 | inline bool isUpperCase(int c) { 88 | unsigned int data[16] = { 89 | 0x0000, 0x0000, 0x0000, 0x0000, 90 | 0xfffe, 0x07ff, 0x0000, 0x0000, 91 | 0x0000, 0x0000, 0x0000, 0x0000, 92 | 0xffff, 0x7f7f, 0x0000, 0x0000 }; 93 | return data[c / 16] & (1 << (c % 16)); 94 | } 95 | 96 | inline bool isWhitespace(int c) { return c == ' ' || c == '\t' || isSpace(c); } 97 | -------------------------------------------------------------------------------- /cpp/arduino/avr/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | # The files in this directory have been copied from Arduino. 2 | # This file configures cpplint to ignore all files in this directory. 3 | exclude_files=.* 4 | -------------------------------------------------------------------------------- /cpp/arduino/avr/README.md: -------------------------------------------------------------------------------- 1 | IO defintions. 2 | 3 | All of it copied from `arduino-1.8.5/hardware/tools/avr/avr/include/avr` 4 | -------------------------------------------------------------------------------- /cpp/arduino/avr/interrupt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _VECTOR(N) __vector_ ## N 4 | #define SIGNAL ( vector ) 5 | 6 | void cli() {}; 7 | void sei() {}; 8 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom164a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom164.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom164p.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom164.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom168a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom168.h" 35 | #define SLEEP_MODE_EXT_STANDBY (0x07<<1) 36 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom169a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom169.h" 35 | 36 | #ifdef PCIE1 37 | #undef PCIE1 38 | #define PCIE1 5 39 | #endif 40 | 41 | #ifdef PCIE0 42 | #undef PCIE0 43 | #define PCIE0 4 44 | #endif 45 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom16hva.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007, Anatoly Sokolov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of the copyright holders nor the names of 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. */ 30 | 31 | /* $Id: iom16hva.h 2102 2010-03-16 22:52:39Z joerg_wunsch $ */ 32 | 33 | /* iom16hva.h - definitions for ATmega16HVA. */ 34 | 35 | #ifndef _AVR_IOM16HVA_H_ 36 | #define _AVR_IOM16HVA_H_ 1 37 | 38 | #include "iomxxhva.h" 39 | 40 | /* Constants */ 41 | #define SPM_PAGESIZE 128 42 | #define RAMSTART 0x100 43 | #define RAMEND 0x2FF 44 | #define XRAMEND RAMEND 45 | #define E2END 0xFF 46 | #define E2PAGESIZE 4 47 | #define FLASHEND 0x3FFF 48 | 49 | 50 | /* Fuses */ 51 | 52 | #define FUSE_MEMORY_SIZE 1 53 | 54 | /* Low Fuse Byte */ 55 | #define FUSE_SUT0 (unsigned char)~_BV(0) 56 | #define FUSE_SUT1 (unsigned char)~_BV(1) 57 | #define FUSE_SUT2 (unsigned char)~_BV(2) 58 | #define FUSE_SELFPRGEN (unsigned char)~_BV(3) 59 | #define FUSE_DWEN (unsigned char)~_BV(4) 60 | #define FUSE_SPIEN (unsigned char)~_BV(5) 61 | #define FUSE_EESAVE (unsigned char)~_BV(6) 62 | #define FUSE_WDTON (unsigned char)~_BV(7) 63 | #define FUSE_DEFAULT (FUSE_SPIEN) 64 | 65 | 66 | /* Lock Bits */ 67 | #define __LOCK_BITS_EXIST 68 | 69 | 70 | /* Signature */ 71 | #define SIGNATURE_0 0x1E 72 | #define SIGNATURE_1 0x94 73 | #define SIGNATURE_2 0x0C 74 | 75 | #define SLEEP_MODE_IDLE (0x00<<1) 76 | #define SLEEP_MODE_ADC (0x01<<1) 77 | #define SLEEP_MODE_PWR_SAVE (0x03<<1) 78 | #define SLEEP_MODE_PWR_OFF (0x04<<1) 79 | 80 | #endif /* _AVR_IOM16HVA_H_ */ 81 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom3250a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom3250.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom3250p.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom3250.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom325a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom325.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom325p.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom325.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom328.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom328p.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom3290a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom3290.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom329a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom329.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom329pa.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom329.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom48a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom48.h" 35 | #define SLEEP_MODE_EXT_STANDBY (0x07<<1) 36 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom644a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom644.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom6450a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom6450.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom6450p.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom6450.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom645a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom645.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom645p.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom645.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom6490a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom6490.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom6490p.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom6490.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom649a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom649.h" 35 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom88a.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * 3 | * Copyright (C) 2011 Atmel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of the copyright holders nor the names of 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | ****************************************************************************/ 33 | 34 | #include "iom88.h" 35 | #define SLEEP_MODE_EXT_STANDBY (0x07<<1) 36 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iom8hva.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007, Anatoly Sokolov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of the copyright holders nor the names of 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. */ 30 | 31 | /* $Id: iom8hva.h 2102 2010-03-16 22:52:39Z joerg_wunsch $ */ 32 | 33 | /* iom8hva.h - definitions for ATmega8HVA. */ 34 | 35 | #ifndef _AVR_IOM8HVA_H_ 36 | #define _AVR_IOM8HVA_H_ 1 37 | 38 | #include "iomxxhva.h" 39 | 40 | /* Constants */ 41 | #define SPM_PAGESIZE 128 42 | #define RAMSTART 0x100 43 | #define RAMEND 0x2FF 44 | #define XRAMEND RAMEND 45 | #define E2END 0xFF 46 | #define E2PAGESIZE 4 47 | #define FLASHEND 0x1FFF 48 | 49 | 50 | /* Fuses */ 51 | 52 | #define FUSE_MEMORY_SIZE 1 53 | 54 | /* Low Fuse Byte */ 55 | #define FUSE_SUT0 (unsigned char)~_BV(0) 56 | #define FUSE_SUT1 (unsigned char)~_BV(1) 57 | #define FUSE_SUT2 (unsigned char)~_BV(2) 58 | #define FUSE_SELFPRGEN (unsigned char)~_BV(3) 59 | #define FUSE_DWEN (unsigned char)~_BV(4) 60 | #define FUSE_SPIEN (unsigned char)~_BV(5) 61 | #define FUSE_EESAVE (unsigned char)~_BV(6) 62 | #define FUSE_WDTON (unsigned char)~_BV(7) 63 | #define FUSE_DEFAULT (FUSE_SPIEN) 64 | 65 | 66 | /* Lock Bits */ 67 | #define __LOCK_BITS_EXIST 68 | 69 | 70 | #define SLEEP_MODE_IDLE (0x00<<1) 71 | #define SLEEP_MODE_ADC (0x01<<1) 72 | #define SLEEP_MODE_PWR_SAVE (0x03<<1) 73 | #define SLEEP_MODE_PWR_OFF (0x04<<1) 74 | 75 | #endif /* _AVR_IOM8HVA_H_ */ 76 | 77 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iotn25.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2005, Joerg Wunsch 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of the copyright holders nor the names of 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. */ 30 | 31 | /* $Id: iotn25.h 2115 2010-04-05 23:19:53Z arcanum $ */ 32 | 33 | /* avr/iotn25.h - definitions for ATtiny25 */ 34 | 35 | #ifndef _AVR_IOTN25_H_ 36 | #define _AVR_IOTN25_H_ 1 37 | 38 | #include "iotnx5.h" 39 | 40 | #define SPM_PAGESIZE 32 41 | #define RAMSTART (0x60) 42 | #define RAMEND 0xDF 43 | #define XRAMEND RAMEND 44 | #define E2END 0x7F 45 | #define E2PAGESIZE 4 46 | #define FLASHEND 0x7FF 47 | 48 | 49 | /* Fuses */ 50 | 51 | #define FUSE_MEMORY_SIZE 3 52 | 53 | /* Low Fuse Byte */ 54 | #define FUSE_CKSEL0 (unsigned char)~_BV(0) 55 | #define FUSE_CKSEL1 (unsigned char)~_BV(1) 56 | #define FUSE_CKSEL2 (unsigned char)~_BV(2) 57 | #define FUSE_CKSEL3 (unsigned char)~_BV(3) 58 | #define FUSE_SUT0 (unsigned char)~_BV(4) 59 | #define FUSE_SUT1 (unsigned char)~_BV(5) 60 | #define FUSE_CKOUT (unsigned char)~_BV(6) 61 | #define FUSE_CKDIV8 (unsigned char)~_BV(7) 62 | #define LFUSE_DEFAULT (FUSE_CKSEL0 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SUT0 & FUSE_CKDIV8) 63 | 64 | /* High Fuse Byte */ 65 | #define FUSE_BODLEVEL0 (unsigned char)~_BV(0) 66 | #define FUSE_BODLEVEL1 (unsigned char)~_BV(1) 67 | #define FUSE_BODLEVEL2 (unsigned char)~_BV(2) 68 | #define FUSE_EESAVE (unsigned char)~_BV(3) 69 | #define FUSE_WDTON (unsigned char)~_BV(4) 70 | #define FUSE_SPIEN (unsigned char)~_BV(5) 71 | #define FUSE_DWEN (unsigned char)~_BV(6) 72 | #define FUSE_RSTDISBL (unsigned char)~_BV(7) 73 | #define HFUSE_DEFAULT (FUSE_SPIEN) 74 | 75 | /* Extended Fuse Byte */ 76 | #define FUSE_SELFPRGEN (unsigned char)~_BV(0) 77 | #define EFUSE_DEFAULT (0xFF) 78 | 79 | 80 | /* Lock Bits */ 81 | #define __LOCK_BITS_EXIST 82 | 83 | 84 | /* Signature */ 85 | #define SIGNATURE_0 0x1E 86 | #define SIGNATURE_1 0x91 87 | #define SIGNATURE_2 0x08 88 | 89 | #define SLEEP_MODE_IDLE (0x00<<3) 90 | #define SLEEP_MODE_ADC (0x01<<3) 91 | #define SLEEP_MODE_PWR_DOWN (0x02<<3) 92 | 93 | #endif /* _AVR_IOTN25_H_ */ 94 | -------------------------------------------------------------------------------- /cpp/arduino/avr/iotn45.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2005, Joerg Wunsch 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of the copyright holders nor the names of 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. */ 30 | 31 | /* $Id: iotn45.h 2115 2010-04-05 23:19:53Z arcanum $ */ 32 | 33 | /* avr/iotn45.h - definitions for ATtiny45 */ 34 | 35 | #ifndef _AVR_IOTN45_H_ 36 | #define _AVR_IOTN45_H_ 1 37 | 38 | #include "iotnx5.h" 39 | 40 | /* Constants */ 41 | #define SPM_PAGESIZE 64 42 | #define RAMSTART (0x60) 43 | #define RAMEND 0x15F 44 | #define XRAMEND RAMEND 45 | #define E2END 0xFF 46 | #define E2PAGESIZE 4 47 | #define FLASHEND 0xFFF 48 | 49 | 50 | /* Fuses */ 51 | #define FUSE_MEMORY_SIZE 3 52 | 53 | /* Low Fuse Byte */ 54 | #define FUSE_CKSEL0 (unsigned char)~_BV(0) 55 | #define FUSE_CKSEL1 (unsigned char)~_BV(1) 56 | #define FUSE_CKSEL2 (unsigned char)~_BV(2) 57 | #define FUSE_CKSEL3 (unsigned char)~_BV(3) 58 | #define FUSE_SUT0 (unsigned char)~_BV(4) 59 | #define FUSE_SUT1 (unsigned char)~_BV(5) 60 | #define FUSE_CKOUT (unsigned char)~_BV(6) 61 | #define FUSE_CKDIV8 (unsigned char)~_BV(7) 62 | #define LFUSE_DEFAULT (FUSE_CKSEL0 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SUT0 & FUSE_CKDIV8) 63 | 64 | /* High Fuse Byte */ 65 | #define FUSE_BODLEVEL0 (unsigned char)~_BV(0) 66 | #define FUSE_BODLEVEL1 (unsigned char)~_BV(1) 67 | #define FUSE_BODLEVEL2 (unsigned char)~_BV(2) 68 | #define FUSE_EESAVE (unsigned char)~_BV(3) 69 | #define FUSE_WDTON (unsigned char)~_BV(4) 70 | #define FUSE_SPIEN (unsigned char)~_BV(5) 71 | #define FUSE_DWEN (unsigned char)~_BV(6) 72 | #define FUSE_RSTDISBL (unsigned char)~_BV(7) 73 | #define HFUSE_DEFAULT (FUSE_SPIEN) 74 | 75 | /* Extended Fuse Byte */ 76 | #define FUSE_SELFPRGEN (unsigned char)~_BV(0) 77 | #define EFUSE_DEFAULT (0xFF) 78 | 79 | 80 | /* Lock Bits */ 81 | #define __LOCK_BITS_EXIST 82 | 83 | 84 | /* Signature */ 85 | #define SIGNATURE_0 0x1E 86 | #define SIGNATURE_1 0x92 87 | #define SIGNATURE_2 0x06 88 | 89 | #define SLEEP_MODE_IDLE (0x00<<3) 90 | #define SLEEP_MODE_ADC (0x01<<3) 91 | #define SLEEP_MODE_PWR_DOWN (0x02<<3) 92 | 93 | #endif /* _AVR_IOTN45_H_ */ 94 | -------------------------------------------------------------------------------- /cpp/arduino/avr/wdt.h: -------------------------------------------------------------------------------- 1 | // Stub for testing that doesn't do anything (but at least compiles!) 2 | 3 | #define wdt_disable() (void)0 4 | #define wdt_enable(timeout) (void)0 5 | #define wdt_reset() (void)0 6 | 7 | #define WDTO_15MS 0 8 | #define WDTO_30MS 1 9 | #define WDTO_60MS 2 10 | #define WDTO_120MS 3 11 | #define WDTO_250MS 4 12 | #define WDTO_500MS 5 13 | #define WDTO_1S 6 14 | #define WDTO_2S 7 15 | #define WDTO_4S 8 16 | #define WDTO_8S 9 17 | -------------------------------------------------------------------------------- /cpp/arduino/avr/xmega.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Joerg Wunsch 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of the copyright holders nor the names of 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. */ 30 | 31 | /* $Id$ */ 32 | 33 | /* 34 | * This file is included by whenever compiling for an Xmega 35 | * device. It abstracts certain features common to the Xmega device 36 | * families. 37 | */ 38 | 39 | #ifndef _AVR_XMEGA_H 40 | #define _AVR_XMEGA_H 41 | 42 | #ifdef __DOXYGEN__ 43 | /** 44 | \def _PROTECTED_WRITE 45 | \ingroup avr_io 46 | 47 | Write value \c value to IO register \c reg that is protected through 48 | the Xmega configuration change protection (CCP) mechanism. This 49 | implements the timed sequence that is required for CCP. 50 | 51 | Example to modify the CPU clock: 52 | \code 53 | #include 54 | 55 | _PROTECTED_WRITE(CLK_PSCTRL, CLK_PSADIV0_bm); 56 | _PROTECTED_WRITE(CLK_CTRL, CLK_SCLKSEL0_bm); 57 | \endcode 58 | */ 59 | #define _PROTECTED_WRITE(reg, value) 60 | #else /* !__DOXYGEN__ */ 61 | #define _PROTECTED_WRITE(reg, value) \ 62 | __asm__ __volatile__("out %[ccp], %[ccp_ioreg]" "\n\t" \ 63 | "sts %[ioreg], %[val]" \ 64 | : \ 65 | : [ccp] "I" (_SFR_IO_ADDR(CCP)), \ 66 | [ccp_ioreg] "d" ((uint8_t)CCP_IOREG_gc), \ 67 | [ioreg] "n" (_SFR_MEM_ADDR(reg)), \ 68 | [val] "r" ((uint8_t)value)) 69 | #endif /* DOXYGEN */ 70 | 71 | #endif /* _AVR_XMEGA_H */ 72 | -------------------------------------------------------------------------------- /cpp/arduino/ci/DeviceUsingBytes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ObservableDataStream.h" 4 | #include "Table.h" 5 | #include 6 | #include 7 | 8 | 9 | // Define a rudimentary serial device that responds to byte sequences 10 | // 11 | // The class monitors whatever stream it is observing, and builds up 12 | // a buffer of the incoming data. If/when that data matches one of 13 | // the stored responses, the buffer is cleared and the response to 14 | // the matched requests is sent to the handler `onMatchInput` 15 | // 16 | // WARNING: if input is consumed and no matches are found, you are 17 | // in a bad state where you can never match anything again. @TODO 18 | // 19 | // The extender of this abstract class should provide the following: 20 | // 1. A set of responses using one of the provided convenience functions: 21 | // * `addResponse`: request and response are taken verbatim 22 | // * `addResponseLine`: request and response are appended a \n 23 | // * `addResponseCRLF`: request and response are appended a \r\n 24 | // 2. An action `onMatchInput` -- what to do with a response when triggered 25 | class DeviceUsingBytes : public DataStreamObserver { 26 | public: 27 | String mMessage; 28 | ArduinoCITable mResponses; 29 | GodmodeState* state; 30 | 31 | 32 | DeviceUsingBytes() : DataStreamObserver(true, false) { 33 | mMessage = ""; 34 | state = GODMODE(); 35 | } 36 | 37 | virtual ~DeviceUsingBytes() {} 38 | 39 | bool addResponse(String hear, String say) { return mResponses.add(hear, say); } 40 | bool addResponseLine(String hear, String say) { return mResponses.add(hear + "\n", say + "\n"); } 41 | bool addResponseCRLF(String hear, String say) { return mResponses.add(hear + "\r\n", say + "\r\n"); } 42 | 43 | // what to do when there is a match 44 | virtual void onMatchInput(String output) = 0; 45 | 46 | virtual String observerName() const { return "DeviceUsingBytes"; } 47 | 48 | virtual void onByte(unsigned char c) { 49 | mMessage.concat(c); 50 | if (mResponses.has(mMessage)) { 51 | onMatchInput(mResponses.get(mMessage)); 52 | mMessage = ""; 53 | } 54 | } 55 | }; 56 | 57 | -------------------------------------------------------------------------------- /cpp/arduino/ci/README.md: -------------------------------------------------------------------------------- 1 | The parent directory is for files that must stand in for their Arduino counterparts -- any `SomeFile` that might be requested as `#include `. 2 | 3 | This directory is specifically for support files required by those other files. That's because we don't want to create collisions on filenames for common data structures like Queue. 4 | 5 | If there end up being class-level conflicts, it is this developer's stated intention to rename our classes such that `class Float` becomes `class FloatyMcFloatFace`. 6 | -------------------------------------------------------------------------------- /cpp/arduino/ci/StreamTape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Stream.h" 4 | 5 | /** 6 | * Stream with godmode-controlled input and godmode-persisted output 7 | */ 8 | class StreamTape : public Stream, public ObservableDataStream 9 | { 10 | protected: 11 | String* mGodmodeDataOut; 12 | // mGodmodeDataIn is provided by Stream 13 | 14 | public: 15 | StreamTape(String* dataIn, String* dataOut, unsigned long* delay): Stream(), ObservableDataStream() { 16 | mGodmodeDataIn = dataIn; 17 | mGodmodeDataOut = dataOut; 18 | mGodmodeMicrosDelay = delay; 19 | } 20 | 21 | // virtual int available(void); 22 | // virtual int peek(void); 23 | // virtual int read(void); 24 | // virtual int availableForWrite(void); 25 | // virtual void flush(void); 26 | virtual size_t write(uint8_t aChar) { 27 | mGodmodeDataOut->append(String((char)aChar)); 28 | advertiseByte((unsigned char)aChar); 29 | return 1; 30 | } 31 | 32 | // https://stackoverflow.com/a/4271276 33 | using Print::write; // pull in write(str) and write(buf, size) from Print 34 | 35 | }; 36 | 37 | -------------------------------------------------------------------------------- /cpp/arduino/stdlib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #if 1 // This code is copied from https://people.cs.umu.se/isak/snippets/ltoa.c and then converted from ltoa to itoa. 3 | /* 4 | ** LTOA.C 5 | ** 6 | ** Converts a integer to a string. 7 | ** 8 | ** Copyright 1988-90 by Robert B. Stout dba MicroFirm 9 | ** 10 | ** Released to public domain, 1991 11 | ** 12 | ** Parameters: 1 - number to be converted 13 | ** 2 - buffer in which to build the converted string 14 | ** 3 - number base to use for conversion 15 | ** 16 | ** Returns: A character pointer to the converted string if 17 | ** successful, a NULL pointer if the number base specified 18 | ** is out of range. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define BUFSIZE (sizeof(int) * 8 + 1) 26 | 27 | char *itoa(int N, char *str, int base) 28 | { 29 | int i = 2; 30 | int uarg; 31 | char *tail, *head = str, buf[BUFSIZE]; 32 | 33 | if (36 < base || 2 > base) 34 | base = 10; /* can only use 0-9, A-Z */ 35 | tail = &buf[BUFSIZE - 1]; /* last character position */ 36 | *tail-- = '\0'; 37 | 38 | if (10 == base && N < 0L) 39 | { 40 | *head++ = '-'; 41 | uarg = -N; 42 | } 43 | else uarg = N; 44 | 45 | if (uarg) 46 | { 47 | for (i = 1; uarg; ++i) 48 | { 49 | ldiv_t r; 50 | 51 | r = ldiv(uarg, base); 52 | *tail-- = (char)(r.rem + ((9L < r.rem) ? 53 | ('A' - 10L) : '0')); 54 | uarg = r.quot; 55 | } 56 | } 57 | else *tail-- = '0'; 58 | 59 | memcpy(head, ++tail, i); 60 | return str; 61 | } 62 | #endif 63 | 64 | /* 65 | The dtostrf() function converts the double value passed in val into 66 | an ASCII representationthat will be stored under s. The caller is 67 | responsible for providing sufficient storage in s. 68 | 69 | Conversion is done in the format “[-]d.ddd”. The minimum field width 70 | of the output string (including the ‘.’ and the possible sign for 71 | negative values) is given in width, and prec determines the number of 72 | digits after the decimal sign. width is signed value, negative for 73 | left adjustment. 74 | 75 | The dtostrf() function returns the pointer to the converted string s. 76 | */ 77 | 78 | char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s) { 79 | sprintf(__s, "%*.*f", __width, __prec, __val); 80 | return __s; 81 | } 82 | -------------------------------------------------------------------------------- /cpp/arduino/stdlib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Header file to compensate for differences between 4 | // arduino-1.x.x/hardware/tools/avr/avr/include/stdlib.h and /usr/include/stdlib.h. 5 | 6 | #include_next 7 | 8 | /* 9 | * Arduino stdlib.h includes a prototype for itoa which is not a standard function, 10 | * and is not available in /usr/include/stdlib.h. Provide one here. 11 | * http://www.cplusplus.com/reference/cstdlib/itoa/ 12 | * https://stackoverflow.com/questions/190229/where-is-the-itoa-function-in-linux 13 | */ 14 | char *itoa(int val, char *s, int radix); 15 | 16 | // another function provided by Arduino 17 | char * dtostrf(double __val, signed char __width, unsigned char __prec, char *__s); 18 | -------------------------------------------------------------------------------- /cpp/unittest/ArduinoUnitTests.cpp: -------------------------------------------------------------------------------- 1 | #include "ArduinoUnitTests.h" 2 | 3 | TestSetup *TestSetup::sInstance; 4 | TestTeardown *TestTeardown::sInstance; 5 | 6 | Test* Test::sRoot = 0; 7 | -------------------------------------------------------------------------------- /cpp/unittest/OstreamHelpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #if (defined __apple_build_version__) && (__apple_build_version__ >= 12000000) 6 | // defined in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:223:20 7 | #else 8 | inline std::ostream& operator << (std::ostream& out, const std::nullptr_t &np) { return out << "nullptr"; } 9 | #endif 10 | -------------------------------------------------------------------------------- /exe/arduino_ci_remote.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts "arduino_ci_remote.rb is deprecated in favor of arduino_ci.rb." 3 | require_relative "arduino_ci" 4 | -------------------------------------------------------------------------------- /exe/arduino_library_location.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'arduino_ci' 3 | 4 | # locate and/or forcibly install Arduino, keep stdout clean 5 | @backend = ArduinoCI::ArduinoInstallation.autolocate!($stderr) 6 | 7 | puts @backend.lib_dir 8 | -------------------------------------------------------------------------------- /exe/ensure_arduino_installation.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'arduino_ci' 3 | 4 | # this will exit after Arduino is located and/or forcibly installed 5 | backend = ArduinoCI::ArduinoInstallation.autolocate! 6 | lib_dir = backend.lib_dir 7 | 8 | unless lib_dir.exist? 9 | puts "Creating libraries directory #{lib_dir}" 10 | lib_dir.mkpath 11 | end 12 | -------------------------------------------------------------------------------- /lib/arduino_ci.rb: -------------------------------------------------------------------------------- 1 | require "arduino_ci/version" 2 | require "arduino_ci/logger" 3 | require "arduino_ci/arduino_installation" 4 | require "arduino_ci/cpp_library" 5 | require "arduino_ci/ci_config" 6 | require "arduino_ci/library_properties" 7 | 8 | # ArduinoCI contains classes for automated testing of Arduino code on the command line 9 | # @author Ian Katz 10 | module ArduinoCI 11 | 12 | end 13 | -------------------------------------------------------------------------------- /lib/arduino_ci/arduino_downloader_linux.rb: -------------------------------------------------------------------------------- 1 | require "arduino_ci/arduino_downloader" 2 | 3 | module ArduinoCI 4 | 5 | # Manage the linux download & install of Arduino 6 | class ArduinoDownloaderLinux < ArduinoDownloader 7 | 8 | # The local filename of the desired IDE package (zip/tar/etc) 9 | # @return [string] 10 | def package_file 11 | "arduino-cli_#{@desired_version}_Linux_64bit.tar.gz" 12 | end 13 | 14 | # The local file (dir) name of the extracted IDE package (zip/tar/etc) 15 | # @return [string] 16 | def self.extracted_file 17 | "arduino-cli" 18 | end 19 | 20 | # Make any preparations or run any checks prior to making changes 21 | # @return [string] Error message, or nil if success 22 | def prepare 23 | reqs = [self.class.extractor] 24 | reqs.each do |req| 25 | return "#{req} does not appear to be installed!" unless Host.which(req) 26 | end 27 | nil 28 | end 29 | 30 | # The technology that will be used to extract the download 31 | # (for logging purposes) 32 | # @return [string] 33 | def self.extractor 34 | "tar" 35 | end 36 | 37 | # Extract the package_file to extracted_file 38 | # @return [bool] whether successful 39 | def self.extract(package_file) 40 | system(extractor, "xf", package_file, extracted_file) 41 | end 42 | 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/arduino_ci/arduino_downloader_osx.rb: -------------------------------------------------------------------------------- 1 | require "arduino_ci/arduino_downloader" 2 | 3 | module ArduinoCI 4 | 5 | # Manage the OSX download & install of Arduino 6 | class ArduinoDownloaderOSX < ArduinoDownloader 7 | 8 | # The local filename of the desired IDE package (zip/tar/etc) 9 | # @return [string] 10 | def package_file 11 | "arduino-cli_#{@desired_version}_macOS_64bit.tar.gz" 12 | end 13 | 14 | # The local file (dir) name of the extracted IDE package (zip/tar/etc) 15 | # @return [string] 16 | def self.extracted_file 17 | "arduino-cli" 18 | end 19 | 20 | # Make any preparations or run any checks prior to making changes 21 | # @return [string] Error message, or nil if success 22 | def prepare 23 | reqs = [self.class.extractor] 24 | reqs.each do |req| 25 | return "#{req} does not appear to be installed!" unless Host.which(req) 26 | end 27 | nil 28 | end 29 | 30 | # The technology that will be used to extract the download 31 | # (for logging purposes) 32 | # @return [string] 33 | def self.extractor 34 | "tar" 35 | end 36 | 37 | # Extract the package_file to extracted_file 38 | # @return [bool] whether successful 39 | def self.extract(package_file) 40 | system(extractor, "xf", package_file, extracted_file) 41 | end 42 | 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/arduino_ci/arduino_downloader_windows.rb: -------------------------------------------------------------------------------- 1 | require 'base64' 2 | require 'shellwords' # fingers crossed this works on win32 3 | require 'win32/registry' 4 | require "arduino_ci/arduino_downloader" 5 | require 'net/http' 6 | require "fileutils" 7 | 8 | module ArduinoCI 9 | 10 | # Manage the POSIX download & install of Arduino 11 | class ArduinoDownloaderWindows < ArduinoDownloader 12 | 13 | # Download the package_url to package_file 14 | # @return [bool] whether successful 15 | def download 16 | # Turned off ssl verification 17 | # This should be acceptable because it won't happen on a user's machine, just CI 18 | open(URI.parse(package_url), ssl_verify_mode: 0) do |url| 19 | File.open(package_file, 'wb') { |file| file.write(url.read) } 20 | end 21 | rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e 22 | @output.puts "\nArduino force-install failed downloading #{package_url}: #{e}" 23 | end 24 | 25 | # The local filename of the desired IDE package (zip/tar/etc) 26 | # @return [string] 27 | def package_file 28 | "arduino-cli_#{@desired_version}_Windows_64bit.zip" 29 | end 30 | 31 | # The technology that will be used to extract the download 32 | # (for logging purposes) 33 | # @return [string] 34 | def self.extractor 35 | "Expand-Archive" 36 | end 37 | 38 | # Extract the package_file to extracted_file 39 | # @return [bool] whether successful 40 | def self.extract(package_file) 41 | Zip::File.open(package_file) do |zip| 42 | zip.each do |file| 43 | file.extract(file.name) 44 | end 45 | end 46 | end 47 | 48 | # The local file (dir) name of the extracted IDE package (zip/tar/etc) 49 | # @return [string] 50 | def self.extracted_file 51 | "arduino-cli.exe" 52 | end 53 | 54 | # The executable Arduino file in a forced installation, or nil 55 | # @return [Pathname] 56 | def self.force_installed_executable 57 | Pathname.new(Host.windows_to_pathname(ENV['HOME'])) + self.extracted_file 58 | end 59 | 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/arduino_ci/arduino_installation.rb: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | require "arduino_ci/host" 3 | require "arduino_ci/arduino_backend" 4 | require "arduino_ci/arduino_downloader_osx" 5 | require "arduino_ci/arduino_downloader_linux" 6 | require "arduino_ci/arduino_downloader_windows" if ArduinoCI::Host.os == :windows 7 | 8 | module ArduinoCI 9 | 10 | class ArduinoInstallationError < StandardError; end 11 | 12 | # Manage the OS-specific install location of Arduino 13 | class ArduinoInstallation 14 | 15 | DESIRED_ARDUINO_CLI_VERSION = "0.29.0".freeze 16 | 17 | class << self 18 | 19 | # attempt to find a workable Arduino executable across platforms 20 | # 21 | # Autolocation assumed to be an expensive operation 22 | # @return [ArduinoCI::ArduinoBackend] an instance of the command or nil if it can't be found 23 | def autolocate 24 | downloader_class = case Host.os 25 | when :osx then ArduinoDownloaderOSX 26 | when :linux then ArduinoDownloaderLinux 27 | when :windows then ArduinoDownloaderWindows 28 | end 29 | 30 | loc = downloader_class.autolocated_executable 31 | return nil if loc.nil? 32 | 33 | ArduinoBackend.new(loc) 34 | end 35 | 36 | # Attempt to find a workable Arduino executable across platforms, and install it if we don't 37 | # @return [ArduinoCI::ArduinoBackend] an instance of a command 38 | def autolocate!(output = $stdout) 39 | candidate = autolocate 40 | return candidate unless candidate.nil? 41 | 42 | # force the install 43 | raise ArduinoInstallationError, "Failed to force-install Arduino" unless force_install(output) 44 | 45 | autolocate 46 | end 47 | 48 | # Forcibly install Arduino from the web 49 | # @return [bool] Whether the command succeeded 50 | def force_install(output = $stdout, version = DESIRED_ARDUINO_CLI_VERSION) 51 | worker_class = case Host.os 52 | when :osx then ArduinoDownloaderOSX 53 | when :windows then ArduinoDownloaderWindows 54 | when :linux then ArduinoDownloaderLinux 55 | end 56 | worker = worker_class.new(version, output) 57 | worker.execute 58 | end 59 | 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/arduino_ci/version.rb: -------------------------------------------------------------------------------- 1 | module ArduinoCI 2 | VERSION = "1.6.2".freeze 3 | end 4 | -------------------------------------------------------------------------------- /release-new-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script automates the gem release project for this repo. 4 | 5 | GEM_NAME=arduino_ci 6 | GEM_MODULE=ArduinoCI 7 | PUSH_REMOTE=upstream 8 | 9 | # test if we have an arguments on the command line 10 | if [ $# -lt 1 ] 11 | then 12 | echo "You must pass an argument for KeepAChangelogManager:" 13 | bundle exec keepachangelog_manager.rb 14 | exit 1 15 | fi 16 | 17 | # set up a cleanup function for any errors, so that we git stash pop 18 | cleanup () { 19 | set +x +e 20 | echo -e "\n### Reverting uncommitted changes" 21 | git checkout README.md CHANGELOG.md lib/$GEM_NAME/version.rb 22 | if [ $DID_STASH -eq 0 ]; then 23 | echo -e "\n### Unstashing changes" 24 | git stash pop 25 | fi 26 | exit $1 27 | } 28 | 29 | DIDNT_STASH="No local changes to save" 30 | DID_STASH=1 31 | echo -ne "\n### Stashing changes..." 32 | STASH_OUTPUT=$(git stash save) 33 | [ "$DIDNT_STASH" != "$STASH_OUTPUT" ] 34 | DID_STASH=$? 35 | echo DID_STASH=$DID_STASH 36 | 37 | trap "cleanup 1" INT TERM ERR 38 | set -xe 39 | 40 | echo "### Checking existence of specified git push destination '$PUSH_REMOTE'" 41 | git remote get-url $PUSH_REMOTE 42 | 43 | # ensure latest master 44 | git pull --rebase 45 | 46 | # update version in changelog and save it 47 | NEW_VERSION=$(bundle exec keepachangelog_manager.rb $@) 48 | 49 | echo "Checking whether new version string is a semver" 50 | echo $NEW_VERSION | grep -Eq ^[0-9]*\.[0-9]*\.[0-9]*$ 51 | 52 | # write version.rb with new version 53 | cat << EOF > lib/$GEM_NAME/version.rb 54 | module $GEM_MODULE 55 | VERSION = "$NEW_VERSION".freeze 56 | end 57 | EOF 58 | 59 | # update README with new version 60 | sed -e "s/\/gems\/$GEM_NAME\/[0-9]*\.[0-9]*\.[0-9]*)/\/gems\/$GEM_NAME\/$NEW_VERSION)/" -i "" README.md 61 | 62 | # mutation! 63 | git add README.md CHANGELOG.md lib/$GEM_NAME/version.rb 64 | git commit -m "v$NEW_VERSION bump" 65 | git tag -a v$NEW_VERSION -m "Released version $NEW_VERSION" 66 | gem build $GEM_NAME.gemspec 67 | gem push $GEM_NAME-$NEW_VERSION.gem 68 | git push $PUSH_REMOTE 69 | git push $PUSH_REMOTE --tags 70 | git fetch 71 | 72 | # do normal cleanup 73 | cleanup 0 74 | -------------------------------------------------------------------------------- /spec/BadSketch/BadSketch.ino: -------------------------------------------------------------------------------- 1 | Oh god how did this get in here I am not good with computer 2 | -------------------------------------------------------------------------------- /spec/FakeSketch/FakeSketch.ino: -------------------------------------------------------------------------------- 1 | void setup(void) { 0; } 2 | void loop(void) { 0; } 3 | -------------------------------------------------------------------------------- /spec/arduino_ci_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | RSpec.describe ArduinoCI do 4 | next if skip_ruby_tests 5 | context "gem" do 6 | it "has a version number" do 7 | expect(ArduinoCI::VERSION).not_to be nil 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/fake_lib_dir.rb: -------------------------------------------------------------------------------- 1 | require "arduino_ci" 2 | 3 | # This class is meant for the :around behavior of RSpec test cases so that 4 | # we can make temporary directories in test cases. Note that since test cases 5 | # are evaluated on load, any temp directories that were created will not exist 6 | # by the time the test runs. So this class handles all of the particulars 7 | # around creating a fake library directory on time and configuring the backend 8 | # to properly use it. 9 | class FakeLibDir 10 | 11 | attr_reader :config_dir 12 | attr_reader :config_file 13 | attr_reader :backend 14 | attr_reader :arduino_dir 15 | attr_reader :libraries_dir 16 | 17 | def initialize 18 | # we will need to install some dummy libraries into a fake location, so do that on demand 19 | @config_dir = Pathname.new(Dir.pwd).realpath 20 | @config_file = ArduinoCI::ArduinoBackend.config_file_path_from_dir(@config_dir) 21 | @backend = ArduinoCI::ArduinoInstallation.autolocate! 22 | @backend.config_file_path = @config_file 23 | end 24 | 25 | # designed to be called by rspec's "around" function 26 | def in_pristine_fake_libraries_dir(example) 27 | # we will make a dummy directory to contain the libraries directory, 28 | # and use that directory in a dummy config which we will pass to the backend. 29 | # then we can run the test case 30 | Dir.mktmpdir do |d| 31 | # write a yaml file containing the current directory 32 | dummy_config = { "directories" => { "user" => d.to_s } } 33 | @arduino_dir = Pathname.new(d) 34 | @libraries_dir = @arduino_dir + "libraries" 35 | Dir.mkdir(@libraries_dir) 36 | 37 | # with the config file, enforce a structure similar to a temp file -- delete after use 38 | File.open(@config_file, "w") do |f| 39 | f.write dummy_config.to_yaml 40 | f.close 41 | example.run 42 | ensure 43 | begin 44 | File.unlink(@config_file) 45 | rescue Errno::ENOENT 46 | # cool, already done 47 | end 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /spec/fake_library/test/mars.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/spec/fake_library/test/mars.cpp -------------------------------------------------------------------------------- /spec/fake_library/test/sam-squamsh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/spec/fake_library/test/sam-squamsh.cpp -------------------------------------------------------------------------------- /spec/fake_library/test/yes-good.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arduino-CI/arduino_ci/bc9c7e5b3bc3f596ae98baeded428d4875ab209d/spec/fake_library/test/yes-good.cpp -------------------------------------------------------------------------------- /spec/host_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | require 'tmpdir' 3 | 4 | 5 | def idempotent_delete(path) 6 | path.delete 7 | rescue Errno::ENOENT 8 | end 9 | 10 | # creates a dir at then deletes it after block executes 11 | # this will DESTROY any existing entry at that location in the filesystem 12 | def with_tmpdir(path) 13 | begin 14 | idempotent_delete(path) 15 | path.mkpath 16 | yield 17 | ensure 18 | idempotent_delete(path) 19 | end 20 | end 21 | 22 | 23 | RSpec.describe ArduinoCI::Host do 24 | next if skip_ruby_tests 25 | 26 | context "symlinks" do 27 | it "creates symlinks that we agree are symlinks" do 28 | our_dir = Pathname.new(__dir__) 29 | foo_dir = our_dir + "foo_dir" 30 | bar_dir = our_dir + "bar_dir" 31 | 32 | with_tmpdir(foo_dir) do 33 | foo_dir.unlink # we just want to place something at this location 34 | expect(foo_dir.exist?).to be_falsey 35 | 36 | with_tmpdir(bar_dir) do 37 | expect(bar_dir.exist?).to be_truthy 38 | expect(bar_dir.symlink?).to be_falsey 39 | 40 | ArduinoCI::Host.symlink(bar_dir, foo_dir) 41 | expect(ArduinoCI::Host.symlink?(bar_dir)).to be_falsey 42 | expect(ArduinoCI::Host.symlink?(foo_dir)).to be_truthy 43 | expect(ArduinoCI::Host.readlink(foo_dir).realpath).to eq(bar_dir.realpath) 44 | end 45 | end 46 | 47 | expect(foo_dir.exist?).to be_falsey 48 | expect(bar_dir.exist?).to be_falsey 49 | 50 | end 51 | end 52 | 53 | context "which" do 54 | it "can find things with which" do 55 | ruby_path = ArduinoCI::Host.which("ruby") 56 | expect(ruby_path).not_to be nil 57 | expect(ruby_path.to_s.include? "ruby").to be true 58 | end 59 | end 60 | 61 | context "path mangling" do 62 | win_path = "D:\\a\\_temp\\d20221224-4508-11w7f4\\foo.yml" 63 | posix_pathname = Pathname.new("D:/a/_temp/d20221224-4508-11w7f4/foo.yml") 64 | 65 | it "converts windows paths to pathnames" do 66 | expect(ArduinoCI::Host.pathname_to_windows(posix_pathname)).to eq(win_path) 67 | end 68 | 69 | it "converts pathnames to windows paths" do 70 | expect(ArduinoCI::Host.windows_to_pathname(win_path)).to eq(posix_pathname) 71 | end 72 | end 73 | 74 | context "merge_capture_results" do 75 | it "merges results" do 76 | a1 = { out: "one", err: "ONE", success: true } 77 | a2 = { out: "two", err: "TWO", success: false } 78 | a3 = { out: "three", err: "THREE", success: true } 79 | res = ArduinoCI::Host.merge_capture_results(a1, a2, a3) 80 | expect(res[:out]).to eq("onetwothree") 81 | expect(res[:err]).to eq("ONETWOTHREE") 82 | expect(res[:success]).to eq(false) 83 | end 84 | 85 | it "handles empty input" do 86 | res = ArduinoCI::Host.merge_capture_results() 87 | expect(res[:out]).to eq("") 88 | expect(res[:err]).to eq("") 89 | expect(res[:success]).to eq(true) 90 | end 91 | end 92 | 93 | end 94 | -------------------------------------------------------------------------------- /spec/library_properties_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | RSpec.describe ArduinoCI::LibraryProperties do 4 | 5 | context "property extraction" do 6 | library_properties = ArduinoCI::LibraryProperties.new(Pathname.new(__dir__) + "properties" + "example.library.properties") 7 | 8 | expected = { 9 | string: { 10 | name: "WebServer", 11 | version: "1.0.0", 12 | maintainer: "Cristian Maglie ", 13 | sentence: "A library that makes coding a Webserver a breeze.", 14 | paragraph: "Supports HTTP1.1 and you can do GET and POST.", 15 | category: "Communication", 16 | url: "http://example.com/", 17 | }, 18 | 19 | bool: { 20 | precompiled: true 21 | }, 22 | 23 | csv: { 24 | author: ["Cristian Maglie ", "Pippo Pluto "], 25 | architectures: ["avr"], 26 | includes: ["WebServer.h"], 27 | depends: ["ArduinoHttpClient"], 28 | }, 29 | }.freeze 30 | 31 | expected.each do |atype, values| 32 | values.each do |meth, val| 33 | it "reads #{atype} field #{meth}" do 34 | expect(library_properties.send(meth)).to eq(val) 35 | end 36 | end 37 | end 38 | 39 | it "reads full_paragraph" do 40 | expect(library_properties.full_paragraph).to eq ([ 41 | expected[:string][:sentence], 42 | expected[:string][:paragraph] 43 | ].join(" ")) 44 | end 45 | 46 | it "doesn't crash on nonexistent fields" do 47 | expect(library_properties.dot_a_linkage).to be(nil) 48 | end 49 | 50 | it "converts to hash" do 51 | h = library_properties.to_h 52 | expect(h[:name].class).to eq(String) 53 | expect(h[:name]).to eq("WebServer") 54 | expect(h[:architectures].class).to eq(Array) 55 | expect(h[:architectures]).to contain_exactly("avr") 56 | end 57 | end 58 | 59 | context "Input handling" do 60 | malformed_examples = [ 61 | "extra_blank_line.library.properties", 62 | "just_equals.library.properties", 63 | "no_equals.library.properties", 64 | "no_key.library.properties", 65 | "no_value.library.properties", 66 | ].map { |e| Pathname.new(__dir__) + "properties" + e } 67 | 68 | malformed_examples.each do |e| 69 | quirk = e.basename.to_s.split(".library.").first 70 | it "reads a properties file with #{quirk}" do 71 | expect { ArduinoCI::LibraryProperties.new(e) }.to_not raise_error 72 | end 73 | end 74 | end 75 | 76 | end 77 | -------------------------------------------------------------------------------- /spec/properties/example.library.properties: -------------------------------------------------------------------------------- 1 | name=WebServer 2 | version=1.0.0 3 | author=Cristian Maglie , Pippo Pluto 4 | maintainer=Cristian Maglie 5 | sentence=A library that makes coding a Webserver a breeze. 6 | paragraph=Supports HTTP1.1 and you can do GET and POST. 7 | category=Communication 8 | url=http://example.com/ 9 | architectures=avr 10 | includes=WebServer.h 11 | depends=ArduinoHttpClient 12 | precompiled=true 13 | -------------------------------------------------------------------------------- /spec/properties/extra_blank_line.library.properties: -------------------------------------------------------------------------------- 1 | name=ExtraBlank 2 | 3 | sentence=We put the blank line in the middle so overzealous text editors dont trim it 4 | -------------------------------------------------------------------------------- /spec/properties/just_equals.library.properties: -------------------------------------------------------------------------------- 1 | name=JustEquals 2 | sentence=Bad file with just an equals on a line 3 | = 4 | -------------------------------------------------------------------------------- /spec/properties/no_equals.library.properties: -------------------------------------------------------------------------------- 1 | name=NoEquals 2 | sentence=Bad file with no equals on a line 3 | wat 4 | -------------------------------------------------------------------------------- /spec/properties/no_key.library.properties: -------------------------------------------------------------------------------- 1 | name=NoKey 2 | sentence=Bad file with no key on a line 3 | =profit 4 | -------------------------------------------------------------------------------- /spec/properties/no_value.library.properties: -------------------------------------------------------------------------------- 1 | name=NoValue 2 | sentence=Bad file with no value on a line 3 | seriously_why_do_we_even_have_this_line= 4 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'simplecov' 2 | SimpleCov.start do 3 | add_filter %r{^/spec/} 4 | end 5 | require "bundler/setup" 6 | require "arduino_ci" 7 | 8 | RSpec.configure do |config| 9 | # Enable flags like --only-failures and --next-failure 10 | config.example_status_persistence_file_path = ".rspec_status" 11 | 12 | # Disable RSpec exposing methods globally on `Module` and `main` 13 | config.disable_monkey_patching! 14 | 15 | config.expect_with :rspec do |c| 16 | c.syntax = :expect 17 | end 18 | end 19 | 20 | def skip_ruby_tests 21 | !ENV["ARDUINO_CI_SKIP_RUBY_RSPEC_TESTS"].nil? 22 | end 23 | 24 | def skip_cpp_tests 25 | !ENV["ARDUINO_CI_SKIP_CPP_RSPEC_TESTS"].nil? 26 | end 27 | -------------------------------------------------------------------------------- /spec/yaml/o1.yaml: -------------------------------------------------------------------------------- 1 | platforms: 2 | bogo: 3 | board: fakeduino:beep:bogo 4 | package: potato:salad 5 | gcc: 6 | features: 7 | - a 8 | - b 9 | defines: 10 | - c 11 | - d 12 | warnings: 13 | - e 14 | - f 15 | flags: 16 | - g 17 | - h 18 | zero: ~ 19 | esp8266: 20 | board: esp8266:esp8266:booo 21 | package: esp8266:esp8266 22 | gcc: 23 | features: 24 | defines: 25 | warnings: 26 | flags: 27 | 28 | compile: 29 | libraries: 30 | - "Adafruit FONA Library" 31 | platforms: 32 | - esp8266 33 | 34 | unittest: 35 | compilers: 36 | - g++ 37 | - g++-7 38 | testfiles: 39 | select: 40 | - "*-*.*" 41 | reject: 42 | - "sam-squamsh.*" 43 | libraries: 44 | - "abc123" 45 | - "def456" 46 | platforms: 47 | - bogo 48 | -------------------------------------------------------------------------------- /spec/yaml/o2.yaml: -------------------------------------------------------------------------------- 1 | platforms: 2 | bogo: 3 | board: fakeduino:beep:bogo 4 | 5 | compile: 6 | libraries: 7 | - "zip" 8 | platforms: 9 | - bogo 10 | 11 | unittest: 12 | testfiles: 13 | select: 14 | - "*-*.*" 15 | reject: 16 | - "sam-squamsh.*" 17 | libraries: 18 | - "def456" 19 | platforms: 20 | - bogo 21 | -------------------------------------------------------------------------------- /spec/yaml/override1/.arduino-ci.yml: -------------------------------------------------------------------------------- 1 | platforms: 2 | bogo: 3 | board: fakeduino:beep:bogo 4 | package: potato:salad 5 | gcc: 6 | features: 7 | - a 8 | - b 9 | defines: 10 | - c 11 | - d 12 | warnings: 13 | - e 14 | - f 15 | flags: 16 | - g 17 | - h 18 | zero: ~ 19 | esp8266: 20 | board: esp8266:esp8266:booo 21 | package: esp8266:esp8266 22 | gcc: 23 | features: 24 | defines: 25 | warnings: 26 | flags: 27 | 28 | compile: 29 | libraries: 30 | - "Adafruit FONA Library" 31 | platforms: 32 | - esp8266 33 | 34 | unittest: 35 | testfiles: 36 | select: 37 | - "*-*.*" 38 | reject: 39 | - "sam-squamsh.*" 40 | libraries: 41 | - "abc123" 42 | - "def456" 43 | platforms: 44 | - bogo 45 | --------------------------------------------------------------------------------