From b9c67c1479637c03d99751d0233a1966995782bb Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 8 Oct 2024 09:52:41 -0700 Subject: [PATCH] Add minimal support for MIMXRT633S With these changes, we have a chance of running embassy-imxrt on MIMXRT633S. --- .github/workflows/check.yml | 97 +++++++- .github/workflows/nostd.yml | 16 +- Cargo.toml | 40 +++- examples/rt685s-evk/Cargo.toml | 2 + src/chips/mimxrt633s.rs | 387 +++++++++++++++++++++++++++++++ src/chips/mimxrt685s.rs | 386 +++++++++++++++++++++++++++++++ src/i2c/master.rs | 2 +- src/i2c/slave.rs | 2 +- src/lib.rs | 407 ++------------------------------- src/pwm.rs | 3 +- src/timer.rs | 2 +- src/uart.rs | 2 +- 12 files changed, 932 insertions(+), 414 deletions(-) create mode 100644 src/chips/mimxrt633s.rs create mode 100644 src/chips/mimxrt685s.rs diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index aefc8789..105a1ed9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -8,25 +8,29 @@ # - msrv: check that the msrv specified in the crate is correct permissions: contents: read + # This configuration allows maintainers of this repo to create a branch and pull request based on # the new branch. Restricting the push trigger to the main branch ensures that the PR only gets # built once. on: + push: branches: [main] pull_request: + # If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that # we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true + name: check -jobs: +jobs: commit_list: runs-on: ubuntu-latest - steps: + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -55,20 +59,24 @@ jobs: runs-on: ubuntu-latest name: nightly / fmt needs: commit_list + strategy: fail-fast: false matrix: commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} workdir: [ ".", "examples/rt685s-evk"] + steps: - uses: actions/checkout@v4 with: submodules: true ref: ${{ matrix.commit }} + - name: Install nightly uses: dtolnay/rust-toolchain@nightly with: components: rustfmt + - name: cargo fmt --check run: cargo fmt --check working-directory: ${{ matrix.workdir }} @@ -77,9 +85,11 @@ jobs: runs-on: ubuntu-latest name: ${{ matrix.toolchain }} / clippy (${{ matrix.commit }}) needs: commit_list + permissions: contents: read checks: write + strategy: fail-fast: false matrix: @@ -87,21 +97,24 @@ jobs: toolchain: [stable, beta] commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} workdir: [ ".", "examples/rt685s-evk"] + steps: - uses: actions/checkout@v4 with: submodules: true ref: ${{ matrix.commit }} + - name: Install ${{ matrix.toolchain }} uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} components: clippy + - name: cargo clippy uses: giraffate/clippy-action@v1 with: - reporter: 'github-pr-check' - clippy_flags: -- -F clippy::suspicious -F clippy::correctness -F clippy::perf -F clippy::style + reporter: 'github-pr-review' + clippy_flags: -- -Dwarnings -F clippy::suspicious -F clippy::correctness -F clippy::perf -F clippy::style github_token: ${{ secrets.GITHUB_TOKEN }} workdir: ${{ matrix.workdir }} @@ -133,19 +146,25 @@ jobs: runs-on: ubuntu-latest name: nightly / doc needs: commit_list + strategy: fail-fast: false matrix: commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} + steps: - uses: actions/checkout@v4 with: submodules: true ref: ${{ matrix.commit }} + - name: Install nightly uses: dtolnay/rust-toolchain@nightly + - name: cargo doc - run: cargo doc --no-deps --all-features + run: | + cargo doc --no-deps -F mimxrt685s,rt,defmt,time,time-driver,unstable-pac + cargo doc --no-deps -F mimxrt633s,rt,defmt,time,time-driver,unstable-pac env: RUSTDOCFLAGS: --cfg docsrs @@ -155,23 +174,74 @@ jobs: runs-on: ubuntu-latest name: ubuntu / stable / features needs: commit_list + strategy: fail-fast: false matrix: commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} + feature: [ "mimxrt633s", "mimxrt633s,rt", "mimxrt633s,defmt", + "mimxrt633s,time", "mimxrt633s,time-driver", + "mimxrt633s,unstable-pac", "mimxrt633s,rt,defmt", + "mimxrt633s,rt,time", "mimxrt633s,rt,time-driver", + "mimxrt633s,rt,unstable-pac", "mimxrt633s,defmt,time", + "mimxrt633s,defmt,time-driver", "mimxrt633s,defmt,unstable-pac", + "mimxrt633s,time,time-driver", "mimxrt633s,time,unstable-pac", + "mimxrt633s,time-driver,unstable-pac", + "mimxrt633s,rt,defmt,time", "mimxrt633s,rt,defmt,time-driver", + "mimxrt633s,rt,defmt,unstable-pac", + "mimxrt633s,rt,time,time-driver", + "mimxrt633s,rt,time,unstable-pac", + "mimxrt633s,rt,time-driver,unstable-pac", + "mimxrt633s,defmt,time,time-driver", + "mimxrt633s,defmt,time,unstable-pac", + "mimxrt633s,defmt,time-driver,unstable-pac", + "mimxrt633s,time,time-driver,unstable-pac", + "mimxrt633s,rt,defmt,time,time-driver", + "mimxrt633s,rt,defmt,time,unstable-pac", + "mimxrt633s,rt,defmt,time-driver,unstable-pac", + "mimxrt633s,rt,time,time-driver,unstable-pac", + "mimxrt633s,defmt,time,time-driver,unstable-pac", + "mimxrt633s,rt,defmt,time,time-driver,unstable-pac", + "mimxrt685s", "mimxrt685s,rt", "mimxrt685s,defmt", + "mimxrt685s,time", "mimxrt685s,time-driver", + "mimxrt685s,unstable-pac", "mimxrt685s,rt,defmt", + "mimxrt685s,rt,time", "mimxrt685s,rt,time-driver", + "mimxrt685s,rt,unstable-pac", "mimxrt685s,defmt,time", + "mimxrt685s,defmt,time-driver", "mimxrt685s,defmt,unstable-pac", + "mimxrt685s,time,time-driver", "mimxrt685s,time,unstable-pac", + "mimxrt685s,time-driver,unstable-pac", + "mimxrt685s,rt,defmt,time", "mimxrt685s,rt,defmt,time-driver", + "mimxrt685s,rt,defmt,unstable-pac", + "mimxrt685s,rt,time,time-driver", + "mimxrt685s,rt,time,unstable-pac", + "mimxrt685s,rt,time-driver,unstable-pac", + "mimxrt685s,defmt,time,time-driver", + "mimxrt685s,defmt,time,unstable-pac", + "mimxrt685s,defmt,time-driver,unstable-pac", + "mimxrt685s,time,time-driver,unstable-pac", + "mimxrt685s,rt,defmt,time,time-driver", + "mimxrt685s,rt,defmt,time,unstable-pac", + "mimxrt685s,rt,defmt,time-driver,unstable-pac", + "mimxrt685s,rt,time,time-driver,unstable-pac", + "mimxrt685s,defmt,time,time-driver,unstable-pac", + "mimxrt685s,rt,defmt,time,time-driver,unstable-pac" ] + steps: - uses: actions/checkout@v4 with: submodules: true ref: ${{ matrix.commit }} + - name: Install stable uses: dtolnay/rust-toolchain@stable + - name: cargo install cargo-hack uses: taiki-e/install-action@cargo-hack + # intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4 # --feature-powerset runs for every combination of features - - name: cargo hack - run: cargo hack --feature-powerset check + - name: cargo manual hack + run: cargo check -F ${{ matrix.feature }} deny: # cargo-deny checks licenses, advisories, sources, and bans for @@ -179,17 +249,21 @@ jobs: runs-on: ubuntu-latest name: ubuntu / stable / deny needs: commit_list + strategy: fail-fast: false matrix: commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} + steps: - uses: actions/checkout@v4 with: submodules: true ref: ${{ matrix.commit }} + - name: Install stable uses: dtolnay/rust-toolchain@stable + - name: cargo install cargo-deny uses: EmbarkStudios/cargo-deny-action@v2 with: @@ -208,7 +282,6 @@ jobs: fail-fast: false matrix: commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} - workdir: [ ".", "examples/rt685s-evk"] msrv: ["1.83"] # We're relying on namespaced-features, which # was released in 1.60 # @@ -222,16 +295,20 @@ jobs: # collapse_debuginfo # # embassy upstream switched to rust 1.83 + name: ubuntu / ${{ matrix.msrv }} (${{ matrix.commit }}) steps: - uses: actions/checkout@v4 with: submodules: true ref: ${{ matrix.commit }} + - name: Install ${{ matrix.msrv }} uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.msrv }} + - name: cargo +${{ matrix.msrv }} check - run: cargo check - working-directory: ${{ matrix.workdir }} + run: | + cargo check -F mimxrt685s,rt,defmt,time,time-driver,unstable-pac + cargo check -F mimxrt633s,rt,defmt,time,time-driver,unstable-pac diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml index c67c9f7a..2504ce83 100644 --- a/.github/workflows/nostd.yml +++ b/.github/workflows/nostd.yml @@ -3,28 +3,42 @@ # information about how the concurrency cancellation and workflow triggering works permissions: contents: read + on: push: branches: [main] pull_request: + concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true + name: no-std + jobs: nostd: runs-on: ubuntu-latest name: ${{ matrix.target }} + strategy: matrix: target: [thumbv8m.main-none-eabihf] + steps: - uses: actions/checkout@v4 with: submodules: true + - name: Install stable uses: dtolnay/rust-toolchain@stable + - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} + + - name: Show variable + run: echo ${{ env.TOKEN }} + - name: cargo check - run: cargo check --target ${{ matrix.target }} --no-default-features + run: | + cargo check --target ${{ matrix.target }} --no-default-features -F mimxrt685s + cargo check --target ${{ matrix.target }} --no-default-features -F mimxrt633s diff --git a/Cargo.toml b/Cargo.toml index 41a0205e..127b036a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,11 +19,19 @@ flavors = [{ name = "imxrt685s", target = "thumbv8m.main-none-eabihf" }] features = ["defmt", "unstable-pac", "time-driver"] [features] -default = ["rt"] -## Enable the rt feature of [`rp-pac`](https://docs.rs/crates/rp-pac). This brings in the [`cortex-m-rt`](https://docs.rs/cortex-m-rt) crate, which adds startup code and minimal runtime initialization. -rt = ["mimxrt685s-pac/rt"] +default = ["mimxrt685s", "rt"] -## Enable [defmt support](https://docs.rs/defmt) and enables `defmt` debug-log messages and formatting in embassy drivers. +## Enable the rt feature of +## [`rp-pac`](https://docs.rs/crates/rp-pac). This brings in the +## [`cortex-m-rt`](https://docs.rs/cortex-m-rt) crate, which adds +## startup code and minimal runtime initialization. +rt = [ + "mimxrt685s-pac?/rt", + "mimxrt633s-pac?/rt", +] + +## Enable [defmt support](https://docs.rs/defmt) and enables `defmt` +## debug-log messages and formatting in embassy drivers. defmt = ["dep:defmt", "mimxrt685s-pac/defmt"] ## Enable features requiring `embassy-time` time = ["dep:embassy-time"] @@ -34,6 +42,20 @@ time-driver = [ "dep:embassy-time-queue-utils", ] +#! ### Chip selection features +## MIMXRT685S +mimxrt685s = ["mimxrt685s-pac", "_mimxrt685s"] +mimxrt633s = ["mimxrt633s-pac", "_mimxrt633s"] + +## Reexport the PAC for the currently enabled chip at `embassy_imxrt::pac` (unstable) +unstable-pac = [] + +# Features starting with `_` are for internal use only. They're not intended +# to be enabled by other crates, and are not covered by semver guarantees. + +_mimxrt685s = [] +_mimxrt633s = [] + [dependencies] embassy-sync = { git = "https://github.com/embassy-rs/embassy" } embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", optional = true } @@ -59,12 +81,6 @@ embedded-storage-async = { version = "0.4.1" } rand_core = "0.6.4" fixed = "1.23.1" -mimxrt685s-pac = { version = "0.2.2", features = [ - "rt", - "critical-section", - "defmt", -] } - embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ "unproven", ] } @@ -75,6 +91,10 @@ embedded-hal-nb = { version = "1.0" } document-features = "0.2.7" paste = "1.0" +# PACs +mimxrt685s-pac = { version = "0.2.2", optional = true, features = ["rt", "critical-section", "defmt"] } +mimxrt633s-pac = { version = "0.2.0", optional = true, features = ["rt", "critical-section", "defmt"] } + [dev-dependencies] embassy-executor = { git = "https://github.com/embassy-rs/embassy" } static_cell = { version = "2" } diff --git a/examples/rt685s-evk/Cargo.toml b/examples/rt685s-evk/Cargo.toml index bc1f2bf7..c508991a 100644 --- a/examples/rt685s-evk/Cargo.toml +++ b/examples/rt685s-evk/Cargo.toml @@ -17,6 +17,8 @@ embassy-imxrt = { version = "0.1.0", path = "../../", features = [ "defmt", "time-driver", "time", + "mimxrt685s", + "unstable-pac", ] } embassy-sync = { git = "https://github.com/embassy-rs/embassy", features = [ diff --git a/src/chips/mimxrt633s.rs b/src/chips/mimxrt633s.rs new file mode 100644 index 00000000..4c326344 --- /dev/null +++ b/src/chips/mimxrt633s.rs @@ -0,0 +1,387 @@ +pub use mimxrt633s_pac as pac; + +#[allow(clippy::missing_safety_doc)] +pub mod interrupts { + embassy_hal_internal::interrupt_mod!( + ACMP, + ADC0, + CASPER, + CTIMER0, + CTIMER1, + CTIMER2, + CTIMER3, + CTIMER4, + DMA0, + DMA1, + DMIC0, + ESPI, + FLEXCOMM0, + FLEXCOMM1, + FLEXCOMM14, + FLEXCOMM15, + FLEXCOMM2, + FLEXCOMM3, + FLEXCOMM4, + FLEXCOMM5, + FLEXCOMM6, + FLEXCOMM7, + FLEXSPI, + GPIO_INTA, + GPIO_INTB, + HASHCRYPT, + HWVAD0, + HYPERVISOR, + I3C0, + MRT0, + MU_A, + OS_EVENT, + PIN_INT0, + PIN_INT1, + PIN_INT2, + PIN_INT3, + PIN_INT4, + PIN_INT5, + PIN_INT6, + PIN_INT7, + PMC_PMIC, + POWERQUAD, + PUF, + RNG, + RTC, + SCT0, + SECUREVIOLATION, + SGPIO_INTA, + SGPIO_INTB, + USB, + USBPHY_DCD, + USB_WAKEUP, + USDHC0, + USDHC1, + UTICK0, + WDT0, + WDT1, + ); +} + +embassy_hal_internal::peripherals!( + ACMP, + ADC0, + CASPER, + CRC, + CTIMER0_COUNT_CHANNEL0, + CTIMER0_COUNT_CHANNEL1, + CTIMER0_COUNT_CHANNEL2, + CTIMER0_COUNT_CHANNEL3, + CTIMER0_CAPTURE_CHANNEL0, + CTIMER0_CAPTURE_CHANNEL1, + CTIMER0_CAPTURE_CHANNEL2, + CTIMER0_CAPTURE_CHANNEL3, + CTIMER1_COUNT_CHANNEL0, + CTIMER1_COUNT_CHANNEL1, + CTIMER1_COUNT_CHANNEL2, + CTIMER1_COUNT_CHANNEL3, + CTIMER1_CAPTURE_CHANNEL0, + CTIMER1_CAPTURE_CHANNEL1, + CTIMER1_CAPTURE_CHANNEL2, + CTIMER1_CAPTURE_CHANNEL3, + CTIMER2_COUNT_CHANNEL0, + CTIMER2_COUNT_CHANNEL1, + CTIMER2_COUNT_CHANNEL2, + CTIMER2_COUNT_CHANNEL3, + CTIMER2_CAPTURE_CHANNEL0, + CTIMER2_CAPTURE_CHANNEL1, + CTIMER2_CAPTURE_CHANNEL2, + CTIMER2_CAPTURE_CHANNEL3, + CTIMER3_COUNT_CHANNEL0, + CTIMER3_COUNT_CHANNEL1, + CTIMER3_COUNT_CHANNEL2, + CTIMER3_COUNT_CHANNEL3, + CTIMER3_CAPTURE_CHANNEL0, + CTIMER3_CAPTURE_CHANNEL1, + CTIMER3_CAPTURE_CHANNEL2, + CTIMER3_CAPTURE_CHANNEL3, + CTIMER4_COUNT_CHANNEL0, + CTIMER4_COUNT_CHANNEL1, + CTIMER4_COUNT_CHANNEL2, + CTIMER4_COUNT_CHANNEL3, + CTIMER4_CAPTURE_CHANNEL0, + CTIMER4_CAPTURE_CHANNEL1, + CTIMER4_CAPTURE_CHANNEL2, + CTIMER4_CAPTURE_CHANNEL3, + DMA0, + DMA0_CH0, + DMA0_CH1, + DMA0_CH2, + DMA0_CH3, + DMA0_CH4, + DMA0_CH5, + DMA0_CH6, + DMA0_CH7, + DMA0_CH8, + DMA0_CH9, + DMA0_CH10, + DMA0_CH11, + DMA0_CH12, + DMA0_CH13, + DMA0_CH14, + DMA0_CH15, + DMA0_CH16, + DMA0_CH17, + DMA0_CH18, + DMA0_CH19, + DMA0_CH20, + DMA0_CH21, + DMA0_CH22, + DMA0_CH23, + DMA0_CH24, + DMA0_CH25, + DMA0_CH26, + DMA0_CH27, + DMA0_CH28, + DMA0_CH29, + DMA0_CH30, + DMA0_CH31, + DMA0_CH32, + DMA1, + DMA1_CH0, + DMA1_CH1, + DMA1_CH2, + DMA1_CH3, + DMA1_CH4, + DMA1_CH5, + DMA1_CH6, + DMA1_CH7, + DMA1_CH8, + DMA1_CH9, + DMA1_CH10, + DMA1_CH11, + DMA1_CH12, + DMA1_CH13, + DMA1_CH14, + DMA1_CH15, + DMA1_CH16, + DMA1_CH17, + DMA1_CH18, + DMA1_CH19, + DMA1_CH20, + DMA1_CH21, + DMA1_CH22, + DMA1_CH23, + DMA1_CH24, + DMA1_CH25, + DMA1_CH26, + DMA1_CH27, + DMA1_CH28, + DMA1_CH29, + DMA1_CH30, + DMA1_CH31, + DMA1_CH32, + DMIC0, + DSPWAKE, + ESPI, + FLEXCOMM0, + FLEXCOMM1, + FLEXCOMM14, + FLEXCOMM15, + FLEXCOMM2, + FLEXCOMM3, + FLEXCOMM4, + FLEXCOMM5, + FLEXCOMM6, + FLEXCOMM7, + FLEXSPI, + FREQME, + GPIO_INTA, + GPIO_INTB, + HASHCRYPT, + HSGPIO0, + HSGPIO1, + HSGPIO2, + HSGPIO3, + HSGPIO4, + HSGPIO5, + HSGPIO6, + HSGPIO7, + HWVAD0, + HYPERVISOR, + I3C0, + MRT0, + MU_A, + OS_EVENT, + PIN_INT0, + PIN_INT1, + PIN_INT2, + PIN_INT3, + PIN_INT4, + PIN_INT5, + PIN_INT6, + PIN_INT7, + PIO0_0, + PIO0_1, + PIO0_10, + PIO0_11, + PIO0_12, + PIO0_13, + PIO0_14, + PIO0_15, + PIO0_16, + PIO0_17, + PIO0_18, + PIO0_19, + PIO0_2, + PIO0_20, + PIO0_21, + PIO0_22, + PIO0_23, + PIO0_24, + PIO0_25, + PIO0_26, + PIO0_27, + PIO0_28, + PIO0_29, + PIO0_3, + PIO0_30, + PIO0_31, + PIO0_4, + PIO0_5, + PIO0_6, + PIO0_7, + PIO0_8, + PIO0_9, + PIO1_0, + PIO1_1, + PIO1_10, + PIO1_11, + PIO1_12, + PIO1_13, + PIO1_14, + PIO1_15, + PIO1_16, + PIO1_17, + PIO1_18, + PIO1_19, + PIO1_2, + PIO1_20, + PIO1_21, + PIO1_22, + PIO1_23, + PIO1_24, + PIO1_25, + PIO1_26, + PIO1_27, + PIO1_28, + PIO1_29, + PIO1_3, + PIO1_30, + PIO1_31, + PIO1_4, + PIO1_5, + PIO1_6, + PIO1_7, + PIO1_8, + PIO1_9, + PIO2_0, + PIO2_1, + PIO2_10, + PIO2_11, + PIO2_12, + PIO2_13, + PIO2_14, + PIO2_15, + PIO2_16, + PIO2_17, + PIO2_18, + PIO2_19, + PIO2_2, + PIO2_20, + PIO2_21, + PIO2_22, + PIO2_23, + PIO2_24, + PIO2_25, + PIO2_26, + PIO2_27, + PIO2_28, + PIO2_29, + PIO2_3, + PIO2_30, + PIO2_31, + PIO2_4, + PIO2_5, + PIO2_6, + PIO2_7, + PIO2_8, + PIO2_9, + PIO3_0, + PIO3_1, + PIO3_10, + PIO3_11, + PIO3_12, + PIO3_13, + PIO3_14, + PIO3_15, + PIO3_16, + PIO3_17, + PIO3_18, + PIO3_19, + PIO3_2, + PIO3_20, + PIO3_21, + PIO3_22, + PIO3_23, + PIO3_24, + PIO3_25, + PIO3_26, + PIO3_27, + PIO3_28, + PIO3_29, + PIO3_3, + PIO3_30, + PIO3_31, + PIO3_4, + PIO3_5, + PIO3_6, + PIO3_7, + PIO3_8, + PIO3_9, + PIO4_0, + PIO4_1, + PIO4_10, + PIO4_2, + PIO4_3, + PIO4_4, + PIO4_5, + PIO4_6, + PIO4_7, + PIO4_8, + PIO4_9, + PIO7_24, + PIO7_25, + PIO7_26, + PIO7_27, + PIO7_28, + PIO7_29, + PIO7_30, + PIO7_31, + PMC_PMIC, + PIMCTL, + POWERQUAD, + PUF, + RNG, + RTC, + SCT0, + SECGPIO, + SECUREVIOLATION, + SEMA42, + SGPIO_INTA, + SGPIO_INTB, + USBHSD, + USBHSH, + USBPHY, + USB_WAKEUP, + USDHC0, + USDHC1, + UTICK0, + WDT0, + WDT1, +); diff --git a/src/chips/mimxrt685s.rs b/src/chips/mimxrt685s.rs new file mode 100644 index 00000000..873779f5 --- /dev/null +++ b/src/chips/mimxrt685s.rs @@ -0,0 +1,386 @@ +pub use mimxrt685s_pac as pac; + +#[allow(clippy::missing_safety_doc)] +pub mod interrupts { + embassy_hal_internal::interrupt_mod!( + ACMP, + ADC0, + CASPER, + CTIMER0, + CTIMER1, + CTIMER2, + CTIMER3, + CTIMER4, + DMA0, + DMA1, + DMIC0, + DSPWAKE, + FLEXCOMM0, + FLEXCOMM1, + FLEXCOMM14, + FLEXCOMM15, + FLEXCOMM2, + FLEXCOMM3, + FLEXCOMM4, + FLEXCOMM5, + FLEXCOMM6, + FLEXCOMM7, + FLEXSPI, + GPIO_INTA, + GPIO_INTB, + HASHCRYPT, + HWVAD0, + HYPERVISOR, + I3C0, + MRT0, + MU_A, + OS_EVENT, + PIN_INT0, + PIN_INT1, + PIN_INT2, + PIN_INT3, + PIN_INT4, + PIN_INT5, + PIN_INT6, + PIN_INT7, + PMC_PMIC, + POWERQUAD, + PUF, + RNG, + RTC, + SCT0, + SECUREVIOLATION, + SGPIO_INTA, + SGPIO_INTB, + USB, + USBPHY_DCD, + USB_WAKEUP, + USDHC0, + USDHC1, + UTICK0, + WDT0, + WDT1, + ); +} + +embassy_hal_internal::peripherals!( + ACMP, + ADC0, + CASPER, + CRC, + CTIMER0_COUNT_CHANNEL0, + CTIMER0_COUNT_CHANNEL1, + CTIMER0_COUNT_CHANNEL2, + CTIMER0_COUNT_CHANNEL3, + CTIMER0_CAPTURE_CHANNEL0, + CTIMER0_CAPTURE_CHANNEL1, + CTIMER0_CAPTURE_CHANNEL2, + CTIMER0_CAPTURE_CHANNEL3, + CTIMER1_COUNT_CHANNEL0, + CTIMER1_COUNT_CHANNEL1, + CTIMER1_COUNT_CHANNEL2, + CTIMER1_COUNT_CHANNEL3, + CTIMER1_CAPTURE_CHANNEL0, + CTIMER1_CAPTURE_CHANNEL1, + CTIMER1_CAPTURE_CHANNEL2, + CTIMER1_CAPTURE_CHANNEL3, + CTIMER2_COUNT_CHANNEL0, + CTIMER2_COUNT_CHANNEL1, + CTIMER2_COUNT_CHANNEL2, + CTIMER2_COUNT_CHANNEL3, + CTIMER2_CAPTURE_CHANNEL0, + CTIMER2_CAPTURE_CHANNEL1, + CTIMER2_CAPTURE_CHANNEL2, + CTIMER2_CAPTURE_CHANNEL3, + CTIMER3_COUNT_CHANNEL0, + CTIMER3_COUNT_CHANNEL1, + CTIMER3_COUNT_CHANNEL2, + CTIMER3_COUNT_CHANNEL3, + CTIMER3_CAPTURE_CHANNEL0, + CTIMER3_CAPTURE_CHANNEL1, + CTIMER3_CAPTURE_CHANNEL2, + CTIMER3_CAPTURE_CHANNEL3, + CTIMER4_COUNT_CHANNEL0, + CTIMER4_COUNT_CHANNEL1, + CTIMER4_COUNT_CHANNEL2, + CTIMER4_COUNT_CHANNEL3, + CTIMER4_CAPTURE_CHANNEL0, + CTIMER4_CAPTURE_CHANNEL1, + CTIMER4_CAPTURE_CHANNEL2, + CTIMER4_CAPTURE_CHANNEL3, + DMA0, + DMA0_CH0, + DMA0_CH1, + DMA0_CH2, + DMA0_CH3, + DMA0_CH4, + DMA0_CH5, + DMA0_CH6, + DMA0_CH7, + DMA0_CH8, + DMA0_CH9, + DMA0_CH10, + DMA0_CH11, + DMA0_CH12, + DMA0_CH13, + DMA0_CH14, + DMA0_CH15, + DMA0_CH16, + DMA0_CH17, + DMA0_CH18, + DMA0_CH19, + DMA0_CH20, + DMA0_CH21, + DMA0_CH22, + DMA0_CH23, + DMA0_CH24, + DMA0_CH25, + DMA0_CH26, + DMA0_CH27, + DMA0_CH28, + DMA0_CH29, + DMA0_CH30, + DMA0_CH31, + DMA0_CH32, + DMA1, + DMA1_CH0, + DMA1_CH1, + DMA1_CH2, + DMA1_CH3, + DMA1_CH4, + DMA1_CH5, + DMA1_CH6, + DMA1_CH7, + DMA1_CH8, + DMA1_CH9, + DMA1_CH10, + DMA1_CH11, + DMA1_CH12, + DMA1_CH13, + DMA1_CH14, + DMA1_CH15, + DMA1_CH16, + DMA1_CH17, + DMA1_CH18, + DMA1_CH19, + DMA1_CH20, + DMA1_CH21, + DMA1_CH22, + DMA1_CH23, + DMA1_CH24, + DMA1_CH25, + DMA1_CH26, + DMA1_CH27, + DMA1_CH28, + DMA1_CH29, + DMA1_CH30, + DMA1_CH31, + DMA1_CH32, + DMIC0, + DSPWAKE, + FLEXCOMM0, + FLEXCOMM1, + FLEXCOMM14, + FLEXCOMM15, + FLEXCOMM2, + FLEXCOMM3, + FLEXCOMM4, + FLEXCOMM5, + FLEXCOMM6, + FLEXCOMM7, + FLEXSPI, + FREQME, + GPIO_INTA, + GPIO_INTB, + HASHCRYPT, + HSGPIO0, + HSGPIO1, + HSGPIO2, + HSGPIO3, + HSGPIO4, + HSGPIO5, + HSGPIO6, + HSGPIO7, + HWVAD0, + HYPERVISOR, + I3C0, + MRT0, + MU_A, + OS_EVENT, + PIN_INT0, + PIN_INT1, + PIN_INT2, + PIN_INT3, + PIN_INT4, + PIN_INT5, + PIN_INT6, + PIN_INT7, + PIO0_0, + PIO0_1, + PIO0_10, + PIO0_11, + PIO0_12, + PIO0_13, + PIO0_14, + PIO0_15, + PIO0_16, + PIO0_17, + PIO0_18, + PIO0_19, + PIO0_2, + PIO0_20, + PIO0_21, + PIO0_22, + PIO0_23, + PIO0_24, + PIO0_25, + PIO0_26, + PIO0_27, + PIO0_28, + PIO0_29, + PIO0_3, + PIO0_30, + PIO0_31, + PIO0_4, + PIO0_5, + PIO0_6, + PIO0_7, + PIO0_8, + PIO0_9, + PIO1_0, + PIO1_1, + PIO1_10, + PIO1_11, + PIO1_12, + PIO1_13, + PIO1_14, + PIO1_15, + PIO1_16, + PIO1_17, + PIO1_18, + PIO1_19, + PIO1_2, + PIO1_20, + PIO1_21, + PIO1_22, + PIO1_23, + PIO1_24, + PIO1_25, + PIO1_26, + PIO1_27, + PIO1_28, + PIO1_29, + PIO1_3, + PIO1_30, + PIO1_31, + PIO1_4, + PIO1_5, + PIO1_6, + PIO1_7, + PIO1_8, + PIO1_9, + PIO2_0, + PIO2_1, + PIO2_10, + PIO2_11, + PIO2_12, + PIO2_13, + PIO2_14, + PIO2_15, + PIO2_16, + PIO2_17, + PIO2_18, + PIO2_19, + PIO2_2, + PIO2_20, + PIO2_21, + PIO2_22, + PIO2_23, + PIO2_24, + PIO2_25, + PIO2_26, + PIO2_27, + PIO2_28, + PIO2_29, + PIO2_3, + PIO2_30, + PIO2_31, + PIO2_4, + PIO2_5, + PIO2_6, + PIO2_7, + PIO2_8, + PIO2_9, + PIO3_0, + PIO3_1, + PIO3_10, + PIO3_11, + PIO3_12, + PIO3_13, + PIO3_14, + PIO3_15, + PIO3_16, + PIO3_17, + PIO3_18, + PIO3_19, + PIO3_2, + PIO3_20, + PIO3_21, + PIO3_22, + PIO3_23, + PIO3_24, + PIO3_25, + PIO3_26, + PIO3_27, + PIO3_28, + PIO3_29, + PIO3_3, + PIO3_30, + PIO3_31, + PIO3_4, + PIO3_5, + PIO3_6, + PIO3_7, + PIO3_8, + PIO3_9, + PIO4_0, + PIO4_1, + PIO4_10, + PIO4_2, + PIO4_3, + PIO4_4, + PIO4_5, + PIO4_6, + PIO4_7, + PIO4_8, + PIO4_9, + PIO7_24, + PIO7_25, + PIO7_26, + PIO7_27, + PIO7_28, + PIO7_29, + PIO7_30, + PIO7_31, + PMC_PMIC, + PIMCTL, + POWERQUAD, + PUF, + RNG, + RTC, + SCT0, + SECGPIO, + SECUREVIOLATION, + SEMA42, + SGPIO_INTA, + SGPIO_INTB, + USBHSD, + USBHSH, + USBPHY, + USB_WAKEUP, + USDHC0, + USDHC1, + UTICK0, + WDT0, + WDT1, +); diff --git a/src/i2c/master.rs b/src/i2c/master.rs index 585b6cc5..a705db0b 100644 --- a/src/i2c/master.rs +++ b/src/i2c/master.rs @@ -10,7 +10,7 @@ use super::{ Async, Blocking, Error, Info, Instance, InterruptHandler, MasterDma, Mode, Result, SclPin, SdaPin, TransferError, I2C_WAKERS, }; -use crate::interrupts::interrupt::typelevel::Interrupt; +use crate::interrupt::typelevel::Interrupt; use crate::{dma, interrupt, Peripheral}; /// Bus speed (nominal SCL, no clock stretching) diff --git a/src/i2c/slave.rs b/src/i2c/slave.rs index 7d32c6e2..d510faee 100644 --- a/src/i2c/slave.rs +++ b/src/i2c/slave.rs @@ -10,7 +10,7 @@ use super::{ Async, Blocking, Info, Instance, InterruptHandler, Mode, Result, SclPin, SdaPin, SlaveDma, TransferError, I2C_WAKERS, }; -use crate::interrupts::interrupt::typelevel::Interrupt; +use crate::interrupt::typelevel::Interrupt; use crate::pac::i2c0::stat::Slvstate; use crate::{dma, interrupt}; diff --git a/src/lib.rs b/src/lib.rs index 7ce0a2e9..f8aa22b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,14 @@ //! ## Feature flags #![doc = document_features::document_features!(feature_label = r#"{feature}"#)] +#[cfg(not(any(feature = "mimxrt633s", feature = "mimxrt685s",)))] +compile_error!( + "No chip feature activated. You must activate exactly one of the following features: + mimxrt633s, + mimxrt685s, + " +); + // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; @@ -32,79 +40,24 @@ pub mod timer; pub mod uart; pub mod wwdt; +// This mod MUST go last, so that it sees all the `impl_foo!' macros +#[cfg_attr(feature = "mimxrt633s", path = "chips/mimxrt633s.rs")] +#[cfg_attr(feature = "mimxrt685s", path = "chips/mimxrt685s.rs")] +mod chip; + // Reexports pub use adc::AdcChannel; +pub use chip::interrupts::*; +#[cfg(feature = "unstable-pac")] +pub use chip::pac; +#[cfg(not(feature = "unstable-pac"))] +pub(crate) use chip::pac; +pub use chip::{peripherals, Peripherals}; pub use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef}; -pub use interrupts::*; -pub use mimxrt685s_pac as pac; #[cfg(feature = "rt")] pub use crate::pac::NVIC_PRIO_BITS; -/// Wrapper module to suppress clippy warning caused by macro. -#[allow(clippy::missing_safety_doc)] -pub mod interrupts { - embassy_hal_internal::interrupt_mod!( - ACMP, - ADC0, - CASPER, - CTIMER0, - CTIMER1, - CTIMER2, - CTIMER3, - CTIMER4, - DMA0, - DMA1, - DMIC0, - DSPWAKE, - FLEXCOMM0, - FLEXCOMM1, - FLEXCOMM14, - FLEXCOMM15, - FLEXCOMM2, - FLEXCOMM3, - FLEXCOMM4, - FLEXCOMM5, - FLEXCOMM6, - FLEXCOMM7, - FLEXSPI, - GPIO_INTA, - GPIO_INTB, - HASHCRYPT, - HWVAD0, - HYPERVISOR, - I3C0, - MRT0, - MU_A, - OS_EVENT, - PIN_INT0, - PIN_INT1, - PIN_INT2, - PIN_INT3, - PIN_INT4, - PIN_INT5, - PIN_INT6, - PIN_INT7, - PMC_PMIC, - POWERQUAD, - PUF, - RNG, - RTC, - SCT0, - SECUREVIOLATION, - SGPIO_INTA, - SGPIO_INTB, - USB, - USBPHY_DCD, - USB_WAKEUP, - USDHC0, - USDHC1, - UTICK0, - WDT0, - WDT1, - ); -} - /// Macro to bind interrupts to handlers. /// /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) @@ -144,328 +97,6 @@ macro_rules! bind_interrupts { }; } -embassy_hal_internal::peripherals!( - ACMP, - ADC0, - CASPER, - CRC, - CTIMER0_COUNT_CHANNEL0, - CTIMER0_COUNT_CHANNEL1, - CTIMER0_COUNT_CHANNEL2, - CTIMER0_COUNT_CHANNEL3, - CTIMER0_CAPTURE_CHANNEL0, - CTIMER0_CAPTURE_CHANNEL1, - CTIMER0_CAPTURE_CHANNEL2, - CTIMER0_CAPTURE_CHANNEL3, - CTIMER1_COUNT_CHANNEL0, - CTIMER1_COUNT_CHANNEL1, - CTIMER1_COUNT_CHANNEL2, - CTIMER1_COUNT_CHANNEL3, - CTIMER1_CAPTURE_CHANNEL0, - CTIMER1_CAPTURE_CHANNEL1, - CTIMER1_CAPTURE_CHANNEL2, - CTIMER1_CAPTURE_CHANNEL3, - CTIMER2_COUNT_CHANNEL0, - CTIMER2_COUNT_CHANNEL1, - CTIMER2_COUNT_CHANNEL2, - CTIMER2_COUNT_CHANNEL3, - CTIMER2_CAPTURE_CHANNEL0, - CTIMER2_CAPTURE_CHANNEL1, - CTIMER2_CAPTURE_CHANNEL2, - CTIMER2_CAPTURE_CHANNEL3, - CTIMER3_COUNT_CHANNEL0, - CTIMER3_COUNT_CHANNEL1, - CTIMER3_COUNT_CHANNEL2, - CTIMER3_COUNT_CHANNEL3, - CTIMER3_CAPTURE_CHANNEL0, - CTIMER3_CAPTURE_CHANNEL1, - CTIMER3_CAPTURE_CHANNEL2, - CTIMER3_CAPTURE_CHANNEL3, - CTIMER4_COUNT_CHANNEL0, - CTIMER4_COUNT_CHANNEL1, - CTIMER4_COUNT_CHANNEL2, - CTIMER4_COUNT_CHANNEL3, - CTIMER4_CAPTURE_CHANNEL0, - CTIMER4_CAPTURE_CHANNEL1, - CTIMER4_CAPTURE_CHANNEL2, - CTIMER4_CAPTURE_CHANNEL3, - DMA0, - DMA0_CH0, - DMA0_CH1, - DMA0_CH2, - DMA0_CH3, - DMA0_CH4, - DMA0_CH5, - DMA0_CH6, - DMA0_CH7, - DMA0_CH8, - DMA0_CH9, - DMA0_CH10, - DMA0_CH11, - DMA0_CH12, - DMA0_CH13, - DMA0_CH14, - DMA0_CH15, - DMA0_CH16, - DMA0_CH17, - DMA0_CH18, - DMA0_CH19, - DMA0_CH20, - DMA0_CH21, - DMA0_CH22, - DMA0_CH23, - DMA0_CH24, - DMA0_CH25, - DMA0_CH26, - DMA0_CH27, - DMA0_CH28, - DMA0_CH29, - DMA0_CH30, - DMA0_CH31, - DMA0_CH32, - DMA1, - DMA1_CH0, - DMA1_CH1, - DMA1_CH2, - DMA1_CH3, - DMA1_CH4, - DMA1_CH5, - DMA1_CH6, - DMA1_CH7, - DMA1_CH8, - DMA1_CH9, - DMA1_CH10, - DMA1_CH11, - DMA1_CH12, - DMA1_CH13, - DMA1_CH14, - DMA1_CH15, - DMA1_CH16, - DMA1_CH17, - DMA1_CH18, - DMA1_CH19, - DMA1_CH20, - DMA1_CH21, - DMA1_CH22, - DMA1_CH23, - DMA1_CH24, - DMA1_CH25, - DMA1_CH26, - DMA1_CH27, - DMA1_CH28, - DMA1_CH29, - DMA1_CH30, - DMA1_CH31, - DMA1_CH32, - DMIC0, - DSPWAKE, - FLEXCOMM0, - FLEXCOMM1, - FLEXCOMM14, - FLEXCOMM15, - FLEXCOMM2, - FLEXCOMM3, - FLEXCOMM4, - FLEXCOMM5, - FLEXCOMM6, - FLEXCOMM7, - FLEXSPI, - FREQME, - GPIO_INTA, - GPIO_INTB, - HASHCRYPT, - HSGPIO0, - HSGPIO1, - HSGPIO2, - HSGPIO3, - HSGPIO4, - HSGPIO5, - HSGPIO6, - HSGPIO7, - HWVAD0, - HYPERVISOR, - I3C0, - MRT0, - MU_A, - OS_EVENT, - PIN_INT0, - PIN_INT1, - PIN_INT2, - PIN_INT3, - PIN_INT4, - PIN_INT5, - PIN_INT6, - PIN_INT7, - PIO0_0, - PIO0_1, - PIO0_10, - PIO0_11, - PIO0_12, - PIO0_13, - PIO0_14, - PIO0_15, - PIO0_16, - PIO0_17, - PIO0_18, - PIO0_19, - PIO0_2, - PIO0_20, - PIO0_21, - PIO0_22, - PIO0_23, - PIO0_24, - PIO0_25, - PIO0_26, - PIO0_27, - PIO0_28, - PIO0_29, - PIO0_3, - PIO0_30, - PIO0_31, - PIO0_4, - PIO0_5, - PIO0_6, - PIO0_7, - PIO0_8, - PIO0_9, - PIO1_0, - PIO1_1, - PIO1_10, - PIO1_11, - PIO1_12, - PIO1_13, - PIO1_14, - PIO1_15, - PIO1_16, - PIO1_17, - PIO1_18, - PIO1_19, - PIO1_2, - PIO1_20, - PIO1_21, - PIO1_22, - PIO1_23, - PIO1_24, - PIO1_25, - PIO1_26, - PIO1_27, - PIO1_28, - PIO1_29, - PIO1_3, - PIO1_30, - PIO1_31, - PIO1_4, - PIO1_5, - PIO1_6, - PIO1_7, - PIO1_8, - PIO1_9, - PIO2_0, - PIO2_1, - PIO2_10, - PIO2_11, - PIO2_12, - PIO2_13, - PIO2_14, - PIO2_15, - PIO2_16, - PIO2_17, - PIO2_18, - PIO2_19, - PIO2_2, - PIO2_20, - PIO2_21, - PIO2_22, - PIO2_23, - PIO2_24, - PIO2_25, - PIO2_26, - PIO2_27, - PIO2_28, - PIO2_29, - PIO2_3, - PIO2_30, - PIO2_31, - PIO2_4, - PIO2_5, - PIO2_6, - PIO2_7, - PIO2_8, - PIO2_9, - PIO3_0, - PIO3_1, - PIO3_10, - PIO3_11, - PIO3_12, - PIO3_13, - PIO3_14, - PIO3_15, - PIO3_16, - PIO3_17, - PIO3_18, - PIO3_19, - PIO3_2, - PIO3_20, - PIO3_21, - PIO3_22, - PIO3_23, - PIO3_24, - PIO3_25, - PIO3_26, - PIO3_27, - PIO3_28, - PIO3_29, - PIO3_3, - PIO3_30, - PIO3_31, - PIO3_4, - PIO3_5, - PIO3_6, - PIO3_7, - PIO3_8, - PIO3_9, - PIO4_0, - PIO4_1, - PIO4_10, - PIO4_2, - PIO4_3, - PIO4_4, - PIO4_5, - PIO4_6, - PIO4_7, - PIO4_8, - PIO4_9, - PIO7_24, - PIO7_25, - PIO7_26, - PIO7_27, - PIO7_28, - PIO7_29, - PIO7_30, - PIO7_31, - PMC_PMIC, - PIMCTL, - POWERQUAD, - PUF, - RNG, - RTC, - SCT0, - SECGPIO, - SECUREVIOLATION, - SEMA42, - SGPIO_INTA, - SGPIO_INTB, - USBHSD, - USBHSH, - USBPHY, - USB_WAKEUP, - USDHC0, - USDHC1, - UTICK0, - WDT0, - WDT1, -); - /// HAL configuration for iMX RT600. pub mod config { use crate::clocks::ClockConfig; diff --git a/src/pwm.rs b/src/pwm.rs index 6a11bccd..1c9a4c15 100644 --- a/src/pwm.rs +++ b/src/pwm.rs @@ -26,8 +26,9 @@ /// include the traits that are implemented + exposed via this implementation use embassy_hal_internal::{Peripheral, PeripheralRef}; + /// include pac definitions for instancing -use mimxrt685s_pac as pac; // TODO: generalize for other chipsets +use crate::pac; /// clock source indicator for selecting while powering on the `SCTimer` #[derive(Copy, Clone, Debug)] diff --git a/src/timer.rs b/src/timer.rs index 08585af3..6c3fb9fe 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -404,7 +404,7 @@ impl_instance!(4, 1); // CTIMER4 Channel 1 impl_instance!(4, 2); // CTIMER4 Channel 2 impl_instance!(4, 3); // CTIMER4 Channel 3 -impl From for mimxrt685s_pac::inputmux::ct32bit_cap::ct32bit_cap_sel::CapnSel { +impl From for crate::pac::inputmux::ct32bit_cap::ct32bit_cap_sel::CapnSel { fn from(input: TriggerInput) -> Self { match input { TriggerInput::TrigIn0 => Self::CtInp0, diff --git a/src/uart.rs b/src/uart.rs index 8683081c..5ccdc94a 100644 --- a/src/uart.rs +++ b/src/uart.rs @@ -12,7 +12,7 @@ use paste::paste; use crate::dma::channel::Channel; use crate::dma::transfer::Transfer; use crate::gpio::{AnyPin, GpioPin as Pin}; -use crate::interrupts::interrupt::typelevel::Interrupt; +use crate::interrupt::typelevel::Interrupt; use crate::iopctl::{DriveMode, DriveStrength, Inverter, IopctlPin, Pull, SlewRate}; use crate::pac::usart0::cfg::{Clkpol, Datalen, Loop, Paritysel as Parity, Stoplen, Syncen, Syncmst}; use crate::pac::usart0::ctl::Cc;