diff options
| -rw-r--r-- | embassy-nrf/Cargo.toml | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf5340_app.rs | 3 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf5340_net.rs | 1 | ||||
| -rw-r--r-- | embassy-nrf/src/chips/nrf9160.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/Cargo.toml | 23 | ||||
| -rw-r--r-- | embassy-stm32/build.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/can/bxcan.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/bdma.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/dma.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/dmamux.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/interrupt.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/g0.rs | 87 | ||||
| -rw-r--r-- | embassy/Cargo.toml | 14 | ||||
| m--------- | stm32-data | 0 | ||||
| -rw-r--r-- | stm32-metapac/Cargo.toml | 21 | ||||
| -rw-r--r-- | stm32-metapac/src/lib.rs | 1 |
18 files changed, 135 insertions, 56 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index aa377580f..d8bac3227 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -4,6 +4,14 @@ version = "0.1.0" | |||
| 4 | authors = ["Dario Nieuwenhuis <[email protected]>"] | 4 | authors = ["Dario Nieuwenhuis <[email protected]>"] |
| 5 | edition = "2018" | 5 | edition = "2018" |
| 6 | 6 | ||
| 7 | [package.metadata.embassy_docs] | ||
| 8 | features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "gpiote", "time-driver-rtc1"] | ||
| 9 | flavors = [ | ||
| 10 | { regex_feature = "nrf52.*", target = "thumbv7em-none-eabihf" }, | ||
| 11 | { regex_feature = "nrf53.*", target = "thumbv8m.main-none-eabihf" }, | ||
| 12 | { regex_feature = "nrf91.*", target = "thumbv8m.main-none-eabihf" }, | ||
| 13 | ] | ||
| 14 | |||
| 7 | [features] | 15 | [features] |
| 8 | 16 | ||
| 9 | # Enable nightly-only features | 17 | # Enable nightly-only features |
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 4fcb742e8..ae6887b3c 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs | |||
| @@ -4,6 +4,7 @@ pub mod pac { | |||
| 4 | // The nRF5340 has a secure and non-secure (NS) mode. | 4 | // The nRF5340 has a secure and non-secure (NS) mode. |
| 5 | // To avoid cfg spam, we remove _ns or _s suffixes here. | 5 | // To avoid cfg spam, we remove _ns or _s suffixes here. |
| 6 | 6 | ||
| 7 | #[doc(no_inline)] | ||
| 7 | pub use nrf5340_app_pac::{ | 8 | pub use nrf5340_app_pac::{ |
| 8 | interrupt, | 9 | interrupt, |
| 9 | Interrupt, | 10 | Interrupt, |
| @@ -57,6 +58,7 @@ pub mod pac { | |||
| 57 | }; | 58 | }; |
| 58 | 59 | ||
| 59 | #[cfg(feature = "nrf5340-app-ns")] | 60 | #[cfg(feature = "nrf5340-app-ns")] |
| 61 | #[doc(no_inline)] | ||
| 60 | pub use nrf5340_app_pac::{ | 62 | pub use nrf5340_app_pac::{ |
| 61 | CLOCK_NS as CLOCK, | 63 | CLOCK_NS as CLOCK, |
| 62 | COMP_NS as COMP, | 64 | COMP_NS as COMP, |
| @@ -127,6 +129,7 @@ pub mod pac { | |||
| 127 | }; | 129 | }; |
| 128 | 130 | ||
| 129 | #[cfg(feature = "nrf5340-app-s")] | 131 | #[cfg(feature = "nrf5340-app-s")] |
| 132 | #[doc(no_inline)] | ||
| 130 | pub use nrf5340_app_pac::{ | 133 | pub use nrf5340_app_pac::{ |
| 131 | CACHEDATA_S as CACHEDATA, | 134 | CACHEDATA_S as CACHEDATA, |
| 132 | CACHEINFO_S as CACHEINFO, | 135 | CACHEINFO_S as CACHEINFO, |
diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index ea09f8d78..e2ae97a9d 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs | |||
| @@ -4,6 +4,7 @@ pub mod pac { | |||
| 4 | // The nRF5340 has a secure and non-secure (NS) mode. | 4 | // The nRF5340 has a secure and non-secure (NS) mode. |
| 5 | // To avoid cfg spam, we remove _ns or _s suffixes here. | 5 | // To avoid cfg spam, we remove _ns or _s suffixes here. |
| 6 | 6 | ||
| 7 | #[doc(no_inline)] | ||
| 7 | pub use nrf5340_net_pac::{ | 8 | pub use nrf5340_net_pac::{ |
| 8 | interrupt, | 9 | interrupt, |
| 9 | Interrupt, | 10 | Interrupt, |
diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 51f6cb804..b8caa1264 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs | |||
| @@ -4,6 +4,7 @@ pub mod pac { | |||
| 4 | // The nRF9160 has a secure and non-secure (NS) mode. | 4 | // The nRF9160 has a secure and non-secure (NS) mode. |
| 5 | // To avoid cfg spam, we remove _ns or _s suffixes here. | 5 | // To avoid cfg spam, we remove _ns or _s suffixes here. |
| 6 | 6 | ||
| 7 | #[doc(no_inline)] | ||
| 7 | pub use nrf9160_pac::{ | 8 | pub use nrf9160_pac::{ |
| 8 | interrupt, | 9 | interrupt, |
| 9 | Interrupt, | 10 | Interrupt, |
| @@ -42,6 +43,7 @@ pub mod pac { | |||
| 42 | }; | 43 | }; |
| 43 | 44 | ||
| 44 | #[cfg(feature = "nrf9160-ns")] | 45 | #[cfg(feature = "nrf9160-ns")] |
| 46 | #[doc(no_inline)] | ||
| 45 | pub use nrf9160_pac::{ | 47 | pub use nrf9160_pac::{ |
| 46 | CLOCK_NS as CLOCK, | 48 | CLOCK_NS as CLOCK, |
| 47 | DPPIC_NS as DPPIC, | 49 | DPPIC_NS as DPPIC, |
| @@ -96,6 +98,7 @@ pub mod pac { | |||
| 96 | }; | 98 | }; |
| 97 | 99 | ||
| 98 | #[cfg(feature = "nrf9160-s")] | 100 | #[cfg(feature = "nrf9160-s")] |
| 101 | #[doc(no_inline)] | ||
| 99 | pub use nrf9160_pac::{ | 102 | pub use nrf9160_pac::{ |
| 100 | CC_HOST_RGF_S as CC_HOST_RGF, | 103 | CC_HOST_RGF_S as CC_HOST_RGF, |
| 101 | CLOCK_S as CLOCK, | 104 | CLOCK_S as CLOCK, |
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index e45dfbacd..116bba2ac 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -5,6 +5,29 @@ authors = ["Dario Nieuwenhuis <[email protected]>"] | |||
| 5 | edition = "2018" | 5 | edition = "2018" |
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [package.metadata.embassy_docs] | ||
| 9 | # TODO: sdmmc | ||
| 10 | # TODO: net | ||
| 11 | # TODO: subghz | ||
| 12 | features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any"] | ||
| 13 | flavors = [ | ||
| 14 | { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, | ||
| 15 | { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, | ||
| 16 | { regex_feature = "stm32f2.*", target = "thumbv7m-none-eabi" }, | ||
| 17 | { regex_feature = "stm32f3.*", target = "thumbv7em-none-eabi" }, | ||
| 18 | { regex_feature = "stm32f42.*", target = "thumbv7em-none-eabi" }, | ||
| 19 | { regex_feature = "stm32f7.*", target = "thumbv7em-none-eabi" }, | ||
| 20 | { regex_feature = "stm32g0.*", target = "thumbv6m-none-eabi" }, | ||
| 21 | { regex_feature = "stm32g4.*", target = "thumbv7em-none-eabi" }, | ||
| 22 | { regex_feature = "stm32h7.*", target = "thumbv7em-none-eabi" }, | ||
| 23 | { regex_feature = "stm32l0.*", target = "thumbv6m-none-eabi" }, | ||
| 24 | { regex_feature = "stm32l1.*", target = "thumbv7m-none-eabi" }, | ||
| 25 | { regex_feature = "stm32l4.*", target = "thumbv7em-none-eabi" }, | ||
| 26 | { regex_feature = "stm32u5.*", target = "thumbv8m.main-none-eabihf" }, | ||
| 27 | { regex_feature = "stm32wb.*", target = "thumbv7em-none-eabi" }, | ||
| 28 | { regex_feature = "stm32wl.*", target = "thumbv7em-none-eabi" }, | ||
| 29 | ] | ||
| 30 | |||
| 8 | [dependencies] | 31 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../embassy" } | 32 | embassy = { version = "0.1.0", path = "../embassy" } |
| 10 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } | 33 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } |
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 737b62476..02d47da81 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -646,13 +646,13 @@ fn main() { | |||
| 646 | make_table(&mut m, "foreach_dma_channel", &dma_channels_table); | 646 | make_table(&mut m, "foreach_dma_channel", &dma_channels_table); |
| 647 | 647 | ||
| 648 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | 648 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); |
| 649 | let out_file = out_dir.join("macros.rs").to_string_lossy().to_string(); | 649 | let out_file = out_dir.join("_macros.rs").to_string_lossy().to_string(); |
| 650 | fs::write(out_file, m).unwrap(); | 650 | fs::write(out_file, m).unwrap(); |
| 651 | 651 | ||
| 652 | // ======== | 652 | // ======== |
| 653 | // Write generated.rs | 653 | // Write generated.rs |
| 654 | 654 | ||
| 655 | let out_file = out_dir.join("generated.rs").to_string_lossy().to_string(); | 655 | let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string(); |
| 656 | fs::write(out_file, g.to_string()).unwrap(); | 656 | fs::write(out_file, g.to_string()).unwrap(); |
| 657 | 657 | ||
| 658 | // ======== | 658 | // ======== |
| @@ -773,7 +773,7 @@ impl<T: Iterator> IteratorExt for T { | |||
| 773 | fn make_table(out: &mut String, name: &str, data: &Vec<Vec<String>>) { | 773 | fn make_table(out: &mut String, name: &str, data: &Vec<Vec<String>>) { |
| 774 | write!( | 774 | write!( |
| 775 | out, | 775 | out, |
| 776 | "#[macro_export] | 776 | "#[allow(unused)] |
| 777 | macro_rules! {} {{ | 777 | macro_rules! {} {{ |
| 778 | ($($pat:tt => $code:tt;)*) => {{ | 778 | ($($pat:tt => $code:tt;)*) => {{ |
| 779 | macro_rules! __{}_inner {{ | 779 | macro_rules! __{}_inner {{ |
diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs index c52d737bc..34182206f 100644 --- a/embassy-stm32/src/can/bxcan.rs +++ b/embassy-stm32/src/can/bxcan.rs | |||
| @@ -7,6 +7,7 @@ use embassy_hal_common::unborrow; | |||
| 7 | use crate::gpio::sealed::AFType; | 7 | use crate::gpio::sealed::AFType; |
| 8 | use crate::{peripherals, rcc::RccPeripheral}; | 8 | use crate::{peripherals, rcc::RccPeripheral}; |
| 9 | 9 | ||
| 10 | #[doc(no_inline)] | ||
| 10 | pub use bxcan::*; | 11 | pub use bxcan::*; |
| 11 | 12 | ||
| 12 | pub struct Can<'d, T: Instance + bxcan::Instance> { | 13 | pub struct Can<'d, T: Instance + bxcan::Instance> { |
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 4fafe7dfa..105bea50e 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs | |||
| @@ -6,8 +6,8 @@ use core::task::Waker; | |||
| 6 | use embassy::interrupt::{Interrupt, InterruptExt}; | 6 | use embassy::interrupt::{Interrupt, InterruptExt}; |
| 7 | use embassy::waitqueue::AtomicWaker; | 7 | use embassy::waitqueue::AtomicWaker; |
| 8 | 8 | ||
| 9 | use crate::_generated::BDMA_CHANNEL_COUNT; | ||
| 9 | use crate::dma::Request; | 10 | use crate::dma::Request; |
| 10 | use crate::generated::BDMA_CHANNEL_COUNT; | ||
| 11 | use crate::pac; | 11 | use crate::pac; |
| 12 | use crate::pac::bdma::vals; | 12 | use crate::pac::bdma::vals; |
| 13 | 13 | ||
| @@ -65,7 +65,7 @@ pub(crate) unsafe fn init() { | |||
| 65 | crate::interrupt::$irq::steal().enable(); | 65 | crate::interrupt::$irq::steal().enable(); |
| 66 | }; | 66 | }; |
| 67 | } | 67 | } |
| 68 | crate::generated::init_bdma(); | 68 | crate::_generated::init_bdma(); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | foreach_dma_channel! { | 71 | foreach_dma_channel! { |
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index fd1732fbb..95a6eea2f 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs | |||
| @@ -4,7 +4,7 @@ use core::task::Waker; | |||
| 4 | use embassy::interrupt::{Interrupt, InterruptExt}; | 4 | use embassy::interrupt::{Interrupt, InterruptExt}; |
| 5 | use embassy::waitqueue::AtomicWaker; | 5 | use embassy::waitqueue::AtomicWaker; |
| 6 | 6 | ||
| 7 | use crate::generated::DMA_CHANNEL_COUNT; | 7 | use crate::_generated::DMA_CHANNEL_COUNT; |
| 8 | use crate::interrupt; | 8 | use crate::interrupt; |
| 9 | use crate::pac; | 9 | use crate::pac; |
| 10 | use crate::pac::dma::{regs, vals}; | 10 | use crate::pac::dma::{regs, vals}; |
| @@ -59,7 +59,7 @@ pub(crate) unsafe fn init() { | |||
| 59 | interrupt::$irq::steal().enable(); | 59 | interrupt::$irq::steal().enable(); |
| 60 | }; | 60 | }; |
| 61 | } | 61 | } |
| 62 | crate::generated::init_dma(); | 62 | crate::_generated::init_dma(); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | foreach_dma_channel! { | 65 | foreach_dma_channel! { |
diff --git a/embassy-stm32/src/dma/dmamux.rs b/embassy-stm32/src/dma/dmamux.rs index 628f496be..c45bebe26 100644 --- a/embassy-stm32/src/dma/dmamux.rs +++ b/embassy-stm32/src/dma/dmamux.rs | |||
| @@ -49,5 +49,5 @@ foreach_dma_channel! { | |||
| 49 | 49 | ||
| 50 | /// safety: must be called only once | 50 | /// safety: must be called only once |
| 51 | pub(crate) unsafe fn init() { | 51 | pub(crate) unsafe fn init() { |
| 52 | crate::generated::init_dmamux(); | 52 | crate::_generated::init_dmamux(); |
| 53 | } | 53 | } |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 4837c4120..3e108736b 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -574,7 +574,7 @@ foreach_pin!( | |||
| 574 | ); | 574 | ); |
| 575 | 575 | ||
| 576 | pub(crate) unsafe fn init() { | 576 | pub(crate) unsafe fn init() { |
| 577 | crate::generated::init_gpio(); | 577 | crate::_generated::init_gpio(); |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | mod eh02 { | 580 | mod eh02 { |
diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index c757b790c..714dcc4ca 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs | |||
| @@ -3,4 +3,4 @@ pub use critical_section::CriticalSection; | |||
| 3 | pub use embassy::interrupt::{take, Interrupt}; | 3 | pub use embassy::interrupt::{take, Interrupt}; |
| 4 | pub use embassy_hal_common::interrupt::Priority4 as Priority; | 4 | pub use embassy_hal_common::interrupt::Priority4 as Priority; |
| 5 | 5 | ||
| 6 | pub use crate::generated::interrupt::*; | 6 | pub use crate::_generated::interrupt::*; |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 5e8d6dd86..45b8e1800 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -11,7 +11,7 @@ pub(crate) use stm32_metapac as pac; | |||
| 11 | 11 | ||
| 12 | // This must go FIRST so that all the other modules see its macros. | 12 | // This must go FIRST so that all the other modules see its macros. |
| 13 | pub mod fmt; | 13 | pub mod fmt; |
| 14 | include!(concat!(env!("OUT_DIR"), "/macros.rs")); | 14 | include!(concat!(env!("OUT_DIR"), "/_macros.rs")); |
| 15 | 15 | ||
| 16 | // Utilities | 16 | // Utilities |
| 17 | pub mod interrupt; | 17 | pub mod interrupt; |
| @@ -63,16 +63,15 @@ pub mod usb_otg; | |||
| 63 | pub mod subghz; | 63 | pub mod subghz; |
| 64 | 64 | ||
| 65 | // This must go last, so that it sees all the impl_foo! macros defined earlier. | 65 | // This must go last, so that it sees all the impl_foo! macros defined earlier. |
| 66 | pub(crate) mod generated { | 66 | pub(crate) mod _generated { |
| 67 | |||
| 68 | #![allow(dead_code)] | 67 | #![allow(dead_code)] |
| 69 | #![allow(unused_imports)] | 68 | #![allow(unused_imports)] |
| 70 | #![allow(non_snake_case)] | 69 | #![allow(non_snake_case)] |
| 71 | 70 | ||
| 72 | include!(concat!(env!("OUT_DIR"), "/generated.rs")); | 71 | include!(concat!(env!("OUT_DIR"), "/_generated.rs")); |
| 73 | } | 72 | } |
| 73 | pub use _generated::{peripherals, Peripherals}; | ||
| 74 | pub use embassy_macros::interrupt; | 74 | pub use embassy_macros::interrupt; |
| 75 | pub use generated::{peripherals, Peripherals}; | ||
| 76 | 75 | ||
| 77 | #[non_exhaustive] | 76 | #[non_exhaustive] |
| 78 | pub struct Config { | 77 | pub struct Config { |
diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs index 71d44fd3c..ad5a661d6 100644 --- a/embassy-stm32/src/rcc/g0.rs +++ b/embassy-stm32/src/rcc/g0.rs | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | use crate::pac::rcc::vals::{Hpre, Hsidiv, Ppre, Sw}; | ||
| 1 | use crate::pac::{PWR, RCC}; | 2 | use crate::pac::{PWR, RCC}; |
| 2 | use crate::rcc::{set_freqs, Clocks}; | 3 | use crate::rcc::{set_freqs, Clocks}; |
| 3 | use crate::time::Hertz; | 4 | use crate::time::Hertz; |
| @@ -29,17 +30,17 @@ pub enum HSI16Prescaler { | |||
| 29 | Div128, | 30 | Div128, |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | impl Into<u8> for HSI16Prescaler { | 33 | impl Into<Hsidiv> for HSI16Prescaler { |
| 33 | fn into(self) -> u8 { | 34 | fn into(self) -> Hsidiv { |
| 34 | match self { | 35 | match self { |
| 35 | HSI16Prescaler::NotDivided => 0x00, | 36 | HSI16Prescaler::NotDivided => Hsidiv::DIV1, |
| 36 | HSI16Prescaler::Div2 => 0x01, | 37 | HSI16Prescaler::Div2 => Hsidiv::DIV2, |
| 37 | HSI16Prescaler::Div4 => 0x02, | 38 | HSI16Prescaler::Div4 => Hsidiv::DIV4, |
| 38 | HSI16Prescaler::Div8 => 0x03, | 39 | HSI16Prescaler::Div8 => Hsidiv::DIV8, |
| 39 | HSI16Prescaler::Div16 => 0x04, | 40 | HSI16Prescaler::Div16 => Hsidiv::DIV16, |
| 40 | HSI16Prescaler::Div32 => 0x05, | 41 | HSI16Prescaler::Div32 => Hsidiv::DIV32, |
| 41 | HSI16Prescaler::Div64 => 0x06, | 42 | HSI16Prescaler::Div64 => Hsidiv::DIV64, |
| 42 | HSI16Prescaler::Div128 => 0x07, | 43 | HSI16Prescaler::Div128 => Hsidiv::DIV128, |
| 43 | } | 44 | } |
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| @@ -68,30 +69,30 @@ pub enum APBPrescaler { | |||
| 68 | Div16, | 69 | Div16, |
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | impl Into<u8> for APBPrescaler { | 72 | impl Into<Ppre> for APBPrescaler { |
| 72 | fn into(self) -> u8 { | 73 | fn into(self) -> Ppre { |
| 73 | match self { | 74 | match self { |
| 74 | APBPrescaler::NotDivided => 1, | 75 | APBPrescaler::NotDivided => Ppre::DIV1, |
| 75 | APBPrescaler::Div2 => 0x04, | 76 | APBPrescaler::Div2 => Ppre::DIV2, |
| 76 | APBPrescaler::Div4 => 0x05, | 77 | APBPrescaler::Div4 => Ppre::DIV4, |
| 77 | APBPrescaler::Div8 => 0x06, | 78 | APBPrescaler::Div8 => Ppre::DIV8, |
| 78 | APBPrescaler::Div16 => 0x07, | 79 | APBPrescaler::Div16 => Ppre::DIV16, |
| 79 | } | 80 | } |
| 80 | } | 81 | } |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | impl Into<u8> for AHBPrescaler { | 84 | impl Into<Hpre> for AHBPrescaler { |
| 84 | fn into(self) -> u8 { | 85 | fn into(self) -> Hpre { |
| 85 | match self { | 86 | match self { |
| 86 | AHBPrescaler::NotDivided => 1, | 87 | AHBPrescaler::NotDivided => Hpre::DIV1, |
| 87 | AHBPrescaler::Div2 => 0x08, | 88 | AHBPrescaler::Div2 => Hpre::DIV2, |
| 88 | AHBPrescaler::Div4 => 0x09, | 89 | AHBPrescaler::Div4 => Hpre::DIV4, |
| 89 | AHBPrescaler::Div8 => 0x0a, | 90 | AHBPrescaler::Div8 => Hpre::DIV8, |
| 90 | AHBPrescaler::Div16 => 0x0b, | 91 | AHBPrescaler::Div16 => Hpre::DIV16, |
| 91 | AHBPrescaler::Div64 => 0x0c, | 92 | AHBPrescaler::Div64 => Hpre::DIV64, |
| 92 | AHBPrescaler::Div128 => 0x0d, | 93 | AHBPrescaler::Div128 => Hpre::DIV128, |
| 93 | AHBPrescaler::Div256 => 0x0e, | 94 | AHBPrescaler::Div256 => Hpre::DIV256, |
| 94 | AHBPrescaler::Div512 => 0x0f, | 95 | AHBPrescaler::Div512 => Hpre::DIV512, |
| 95 | } | 96 | } |
| 96 | } | 97 | } |
| 97 | } | 98 | } |
| @@ -120,27 +121,27 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 120 | let (sys_clk, sw) = match config.mux { | 121 | let (sys_clk, sw) = match config.mux { |
| 121 | ClockSrc::HSI16(div) => { | 122 | ClockSrc::HSI16(div) => { |
| 122 | // Enable HSI16 | 123 | // Enable HSI16 |
| 123 | let div: u8 = div.into(); | 124 | let div: Hsidiv = div.into(); |
| 124 | RCC.cr().write(|w| { | 125 | RCC.cr().write(|w| { |
| 125 | w.set_hsidiv(div); | 126 | w.set_hsidiv(div); |
| 126 | w.set_hsion(true) | 127 | w.set_hsion(true) |
| 127 | }); | 128 | }); |
| 128 | while !RCC.cr().read().hsirdy() {} | 129 | while !RCC.cr().read().hsirdy() {} |
| 129 | 130 | ||
| 130 | (HSI_FREQ >> div, 0x00) | 131 | (HSI_FREQ >> div.0, Sw::HSI) |
| 131 | } | 132 | } |
| 132 | ClockSrc::HSE(freq) => { | 133 | ClockSrc::HSE(freq) => { |
| 133 | // Enable HSE | 134 | // Enable HSE |
| 134 | RCC.cr().write(|w| w.set_hseon(true)); | 135 | RCC.cr().write(|w| w.set_hseon(true)); |
| 135 | while !RCC.cr().read().hserdy() {} | 136 | while !RCC.cr().read().hserdy() {} |
| 136 | 137 | ||
| 137 | (freq.0, 0x01) | 138 | (freq.0, Sw::HSE) |
| 138 | } | 139 | } |
| 139 | ClockSrc::LSI => { | 140 | ClockSrc::LSI => { |
| 140 | // Enable LSI | 141 | // Enable LSI |
| 141 | RCC.csr().write(|w| w.set_lsion(true)); | 142 | RCC.csr().write(|w| w.set_lsion(true)); |
| 142 | while !RCC.csr().read().lsirdy() {} | 143 | while !RCC.csr().read().lsirdy() {} |
| 143 | (LSI_FREQ, 0x03) | 144 | (LSI_FREQ, Sw::LSI) |
| 144 | } | 145 | } |
| 145 | }; | 146 | }; |
| 146 | 147 | ||
| @@ -150,20 +151,24 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 150 | w.set_ppre(config.apb_pre.into()); | 151 | w.set_ppre(config.apb_pre.into()); |
| 151 | }); | 152 | }); |
| 152 | 153 | ||
| 153 | let ahb_freq: u32 = match config.ahb_pre { | 154 | let ahb_div = match config.ahb_pre { |
| 154 | AHBPrescaler::NotDivided => sys_clk, | 155 | AHBPrescaler::NotDivided => 1, |
| 155 | pre => { | 156 | AHBPrescaler::Div2 => 2, |
| 156 | let pre: u8 = pre.into(); | 157 | AHBPrescaler::Div4 => 4, |
| 157 | let pre = 1 << (pre as u32 - 7); | 158 | AHBPrescaler::Div8 => 8, |
| 158 | sys_clk / pre | 159 | AHBPrescaler::Div16 => 16, |
| 159 | } | 160 | AHBPrescaler::Div64 => 64, |
| 161 | AHBPrescaler::Div128 => 128, | ||
| 162 | AHBPrescaler::Div256 => 256, | ||
| 163 | AHBPrescaler::Div512 => 512, | ||
| 160 | }; | 164 | }; |
| 165 | let ahb_freq = sys_clk / ahb_div; | ||
| 161 | 166 | ||
| 162 | let (apb_freq, apb_tim_freq) = match config.apb_pre { | 167 | let (apb_freq, apb_tim_freq) = match config.apb_pre { |
| 163 | APBPrescaler::NotDivided => (ahb_freq, ahb_freq), | 168 | APBPrescaler::NotDivided => (ahb_freq, ahb_freq), |
| 164 | pre => { | 169 | pre => { |
| 165 | let pre: u8 = pre.into(); | 170 | let pre: Ppre = pre.into(); |
| 166 | let pre: u8 = 1 << (pre - 3); | 171 | let pre: u8 = 1 << (pre.0 - 3); |
| 167 | let freq = ahb_freq / pre as u32; | 172 | let freq = ahb_freq / pre as u32; |
| 168 | (freq, freq * 2) | 173 | (freq, freq * 2) |
| 169 | } | 174 | } |
diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml index 9a5467c6f..9b7e72078 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml | |||
| @@ -5,6 +5,20 @@ authors = ["Dario Nieuwenhuis <[email protected]>"] | |||
| 5 | edition = "2018" | 5 | edition = "2018" |
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [package.metadata.embassy_docs] | ||
| 9 | features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] | ||
| 10 | flavors = [ | ||
| 11 | { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, | ||
| 12 | { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] }, | ||
| 13 | { name = "thumbv6m-none-eabi", target = "thumbv6m-none-eabi", features = [] }, | ||
| 14 | { name = "thumbv7m-none-eabi", target = "thumbv7m-none-eabi", features = [] }, | ||
| 15 | { name = "thumbv7em-none-eabi", target = "thumbv7em-none-eabi", features = [] }, | ||
| 16 | { name = "thumbv7em-none-eabihf", target = "thumbv7em-none-eabihf", features = [] }, | ||
| 17 | { name = "thumbv8m.base-none-eabi", target = "thumbv8m.base-none-eabi", features = [] }, | ||
| 18 | { name = "thumbv8m.main-none-eabi", target = "thumbv8m.main-none-eabi", features = [] }, | ||
| 19 | { name = "thumbv8m.main-none-eabihf", target = "thumbv8m.main-none-eabihf", features = [] }, | ||
| 20 | ] | ||
| 21 | |||
| 8 | [features] | 22 | [features] |
| 9 | default = [] | 23 | default = [] |
| 10 | std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] | 24 | std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] |
diff --git a/stm32-data b/stm32-data | |||
| Subproject 5fcc7795c880c7b19bb7b6226cd6d7db0b5cd95 | Subproject ad77937fb81628b982d2a674a88d983ec020fec | ||
diff --git a/stm32-metapac/Cargo.toml b/stm32-metapac/Cargo.toml index c994797b7..98249ec6a 100644 --- a/stm32-metapac/Cargo.toml +++ b/stm32-metapac/Cargo.toml | |||
| @@ -19,6 +19,27 @@ features = ["stm32h755zi-cm7", "pac", "metadata"] | |||
| 19 | default-target = "thumbv7em-none-eabihf" | 19 | default-target = "thumbv7em-none-eabihf" |
| 20 | targets = [] | 20 | targets = [] |
| 21 | 21 | ||
| 22 | [package.metadata.embassy_docs] | ||
| 23 | features = ["pac", "metadata"] | ||
| 24 | flavors = [ | ||
| 25 | { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, | ||
| 26 | { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, | ||
| 27 | { regex_feature = "stm32f2.*", target = "thumbv7m-none-eabi" }, | ||
| 28 | { regex_feature = "stm32f3.*", target = "thumbv7em-none-eabi" }, | ||
| 29 | { regex_feature = "stm32f4.*", target = "thumbv7em-none-eabi" }, | ||
| 30 | { regex_feature = "stm32f7.*", target = "thumbv7em-none-eabi" }, | ||
| 31 | { regex_feature = "stm32g0.*", target = "thumbv6m-none-eabi" }, | ||
| 32 | { regex_feature = "stm32g4.*", target = "thumbv7em-none-eabi" }, | ||
| 33 | { regex_feature = "stm32h7.*", target = "thumbv7em-none-eabi" }, | ||
| 34 | { regex_feature = "stm32l0.*", target = "thumbv6m-none-eabi" }, | ||
| 35 | { regex_feature = "stm32l1.*", target = "thumbv7m-none-eabi" }, | ||
| 36 | { regex_feature = "stm32l4.*", target = "thumbv7em-none-eabi" }, | ||
| 37 | { regex_feature = "stm32l5.*", target = "thumbv8m.main-none-eabihf" }, | ||
| 38 | { regex_feature = "stm32u5.*", target = "thumbv8m.main-none-eabihf" }, | ||
| 39 | { regex_feature = "stm32wb.*", target = "thumbv7em-none-eabi" }, | ||
| 40 | { regex_feature = "stm32wl.*", target = "thumbv7em-none-eabi" }, | ||
| 41 | ] | ||
| 42 | |||
| 22 | [dependencies] | 43 | [dependencies] |
| 23 | cortex-m = "0.7.3" | 44 | cortex-m = "0.7.3" |
| 24 | cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true } | 45 | cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true } |
diff --git a/stm32-metapac/src/lib.rs b/stm32-metapac/src/lib.rs index 9cdc5e0b4..4eab29861 100644 --- a/stm32-metapac/src/lib.rs +++ b/stm32-metapac/src/lib.rs | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #![allow(non_snake_case)] | 2 | #![allow(non_snake_case)] |
| 3 | #![allow(unused)] | 3 | #![allow(unused)] |
| 4 | #![allow(non_camel_case_types)] | 4 | #![allow(non_camel_case_types)] |
| 5 | #![doc(html_no_source)] | ||
| 5 | 6 | ||
| 6 | pub mod common; | 7 | pub mod common; |
| 7 | 8 | ||
