diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..a8608a4 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,9 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = , +skip = ./.git,./.licenses,__pycache__,node_modules,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock +builtin = clear,informal,en-GB_to_en-US +check-filenames = +check-hidden = diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fd7388a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md + # See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily + labels: + - "topic: infrastructure" diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml new file mode 100644 index 0000000..dfcac2e --- /dev/null +++ b/.github/workflows/check-arduino.yml @@ -0,0 +1,31 @@ +name: Check Arduino + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + compliance: strict + # Change this to "update" once the library is added to the index. + library-manager: submit + # Always use this setting for official repositories. Remove for 3rd party projects. + official: true diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..cc19b1f --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,75 @@ +name: Compile Examples + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-examples.ya?ml" + - "library.properties" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.ya?ml" + - "library.properties" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +permissions: + contents: read + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:mbed_nicla:nicla_vision + # See: https://github.com/arduino/compile-sketches#platforms + platforms: | + - name: arduino:mbed_nicla + - fqbn: arduino:mbed_portenta:envie_m4 + platforms: | + - name: arduino:mbed_portenta + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + # Install the library from the local path. + - source-path: ./ + # Additional library dependencies can be listed here. + # See: https://github.com/arduino/compile-sketches#libraries + sketch-paths: | + - examples + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v3 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..32122aa --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,27 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.ya?ml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +permissions: + pull-requests: write + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..be559af --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,25 @@ +name: Spell Check + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +permissions: + contents: read + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Spell check + uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..3a330c1 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,138 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md +name: Sync Labels + +# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + pull_request: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + schedule: + # Run daily at 8 AM UTC to sync with changes to shared label configurations. + - cron: "0 8 * * *" + workflow_dispatch: + repository_dispatch: + +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT: label-configuration-files + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download JSON schema for labels configuration file + id: download-schema + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json + location: ${{ runner.temp }}/label-configuration-schema + + - name: Install JSON schema validator + run: | + sudo npm install \ + --global \ + ajv-cli \ + ajv-formats + + - name: Validate local labels configuration + run: | + # See: https://github.com/ajv-validator/ajv-cli#readme + ajv validate \ + --all-errors \ + -c ajv-formats \ + -s "${{ steps.download-schema.outputs.file-path }}" \ + -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" + + download: + needs: check + runs-on: ubuntu-latest + + strategy: + matrix: + filename: + # Filenames of the shared configurations to apply to the repository in addition to the local configuration. + # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels + - universal.yml + + steps: + - name: Download + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} + + - name: Pass configuration files to next job via workflow artifact + uses: actions/upload-artifact@v3 + with: + path: | + *.yaml + *.yml + if-no-files-found: error + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + sync: + needs: download + runs-on: ubuntu-latest + + steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable + echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" + + - name: Determine whether to dry run + id: dry-run + if: > + github.event_name == 'pull_request' || + ( + ( + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + ) && + github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ) + run: | + # Use of this flag in the github-label-sync command will cause it to only check the validity of the + # configuration. + echo "::set-output name=flag::--dry-run" + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download configuration files artifact + uses: actions/download-artifact@v3 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + path: ${{ env.CONFIGURATIONS_FOLDER }} + + - name: Remove unneeded artifact + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + - name: Merge label configuration files + run: | + # Merge all configuration files + shopt -s extglob + cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" + + - name: Install github-label-sync + run: sudo npm install --global github-label-sync + + - name: Sync labels + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # See: https://github.com/Financial-Times/github-label-sync + github-label-sync \ + --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ + ${{ steps.dry-run.outputs.flag }} \ + ${{ github.repository }} diff --git a/README.md b/README.md index cd8a48e..c1af7ee 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ - -Library to handle the PMIC (Power Management IC) on the following Arduino boards - -- [Arduino Portenta H7](https://docs.arduino.cc/hardware/portenta-h7) -- [Arduino Portenta H7 Lite](https://docs.arduino.cc/hardware/portenta-h7-lite) -- [Arduino Portenta H7 Lite Connected](https://docs.arduino.cc/hardware/portenta-h7-lite-connected) +# Arduino_PF1550 + +[![Check Arduino status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/check-arduino.yml) +[![Compile Examples status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/compile-examples.yml) +[![Spell Check status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml) + +Library to handle the PMIC (Power Management IC) on the following Arduino boards + +- [Arduino Portenta H7](https://docs.arduino.cc/hardware/portenta-h7) +- [Arduino Portenta H7 Lite](https://docs.arduino.cc/hardware/portenta-h7-lite) +- [Arduino Portenta H7 Lite Connected](https://docs.arduino.cc/hardware/portenta-h7-lite-connected) - [Arduino Nicla Vision](https://docs.arduino.cc/hardware/nicla-vision) \ No newline at end of file diff --git a/examples/BasicUsage/BasicUsage.ino b/examples/BasicUsage/BasicUsage.ino index 1e68738..4f126d0 100644 --- a/examples/BasicUsage/BasicUsage.ino +++ b/examples/BasicUsage/BasicUsage.ino @@ -20,7 +20,7 @@ void setup() { IEndOfCharge::I_5_mA, IInputCurrentLimit::I_100_mA); - /* TODO: Clarify if a interrupt event is generated by a rising or falling edge, + /* TODO: Clarify if an interrupt event is generated by a rising or falling edge, * according to schematic/datasheet it's a open-drain output with a pull-up resistor. * Probably we need to do the registering with a ISR handler internally in the future * since the PMIC_INT pin PK0 will not be exposed externally. diff --git a/src/PF1550/PF1550_Control.cpp b/src/PF1550/PF1550_Control.cpp index fba05dd..a8d6e93 100644 --- a/src/PF1550/PF1550_Control.cpp +++ b/src/PF1550/PF1550_Control.cpp @@ -211,7 +211,7 @@ void PF1550_Control::onPMICEvent() uint8_t int_category; _io.readRegister(Register::PMIC_INT_CATEGORY, &int_category); - /* Call the appopriate event handler */ + /* Call the appropriate event handler */ if(isBitSet(int_category, REG_INT_CATEGORY_CHG_INT_bp )) onChargerEvent (); if(isBitSet(int_category, REG_INT_CATEGORY_SW1_INT_bp )) onSwitch1Event (); if(isBitSet(int_category, REG_INT_CATEGORY_SW2_INT_bp )) onSwitch2Event (); diff --git a/src/PF1550/PF1550_Register.h b/src/PF1550/PF1550_Register.h index 503e4ac..71979a1 100644 --- a/src/PF1550/PF1550_Register.h +++ b/src/PF1550/PF1550_Register.h @@ -31,7 +31,7 @@ enum class Register : uint8_t { - /* PMIC Register Adresses */ + /* PMIC Register Addresses */ PMIC_DEVICE_ID = 0x00, PMIC_OTP_FLAVOR = 0x01, PMIC_SILICON_REV = 0x02, @@ -96,7 +96,7 @@ enum class Register : uint8_t PMIC_I2C_ADDR = 0x68, PMIC_RC_16MHZ = 0x6B, PMIC_KEY1 = 0x6B, - /* Charger Register Adresses */ + /* Charger Register Addresses */ CHARGER_CHG_INT = 0x80 + 0x00, CHARGER_CHG_INT_MASK = 0x80 + 0x02, CHARGER_CHG_INT_OK = 0x80 + 0x04,