diff --git a/Cargo.toml b/Cargo.toml index 17a6540..ecca95a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ members = [ "src/periph/adc", "src/periph/dma", "src/periph/exti", + "src/periph/flash", "src/periph/gpio", "src/periph/i2c", "src/periph/rtc", @@ -64,6 +65,7 @@ std = ["drone-core/std", "drone-cortexm/std"] adc = ["drone-stm32-map-periph-adc"] dma = ["drone-stm32-map-periph-dma"] exti = ["drone-stm32-map-periph-exti"] +flash = ["drone-stm32-map-periph-flash"] gpio = ["drone-stm32-map-periph-gpio"] i2c = ["drone-stm32-map-periph-i2c"] rtc = ["drone-stm32-map-periph-rtc"] @@ -98,6 +100,11 @@ version = "=0.14.0" path = "src/periph/exti" optional = true +[dependencies.drone-stm32-map-periph-flash] +version = "=0.14.0" +path = "src/periph/flash" +optional = true + [dependencies.drone-stm32-map-periph-gpio] version = "=0.14.0" path = "src/periph/gpio" diff --git a/Justfile b/Justfile index 1c6a398..46a0c4f 100644 --- a/Justfile +++ b/Justfile @@ -1,4 +1,4 @@ -features := 'adc dma exti gpio i2c rtc spi tim uart' +features := 'adc dma exti flash gpio i2c rtc spi tim uart' target := `drone print target 2>/dev/null || echo ""` # Install dependencies @@ -109,6 +109,7 @@ publish: cd src/periph/adc && cargo publish cd src/periph/dma && cargo publish cd src/periph/exti && cargo publish + cd src/periph/flash && cargo publish cd src/periph/gpio && cargo publish cd src/periph/i2c && cargo publish cd src/periph/rtc && cargo publish diff --git a/README.md b/README.md index de961db..1ed84e5 100644 --- a/README.md +++ b/README.md @@ -18,40 +18,55 @@ drop-in replacement for it. ## Supported Devices -| `stm32_mcu` | Core name | Reference manual | Available features | -|-------------|-----------------------|--------------------------------------------------------------------------|----------------------------------------------------------| -| `stm32f100` | ARM® Cortex®-M3 r1p1 | [RM0041](https://www.st.com/resource/en/reference_manual/cd00246267.pdf) | `dma` `gpio` `spi` `tim` | -| `stm32f101` | ARM® Cortex®-M3 r1p1 | [RM0008](https://www.st.com/resource/en/reference_manual/cd00171190.pdf) | `dma` `gpio` `spi` `tim` | -| `stm32f102` | ARM® Cortex®-M3 r1p1 | [RM0008](https://www.st.com/resource/en/reference_manual/cd00171190.pdf) | `dma` `gpio` `spi` `tim` | -| `stm32f103` | ARM® Cortex®-M3 r1p1 | [RM0008](https://www.st.com/resource/en/reference_manual/cd00171190.pdf) | `dma` `gpio` `spi` `tim` | -| `stm32f107` | ARM® Cortex®-M3 r1p1 | [RM0008](https://www.st.com/resource/en/reference_manual/cd00171190.pdf) | `dma` `gpio` `spi` `tim` | -| `stm32f303` | ARM® Cortex®-M4F r0p1 | [RM0316](https://www.st.com/resource/en/reference_manual/dm00043574.pdf) | `adc` `dma` `exti` `gpio` `i2c` `tim` | -| `stm32f401` | ARM® Cortex®-M4F r0p1 | [RM0368](https://www.st.com/resource/en/reference_manual/dm00096844.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f405` | ARM® Cortex®-M4F r0p1 | [RM0090](https://www.st.com/resource/en/reference_manual/dm00031020.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f407` | ARM® Cortex®-M4F r0p1 | [RM0090](https://www.st.com/resource/en/reference_manual/dm00031020.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f410` | ARM® Cortex®-M4F r0p1 | [RM0401](https://www.st.com/resource/en/reference_manual/dm00180366.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f411` | ARM® Cortex®-M4F r0p1 | [RM0383](https://www.st.com/resource/en/reference_manual/dm00119316.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f412` | ARM® Cortex®-M4F r0p1 | [RM0402](https://www.st.com/resource/en/reference_manual/dm00180369.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f413` | ARM® Cortex®-M4F r0p1 | [RM0430](https://www.st.com/resource/en/reference_manual/dm00305666.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f427` | ARM® Cortex®-M4F r0p1 | [RM0090](https://www.st.com/resource/en/reference_manual/dm00031020.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f429` | ARM® Cortex®-M4F r0p1 | [RM0090](https://www.st.com/resource/en/reference_manual/dm00031020.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f446` | ARM® Cortex®-M4F r0p1 | [RM0390](https://www.st.com/resource/en/reference_manual/dm00135183.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32f469` | ARM® Cortex®-M4F r0p1 | [RM0386](https://www.st.com/resource/en/reference_manual/dm00127514.pdf) | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | -| `stm32l4x1` | ARM® Cortex®-M4F r0p1 | [RM0394](https://www.st.com/resource/en/reference_manual/dm00151940.pdf) | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4x2` | ARM® Cortex®-M4F r0p1 | [RM0394](https://www.st.com/resource/en/reference_manual/dm00151940.pdf) | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4x3` | ARM® Cortex®-M4F r0p1 | [RM0394](https://www.st.com/resource/en/reference_manual/dm00151940.pdf) | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4x5` | ARM® Cortex®-M4F r0p1 | [RM0351](https://www.st.com/resource/en/reference_manual/dm00083560.pdf) | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4x6` | ARM® Cortex®-M4F r0p1 | [RM0351](https://www.st.com/resource/en/reference_manual/dm00083560.pdf) | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4r5` | ARM® Cortex®-M4F r0p1 | [RM0432](https://www.st.com/resource/en/reference_manual/dm00310109.pdf) | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4s5` | ARM® Cortex®-M4F r0p1 | [RM0432](https://www.st.com/resource/en/reference_manual/dm00310109.pdf) | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4r7` | ARM® Cortex®-M4F r0p1 | [RM0432](https://www.st.com/resource/en/reference_manual/dm00310109.pdf) | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4s7` | ARM® Cortex®-M4F r0p1 | [RM0432](https://www.st.com/resource/en/reference_manual/dm00310109.pdf) | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4r9` | ARM® Cortex®-M4F r0p1 | [RM0432](https://www.st.com/resource/en/reference_manual/dm00310109.pdf) | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | -| `stm32l4s9` | ARM® Cortex®-M4F r0p1 | [RM0432](https://www.st.com/resource/en/reference_manual/dm00310109.pdf) | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32_mcu` | Core name | Reference manual | Available features | +|-------------|-----------------------|------------------|------------------------------------------------------------| +| `stm32f100` | ARM® Cortex®-M3 r1p1 | [RM0041][RM0041] | `dma` `gpio` `spi` `tim` | +| `stm32f101` | ARM® Cortex®-M3 r1p1 | [RM0008][RM0008] | `dma` `gpio` `spi` `tim` | +| `stm32f102` | ARM® Cortex®-M3 r1p1 | [RM0008][RM0008] | `dma` `gpio` `spi` `tim` | +| `stm32f103` | ARM® Cortex®-M3 r1p1 | [RM0008][RM0008] | `dma` `gpio` `spi` `tim` | +| `stm32f107` | ARM® Cortex®-M3 r1p1 | [RM0008][RM0008] | `dma` `gpio` `spi` `tim` | +| `stm32f303` | ARM® Cortex®-M4F r0p1 | [RM0316][RM0316] | `adc` `dma` `exti` `gpio` `i2c` `tim` | +| `stm32f401` | ARM® Cortex®-M4F r0p1 | [RM0368][RM0368] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f405` | ARM® Cortex®-M4F r0p1 | [RM0090][RM0090] | `adc` `dma` `exti` `flash` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f407` | ARM® Cortex®-M4F r0p1 | [RM0090][RM0090] | `adc` `dma` `exti` `flash` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f410` | ARM® Cortex®-M4F r0p1 | [RM0401][RM0401] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f411` | ARM® Cortex®-M4F r0p1 | [RM0383][RM0383] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f412` | ARM® Cortex®-M4F r0p1 | [RM0402][RM0402] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f413` | ARM® Cortex®-M4F r0p1 | [RM0430][RM0430] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f427` | ARM® Cortex®-M4F r0p1 | [RM0090][RM0090] | `adc` `dma` `exti` `flash` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f429` | ARM® Cortex®-M4F r0p1 | [RM0090][RM0090] | `adc` `dma` `exti` `flash` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f446` | ARM® Cortex®-M4F r0p1 | [RM0390][RM0390] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32f469` | ARM® Cortex®-M4F r0p1 | [RM0386][RM0386] | `adc` `dma` `exti` `gpio` `i2c` `spi` `tim` `uart` | +| `stm32l4x1` | ARM® Cortex®-M4F r0p1 | [RM0394][RM0394] | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4x2` | ARM® Cortex®-M4F r0p1 | [RM0394][RM0394] | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4x3` | ARM® Cortex®-M4F r0p1 | [RM0394][RM0394] | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4x5` | ARM® Cortex®-M4F r0p1 | [RM0351][RM0351] | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4x6` | ARM® Cortex®-M4F r0p1 | [RM0351][RM0351] | `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4r5` | ARM® Cortex®-M4F r0p1 | [RM0432][RM0432] | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4s5` | ARM® Cortex®-M4F r0p1 | [RM0432][RM0432] | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4r7` | ARM® Cortex®-M4F r0p1 | [RM0432][RM0432] | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4s7` | ARM® Cortex®-M4F r0p1 | [RM0432][RM0432] | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4r9` | ARM® Cortex®-M4F r0p1 | [RM0432][RM0432] | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | +| `stm32l4s9` | ARM® Cortex®-M4F r0p1 | [RM0432][RM0432] | `adc` `dma` `exti` `gpio` `i2c` `rtc` `spi` `tim` `uart` | `stm32_mcu` config flag should be set at the application level according to this table. +[RM0008]: https://www.st.com/resource/en/reference_manual/cd00171190.pdf +[RM0041]: https://www.st.com/resource/en/reference_manual/cd00246267.pdf +[RM0090]: https://www.st.com/resource/en/reference_manual/dm00031020.pdf +[RM0316]: https://www.st.com/resource/en/reference_manual/dm00043574.pdf +[RM0351]: https://www.st.com/resource/en/reference_manual/dm00083560.pdf +[RM0368]: https://www.st.com/resource/en/reference_manual/dm00096844.pdf +[RM0383]: https://www.st.com/resource/en/reference_manual/dm00119316.pdf +[RM0386]: https://www.st.com/resource/en/reference_manual/dm00127514.pdf +[RM0390]: https://www.st.com/resource/en/reference_manual/dm00135183.pdf +[RM0394]: https://www.st.com/resource/en/reference_manual/dm00151940.pdf +[RM0401]: https://www.st.com/resource/en/reference_manual/dm00180366.pdf +[RM0402]: https://www.st.com/resource/en/reference_manual/dm00180369.pdf +[RM0430]: https://www.st.com/resource/en/reference_manual/dm00305666.pdf +[RM0432]: https://www.st.com/resource/en/reference_manual/dm00310109.pdf + ## Documentation - [Drone Book](https://book.drone-os.com/) diff --git a/src/periph/flash/Cargo.toml b/src/periph/flash/Cargo.toml new file mode 100644 index 0000000..2ef43d8 --- /dev/null +++ b/src/periph/flash/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "drone-stm32-map-periph-flash" +version = "0.14.0" +authors = ["Valentine Valyaeff "] +edition = "2018" +resolver = "2" +repository = "https://github.com/drone-os/drone-stm32-map" +homepage = "https://www.drone-os.com/" +documentation = "https://api.drone-os.com/drone-stm32-map/0.14/drone_stm32_map_periph_flash/" +license = "MIT OR Apache-2.0" +description = """ +STM32 peripheral mappings for Drone, an Embedded Operating System. +""" + +[lib] +path = "lib.rs" + +[dependencies.drone-core] +version = "0.14.0" +path = "../../../../drone-core" + +[dependencies.drone-cortexm] +version = "0.14.0" +path = "../../../../drone-cortexm" + +[dependencies.drone-stm32-map-pieces] +version = "=0.14.0" +path = "../../pieces" diff --git a/src/periph/flash/f4.rs b/src/periph/flash/f4.rs new file mode 100644 index 0000000..9f8ebd0 --- /dev/null +++ b/src/periph/flash/f4.rs @@ -0,0 +1,32 @@ +//! Mapping for Flash. +//! +//! For STM32F4 series of high-performance MCUs with DSP and FPU instructions. + +use drone_core::periph; + +periph::singular! { + /// Extracts Flash register tokens. + pub macro periph_flash; + + /// FLASH peripheral. + pub struct FlashPeriph; + + drone_stm32_map_pieces::reg; + crate; + + FLASH { + ACR; + KEYR; + OPTKEYR; + SR; + CR; + OPTCR; + #[cfg(any( + stm32_mcu = "stm32f427", + stm32_mcu = "stm32f429", + stm32_mcu = "stm32f437", + stm32_mcu = "stm32f439", + ))] + OPTCR1; + } +} diff --git a/src/periph/flash/lib.rs b/src/periph/flash/lib.rs new file mode 100644 index 0000000..d0f74b6 --- /dev/null +++ b/src/periph/flash/lib.rs @@ -0,0 +1,31 @@ +//! Flash. + +#![feature(proc_macro_hygiene)] +#![warn(missing_docs)] +#![warn(clippy::pedantic)] +#![allow(clippy::type_repetition_in_bounds, clippy::wildcard_imports)] +#![no_std] + +#[cfg(any( + stm32_mcu = "stm32f405", + stm32_mcu = "stm32f407", + stm32_mcu = "stm32f415", + stm32_mcu = "stm32f417", + stm32_mcu = "stm32f427", + stm32_mcu = "stm32f429", + stm32_mcu = "stm32f437", + stm32_mcu = "stm32f439", +))] +mod f4; + +#[cfg(any( + stm32_mcu = "stm32f405", + stm32_mcu = "stm32f407", + stm32_mcu = "stm32f415", + stm32_mcu = "stm32f417", + stm32_mcu = "stm32f427", + stm32_mcu = "stm32f429", + stm32_mcu = "stm32f437", + stm32_mcu = "stm32f439", +))] +pub use self::f4::*; diff --git a/src/periph/mod.rs b/src/periph/mod.rs index 0865b0e..b66ace5 100644 --- a/src/periph/mod.rs +++ b/src/periph/mod.rs @@ -9,6 +9,8 @@ pub extern crate drone_stm32_map_periph_adc as adc; pub extern crate drone_stm32_map_periph_dma as dma; #[cfg(feature = "exti")] pub extern crate drone_stm32_map_periph_exti as exti; +#[cfg(feature = "flash")] +pub extern crate drone_stm32_map_periph_flash as flash; #[cfg(feature = "gpio")] pub extern crate drone_stm32_map_periph_gpio as gpio; #[cfg(feature = "i2c")] diff --git a/tests/periph_macros.rs b/tests/periph_macros.rs index dcc8e75..39eac81 100644 --- a/tests/periph_macros.rs +++ b/tests/periph_macros.rs @@ -404,6 +404,22 @@ fn periph_macros1() { { let exti40 = drone_stm32_map::periph::exti::periph_exti40!(reg); } + #[cfg(all( + feature = "flash", + any( + stm32_mcu = "stm32f405", + stm32_mcu = "stm32f407", + stm32_mcu = "stm32f415", + stm32_mcu = "stm32f417", + stm32_mcu = "stm32f427", + stm32_mcu = "stm32f429", + stm32_mcu = "stm32f437", + stm32_mcu = "stm32f439", + ) + ))] + { + let flash = drone_stm32_map::periph::flash::periph_flash!(reg); + } #[cfg(all( feature = "gpio", any(