diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index aa377580..d8bac322 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -4,6 +4,14 @@ version = "0.1.0" authors = ["Dario Nieuwenhuis "] edition = "2018" +[package.metadata.embassy_docs] +features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "gpiote", "time-driver-rtc1"] +flavors = [ + { regex_feature = "nrf52.*", target = "thumbv7em-none-eabihf" }, + { regex_feature = "nrf53.*", target = "thumbv8m.main-none-eabihf" }, + { regex_feature = "nrf91.*", target = "thumbv8m.main-none-eabihf" }, +] + [features] # Enable nightly-only features diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 4fcb742e..ae6887b3 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs @@ -4,6 +4,7 @@ pub mod pac { // The nRF5340 has a secure and non-secure (NS) mode. // To avoid cfg spam, we remove _ns or _s suffixes here. + #[doc(no_inline)] pub use nrf5340_app_pac::{ interrupt, Interrupt, @@ -57,6 +58,7 @@ pub mod pac { }; #[cfg(feature = "nrf5340-app-ns")] + #[doc(no_inline)] pub use nrf5340_app_pac::{ CLOCK_NS as CLOCK, COMP_NS as COMP, @@ -127,6 +129,7 @@ pub mod pac { }; #[cfg(feature = "nrf5340-app-s")] + #[doc(no_inline)] pub use nrf5340_app_pac::{ CACHEDATA_S as CACHEDATA, CACHEINFO_S as CACHEINFO, diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index ea09f8d7..e2ae97a9 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs @@ -4,6 +4,7 @@ pub mod pac { // The nRF5340 has a secure and non-secure (NS) mode. // To avoid cfg spam, we remove _ns or _s suffixes here. + #[doc(no_inline)] pub use nrf5340_net_pac::{ interrupt, Interrupt, diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 51f6cb80..b8caa126 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs @@ -4,6 +4,7 @@ pub mod pac { // The nRF9160 has a secure and non-secure (NS) mode. // To avoid cfg spam, we remove _ns or _s suffixes here. + #[doc(no_inline)] pub use nrf9160_pac::{ interrupt, Interrupt, @@ -42,6 +43,7 @@ pub mod pac { }; #[cfg(feature = "nrf9160-ns")] + #[doc(no_inline)] pub use nrf9160_pac::{ CLOCK_NS as CLOCK, DPPIC_NS as DPPIC, @@ -96,6 +98,7 @@ pub mod pac { }; #[cfg(feature = "nrf9160-s")] + #[doc(no_inline)] pub use nrf9160_pac::{ CC_HOST_RGF_S as CC_HOST_RGF, CLOCK_S as CLOCK, diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index e45dfbac..116bba2a 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -5,6 +5,29 @@ authors = ["Dario Nieuwenhuis "] edition = "2018" resolver = "2" +[package.metadata.embassy_docs] +# TODO: sdmmc +# TODO: net +# TODO: subghz +features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any"] +flavors = [ + { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, + { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, + { regex_feature = "stm32f2.*", target = "thumbv7m-none-eabi" }, + { regex_feature = "stm32f3.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32f42.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32f7.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32g0.*", target = "thumbv6m-none-eabi" }, + { regex_feature = "stm32g4.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32h7.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32l0.*", target = "thumbv6m-none-eabi" }, + { regex_feature = "stm32l1.*", target = "thumbv7m-none-eabi" }, + { regex_feature = "stm32l4.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32u5.*", target = "thumbv8m.main-none-eabihf" }, + { regex_feature = "stm32wb.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32wl.*", target = "thumbv7em-none-eabi" }, +] + [dependencies] embassy = { version = "0.1.0", path = "../embassy" } embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 737b6247..02d47da8 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -646,13 +646,13 @@ fn main() { make_table(&mut m, "foreach_dma_channel", &dma_channels_table); let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let out_file = out_dir.join("macros.rs").to_string_lossy().to_string(); + let out_file = out_dir.join("_macros.rs").to_string_lossy().to_string(); fs::write(out_file, m).unwrap(); // ======== // Write generated.rs - let out_file = out_dir.join("generated.rs").to_string_lossy().to_string(); + let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string(); fs::write(out_file, g.to_string()).unwrap(); // ======== @@ -773,7 +773,7 @@ impl IteratorExt for T { fn make_table(out: &mut String, name: &str, data: &Vec>) { write!( out, - "#[macro_export] + "#[allow(unused)] macro_rules! {} {{ ($($pat:tt => $code:tt;)*) => {{ macro_rules! __{}_inner {{ diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs index c52d737b..34182206 100644 --- a/embassy-stm32/src/can/bxcan.rs +++ b/embassy-stm32/src/can/bxcan.rs @@ -7,6 +7,7 @@ use embassy_hal_common::unborrow; use crate::gpio::sealed::AFType; use crate::{peripherals, rcc::RccPeripheral}; +#[doc(no_inline)] pub use bxcan::*; 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 4fafe7df..105bea50 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs @@ -6,8 +6,8 @@ use core::task::Waker; use embassy::interrupt::{Interrupt, InterruptExt}; use embassy::waitqueue::AtomicWaker; +use crate::_generated::BDMA_CHANNEL_COUNT; use crate::dma::Request; -use crate::generated::BDMA_CHANNEL_COUNT; use crate::pac; use crate::pac::bdma::vals; @@ -65,7 +65,7 @@ pub(crate) unsafe fn init() { crate::interrupt::$irq::steal().enable(); }; } - crate::generated::init_bdma(); + crate::_generated::init_bdma(); } foreach_dma_channel! { diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index fd1732fb..95a6eea2 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs @@ -4,7 +4,7 @@ use core::task::Waker; use embassy::interrupt::{Interrupt, InterruptExt}; use embassy::waitqueue::AtomicWaker; -use crate::generated::DMA_CHANNEL_COUNT; +use crate::_generated::DMA_CHANNEL_COUNT; use crate::interrupt; use crate::pac; use crate::pac::dma::{regs, vals}; @@ -59,7 +59,7 @@ pub(crate) unsafe fn init() { interrupt::$irq::steal().enable(); }; } - crate::generated::init_dma(); + crate::_generated::init_dma(); } foreach_dma_channel! { diff --git a/embassy-stm32/src/dma/dmamux.rs b/embassy-stm32/src/dma/dmamux.rs index 628f496b..c45bebe2 100644 --- a/embassy-stm32/src/dma/dmamux.rs +++ b/embassy-stm32/src/dma/dmamux.rs @@ -49,5 +49,5 @@ foreach_dma_channel! { /// safety: must be called only once pub(crate) unsafe fn init() { - crate::generated::init_dmamux(); + crate::_generated::init_dmamux(); } diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 4837c412..3e108736 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -574,7 +574,7 @@ foreach_pin!( ); pub(crate) unsafe fn init() { - crate::generated::init_gpio(); + crate::_generated::init_gpio(); } mod eh02 { diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index c757b790..714dcc4c 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs @@ -3,4 +3,4 @@ pub use critical_section::CriticalSection; pub use embassy::interrupt::{take, Interrupt}; pub use embassy_hal_common::interrupt::Priority4 as Priority; -pub use crate::generated::interrupt::*; +pub use crate::_generated::interrupt::*; diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 5e8d6dd8..45b8e180 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -11,7 +11,7 @@ pub(crate) use stm32_metapac as pac; // This must go FIRST so that all the other modules see its macros. pub mod fmt; -include!(concat!(env!("OUT_DIR"), "/macros.rs")); +include!(concat!(env!("OUT_DIR"), "/_macros.rs")); // Utilities pub mod interrupt; @@ -63,16 +63,15 @@ pub mod usb_otg; pub mod subghz; // This must go last, so that it sees all the impl_foo! macros defined earlier. -pub(crate) mod generated { - +pub(crate) mod _generated { #![allow(dead_code)] #![allow(unused_imports)] #![allow(non_snake_case)] - include!(concat!(env!("OUT_DIR"), "/generated.rs")); + include!(concat!(env!("OUT_DIR"), "/_generated.rs")); } +pub use _generated::{peripherals, Peripherals}; pub use embassy_macros::interrupt; -pub use generated::{peripherals, Peripherals}; #[non_exhaustive] pub struct Config { diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs index 71d44fd3..ad5a661d 100644 --- a/embassy-stm32/src/rcc/g0.rs +++ b/embassy-stm32/src/rcc/g0.rs @@ -1,3 +1,4 @@ +use crate::pac::rcc::vals::{Hpre, Hsidiv, Ppre, Sw}; use crate::pac::{PWR, RCC}; use crate::rcc::{set_freqs, Clocks}; use crate::time::Hertz; @@ -29,17 +30,17 @@ pub enum HSI16Prescaler { Div128, } -impl Into for HSI16Prescaler { - fn into(self) -> u8 { +impl Into for HSI16Prescaler { + fn into(self) -> Hsidiv { match self { - HSI16Prescaler::NotDivided => 0x00, - HSI16Prescaler::Div2 => 0x01, - HSI16Prescaler::Div4 => 0x02, - HSI16Prescaler::Div8 => 0x03, - HSI16Prescaler::Div16 => 0x04, - HSI16Prescaler::Div32 => 0x05, - HSI16Prescaler::Div64 => 0x06, - HSI16Prescaler::Div128 => 0x07, + HSI16Prescaler::NotDivided => Hsidiv::DIV1, + HSI16Prescaler::Div2 => Hsidiv::DIV2, + HSI16Prescaler::Div4 => Hsidiv::DIV4, + HSI16Prescaler::Div8 => Hsidiv::DIV8, + HSI16Prescaler::Div16 => Hsidiv::DIV16, + HSI16Prescaler::Div32 => Hsidiv::DIV32, + HSI16Prescaler::Div64 => Hsidiv::DIV64, + HSI16Prescaler::Div128 => Hsidiv::DIV128, } } } @@ -68,30 +69,30 @@ pub enum APBPrescaler { Div16, } -impl Into for APBPrescaler { - fn into(self) -> u8 { +impl Into for APBPrescaler { + fn into(self) -> Ppre { match self { - APBPrescaler::NotDivided => 1, - APBPrescaler::Div2 => 0x04, - APBPrescaler::Div4 => 0x05, - APBPrescaler::Div8 => 0x06, - APBPrescaler::Div16 => 0x07, + APBPrescaler::NotDivided => Ppre::DIV1, + APBPrescaler::Div2 => Ppre::DIV2, + APBPrescaler::Div4 => Ppre::DIV4, + APBPrescaler::Div8 => Ppre::DIV8, + APBPrescaler::Div16 => Ppre::DIV16, } } } -impl Into for AHBPrescaler { - fn into(self) -> u8 { +impl Into for AHBPrescaler { + fn into(self) -> Hpre { match self { - AHBPrescaler::NotDivided => 1, - AHBPrescaler::Div2 => 0x08, - AHBPrescaler::Div4 => 0x09, - AHBPrescaler::Div8 => 0x0a, - AHBPrescaler::Div16 => 0x0b, - AHBPrescaler::Div64 => 0x0c, - AHBPrescaler::Div128 => 0x0d, - AHBPrescaler::Div256 => 0x0e, - AHBPrescaler::Div512 => 0x0f, + AHBPrescaler::NotDivided => Hpre::DIV1, + AHBPrescaler::Div2 => Hpre::DIV2, + AHBPrescaler::Div4 => Hpre::DIV4, + AHBPrescaler::Div8 => Hpre::DIV8, + AHBPrescaler::Div16 => Hpre::DIV16, + AHBPrescaler::Div64 => Hpre::DIV64, + AHBPrescaler::Div128 => Hpre::DIV128, + AHBPrescaler::Div256 => Hpre::DIV256, + AHBPrescaler::Div512 => Hpre::DIV512, } } } @@ -120,27 +121,27 @@ pub(crate) unsafe fn init(config: Config) { let (sys_clk, sw) = match config.mux { ClockSrc::HSI16(div) => { // Enable HSI16 - let div: u8 = div.into(); + let div: Hsidiv = div.into(); RCC.cr().write(|w| { w.set_hsidiv(div); w.set_hsion(true) }); while !RCC.cr().read().hsirdy() {} - (HSI_FREQ >> div, 0x00) + (HSI_FREQ >> div.0, Sw::HSI) } ClockSrc::HSE(freq) => { // Enable HSE RCC.cr().write(|w| w.set_hseon(true)); while !RCC.cr().read().hserdy() {} - (freq.0, 0x01) + (freq.0, Sw::HSE) } ClockSrc::LSI => { // Enable LSI RCC.csr().write(|w| w.set_lsion(true)); while !RCC.csr().read().lsirdy() {} - (LSI_FREQ, 0x03) + (LSI_FREQ, Sw::LSI) } }; @@ -150,20 +151,24 @@ pub(crate) unsafe fn init(config: Config) { w.set_ppre(config.apb_pre.into()); }); - let ahb_freq: u32 = match config.ahb_pre { - AHBPrescaler::NotDivided => sys_clk, - pre => { - let pre: u8 = pre.into(); - let pre = 1 << (pre as u32 - 7); - sys_clk / pre - } + let ahb_div = match config.ahb_pre { + AHBPrescaler::NotDivided => 1, + AHBPrescaler::Div2 => 2, + AHBPrescaler::Div4 => 4, + AHBPrescaler::Div8 => 8, + AHBPrescaler::Div16 => 16, + AHBPrescaler::Div64 => 64, + AHBPrescaler::Div128 => 128, + AHBPrescaler::Div256 => 256, + AHBPrescaler::Div512 => 512, }; + let ahb_freq = sys_clk / ahb_div; let (apb_freq, apb_tim_freq) = match config.apb_pre { APBPrescaler::NotDivided => (ahb_freq, ahb_freq), pre => { - let pre: u8 = pre.into(); - let pre: u8 = 1 << (pre - 3); + let pre: Ppre = pre.into(); + let pre: u8 = 1 << (pre.0 - 3); let freq = ahb_freq / pre as u32; (freq, freq * 2) } diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml index 9a5467c6..9b7e7207 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml @@ -5,6 +5,20 @@ authors = ["Dario Nieuwenhuis "] edition = "2018" resolver = "2" +[package.metadata.embassy_docs] +features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] +flavors = [ + { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, + { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] }, + { name = "thumbv6m-none-eabi", target = "thumbv6m-none-eabi", features = [] }, + { name = "thumbv7m-none-eabi", target = "thumbv7m-none-eabi", features = [] }, + { name = "thumbv7em-none-eabi", target = "thumbv7em-none-eabi", features = [] }, + { name = "thumbv7em-none-eabihf", target = "thumbv7em-none-eabihf", features = [] }, + { name = "thumbv8m.base-none-eabi", target = "thumbv8m.base-none-eabi", features = [] }, + { name = "thumbv8m.main-none-eabi", target = "thumbv8m.main-none-eabi", features = [] }, + { name = "thumbv8m.main-none-eabihf", target = "thumbv8m.main-none-eabihf", features = [] }, +] + [features] default = [] std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] diff --git a/stm32-data b/stm32-data index 5fcc7795..ad77937f 160000 --- a/stm32-data +++ b/stm32-data @@ -1 +1 @@ -Subproject commit 5fcc7795c880c7b19bb7b6226cd6d7db0b5cd953 +Subproject commit ad77937fb81628b982d2a674a88d983ec020fec7 diff --git a/stm32-metapac/Cargo.toml b/stm32-metapac/Cargo.toml index c994797b..98249ec6 100644 --- a/stm32-metapac/Cargo.toml +++ b/stm32-metapac/Cargo.toml @@ -19,6 +19,27 @@ features = ["stm32h755zi-cm7", "pac", "metadata"] default-target = "thumbv7em-none-eabihf" targets = [] +[package.metadata.embassy_docs] +features = ["pac", "metadata"] +flavors = [ + { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, + { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, + { regex_feature = "stm32f2.*", target = "thumbv7m-none-eabi" }, + { regex_feature = "stm32f3.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32f4.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32f7.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32g0.*", target = "thumbv6m-none-eabi" }, + { regex_feature = "stm32g4.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32h7.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32l0.*", target = "thumbv6m-none-eabi" }, + { regex_feature = "stm32l1.*", target = "thumbv7m-none-eabi" }, + { regex_feature = "stm32l4.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32l5.*", target = "thumbv8m.main-none-eabihf" }, + { regex_feature = "stm32u5.*", target = "thumbv8m.main-none-eabihf" }, + { regex_feature = "stm32wb.*", target = "thumbv7em-none-eabi" }, + { regex_feature = "stm32wl.*", target = "thumbv7em-none-eabi" }, +] + [dependencies] cortex-m = "0.7.3" 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 9cdc5e0b..4eab2986 100644 --- a/stm32-metapac/src/lib.rs +++ b/stm32-metapac/src/lib.rs @@ -2,6 +2,7 @@ #![allow(non_snake_case)] #![allow(unused)] #![allow(non_camel_case_types)] +#![doc(html_no_source)] pub mod common;