Skip to content

Commit

Permalink
Merge pull request #2310 from embassy-rs/stm32-docs
Browse files Browse the repository at this point in the history
stm32/sai: docs, cleanup api.
  • Loading branch information
Dirbaio authored Dec 18, 2023
2 parents 4ed7747 + e1f588f commit 08e9a4d
Show file tree
Hide file tree
Showing 26 changed files with 291 additions and 352 deletions.
6 changes: 5 additions & 1 deletion embassy-nrf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ unsafe fn uicr_write_masked(address: *mut u32, value: u32, mask: u32) -> WriteRe
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 {
// Do this first, so that it panics if user is calling `init` a second time
// before doing anything important.
Expand Down
20 changes: 10 additions & 10 deletions embassy-stm32/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,14 @@ fn main() {
(("lpuart", "RTS"), quote!(crate::usart::RtsPin)),
(("lpuart", "CK"), quote!(crate::usart::CkPin)),
(("lpuart", "DE"), quote!(crate::usart::DePin)),
(("sai", "SCK_A"), quote!(crate::sai::SckAPin)),
(("sai", "SCK_B"), quote!(crate::sai::SckBPin)),
(("sai", "FS_A"), quote!(crate::sai::FsAPin)),
(("sai", "FS_B"), quote!(crate::sai::FsBPin)),
(("sai", "SD_A"), quote!(crate::sai::SdAPin)),
(("sai", "SD_B"), quote!(crate::sai::SdBPin)),
(("sai", "MCLK_A"), quote!(crate::sai::MclkAPin)),
(("sai", "MCLK_B"), quote!(crate::sai::MclkBPin)),
(("sai", "SCK_A"), quote!(crate::sai::SckPin<A>)),
(("sai", "SCK_B"), quote!(crate::sai::SckPin<B>)),
(("sai", "FS_A"), quote!(crate::sai::FsPin<A>)),
(("sai", "FS_B"), quote!(crate::sai::FsPin<B>)),
(("sai", "SD_A"), quote!(crate::sai::SdPin<A>)),
(("sai", "SD_B"), quote!(crate::sai::SdPin<B>)),
(("sai", "MCLK_A"), quote!(crate::sai::MclkPin<A>)),
(("sai", "MCLK_B"), quote!(crate::sai::MclkPin<B>)),
(("sai", "WS"), quote!(crate::sai::WsPin)),
(("spi", "SCK"), quote!(crate::spi::SckPin)),
(("spi", "MOSI"), quote!(crate::spi::MosiPin)),
Expand Down Expand Up @@ -995,8 +995,8 @@ fn main() {
(("usart", "TX"), quote!(crate::usart::TxDma)),
(("lpuart", "RX"), quote!(crate::usart::RxDma)),
(("lpuart", "TX"), quote!(crate::usart::TxDma)),
(("sai", "A"), quote!(crate::sai::DmaA)),
(("sai", "B"), quote!(crate::sai::DmaB)),
(("sai", "A"), quote!(crate::sai::Dma<A>)),
(("sai", "B"), quote!(crate::sai::Dma<B>)),
(("spi", "RX"), quote!(crate::spi::RxDma)),
(("spi", "TX"), quote!(crate::spi::TxDma)),
(("i2c", "RX"), quote!(crate::i2c::RxDma)),
Expand Down
3 changes: 2 additions & 1 deletion embassy-stm32/src/adc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Analog to Digital (ADC) converter driver.
//! Analog to Digital Converter (ADC)
#![macro_use]
#![allow(missing_docs)] // TODO

Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/can/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Controller Area Network (CAN)
#![macro_use]

#[cfg_attr(can_bxcan, path = "bxcan.rs")]
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/crc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Cyclic Redundancy Check (CRC)
#[cfg_attr(crc_v1, path = "v1.rs")]
#[cfg_attr(crc_v2, path = "v2v3.rs")]
#[cfg_attr(crc_v3, path = "v2v3.rs")]
Expand Down
2 changes: 1 addition & 1 deletion embassy-stm32/src/dac/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Provide access to the STM32 digital-to-analog converter (DAC).
//! Digital to Analog Converter (DAC)
#![macro_use]

use core::marker::PhantomData;
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/dcmi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Digital Camera Interface (DCMI)
use core::future::poll_fn;
use core::marker::PhantomData;
use core::task::Poll;
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/eth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Ethernet (ETH)
#![macro_use]

#[cfg_attr(any(eth_v1a, eth_v1b, eth_v1c), path = "v1/mod.rs")]
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/exti.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! External Interrupts (EXTI)
use core::convert::Infallible;
use core::future::Future;
use core::marker::PhantomData;
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/flash/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Flash memory (FLASH)
use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};

#[cfg(flash_f4)]
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/fmc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Flexible Memory Controller (FMC) / Flexible Static Memory Controller (FSMC)
use core::marker::PhantomData;

use embassy_hal_internal::into_ref;
Expand Down
2 changes: 2 additions & 0 deletions embassy-stm32/src/hrtim/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! High Resolution Timer (HRTIM)
mod traits;

use core::marker::PhantomData;
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/i2c/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Inter-Integrated-Circuit (I2C)
#![macro_use]

#[cfg_attr(i2c_v1, path = "v1.rs")]
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/i2s.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Inter-IC Sound (I2S)
use embassy_hal_internal::into_ref;

use crate::gpio::sealed::{AFType, Pin as _};
Expand Down
24 changes: 23 additions & 1 deletion embassy-stm32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,33 @@ use crate::interrupt::Priority;
pub use crate::pac::NVIC_PRIO_BITS;
use crate::rcc::sealed::RccPeripheral;

/// `embassy-stm32` global configuration.
#[non_exhaustive]
pub struct Config {
/// RCC config.
pub rcc: rcc::Config,

/// Enable debug during sleep.
///
/// May incrase power consumption. Defaults to true.
#[cfg(dbgmcu)]
pub enable_debug_during_sleep: bool,

/// BDMA interrupt priority.
///
/// Defaults to P0 (highest).
#[cfg(bdma)]
pub bdma_interrupt_priority: Priority,

/// DMA interrupt priority.
///
/// Defaults to P0 (highest).
#[cfg(dma)]
pub dma_interrupt_priority: Priority,

/// GPDMA interrupt priority.
///
/// Defaults to P0 (highest).
#[cfg(gpdma)]
pub gpdma_interrupt_priority: Priority,
}
Expand All @@ -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 {
critical_section::with(|cs| {
let p = Peripherals::take_with_cs(cs);
Expand Down
2 changes: 2 additions & 0 deletions embassy-stm32/src/qspi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Quad Serial Peripheral Interface (QSPI)
#![macro_use]

pub mod enums;
Expand Down
1 change: 1 addition & 0 deletions embassy-stm32/src/rng.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Random Number Generator (RNG)
#![macro_use]

use core::future::poll_fn;
Expand Down
4 changes: 2 additions & 2 deletions embassy-stm32/src/rtc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! RTC peripheral abstraction
//! Real Time Clock (RTC)
mod datetime;

#[cfg(feature = "low-power")]
Expand Down Expand Up @@ -163,7 +163,7 @@ impl RtcTimeProvider {
}
}

/// RTC Abstraction
/// RTC driver.
pub struct Rtc {
#[cfg(feature = "low-power")]
stop_time: Mutex<CriticalSectionRawMutex, Cell<Option<RtcInstant>>>,
Expand Down
Loading

0 comments on commit 08e9a4d

Please sign in to comment.