diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-12-18 19:11:13 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-12-18 19:11:23 +0100 |
| commit | 124478c5e9df16f0930d019c6f0db358666b3249 (patch) | |
| tree | 9c2ed7fe64b273efdd84f5952516b64a0b5f8566 | |
| parent | 59d2977c0aef1104138473252fe8d84e3550e378 (diff) | |
stm32: more docs.
| -rw-r--r-- | embassy-stm32/src/adc/mod.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/crc/v1.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/eth/v1/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/asynch.rs | 17 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/fmc.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v1.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/i2s.rs | 35 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/mod.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/src/rng.rs | 15 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/datetime.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/mod.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/mod.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/qei.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/simple_pwm.rs | 2 |
18 files changed, 112 insertions, 14 deletions
diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index 2e470662d..ff523ca3b 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | //! Analog to Digital (ADC) converter driver. | 1 | //! Analog to Digital (ADC) converter driver. |
| 2 | #![macro_use] | 2 | #![macro_use] |
| 3 | #![allow(missing_docs)] // TODO | ||
| 3 | 4 | ||
| 4 | #[cfg(not(adc_f3_v2))] | 5 | #[cfg(not(adc_f3_v2))] |
| 5 | #[cfg_attr(adc_f1, path = "f1.rs")] | 6 | #[cfg_attr(adc_f1, path = "f1.rs")] |
diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs index c0f580830..0166ab819 100644 --- a/embassy-stm32/src/crc/v1.rs +++ b/embassy-stm32/src/crc/v1.rs | |||
| @@ -5,6 +5,7 @@ use crate::peripherals::CRC; | |||
| 5 | use crate::rcc::sealed::RccPeripheral; | 5 | use crate::rcc::sealed::RccPeripheral; |
| 6 | use crate::Peripheral; | 6 | use crate::Peripheral; |
| 7 | 7 | ||
| 8 | /// CRC driver. | ||
| 8 | pub struct Crc<'d> { | 9 | pub struct Crc<'d> { |
| 9 | _peri: PeripheralRef<'d, CRC>, | 10 | _peri: PeripheralRef<'d, CRC>, |
| 10 | } | 11 | } |
| @@ -34,6 +35,7 @@ impl<'d> Crc<'d> { | |||
| 34 | PAC_CRC.dr().write_value(word); | 35 | PAC_CRC.dr().write_value(word); |
| 35 | self.read() | 36 | self.read() |
| 36 | } | 37 | } |
| 38 | |||
| 37 | /// Feed a slice of words to the peripheral and return the result. | 39 | /// Feed a slice of words to the peripheral and return the result. |
| 38 | pub fn feed_words(&mut self, words: &[u32]) -> u32 { | 40 | pub fn feed_words(&mut self, words: &[u32]) -> u32 { |
| 39 | for word in words { | 41 | for word in words { |
| @@ -42,6 +44,8 @@ impl<'d> Crc<'d> { | |||
| 42 | 44 | ||
| 43 | self.read() | 45 | self.read() |
| 44 | } | 46 | } |
| 47 | |||
| 48 | /// Read the CRC result value. | ||
| 45 | pub fn read(&self) -> u32 { | 49 | pub fn read(&self) -> u32 { |
| 46 | PAC_CRC.dr().read() | 50 | PAC_CRC.dr().read() |
| 47 | } | 51 | } |
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index fb40a4b5e..38945ac33 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | //! Direct Memory Access (DMA) | ||
| 2 | |||
| 1 | #[cfg(dma)] | 3 | #[cfg(dma)] |
| 2 | pub(crate) mod dma; | 4 | pub(crate) mod dma; |
| 3 | #[cfg(dma)] | 5 | #[cfg(dma)] |
diff --git a/embassy-stm32/src/eth/v1/mod.rs b/embassy-stm32/src/eth/v1/mod.rs index 13e53f687..2ce5b3927 100644 --- a/embassy-stm32/src/eth/v1/mod.rs +++ b/embassy-stm32/src/eth/v1/mod.rs | |||
| @@ -43,6 +43,7 @@ impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandl | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | /// Ethernet driver. | ||
| 46 | pub struct Ethernet<'d, T: Instance, P: PHY> { | 47 | pub struct Ethernet<'d, T: Instance, P: PHY> { |
| 47 | _peri: PeripheralRef<'d, T>, | 48 | _peri: PeripheralRef<'d, T>, |
| 48 | pub(crate) tx: TDesRing<'d>, | 49 | pub(crate) tx: TDesRing<'d>, |
| @@ -266,6 +267,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 266 | } | 267 | } |
| 267 | } | 268 | } |
| 268 | 269 | ||
| 270 | /// Ethernet station management interface. | ||
| 269 | pub struct EthernetStationManagement<T: Instance> { | 271 | pub struct EthernetStationManagement<T: Instance> { |
| 270 | peri: PhantomData<T>, | 272 | peri: PhantomData<T>, |
| 271 | clock_range: Cr, | 273 | clock_range: Cr, |
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index e3c6d4d67..97eaece81 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -17,6 +17,7 @@ use crate::{interrupt, Peripheral}; | |||
| 17 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); | 17 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); |
| 18 | 18 | ||
| 19 | impl<'d> Flash<'d, Async> { | 19 | impl<'d> Flash<'d, Async> { |
| 20 | /// Create a new flash driver with async capabilities. | ||
| 20 | pub fn new( | 21 | pub fn new( |
| 21 | p: impl Peripheral<P = FLASH> + 'd, | 22 | p: impl Peripheral<P = FLASH> + 'd, |
| 22 | _irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd, | 23 | _irq: impl interrupt::typelevel::Binding<crate::interrupt::typelevel::FLASH, InterruptHandler> + 'd, |
| @@ -32,15 +33,26 @@ impl<'d> Flash<'d, Async> { | |||
| 32 | } | 33 | } |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 36 | /// Split this flash driver into one instance per flash memory region. | ||
| 37 | /// | ||
| 38 | /// See module-level documentation for details on how memory regions work. | ||
| 35 | pub fn into_regions(self) -> FlashLayout<'d, Async> { | 39 | pub fn into_regions(self) -> FlashLayout<'d, Async> { |
| 36 | assert!(family::is_default_layout()); | 40 | assert!(family::is_default_layout()); |
| 37 | FlashLayout::new(self.inner) | 41 | FlashLayout::new(self.inner) |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 44 | /// Async write. | ||
| 45 | /// | ||
| 46 | /// NOTE: `offset` is an offset from the flash start, NOT an absolute address. | ||
| 47 | /// For example, to write address `0x0800_1234` you have to use offset `0x1234`. | ||
| 40 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 48 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 41 | unsafe { write_chunked(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes).await } | 49 | unsafe { write_chunked(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes).await } |
| 42 | } | 50 | } |
| 43 | 51 | ||
| 52 | /// Async erase. | ||
| 53 | /// | ||
| 54 | /// NOTE: `from` and `to` are offsets from the flash start, NOT an absolute address. | ||
| 55 | /// For example, to erase address `0x0801_0000` you have to use offset `0x1_0000`. | ||
| 44 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { | 56 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { |
| 45 | unsafe { erase_sectored(FLASH_BASE as u32, from, to).await } | 57 | unsafe { erase_sectored(FLASH_BASE as u32, from, to).await } |
| 46 | } | 58 | } |
| @@ -141,15 +153,20 @@ pub(super) async unsafe fn erase_sectored(base: u32, from: u32, to: u32) -> Resu | |||
| 141 | foreach_flash_region! { | 153 | foreach_flash_region! { |
| 142 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { | 154 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { |
| 143 | impl crate::_generated::flash_regions::$type_name<'_, Async> { | 155 | impl crate::_generated::flash_regions::$type_name<'_, Async> { |
| 156 | /// Async read. | ||
| 157 | /// | ||
| 158 | /// Note: reading from flash can't actually block, so this is the same as `blocking_read`. | ||
| 144 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 159 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 145 | blocking_read(self.0.base, self.0.size, offset, bytes) | 160 | blocking_read(self.0.base, self.0.size, offset, bytes) |
| 146 | } | 161 | } |
| 147 | 162 | ||
| 163 | /// Async write. | ||
| 148 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 164 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 149 | let _guard = REGION_ACCESS.lock().await; | 165 | let _guard = REGION_ACCESS.lock().await; |
| 150 | unsafe { write_chunked(self.0.base, self.0.size, offset, bytes).await } | 166 | unsafe { write_chunked(self.0.base, self.0.size, offset, bytes).await } |
| 151 | } | 167 | } |
| 152 | 168 | ||
| 169 | /// Async erase. | ||
| 153 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { | 170 | pub async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { |
| 154 | let _guard = REGION_ACCESS.lock().await; | 171 | let _guard = REGION_ACCESS.lock().await; |
| 155 | unsafe { erase_sectored(self.0.base, from, to).await } | 172 | unsafe { erase_sectored(self.0.base, from, to).await } |
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index f442c5894..2671dfb04 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -9,7 +9,7 @@ use pac::FLASH_SIZE; | |||
| 9 | use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; | 9 | use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; |
| 10 | use crate::flash::Error; | 10 | use crate::flash::Error; |
| 11 | use crate::pac; | 11 | use crate::pac; |
| 12 | 12 | #[allow(missing_docs)] // TODO | |
| 13 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] | 13 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] |
| 14 | mod alt_regions { | 14 | mod alt_regions { |
| 15 | use core::marker::PhantomData; | 15 | use core::marker::PhantomData; |
diff --git a/embassy-stm32/src/fmc.rs b/embassy-stm32/src/fmc.rs index dd0d27217..23ac82f63 100644 --- a/embassy-stm32/src/fmc.rs +++ b/embassy-stm32/src/fmc.rs | |||
| @@ -6,6 +6,7 @@ use crate::gpio::sealed::AFType; | |||
| 6 | use crate::gpio::{Pull, Speed}; | 6 | use crate::gpio::{Pull, Speed}; |
| 7 | use crate::Peripheral; | 7 | use crate::Peripheral; |
| 8 | 8 | ||
| 9 | /// FMC driver | ||
| 9 | pub struct Fmc<'d, T: Instance> { | 10 | pub struct Fmc<'d, T: Instance> { |
| 10 | peri: PhantomData<&'d mut T>, | 11 | peri: PhantomData<&'d mut T>, |
| 11 | } | 12 | } |
| @@ -38,6 +39,7 @@ where | |||
| 38 | T::REGS.bcr1().modify(|r| r.set_fmcen(true)); | 39 | T::REGS.bcr1().modify(|r| r.set_fmcen(true)); |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 42 | /// Get the kernel clock currently in use for this FMC instance. | ||
| 41 | pub fn source_clock_hz(&self) -> u32 { | 43 | pub fn source_clock_hz(&self) -> u32 { |
| 42 | <T as crate::rcc::sealed::RccPeripheral>::frequency().0 | 44 | <T as crate::rcc::sealed::RccPeripheral>::frequency().0 |
| 43 | } | 45 | } |
| @@ -85,6 +87,7 @@ macro_rules! fmc_sdram_constructor { | |||
| 85 | nbl: [$(($nbl_pin_name:ident: $nbl_signal:ident)),*], | 87 | nbl: [$(($nbl_pin_name:ident: $nbl_signal:ident)),*], |
| 86 | ctrl: [$(($ctrl_pin_name:ident: $ctrl_signal:ident)),*] | 88 | ctrl: [$(($ctrl_pin_name:ident: $ctrl_signal:ident)),*] |
| 87 | )) => { | 89 | )) => { |
| 90 | /// Create a new FMC instance. | ||
| 88 | pub fn $name<CHIP: stm32_fmc::SdramChip>( | 91 | pub fn $name<CHIP: stm32_fmc::SdramChip>( |
| 89 | _instance: impl Peripheral<P = T> + 'd, | 92 | _instance: impl Peripheral<P = T> + 'd, |
| 90 | $($addr_pin_name: impl Peripheral<P = impl $addr_signal<T>> + 'd),*, | 93 | $($addr_pin_name: impl Peripheral<P = impl $addr_signal<T>> + 'd),*, |
| @@ -199,6 +202,7 @@ pub(crate) mod sealed { | |||
| 199 | } | 202 | } |
| 200 | } | 203 | } |
| 201 | 204 | ||
| 205 | /// FMC instance trait. | ||
| 202 | pub trait Instance: sealed::Instance + 'static {} | 206 | pub trait Instance: sealed::Instance + 'static {} |
| 203 | 207 | ||
| 204 | foreach_peripheral!( | 208 | foreach_peripheral!( |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 083b3237c..c300a079e 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | //! General-purpose Input/Output (GPIO) | ||
| 2 | |||
| 1 | #![macro_use] | 3 | #![macro_use] |
| 2 | use core::convert::Infallible; | 4 | use core::convert::Infallible; |
| 3 | 5 | ||
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 84802d129..df5b44c2d 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -247,10 +247,12 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | /// Blocking read. | ||
| 250 | pub fn blocking_read(&mut self, addr: u8, read: &mut [u8]) -> Result<(), Error> { | 251 | pub fn blocking_read(&mut self, addr: u8, read: &mut [u8]) -> Result<(), Error> { |
| 251 | self.blocking_read_timeout(addr, read, self.timeout()) | 252 | self.blocking_read_timeout(addr, read, self.timeout()) |
| 252 | } | 253 | } |
| 253 | 254 | ||
| 255 | /// Blocking write. | ||
| 254 | pub fn blocking_write(&mut self, addr: u8, write: &[u8]) -> Result<(), Error> { | 256 | pub fn blocking_write(&mut self, addr: u8, write: &[u8]) -> Result<(), Error> { |
| 255 | let timeout = self.timeout(); | 257 | let timeout = self.timeout(); |
| 256 | 258 | ||
| @@ -266,6 +268,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 266 | Ok(()) | 268 | Ok(()) |
| 267 | } | 269 | } |
| 268 | 270 | ||
| 271 | /// Blocking write, restart, read. | ||
| 269 | pub fn blocking_write_read(&mut self, addr: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> { | 272 | pub fn blocking_write_read(&mut self, addr: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> { |
| 270 | let timeout = self.timeout(); | 273 | let timeout = self.timeout(); |
| 271 | 274 | ||
| @@ -435,6 +438,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 435 | Ok(()) | 438 | Ok(()) |
| 436 | } | 439 | } |
| 437 | 440 | ||
| 441 | /// Write. | ||
| 438 | pub async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> | 442 | pub async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> |
| 439 | where | 443 | where |
| 440 | TXDMA: crate::i2c::TxDma<T>, | 444 | TXDMA: crate::i2c::TxDma<T>, |
| @@ -457,6 +461,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 457 | Ok(()) | 461 | Ok(()) |
| 458 | } | 462 | } |
| 459 | 463 | ||
| 464 | /// Read. | ||
| 460 | pub async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Error> | 465 | pub async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Error> |
| 461 | where | 466 | where |
| 462 | RXDMA: crate::i2c::RxDma<T>, | 467 | RXDMA: crate::i2c::RxDma<T>, |
| @@ -616,6 +621,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 616 | Ok(()) | 621 | Ok(()) |
| 617 | } | 622 | } |
| 618 | 623 | ||
| 624 | /// Write, restart, read. | ||
| 619 | pub async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> | 625 | pub async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> |
| 620 | where | 626 | where |
| 621 | RXDMA: crate::i2c::RxDma<T>, | 627 | RXDMA: crate::i2c::RxDma<T>, |
diff --git a/embassy-stm32/src/i2s.rs b/embassy-stm32/src/i2s.rs index 67d40c479..372c86db3 100644 --- a/embassy-stm32/src/i2s.rs +++ b/embassy-stm32/src/i2s.rs | |||
| @@ -8,30 +8,42 @@ use crate::spi::{Config as SpiConfig, *}; | |||
| 8 | use crate::time::Hertz; | 8 | use crate::time::Hertz; |
| 9 | use crate::{Peripheral, PeripheralRef}; | 9 | use crate::{Peripheral, PeripheralRef}; |
| 10 | 10 | ||
| 11 | /// I2S mode | ||
| 11 | #[derive(Copy, Clone)] | 12 | #[derive(Copy, Clone)] |
| 12 | pub enum Mode { | 13 | pub enum Mode { |
| 14 | /// Master mode | ||
| 13 | Master, | 15 | Master, |
| 16 | /// Slave mode | ||
| 14 | Slave, | 17 | Slave, |
| 15 | } | 18 | } |
| 16 | 19 | ||
| 20 | /// I2S function | ||
| 17 | #[derive(Copy, Clone)] | 21 | #[derive(Copy, Clone)] |
| 18 | pub enum Function { | 22 | pub enum Function { |
| 23 | /// Transmit audio data | ||
| 19 | Transmit, | 24 | Transmit, |
| 25 | /// Receive audio data | ||
| 20 | Receive, | 26 | Receive, |
| 21 | } | 27 | } |
| 22 | 28 | ||
| 29 | /// I2C standard | ||
| 23 | #[derive(Copy, Clone)] | 30 | #[derive(Copy, Clone)] |
| 24 | pub enum Standard { | 31 | pub enum Standard { |
| 32 | /// Philips | ||
| 25 | Philips, | 33 | Philips, |
| 34 | /// Most significant bit first. | ||
| 26 | MsbFirst, | 35 | MsbFirst, |
| 36 | /// Least significant bit first. | ||
| 27 | LsbFirst, | 37 | LsbFirst, |
| 38 | /// PCM with long sync. | ||
| 28 | PcmLongSync, | 39 | PcmLongSync, |
| 40 | /// PCM with short sync. | ||
| 29 | PcmShortSync, | 41 | PcmShortSync, |
| 30 | } | 42 | } |
| 31 | 43 | ||
| 32 | impl Standard { | 44 | impl Standard { |
| 33 | #[cfg(any(spi_v1, spi_f1))] | 45 | #[cfg(any(spi_v1, spi_f1))] |
| 34 | pub const fn i2sstd(&self) -> vals::I2sstd { | 46 | const fn i2sstd(&self) -> vals::I2sstd { |
| 35 | match self { | 47 | match self { |
| 36 | Standard::Philips => vals::I2sstd::PHILIPS, | 48 | Standard::Philips => vals::I2sstd::PHILIPS, |
| 37 | Standard::MsbFirst => vals::I2sstd::MSB, | 49 | Standard::MsbFirst => vals::I2sstd::MSB, |
| @@ -42,7 +54,7 @@ impl Standard { | |||
| 42 | } | 54 | } |
| 43 | 55 | ||
| 44 | #[cfg(any(spi_v1, spi_f1))] | 56 | #[cfg(any(spi_v1, spi_f1))] |
| 45 | pub const fn pcmsync(&self) -> vals::Pcmsync { | 57 | const fn pcmsync(&self) -> vals::Pcmsync { |
| 46 | match self { | 58 | match self { |
| 47 | Standard::PcmLongSync => vals::Pcmsync::LONG, | 59 | Standard::PcmLongSync => vals::Pcmsync::LONG, |
| 48 | _ => vals::Pcmsync::SHORT, | 60 | _ => vals::Pcmsync::SHORT, |
| @@ -50,6 +62,7 @@ impl Standard { | |||
| 50 | } | 62 | } |
| 51 | } | 63 | } |
| 52 | 64 | ||
| 65 | /// I2S data format. | ||
| 53 | #[derive(Copy, Clone)] | 66 | #[derive(Copy, Clone)] |
| 54 | pub enum Format { | 67 | pub enum Format { |
| 55 | /// 16 bit data length on 16 bit wide channel | 68 | /// 16 bit data length on 16 bit wide channel |
| @@ -64,7 +77,7 @@ pub enum Format { | |||
| 64 | 77 | ||
| 65 | impl Format { | 78 | impl Format { |
| 66 | #[cfg(any(spi_v1, spi_f1))] | 79 | #[cfg(any(spi_v1, spi_f1))] |
| 67 | pub const fn datlen(&self) -> vals::Datlen { | 80 | const fn datlen(&self) -> vals::Datlen { |
| 68 | match self { | 81 | match self { |
| 69 | Format::Data16Channel16 => vals::Datlen::SIXTEENBIT, | 82 | Format::Data16Channel16 => vals::Datlen::SIXTEENBIT, |
| 70 | Format::Data16Channel32 => vals::Datlen::SIXTEENBIT, | 83 | Format::Data16Channel32 => vals::Datlen::SIXTEENBIT, |
| @@ -74,7 +87,7 @@ impl Format { | |||
| 74 | } | 87 | } |
| 75 | 88 | ||
| 76 | #[cfg(any(spi_v1, spi_f1))] | 89 | #[cfg(any(spi_v1, spi_f1))] |
| 77 | pub const fn chlen(&self) -> vals::Chlen { | 90 | const fn chlen(&self) -> vals::Chlen { |
| 78 | match self { | 91 | match self { |
| 79 | Format::Data16Channel16 => vals::Chlen::SIXTEENBIT, | 92 | Format::Data16Channel16 => vals::Chlen::SIXTEENBIT, |
| 80 | Format::Data16Channel32 => vals::Chlen::THIRTYTWOBIT, | 93 | Format::Data16Channel32 => vals::Chlen::THIRTYTWOBIT, |
| @@ -84,15 +97,18 @@ impl Format { | |||
| 84 | } | 97 | } |
| 85 | } | 98 | } |
| 86 | 99 | ||
| 100 | /// Clock polarity | ||
| 87 | #[derive(Copy, Clone)] | 101 | #[derive(Copy, Clone)] |
| 88 | pub enum ClockPolarity { | 102 | pub enum ClockPolarity { |
| 103 | /// Low on idle. | ||
| 89 | IdleLow, | 104 | IdleLow, |
| 105 | /// High on idle. | ||
| 90 | IdleHigh, | 106 | IdleHigh, |
| 91 | } | 107 | } |
| 92 | 108 | ||
| 93 | impl ClockPolarity { | 109 | impl ClockPolarity { |
| 94 | #[cfg(any(spi_v1, spi_f1))] | 110 | #[cfg(any(spi_v1, spi_f1))] |
| 95 | pub const fn ckpol(&self) -> vals::Ckpol { | 111 | const fn ckpol(&self) -> vals::Ckpol { |
| 96 | match self { | 112 | match self { |
| 97 | ClockPolarity::IdleHigh => vals::Ckpol::IDLEHIGH, | 113 | ClockPolarity::IdleHigh => vals::Ckpol::IDLEHIGH, |
| 98 | ClockPolarity::IdleLow => vals::Ckpol::IDLELOW, | 114 | ClockPolarity::IdleLow => vals::Ckpol::IDLELOW, |
| @@ -109,11 +125,17 @@ impl ClockPolarity { | |||
| 109 | #[non_exhaustive] | 125 | #[non_exhaustive] |
| 110 | #[derive(Copy, Clone)] | 126 | #[derive(Copy, Clone)] |
| 111 | pub struct Config { | 127 | pub struct Config { |
| 128 | /// Mode | ||
| 112 | pub mode: Mode, | 129 | pub mode: Mode, |
| 130 | /// Function (transmit, receive) | ||
| 113 | pub function: Function, | 131 | pub function: Function, |
| 132 | /// Which I2S standard to use. | ||
| 114 | pub standard: Standard, | 133 | pub standard: Standard, |
| 134 | /// Data format. | ||
| 115 | pub format: Format, | 135 | pub format: Format, |
| 136 | /// Clock polarity. | ||
| 116 | pub clock_polarity: ClockPolarity, | 137 | pub clock_polarity: ClockPolarity, |
| 138 | /// True to eanble master clock output from this instance. | ||
| 117 | pub master_clock: bool, | 139 | pub master_clock: bool, |
| 118 | } | 140 | } |
| 119 | 141 | ||
| @@ -130,6 +152,7 @@ impl Default for Config { | |||
| 130 | } | 152 | } |
| 131 | } | 153 | } |
| 132 | 154 | ||
| 155 | /// I2S driver. | ||
| 133 | pub struct I2S<'d, T: Instance, Tx, Rx> { | 156 | pub struct I2S<'d, T: Instance, Tx, Rx> { |
| 134 | _peri: Spi<'d, T, Tx, Rx>, | 157 | _peri: Spi<'d, T, Tx, Rx>, |
| 135 | sd: Option<PeripheralRef<'d, AnyPin>>, | 158 | sd: Option<PeripheralRef<'d, AnyPin>>, |
| @@ -242,6 +265,7 @@ impl<'d, T: Instance, Tx, Rx> I2S<'d, T, Tx, Rx> { | |||
| 242 | } | 265 | } |
| 243 | } | 266 | } |
| 244 | 267 | ||
| 268 | /// Write audio data. | ||
| 245 | pub async fn write<W: Word>(&mut self, data: &[W]) -> Result<(), Error> | 269 | pub async fn write<W: Word>(&mut self, data: &[W]) -> Result<(), Error> |
| 246 | where | 270 | where |
| 247 | Tx: TxDma<T>, | 271 | Tx: TxDma<T>, |
| @@ -249,6 +273,7 @@ impl<'d, T: Instance, Tx, Rx> I2S<'d, T, Tx, Rx> { | |||
| 249 | self._peri.write(data).await | 273 | self._peri.write(data).await |
| 250 | } | 274 | } |
| 251 | 275 | ||
| 276 | /// Read audio data. | ||
| 252 | pub async fn read<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> | 277 | pub async fn read<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> |
| 253 | where | 278 | where |
| 254 | Tx: TxDma<T>, | 279 | Tx: TxDma<T>, |
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index dc829a9ad..04a51110c 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | //! Reset and Clock Control (RCC) | ||
| 2 | |||
| 1 | #![macro_use] | 3 | #![macro_use] |
| 4 | #![allow(missing_docs)] // TODO | ||
| 2 | 5 | ||
| 3 | use core::mem::MaybeUninit; | 6 | use core::mem::MaybeUninit; |
| 4 | 7 | ||
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 5e6922e9b..b2196b0d5 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -13,13 +13,19 @@ use crate::{interrupt, pac, peripherals, Peripheral}; | |||
| 13 | 13 | ||
| 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); | 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); |
| 15 | 15 | ||
| 16 | /// RNG error | ||
| 16 | #[derive(Debug, PartialEq, Eq)] | 17 | #[derive(Debug, PartialEq, Eq)] |
| 17 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 18 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 18 | pub enum Error { | 19 | pub enum Error { |
| 20 | /// Seed error. | ||
| 19 | SeedError, | 21 | SeedError, |
| 22 | /// Clock error. Double-check the RCC configuration, | ||
| 23 | /// see the Reference Manual for details on restrictions | ||
| 24 | /// on RNG clocks. | ||
| 20 | ClockError, | 25 | ClockError, |
| 21 | } | 26 | } |
| 22 | 27 | ||
| 28 | /// RNG interrupt handler. | ||
| 23 | pub struct InterruptHandler<T: Instance> { | 29 | pub struct InterruptHandler<T: Instance> { |
| 24 | _phantom: PhantomData<T>, | 30 | _phantom: PhantomData<T>, |
| 25 | } | 31 | } |
| @@ -34,11 +40,13 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 34 | } | 40 | } |
| 35 | } | 41 | } |
| 36 | 42 | ||
| 43 | /// RNG driver. | ||
| 37 | pub struct Rng<'d, T: Instance> { | 44 | pub struct Rng<'d, T: Instance> { |
| 38 | _inner: PeripheralRef<'d, T>, | 45 | _inner: PeripheralRef<'d, T>, |
| 39 | } | 46 | } |
| 40 | 47 | ||
| 41 | impl<'d, T: Instance> Rng<'d, T> { | 48 | impl<'d, T: Instance> Rng<'d, T> { |
| 49 | /// Create a new RNG driver. | ||
| 42 | pub fn new( | 50 | pub fn new( |
| 43 | inner: impl Peripheral<P = T> + 'd, | 51 | inner: impl Peripheral<P = T> + 'd, |
| 44 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 52 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| @@ -54,6 +62,7 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 54 | random | 62 | random |
| 55 | } | 63 | } |
| 56 | 64 | ||
| 65 | /// Reset the RNG. | ||
| 57 | #[cfg(rng_v1)] | 66 | #[cfg(rng_v1)] |
| 58 | pub fn reset(&mut self) { | 67 | pub fn reset(&mut self) { |
| 59 | T::regs().cr().write(|reg| { | 68 | T::regs().cr().write(|reg| { |
| @@ -106,7 +115,8 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 106 | while T::regs().cr().read().condrst() {} | 115 | while T::regs().cr().read().condrst() {} |
| 107 | } | 116 | } |
| 108 | 117 | ||
| 109 | pub fn recover_seed_error(&mut self) -> () { | 118 | /// Try to recover from a seed error. |
| 119 | pub fn recover_seed_error(&mut self) { | ||
| 110 | self.reset(); | 120 | self.reset(); |
| 111 | // reset should also clear the SEIS flag | 121 | // reset should also clear the SEIS flag |
| 112 | if T::regs().sr().read().seis() { | 122 | if T::regs().sr().read().seis() { |
| @@ -117,6 +127,7 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 117 | while T::regs().sr().read().secs() {} | 127 | while T::regs().sr().read().secs() {} |
| 118 | } | 128 | } |
| 119 | 129 | ||
| 130 | /// Fill the given slice with random values. | ||
| 120 | pub async fn async_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { | 131 | pub async fn async_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { |
| 121 | for chunk in dest.chunks_mut(4) { | 132 | for chunk in dest.chunks_mut(4) { |
| 122 | let mut bits = T::regs().sr().read(); | 133 | let mut bits = T::regs().sr().read(); |
| @@ -217,7 +228,9 @@ pub(crate) mod sealed { | |||
| 217 | } | 228 | } |
| 218 | } | 229 | } |
| 219 | 230 | ||
| 231 | /// RNG instance trait. | ||
| 220 | pub trait Instance: sealed::Instance + Peripheral<P = Self> + crate::rcc::RccPeripheral + 'static + Send { | 232 | pub trait Instance: sealed::Instance + Peripheral<P = Self> + crate::rcc::RccPeripheral + 'static + Send { |
| 233 | /// Interrupt for this RNG instance. | ||
| 221 | type Interrupt: interrupt::typelevel::Interrupt; | 234 | type Interrupt: interrupt::typelevel::Interrupt; |
| 222 | } | 235 | } |
| 223 | 236 | ||
diff --git a/embassy-stm32/src/rtc/datetime.rs b/embassy-stm32/src/rtc/datetime.rs index f4e86dd87..ef92fa4bb 100644 --- a/embassy-stm32/src/rtc/datetime.rs +++ b/embassy-stm32/src/rtc/datetime.rs | |||
| @@ -104,45 +104,51 @@ pub struct DateTime { | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | impl DateTime { | 106 | impl DateTime { |
| 107 | /// Get the year (0..=4095) | ||
| 107 | pub const fn year(&self) -> u16 { | 108 | pub const fn year(&self) -> u16 { |
| 108 | self.year | 109 | self.year |
| 109 | } | 110 | } |
| 110 | 111 | ||
| 112 | /// Get the month (1..=12, 1 is January) | ||
| 111 | pub const fn month(&self) -> u8 { | 113 | pub const fn month(&self) -> u8 { |
| 112 | self.month | 114 | self.month |
| 113 | } | 115 | } |
| 114 | 116 | ||
| 117 | /// Get the day (1..=31) | ||
| 115 | pub const fn day(&self) -> u8 { | 118 | pub const fn day(&self) -> u8 { |
| 116 | self.day | 119 | self.day |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 122 | /// Get the day of week | ||
| 119 | pub const fn day_of_week(&self) -> DayOfWeek { | 123 | pub const fn day_of_week(&self) -> DayOfWeek { |
| 120 | self.day_of_week | 124 | self.day_of_week |
| 121 | } | 125 | } |
| 122 | 126 | ||
| 127 | /// Get the hour (0..=23) | ||
| 123 | pub const fn hour(&self) -> u8 { | 128 | pub const fn hour(&self) -> u8 { |
| 124 | self.hour | 129 | self.hour |
| 125 | } | 130 | } |
| 126 | 131 | ||
| 132 | /// Get the minute (0..=59) | ||
| 127 | pub const fn minute(&self) -> u8 { | 133 | pub const fn minute(&self) -> u8 { |
| 128 | self.minute | 134 | self.minute |
| 129 | } | 135 | } |
| 130 | 136 | ||
| 137 | /// Get the second (0..=59) | ||
| 131 | pub const fn second(&self) -> u8 { | 138 | pub const fn second(&self) -> u8 { |
| 132 | self.second | 139 | self.second |
| 133 | } | 140 | } |
| 134 | 141 | ||
| 142 | /// Create a new DateTime with the given information. | ||
| 135 | pub fn from( | 143 | pub fn from( |
| 136 | year: u16, | 144 | year: u16, |
| 137 | month: u8, | 145 | month: u8, |
| 138 | day: u8, | 146 | day: u8, |
| 139 | day_of_week: u8, | 147 | day_of_week: DayOfWeek, |
| 140 | hour: u8, | 148 | hour: u8, |
| 141 | minute: u8, | 149 | minute: u8, |
| 142 | second: u8, | 150 | second: u8, |
| 143 | ) -> Result<Self, Error> { | 151 | ) -> Result<Self, Error> { |
| 144 | let day_of_week = day_of_week_from_u8(day_of_week)?; | ||
| 145 | |||
| 146 | if year > 4095 { | 152 | if year > 4095 { |
| 147 | Err(Error::InvalidYear) | 153 | Err(Error::InvalidYear) |
| 148 | } else if month < 1 || month > 12 { | 154 | } else if month < 1 || month > 12 { |
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index b4315f535..fa359cdae 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -9,9 +9,9 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 9 | #[cfg(feature = "low-power")] | 9 | #[cfg(feature = "low-power")] |
| 10 | use embassy_sync::blocking_mutex::Mutex; | 10 | use embassy_sync::blocking_mutex::Mutex; |
| 11 | 11 | ||
| 12 | use self::datetime::day_of_week_to_u8; | ||
| 13 | #[cfg(not(rtc_v2f2))] | 12 | #[cfg(not(rtc_v2f2))] |
| 14 | use self::datetime::RtcInstant; | 13 | use self::datetime::RtcInstant; |
| 14 | use self::datetime::{day_of_week_from_u8, day_of_week_to_u8}; | ||
| 15 | pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; | 15 | pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; |
| 16 | use crate::pac::rtc::regs::{Dr, Tr}; | 16 | use crate::pac::rtc::regs::{Dr, Tr}; |
| 17 | use crate::time::Hertz; | 17 | use crate::time::Hertz; |
| @@ -102,7 +102,7 @@ pub enum RtcError { | |||
| 102 | NotRunning, | 102 | NotRunning, |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | pub struct RtcTimeProvider { | 105 | pub(crate) struct RtcTimeProvider { |
| 106 | _private: (), | 106 | _private: (), |
| 107 | } | 107 | } |
| 108 | 108 | ||
| @@ -127,7 +127,7 @@ impl RtcTimeProvider { | |||
| 127 | let minute = bcd2_to_byte((tr.mnt(), tr.mnu())); | 127 | let minute = bcd2_to_byte((tr.mnt(), tr.mnu())); |
| 128 | let hour = bcd2_to_byte((tr.ht(), tr.hu())); | 128 | let hour = bcd2_to_byte((tr.ht(), tr.hu())); |
| 129 | 129 | ||
| 130 | let weekday = dr.wdu(); | 130 | let weekday = day_of_week_from_u8(dr.wdu()).map_err(RtcError::InvalidDateTime)?; |
| 131 | let day = bcd2_to_byte((dr.dt(), dr.du())); | 131 | let day = bcd2_to_byte((dr.dt(), dr.du())); |
| 132 | let month = bcd2_to_byte((dr.mt() as u8, dr.mu())); | 132 | let month = bcd2_to_byte((dr.mt() as u8, dr.mu())); |
| 133 | let year = bcd2_to_byte((dr.yt(), dr.yu())) as u16 + 1970_u16; | 133 | let year = bcd2_to_byte((dr.yt(), dr.yu())) as u16 + 1970_u16; |
| @@ -171,6 +171,7 @@ pub struct Rtc { | |||
| 171 | _private: (), | 171 | _private: (), |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | /// RTC configuration. | ||
| 174 | #[non_exhaustive] | 175 | #[non_exhaustive] |
| 175 | #[derive(Copy, Clone, PartialEq)] | 176 | #[derive(Copy, Clone, PartialEq)] |
| 176 | pub struct RtcConfig { | 177 | pub struct RtcConfig { |
| @@ -188,6 +189,7 @@ impl Default for RtcConfig { | |||
| 188 | } | 189 | } |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 192 | /// Calibration cycle period. | ||
| 191 | #[derive(Copy, Clone, Debug, PartialEq)] | 193 | #[derive(Copy, Clone, Debug, PartialEq)] |
| 192 | #[repr(u8)] | 194 | #[repr(u8)] |
| 193 | pub enum RtcCalibrationCyclePeriod { | 195 | pub enum RtcCalibrationCyclePeriod { |
| @@ -206,6 +208,7 @@ impl Default for RtcCalibrationCyclePeriod { | |||
| 206 | } | 208 | } |
| 207 | 209 | ||
| 208 | impl Rtc { | 210 | impl Rtc { |
| 211 | /// Create a new RTC instance. | ||
| 209 | pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self { | 212 | pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self { |
| 210 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] | 213 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] |
| 211 | <RTC as crate::rcc::sealed::RccPeripheral>::enable_and_reset(); | 214 | <RTC as crate::rcc::sealed::RccPeripheral>::enable_and_reset(); |
| @@ -240,7 +243,7 @@ impl Rtc { | |||
| 240 | } | 243 | } |
| 241 | 244 | ||
| 242 | /// Acquire a [`RtcTimeProvider`] instance. | 245 | /// Acquire a [`RtcTimeProvider`] instance. |
| 243 | pub const fn time_provider(&self) -> RtcTimeProvider { | 246 | pub(crate) const fn time_provider(&self) -> RtcTimeProvider { |
| 244 | RtcTimeProvider { _private: () } | 247 | RtcTimeProvider { _private: () } |
| 245 | } | 248 | } |
| 246 | 249 | ||
| @@ -315,6 +318,7 @@ impl Rtc { | |||
| 315 | }) | 318 | }) |
| 316 | } | 319 | } |
| 317 | 320 | ||
| 321 | /// Number of backup registers of this instance. | ||
| 318 | pub const BACKUP_REGISTER_COUNT: usize = RTC::BACKUP_REGISTER_COUNT; | 322 | pub const BACKUP_REGISTER_COUNT: usize = RTC::BACKUP_REGISTER_COUNT; |
| 319 | 323 | ||
| 320 | /// Read content of the backup register. | 324 | /// Read content of the backup register. |
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 6654366cd..e543a5b43 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | //! PWM driver with complementary output support. | ||
| 2 | |||
| 1 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 2 | 4 | ||
| 3 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 9f93c6425..42ef878f7 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | //! Timers, PWM, quadrature decoder. | ||
| 2 | |||
| 1 | pub mod complementary_pwm; | 3 | pub mod complementary_pwm; |
| 2 | pub mod qei; | 4 | pub mod qei; |
| 3 | pub mod simple_pwm; | 5 | pub mod simple_pwm; |
| @@ -8,6 +10,7 @@ use crate::interrupt; | |||
| 8 | use crate::rcc::RccPeripheral; | 10 | use crate::rcc::RccPeripheral; |
| 9 | use crate::time::Hertz; | 11 | use crate::time::Hertz; |
| 10 | 12 | ||
| 13 | /// Low-level timer access. | ||
| 11 | #[cfg(feature = "unstable-pac")] | 14 | #[cfg(feature = "unstable-pac")] |
| 12 | pub mod low_level { | 15 | pub mod low_level { |
| 13 | pub use super::sealed::*; | 16 | pub use super::sealed::*; |
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index 01d028bf9..9f9379c20 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | //! Quadrature decoder using a timer. | ||
| 2 | |||
| 1 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 2 | 4 | ||
| 3 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 1cf0ad728..234bbaff0 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | //! Simple PWM driver. | ||
| 2 | |||
| 1 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 2 | 4 | ||
| 3 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
