diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 703a34d29..30dad0509 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -12,11 +12,14 @@ jobs: - name: Install cargo-hack run: | curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin - - name: Build rp2040-hal's workspace (without the examples) - run: cargo hack build --optional-deps --each-feature - - run: cargo clean - - name: Build rp2040-hal's workspace (with the examples) - run: cargo hack build --examples --optional-deps --each-feature + - name: Build rp2040-hal + run: cd rp2040-hal && cargo hack build --optional-deps --each-feature --target=thumbv6m-none-eabi + - name: Build rp2040-hal-macros + run: cd rp2040-hal-macros && cargo hack build --optional-deps --each-feature + - name: Build on-target-tests + run: cd on-target-tests && cargo hack build --optional-deps --each-feature + - name: Build rp2040-hal-examples + run: cd rp2040-hal-examples && cargo hack build --optional-deps --each-feature tests: name: Execute host-runable tests runs-on: ubuntu-20.04 @@ -29,15 +32,13 @@ jobs: run: | curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin - name: Test - run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --tests --features critical-section-impl + run: cd rp2040-hal && cargo hack test --optional-deps --each-feature --tests --features critical-section-impl - name: Test docs - run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --doc --features critical-section-impl + run: cd rp2040-hal && cargo hack test --optional-deps --each-feature --doc --features critical-section-impl - name: Test macros - run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --tests --each-feature + run: cd rp2040-hal-macros && cargo hack test --optional-deps --tests --each-feature - name: Test macro docs - run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --doc --each-feature - - name: Clean - run: cargo clean + run: cd rp2040-hal-macros && cargo hack test --optional-deps --doc --each-feature udeps: name: Check rp2040-hal for unused dependencies runs-on: ubuntu-20.04 @@ -53,8 +54,14 @@ jobs: - name: Install cargo-udeps run: | curl -sSL https://github.com/est31/cargo-udeps/releases/download/v0.1.45/cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - --strip-components=2 -C ~/.cargo/bin ./cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu/cargo-udeps - - name: Check unused deps - run: cargo hack udeps --optional-deps --each-feature + - name: Check unused deps in rp2040-hal + run: cd rp2040-hal && cargo hack udeps --optional-deps --each-feature --target=thumbv6m-none-eabi + - name: Check unused deps in rp2040-hal-macros + run: cd rp2040-hal-macros && cargo hack udeps --optional-deps --each-feature + - name: Check unused deps in rp2040-hal-examples + run: cd rp2040-hal-examples && cargo hack udeps --optional-deps --each-feature + - name: Check unused deps in on-target-tests + run: cd on-target-tests && cargo hack udeps --optional-deps --each-feature msrv: name: Verify build on MSRV runs-on: ubuntu-20.04 @@ -69,5 +76,11 @@ jobs: curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin - name: Use older version of regex run: cargo update -p regex --precise 1.9.3 - - name: Verify MSRV - run: cargo hack build --examples --optional-deps --each-feature + - name: Build rp2040-hal (on MSRV) + run: cd rp2040-hal && cargo hack build --optional-deps --each-feature --target=thumbv6m-none-eabi + - name: Build rp2040-hal-macros (on MSRV) + run: cd rp2040-hal-macros && cargo hack build --optional-deps --each-feature + - name: Build on-target-tests (on MSRV) + run: cd on-target-tests && cargo hack build --optional-deps --each-feature + - name: Build rp2040-hal-examples (on MSRV) + run: cd rp2040-hal-examples && cargo hack build --optional-deps --each-feature diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 3483dd414..9378bd470 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -12,5 +12,13 @@ jobs: with: target: thumbv6m-none-eabi components: clippy - - run: cargo clippy --workspace --examples - - run: cargo clippy --workspace --examples --all-features + - name: Build rp2040-hal + run: cd rp2040-hal && cargo clippy --target=thumbv6m-none-eabi + - name: Build rp2040-hal (with all features) + run: cd rp2040-hal && cargo clippy --target=thumbv6m-none-eabi --all-features + - name: Build rp2040-hal-macros + run: cd rp2040-hal-macros && cargo clippy + - name: Build on-target-tests + run: cd on-target-tests && cargo clippy + - name: Build rp2040-hal-examples + run: cd rp2040-hal-examples && cargo clippy diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 9d7b8065b..c2e7cc75a 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -12,4 +12,11 @@ jobs: with: target: thumbv6m-none-eabi components: rustfmt - - run: cargo fmt -- --check + - name: Check format of rp2040-hal + run: cd rp2040-hal && cargo fmt -- --check + - name: Check format of rp2040-hal-macros + run: cd rp2040-hal-macros && cargo fmt -- --check + - name: Check format of on-target-tests + run: cd on-target-tests && cargo fmt -- --check + - name: Check format of rp2040-hal-examples + run: cd rp2040-hal-examples && cargo fmt -- --check diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 17b93a079..000000000 --- a/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[workspace] -resolver = "2" -members = ["rp2040-hal", "rp2040-hal-macros", "on-target-tests"] -exclude = [] - -[patch.'https://github.com/rp-rs/rp-hal.git'] -rp2040-hal = { path = "./rp2040-hal" } - -[patch.crates-io] -rp2040-hal = { path = "./rp2040-hal" } - -# Those profiles are only used for `on-target-tests` compilation -[profile.dev] -codegen-units = 1 -incremental = false -lto = 'fat' -opt-level = 's' - -[profile.test] -codegen-units = 1 -incremental = false -lto = 'fat' -opt-level = 's' diff --git a/format.bat b/format.bat new file mode 100644 index 000000000..c22532265 --- /dev/null +++ b/format.bat @@ -0,0 +1,6 @@ +rem Formats all the files in the repo + +cargo fmt --manifest-path rp2040-hal\Cargo.toml -- --check +cargo fmt --manifest-path rp2040-hal-macros\Cargo.toml -- --check +cargo fmt --manifest-path rp2040-hal-examples\Cargo.toml -- --check +cargo fmt --manifest-path on-target-tests\Cargo.toml -- --check diff --git a/format.sh b/format.sh new file mode 100755 index 000000000..3f141459a --- /dev/null +++ b/format.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Formats all the files in the repo + +cargo fmt --manifest-path rp2040-hal/Cargo.toml -- --check +cargo fmt --manifest-path rp2040-hal-macros/Cargo.toml -- --check +cargo fmt --manifest-path rp2040-hal-examples/Cargo.toml -- --check +cargo fmt --manifest-path on-target-tests/Cargo.toml -- --check diff --git a/.cargo/config.toml b/on-target-tests/.cargo/config.toml similarity index 100% rename from .cargo/config.toml rename to on-target-tests/.cargo/config.toml diff --git a/on-target-tests/Cargo.toml b/on-target-tests/Cargo.toml index 90b9274b1..2352d9872 100644 --- a/on-target-tests/Cargo.toml +++ b/on-target-tests/Cargo.toml @@ -77,3 +77,15 @@ futures = { version = "0.3.30", default-features = false, features = [ ] } i2c-write-iter = { version = "1.0.0", features = ["async"] } itertools = { version = "0.12.0", default-features = false } + +[profile.dev] +codegen-units = 1 +incremental = false +lto = 'fat' +opt-level = 's' + +[profile.test] +codegen-units = 1 +incremental = false +lto = 'fat' +opt-level = 's' diff --git a/on-target-tests/README.md b/on-target-tests/README.md index 5bddb161f..71a1ac9cb 100644 --- a/on-target-tests/README.md +++ b/on-target-tests/README.md @@ -9,10 +9,12 @@ Adding a test: Running all tests: Linux (and any other Unix-likes where probe-rs are supported): ```system +cd on-target-tests ./run_tests.sh ``` Windows ```system +cd on-target-tests run_tests.bat ``` diff --git a/run_tests.bat b/on-target-tests/run_tests.bat similarity index 78% rename from run_tests.bat rename to on-target-tests/run_tests.bat index afe938520..f8fcfa61d 100755 --- a/run_tests.bat +++ b/on-target-tests/run_tests.bat @@ -3,4 +3,4 @@ @SET "CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER=probe-rs run" -cargo test -p on-target-tests --no-fail-fast -- --chip rp2040 +cargo test --no-fail-fast -- --chip rp2040 diff --git a/run_tests.sh b/on-target-tests/run_tests.sh similarity index 83% rename from run_tests.sh rename to on-target-tests/run_tests.sh index 92b3402af..326e7992b 100755 --- a/run_tests.sh +++ b/on-target-tests/run_tests.sh @@ -3,4 +3,4 @@ # Keep running tests even if one of them fails # We need to specify probe-rs as our runner via environment variables here # to control build since we aren't able to override them in config.toml -CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test -p on-target-tests --no-fail-fast -- --chip rp2040 +CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test --no-fail-fast -- --chip rp2040 diff --git a/rp2040-hal-examples/.cargo/config.toml b/rp2040-hal-examples/.cargo/config.toml new file mode 100644 index 000000000..256fec245 --- /dev/null +++ b/rp2040-hal-examples/.cargo/config.toml @@ -0,0 +1,41 @@ +# +# Cargo Configuration for the https://github.com/rp-rs/rp-hal.git repository. +# +# Copyright (c) The RP-RS Developers, 2021 +# +# You might want to make a similar file in your own repository if you are +# writing programs for Raspberry Silicon microcontrollers. +# +# This file is MIT or Apache-2.0 as per the repository README.md file +# + +[build] +# Set the default target to match the Cortex-M0+ in the RP2040 +target = "thumbv6m-none-eabi" + +# Target specific options +[target.thumbv6m-none-eabi] +# Pass some extra options to rustc, some of which get passed on to the linker. +# +# * linker argument --nmagic turns off page alignment of sections (which saves +# flash space) +# * linker argument -Tlink.x tells the linker to use link.x as the linker +# script. This is usually provided by the cortex-m-rt crate, and by default +# the version in that crate will include a file called `memory.x` which +# describes the particular memory layout for your specific chip. +# * no-vectorize-loops turns off the loop vectorizer (seeing as the M0+ doesn't +# have SIMD) +rustflags = [ + "-C", "link-arg=--nmagic", + "-C", "link-arg=-Tlink.x", + "-C", "link-arg=-Tdefmt.x", + "-C", "no-vectorize-loops", +] + +# This runner will make a UF2 file and then copy it to a mounted RP2040 in USB +# Bootloader mode: +runner = "elf2uf2-rs -d" + +# This runner will find a supported SWD debug probe and flash your RP2040 over +# SWD: +# runner = "probe-rs run --chip RP2040" diff --git a/rp2040-hal-examples/Cargo.toml b/rp2040-hal-examples/Cargo.toml new file mode 100644 index 000000000..f7ccfee15 --- /dev/null +++ b/rp2040-hal-examples/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "rp2040-hal-examples" +version = "0.1.0" +edition = "2021" +authors = ["The rp-rs Developers"] +homepage = "https://github.com/rp-rs/rp-hal" +description = "Examples for the rp2040-hal crate" +license = "MIT OR Apache-2.0" +rust-version = "1.77" +repository = "https://github.com/rp-rs/rp-hal" +categories = ["embedded", "hardware-support", "no-std", "no-std::no-alloc"] +keywords = ["embedded", "hal", "raspberry-pi", "rp2040", "embedded-hal"] + +[dependencies] +cortex-m = "0.7.2" +cortex-m-rt = "0.7" +cortex-m-rtic = "1.1.4" +critical-section = { version = "1.0.0" } +defmt = "0.3" +defmt-rtt = "0.4.0" +dht-sensor = "0.2.1" +embedded_hal_0_2 = { package = "embedded-hal", version = "0.2.5", features = ["unproven"] } +embedded-alloc = "0.5.1" +embedded-hal = "1.0.0" +embedded-hal-async = "1.0.0" +fugit = "0.3.6" +futures = { version = "0.3.30", default-features = false, features = ["async-await"] } +hd44780-driver = "0.4.0" +nb = "1.0" +nostd_async = { version = "0.6.1", features = ["cortex_m"] } +panic-halt = "0.2.0" +panic-probe = { version = "0.3.1", features = ["print-defmt"] } +pio = "0.2.0" +pio-proc = "0.2.0" +rand = { version = "0.8.5", default-features = false } +rp2040-boot2 = "0.3.0" +rp2040-hal = { path = "../rp2040-hal", version = "0.10.0", features = ["binary-info", "critical-section-impl", "rt", "defmt"] } diff --git a/rp2040-hal-examples/build.rs b/rp2040-hal-examples/build.rs new file mode 100644 index 000000000..b2dd9ec07 --- /dev/null +++ b/rp2040-hal-examples/build.rs @@ -0,0 +1,14 @@ +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + // Put the linker script somewhere the linker can find it + let out = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()); + let memory_x = include_bytes!("memory.x"); + let mut f = File::create(out.join("memory.x")).unwrap(); + f.write_all(memory_x).unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=memory.x"); +} diff --git a/memory.x b/rp2040-hal-examples/memory.x similarity index 91% rename from memory.x rename to rp2040-hal-examples/memory.x index 67df0fc02..10c6cfa62 100644 --- a/memory.x +++ b/rp2040-hal-examples/memory.x @@ -1,5 +1,10 @@ MEMORY { BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 + /* + * Here we assume you have 2048 KiB of Flash. This is what the Pi Pico + * has, but your board may have more or less Flash and you should adjust + * this value to suit. + */ FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 /* * RAM consists of 4 banks, SRAM0-SRAM3, with a striped mapping. @@ -75,4 +80,4 @@ SECTIONS { /* We put this in the header */ __bi_entries_end = .; } > FLASH -} INSERT AFTER .text; \ No newline at end of file +} INSERT AFTER .text; diff --git a/rp2040-hal/examples/adc.rs b/rp2040-hal-examples/src/bin/adc.rs similarity index 100% rename from rp2040-hal/examples/adc.rs rename to rp2040-hal-examples/src/bin/adc.rs diff --git a/rp2040-hal/examples/adc_fifo_dma.rs b/rp2040-hal-examples/src/bin/adc_fifo_dma.rs similarity index 100% rename from rp2040-hal/examples/adc_fifo_dma.rs rename to rp2040-hal-examples/src/bin/adc_fifo_dma.rs diff --git a/rp2040-hal/examples/adc_fifo_irq.rs b/rp2040-hal-examples/src/bin/adc_fifo_irq.rs similarity index 100% rename from rp2040-hal/examples/adc_fifo_irq.rs rename to rp2040-hal-examples/src/bin/adc_fifo_irq.rs diff --git a/rp2040-hal/examples/adc_fifo_poll.rs b/rp2040-hal-examples/src/bin/adc_fifo_poll.rs similarity index 100% rename from rp2040-hal/examples/adc_fifo_poll.rs rename to rp2040-hal-examples/src/bin/adc_fifo_poll.rs diff --git a/rp2040-hal/examples/alloc.rs b/rp2040-hal-examples/src/bin/alloc.rs similarity index 100% rename from rp2040-hal/examples/alloc.rs rename to rp2040-hal-examples/src/bin/alloc.rs diff --git a/rp2040-hal/examples/binary_info_demo.rs b/rp2040-hal-examples/src/bin/binary_info_demo.rs similarity index 100% rename from rp2040-hal/examples/binary_info_demo.rs rename to rp2040-hal-examples/src/bin/binary_info_demo.rs diff --git a/rp2040-hal/examples/blinky.rs b/rp2040-hal-examples/src/bin/blinky.rs similarity index 100% rename from rp2040-hal/examples/blinky.rs rename to rp2040-hal-examples/src/bin/blinky.rs diff --git a/rp2040-hal/examples/dht11.rs b/rp2040-hal-examples/src/bin/dht11.rs similarity index 100% rename from rp2040-hal/examples/dht11.rs rename to rp2040-hal-examples/src/bin/dht11.rs diff --git a/rp2040-hal/examples/dormant_sleep.rs b/rp2040-hal-examples/src/bin/dormant_sleep.rs similarity index 100% rename from rp2040-hal/examples/dormant_sleep.rs rename to rp2040-hal-examples/src/bin/dormant_sleep.rs diff --git a/rp2040-hal/examples/gpio_dyn_pin_array.rs b/rp2040-hal-examples/src/bin/gpio_dyn_pin_array.rs similarity index 100% rename from rp2040-hal/examples/gpio_dyn_pin_array.rs rename to rp2040-hal-examples/src/bin/gpio_dyn_pin_array.rs diff --git a/rp2040-hal/examples/gpio_in_out.rs b/rp2040-hal-examples/src/bin/gpio_in_out.rs similarity index 100% rename from rp2040-hal/examples/gpio_in_out.rs rename to rp2040-hal-examples/src/bin/gpio_in_out.rs diff --git a/rp2040-hal/examples/gpio_irq_example.rs b/rp2040-hal-examples/src/bin/gpio_irq_example.rs similarity index 100% rename from rp2040-hal/examples/gpio_irq_example.rs rename to rp2040-hal-examples/src/bin/gpio_irq_example.rs diff --git a/rp2040-hal/examples/i2c.rs b/rp2040-hal-examples/src/bin/i2c.rs similarity index 100% rename from rp2040-hal/examples/i2c.rs rename to rp2040-hal-examples/src/bin/i2c.rs diff --git a/rp2040-hal/examples/i2c_async.rs b/rp2040-hal-examples/src/bin/i2c_async.rs similarity index 100% rename from rp2040-hal/examples/i2c_async.rs rename to rp2040-hal-examples/src/bin/i2c_async.rs diff --git a/rp2040-hal/examples/i2c_async_cancelled.rs b/rp2040-hal-examples/src/bin/i2c_async_cancelled.rs similarity index 100% rename from rp2040-hal/examples/i2c_async_cancelled.rs rename to rp2040-hal-examples/src/bin/i2c_async_cancelled.rs diff --git a/rp2040-hal/examples/lcd_display.rs b/rp2040-hal-examples/src/bin/lcd_display.rs similarity index 100% rename from rp2040-hal/examples/lcd_display.rs rename to rp2040-hal-examples/src/bin/lcd_display.rs diff --git a/rp2040-hal/examples/mem_to_mem_dma.rs b/rp2040-hal-examples/src/bin/mem_to_mem_dma.rs similarity index 100% rename from rp2040-hal/examples/mem_to_mem_dma.rs rename to rp2040-hal-examples/src/bin/mem_to_mem_dma.rs diff --git a/rp2040-hal/examples/multicore_fifo_blink.rs b/rp2040-hal-examples/src/bin/multicore_fifo_blink.rs similarity index 100% rename from rp2040-hal/examples/multicore_fifo_blink.rs rename to rp2040-hal-examples/src/bin/multicore_fifo_blink.rs diff --git a/rp2040-hal/examples/multicore_polyblink.rs b/rp2040-hal-examples/src/bin/multicore_polyblink.rs similarity index 100% rename from rp2040-hal/examples/multicore_polyblink.rs rename to rp2040-hal-examples/src/bin/multicore_polyblink.rs diff --git a/rp2040-hal/examples/pio_blink.rs b/rp2040-hal-examples/src/bin/pio_blink.rs similarity index 100% rename from rp2040-hal/examples/pio_blink.rs rename to rp2040-hal-examples/src/bin/pio_blink.rs diff --git a/rp2040-hal/examples/pio_dma.rs b/rp2040-hal-examples/src/bin/pio_dma.rs similarity index 100% rename from rp2040-hal/examples/pio_dma.rs rename to rp2040-hal-examples/src/bin/pio_dma.rs diff --git a/rp2040-hal/examples/pio_proc_blink.rs b/rp2040-hal-examples/src/bin/pio_proc_blink.rs similarity index 100% rename from rp2040-hal/examples/pio_proc_blink.rs rename to rp2040-hal-examples/src/bin/pio_proc_blink.rs diff --git a/rp2040-hal/examples/pio_side_set.rs b/rp2040-hal-examples/src/bin/pio_side_set.rs similarity index 100% rename from rp2040-hal/examples/pio_side_set.rs rename to rp2040-hal-examples/src/bin/pio_side_set.rs diff --git a/rp2040-hal/examples/pio_synchronized.rs b/rp2040-hal-examples/src/bin/pio_synchronized.rs similarity index 100% rename from rp2040-hal/examples/pio_synchronized.rs rename to rp2040-hal-examples/src/bin/pio_synchronized.rs diff --git a/rp2040-hal/examples/pwm_blink.rs b/rp2040-hal-examples/src/bin/pwm_blink.rs similarity index 100% rename from rp2040-hal/examples/pwm_blink.rs rename to rp2040-hal-examples/src/bin/pwm_blink.rs diff --git a/rp2040-hal/examples/pwm_blink_embedded_hal_1.rs b/rp2040-hal-examples/src/bin/pwm_blink_embedded_hal_1.rs similarity index 100% rename from rp2040-hal/examples/pwm_blink_embedded_hal_1.rs rename to rp2040-hal-examples/src/bin/pwm_blink_embedded_hal_1.rs diff --git a/rp2040-hal/examples/pwm_irq_input.rs b/rp2040-hal-examples/src/bin/pwm_irq_input.rs similarity index 100% rename from rp2040-hal/examples/pwm_irq_input.rs rename to rp2040-hal-examples/src/bin/pwm_irq_input.rs diff --git a/rp2040-hal/examples/rom_funcs.rs b/rp2040-hal-examples/src/bin/rom_funcs.rs similarity index 100% rename from rp2040-hal/examples/rom_funcs.rs rename to rp2040-hal-examples/src/bin/rom_funcs.rs diff --git a/rp2040-hal/examples/rosc_as_system_clock.rs b/rp2040-hal-examples/src/bin/rosc_as_system_clock.rs similarity index 100% rename from rp2040-hal/examples/rosc_as_system_clock.rs rename to rp2040-hal-examples/src/bin/rosc_as_system_clock.rs diff --git a/rp2040-hal/examples/rtc_irq_example.rs b/rp2040-hal-examples/src/bin/rtc_irq_example.rs similarity index 100% rename from rp2040-hal/examples/rtc_irq_example.rs rename to rp2040-hal-examples/src/bin/rtc_irq_example.rs diff --git a/rp2040-hal/examples/rtc_sleep_example.rs b/rp2040-hal-examples/src/bin/rtc_sleep_example.rs similarity index 100% rename from rp2040-hal/examples/rtc_sleep_example.rs rename to rp2040-hal-examples/src/bin/rtc_sleep_example.rs diff --git a/rp2040-hal/examples/spi.rs b/rp2040-hal-examples/src/bin/spi.rs similarity index 100% rename from rp2040-hal/examples/spi.rs rename to rp2040-hal-examples/src/bin/spi.rs diff --git a/rp2040-hal/examples/spi_dma.rs b/rp2040-hal-examples/src/bin/spi_dma.rs similarity index 100% rename from rp2040-hal/examples/spi_dma.rs rename to rp2040-hal-examples/src/bin/spi_dma.rs diff --git a/rp2040-hal/examples/uart.rs b/rp2040-hal-examples/src/bin/uart.rs similarity index 100% rename from rp2040-hal/examples/uart.rs rename to rp2040-hal-examples/src/bin/uart.rs diff --git a/rp2040-hal/examples/uart_dma.rs b/rp2040-hal-examples/src/bin/uart_dma.rs similarity index 100% rename from rp2040-hal/examples/uart_dma.rs rename to rp2040-hal-examples/src/bin/uart_dma.rs diff --git a/rp2040-hal/examples/vector_table.rs b/rp2040-hal-examples/src/bin/vector_table.rs similarity index 100% rename from rp2040-hal/examples/vector_table.rs rename to rp2040-hal-examples/src/bin/vector_table.rs diff --git a/rp2040-hal/examples/watchdog.rs b/rp2040-hal-examples/src/bin/watchdog.rs similarity index 100% rename from rp2040-hal/examples/watchdog.rs rename to rp2040-hal-examples/src/bin/watchdog.rs diff --git a/rp2040-hal/Cargo.toml b/rp2040-hal/Cargo.toml index 48a5caa8f..428f70e5a 100644 --- a/rp2040-hal/Cargo.toml +++ b/rp2040-hal/Cargo.toml @@ -18,57 +18,31 @@ targets = ["thumbv6m-none-eabi"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +bitfield = { version = "0.14.0" } +chrono = { version = "0.4", default-features = false, optional = true } cortex-m = "0.7.2" -embedded_hal_0_2 = { package = "embedded-hal", version = "0.2.5", features = [ - "unproven", -] } +critical-section = { version = "1.0.0" } +defmt = { version = ">=0.2.0, <0.4", optional = true } +embedded_hal_0_2 = { package = "embedded-hal", version = "0.2.5", features = ["unproven"] } +embedded-dma = "0.2.0" embedded-hal = "1.0.0" -embedded-hal-nb = "1.0.0" embedded-hal-async = "1.0.0" -embedded-dma = "0.2.0" +embedded-hal-nb = "1.0.0" embedded-io = "0.6.1" +frunk = { version = "0.4.1", default-features = false } fugit = "0.3.6" +i2c-write-iter = { version = "1.0.0", features = ["async"], optional = true } itertools = { version = "0.10.1", default-features = false } nb = "1.0" -rp2040-pac = { version = "0.6.0", features = ["critical-section"] } paste = "1.0" pio = "0.2.0" +rand_core = "0.6.3" rp2040-hal-macros = { version = "0.1.0", path = "../rp2040-hal-macros" } +rp2040-pac = { version = "0.6.0", features = ["critical-section"] } +rtic-monotonic = { version = "1.0.0", optional = true } usb-device = "0.3" vcell = "0.1" void = { version = "1.0.2", default-features = false } -rand_core = "0.6.3" -critical-section = { version = "1.0.0" } - -chrono = { version = "0.4", default-features = false, optional = true } - -defmt = { version = ">=0.2.0, <0.4", optional = true } - -rtic-monotonic = { version = "1.0.0", optional = true } - -frunk = { version = "0.4.1", default-features = false } - -bitfield = { version = "0.14.0" } - -i2c-write-iter = { version = "1.0.0", features = ["async"], optional = true } - -[dev-dependencies] -cortex-m-rt = "0.7" -cortex-m-rtic = "1.1.4" -panic-halt = "0.2.0" -rp2040-boot2 = "0.3.0" -hd44780-driver = "0.4.0" -pio-proc = "0.2.0" -dht-sensor = "0.2.1" -rand = { version = "0.8.5", default-features = false } -nostd_async = { version = "0.6.1", features = ["cortex_m"] } -futures = { version = "0.3.30", default-features = false, features = [ - "async-await", -] } -defmt-rtt = "0.4.0" -panic-probe = { version = "0.3.1", features = ["print-defmt"] } -defmt = "0.3" -embedded-alloc = "0.5.1" [features] # Minimal startup / runtime for Cortex-M microcontrollers @@ -111,159 +85,3 @@ i2c-write-iter = ["dep:i2c-write-iter"] # Requires 'rt' so that the vector table is correctly sized and therefore the # header is within reach of picotool. binary-info = ["rt"] - -[[example]] -name = "binary_info_demo" -required-features = ["binary-info", "critical-section-impl"] - -[[example]] -# irq example uses cortex-m-rt::interrupt, need rt feature for that -name = "gpio_irq_example" -required-features = ["rt", "critical-section-impl"] - -[[example]] -# irq example uses cortex-m-rt::interrupt, need rt feature for that -name = "rtc_irq_example" -required-features = ["rt", "critical-section-impl"] - -[[example]] -# irq example uses cortex-m-rt::interrupt, need rt feature for that -name = "rtc_sleep_example" -required-features = ["rt", "critical-section-impl"] - -[[example]] -# pwm irq input example uses cortex-m-rt::interrupt, need rt feature for that -name = "pwm_irq_input" -required-features = ["rt", "critical-section-impl"] - -[[example]] -# vector_table example uses cortex-m-rt::interrupt, need rt feature for that -name = "vector_table" -required-features = ["rt", "critical-section-impl"] - -[[example]] -# adc_fifo_irq example uses cortex-m-rt::interrupt, need rt feature for that -name = "adc_fifo_irq" -required-features = ["rt", "critical-section-impl"] - -[[example]] -# adc_fifo_dma example uses cortex-m-rt::interrupt, need rt feature for that -name = "adc_fifo_dma" -required-features = ["rt", "critical-section-impl"] - -[[example]] -name = "adc" -required-features = ["critical-section-impl"] - -[[example]] -name = "adc_fifo_poll" -required-features = ["critical-section-impl"] - -[[example]] -name = "alloc" -required-features = ["critical-section-impl"] - -[[example]] -name = "blinky" -required-features = ["critical-section-impl"] - -[[example]] -name = "dht11" -required-features = ["critical-section-impl"] - -[[example]] -# dormant_sleep example uses cortex-m-rt::interrupt, need rt feature for that -name = "dormant_sleep" -required-features = ["rt", "critical-section-impl"] - -[[example]] -name = "gpio_in_out" -required-features = ["critical-section-impl"] - -[[example]] -name = "i2c" -required-features = ["critical-section-impl"] - -[[example]] -name = "i2c_async" -required-features = ["critical-section-impl", "rt"] - -[[example]] -name = "i2c_async_cancelled" -required-features = ["critical-section-impl", "rt", "defmt"] - -[[example]] -name = "lcd_display" -required-features = ["critical-section-impl"] - -[[example]] -name = "mem_to_mem_dma" -required-features = ["critical-section-impl"] - -[[example]] -name = "multicore_fifo_blink" -required-features = ["critical-section-impl"] - -[[example]] -name = "multicore_polyblink" -required-features = ["critical-section-impl"] - -[[example]] -name = "pio_blink" -required-features = ["critical-section-impl"] - -[[example]] -name = "pio_dma" -required-features = ["critical-section-impl"] - -[[example]] -name = "pio_proc_blink" -required-features = ["critical-section-impl"] - -[[example]] -name = "pio_side_set" -required-features = ["critical-section-impl"] - -[[example]] -name = "pio_synchronized" -required-features = ["critical-section-impl"] - -[[example]] -name = "pwm_blink" -required-features = ["critical-section-impl"] - -[[example]] -name = "pwm_blink_embedded_hal_1" -required-features = ["critical-section-impl"] - -[[example]] -name = "rom_funcs" -required-features = ["critical-section-impl"] - -[[example]] -name = "rosc_as_system_clock" -required-features = ["critical-section-impl"] - -[[example]] -name = "spi" -required-features = ["critical-section-impl"] - -[[example]] -name = "spi_dma" -required-features = ["critical-section-impl"] - -[[example]] -name = "uart" -required-features = ["critical-section-impl"] - -[[example]] -name = "uart_dma" -required-features = ["critical-section-impl"] - -[[example]] -name = "watchdog" -required-features = ["critical-section-impl"] - -[[example]] -name = "gpio_dyn_pin_array" -required-features = ["critical-section-impl"]