Skip to content

Add Flash mapping for STM32F405 targets. #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
75 changes: 45 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
28 changes: 28 additions & 0 deletions src/periph/flash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "drone-stm32-map-periph-flash"
version = "0.14.0"
authors = ["Valentine Valyaeff <[email protected]>"]
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"
32 changes: 32 additions & 0 deletions src/periph/flash/f4.rs
Original file line number Diff line number Diff line change
@@ -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;
}
}
31 changes: 31 additions & 0 deletions src/periph/flash/lib.rs
Original file line number Diff line number Diff line change
@@ -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::*;
2 changes: 2 additions & 0 deletions src/periph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
16 changes: 16 additions & 0 deletions tests/periph_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down