stm32: more docs.

This commit is contained in:
Dario Nieuwenhuis 2023-12-19 00:05:54 +01:00
parent 138318f611
commit 49534cd405
23 changed files with 55 additions and 6 deletions

View File

@ -354,7 +354,11 @@ unsafe fn uicr_write_masked(address: *mut u32, value: u32, mask: u32) -> WriteRe
WriteResult::Written WriteResult::Written
} }
/// Initialize peripherals with the provided configuration. This should only be called once at startup. /// Initialize the `embassy-nrf` HAL with the provided configuration.
///
/// This returns the peripheral singletons that can be used for creating drivers.
///
/// This should only be called once at startup, otherwise it panics.
pub fn init(config: config::Config) -> Peripherals { pub fn init(config: config::Config) -> Peripherals {
// Do this first, so that it panics if user is calling `init` a second time // Do this first, so that it panics if user is calling `init` a second time
// before doing anything important. // before doing anything important.

View File

@ -1,4 +1,5 @@
//! Analog to Digital (ADC) converter driver. //! Analog to Digital Converter (ADC)
#![macro_use] #![macro_use]
#![allow(missing_docs)] // TODO #![allow(missing_docs)] // TODO

View File

@ -1,3 +1,4 @@
//! Controller Area Network (CAN)
#![macro_use] #![macro_use]
#[cfg_attr(can_bxcan, path = "bxcan.rs")] #[cfg_attr(can_bxcan, path = "bxcan.rs")]

View File

@ -1,3 +1,4 @@
//! Cyclic Redundancy Check (CRC)
#[cfg_attr(crc_v1, path = "v1.rs")] #[cfg_attr(crc_v1, path = "v1.rs")]
#[cfg_attr(crc_v2, path = "v2v3.rs")] #[cfg_attr(crc_v2, path = "v2v3.rs")]
#[cfg_attr(crc_v3, path = "v2v3.rs")] #[cfg_attr(crc_v3, path = "v2v3.rs")]

View File

@ -1,4 +1,4 @@
//! Provide access to the STM32 digital-to-analog converter (DAC). //! Digital to Analog Converter (DAC)
#![macro_use] #![macro_use]
use core::marker::PhantomData; use core::marker::PhantomData;

View File

@ -1,3 +1,4 @@
//! Digital Camera Interface (DCMI)
use core::future::poll_fn; use core::future::poll_fn;
use core::marker::PhantomData; use core::marker::PhantomData;
use core::task::Poll; use core::task::Poll;

View File

@ -1,3 +1,4 @@
//! Ethernet (ETH)
#![macro_use] #![macro_use]
#[cfg_attr(any(eth_v1a, eth_v1b, eth_v1c), path = "v1/mod.rs")] #[cfg_attr(any(eth_v1a, eth_v1b, eth_v1c), path = "v1/mod.rs")]

View File

@ -1,3 +1,4 @@
//! External Interrupts (EXTI)
use core::convert::Infallible; use core::convert::Infallible;
use core::future::Future; use core::future::Future;
use core::marker::PhantomData; use core::marker::PhantomData;

View File

@ -1,3 +1,4 @@
//! Flash memory (FLASH)
use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
#[cfg(flash_f4)] #[cfg(flash_f4)]

View File

@ -1,3 +1,4 @@
//! Flexible Memory Controller (FMC) / Flexible Static Memory Controller (FSMC)
use core::marker::PhantomData; use core::marker::PhantomData;
use embassy_hal_internal::into_ref; use embassy_hal_internal::into_ref;

View File

@ -1,3 +1,5 @@
//! High Resolution Timer (HRTIM)
mod traits; mod traits;
use core::marker::PhantomData; use core::marker::PhantomData;

View File

@ -1,3 +1,4 @@
//! Inter-Integrated-Circuit (I2C)
#![macro_use] #![macro_use]
#[cfg_attr(i2c_v1, path = "v1.rs")] #[cfg_attr(i2c_v1, path = "v1.rs")]

View File

@ -1,3 +1,4 @@
//! Inter-IC Sound (I2S)
use embassy_hal_internal::into_ref; use embassy_hal_internal::into_ref;
use crate::gpio::sealed::{AFType, Pin as _}; use crate::gpio::sealed::{AFType, Pin as _};

View File

@ -149,15 +149,33 @@ use crate::interrupt::Priority;
pub use crate::pac::NVIC_PRIO_BITS; pub use crate::pac::NVIC_PRIO_BITS;
use crate::rcc::sealed::RccPeripheral; use crate::rcc::sealed::RccPeripheral;
/// `embassy-stm32` global configuration.
#[non_exhaustive] #[non_exhaustive]
pub struct Config { pub struct Config {
/// RCC config.
pub rcc: rcc::Config, pub rcc: rcc::Config,
/// Enable debug during sleep.
///
/// May incrase power consumption. Defaults to true.
#[cfg(dbgmcu)] #[cfg(dbgmcu)]
pub enable_debug_during_sleep: bool, pub enable_debug_during_sleep: bool,
/// BDMA interrupt priority.
///
/// Defaults to P0 (highest).
#[cfg(bdma)] #[cfg(bdma)]
pub bdma_interrupt_priority: Priority, pub bdma_interrupt_priority: Priority,
/// DMA interrupt priority.
///
/// Defaults to P0 (highest).
#[cfg(dma)] #[cfg(dma)]
pub dma_interrupt_priority: Priority, pub dma_interrupt_priority: Priority,
/// GPDMA interrupt priority.
///
/// Defaults to P0 (highest).
#[cfg(gpdma)] #[cfg(gpdma)]
pub gpdma_interrupt_priority: Priority, pub gpdma_interrupt_priority: Priority,
} }
@ -178,7 +196,11 @@ impl Default for Config {
} }
} }
/// Initialize embassy. /// Initialize the `embassy-stm32` HAL with the provided configuration.
///
/// This returns the peripheral singletons that can be used for creating drivers.
///
/// This should only be called once at startup, otherwise it panics.
pub fn init(config: Config) -> Peripherals { pub fn init(config: Config) -> Peripherals {
critical_section::with(|cs| { critical_section::with(|cs| {
let p = Peripherals::take_with_cs(cs); let p = Peripherals::take_with_cs(cs);

View File

@ -1,3 +1,5 @@
//! Quad Serial Peripheral Interface (QSPI)
#![macro_use] #![macro_use]
pub mod enums; pub mod enums;

View File

@ -1,3 +1,4 @@
//! Random Number Generator (RNG)
#![macro_use] #![macro_use]
use core::future::poll_fn; use core::future::poll_fn;

View File

@ -1,4 +1,4 @@
//! RTC peripheral abstraction //! Real Time Clock (RTC)
mod datetime; mod datetime;
#[cfg(feature = "low-power")] #[cfg(feature = "low-power")]
@ -163,7 +163,7 @@ impl RtcTimeProvider {
} }
} }
/// RTC Abstraction /// RTC driver.
pub struct Rtc { pub struct Rtc {
#[cfg(feature = "low-power")] #[cfg(feature = "low-power")]
stop_time: Mutex<CriticalSectionRawMutex, Cell<Option<RtcInstant>>>, stop_time: Mutex<CriticalSectionRawMutex, Cell<Option<RtcInstant>>>,

View File

@ -1,3 +1,4 @@
//! Secure Digital / MultiMedia Card (SDMMC)
#![macro_use] #![macro_use]
use core::default::Default; use core::default::Default;

View File

@ -1,3 +1,4 @@
//! Serial Peripheral Interface (SPI)
#![macro_use] #![macro_use]
use core::ptr; use core::ptr;

View File

@ -1,3 +1,5 @@
//! Unique ID (UID)
/// Get this device's unique 96-bit ID. /// Get this device's unique 96-bit ID.
pub fn uid() -> &'static [u8; 12] { pub fn uid() -> &'static [u8; 12] {
unsafe { &*crate::pac::UID.uid(0).as_ptr().cast::<[u8; 12]>() } unsafe { &*crate::pac::UID.uid(0).as_ptr().cast::<[u8; 12]>() }

View File

@ -1,3 +1,4 @@
//! Universal Synchronous/Asynchronous Receiver Transmitter (USART, UART, LPUART)
#![macro_use] #![macro_use]
use core::future::poll_fn; use core::future::poll_fn;

View File

@ -1,3 +1,5 @@
//! USB On The Go (OTG)
use crate::rcc::RccPeripheral; use crate::rcc::RccPeripheral;
use crate::{interrupt, peripherals}; use crate::{interrupt, peripherals};

View File

@ -1,3 +1,4 @@
//! Watchdog Timer (IWDG, WWDG)
use core::marker::PhantomData; use core::marker::PhantomData;
use embassy_hal_internal::{into_ref, Peripheral}; use embassy_hal_internal::{into_ref, Peripheral};