diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/crc | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/crc')
| -rw-r--r-- | embassy-stm32/src/crc/v1.rs | 11 | ||||
| -rw-r--r-- | embassy-stm32/src/crc/v2v3.rs | 9 |
2 files changed, 6 insertions, 14 deletions
diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs index f3d13de7c..a78b3c2b7 100644 --- a/embassy-stm32/src/crc/v1.rs +++ b/embassy-stm32/src/crc/v1.rs | |||
| @@ -1,23 +1,18 @@ | |||
| 1 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 2 | |||
| 3 | use crate::pac::CRC as PAC_CRC; | 1 | use crate::pac::CRC as PAC_CRC; |
| 4 | use crate::peripherals::CRC; | 2 | use crate::peripherals::CRC; |
| 5 | use crate::{rcc, Peripheral}; | 3 | use crate::{rcc, Peri}; |
| 6 | 4 | ||
| 7 | /// CRC driver. | 5 | /// CRC driver. |
| 8 | pub struct Crc<'d> { | 6 | pub struct Crc<'d> { |
| 9 | _peri: PeripheralRef<'d, CRC>, | 7 | _peri: Peri<'d, CRC>, |
| 10 | } | 8 | } |
| 11 | 9 | ||
| 12 | impl<'d> Crc<'d> { | 10 | impl<'d> Crc<'d> { |
| 13 | /// Instantiates the CRC32 peripheral and initializes it to default values. | 11 | /// Instantiates the CRC32 peripheral and initializes it to default values. |
| 14 | pub fn new(peripheral: impl Peripheral<P = CRC> + 'd) -> Self { | 12 | pub fn new(peripheral: Peri<'d, CRC>) -> Self { |
| 15 | into_ref!(peripheral); | ||
| 16 | |||
| 17 | // Note: enable and reset come from RccPeripheral. | 13 | // Note: enable and reset come from RccPeripheral. |
| 18 | // enable CRC clock in RCC. | 14 | // enable CRC clock in RCC. |
| 19 | rcc::enable_and_reset::<CRC>(); | 15 | rcc::enable_and_reset::<CRC>(); |
| 20 | // Peripheral the peripheral | ||
| 21 | let mut instance = Self { _peri: peripheral }; | 16 | let mut instance = Self { _peri: peripheral }; |
| 22 | instance.reset(); | 17 | instance.reset(); |
| 23 | instance | 18 | instance |
diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs index ecb507ff4..c94c9f380 100644 --- a/embassy-stm32/src/crc/v2v3.rs +++ b/embassy-stm32/src/crc/v2v3.rs | |||
| @@ -1,13 +1,11 @@ | |||
| 1 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 2 | |||
| 3 | use crate::pac::crc::vals; | 1 | use crate::pac::crc::vals; |
| 4 | use crate::pac::CRC as PAC_CRC; | 2 | use crate::pac::CRC as PAC_CRC; |
| 5 | use crate::peripherals::CRC; | 3 | use crate::peripherals::CRC; |
| 6 | use crate::{rcc, Peripheral}; | 4 | use crate::{rcc, Peri}; |
| 7 | 5 | ||
| 8 | /// CRC driver. | 6 | /// CRC driver. |
| 9 | pub struct Crc<'d> { | 7 | pub struct Crc<'d> { |
| 10 | _peripheral: PeripheralRef<'d, CRC>, | 8 | _peripheral: Peri<'d, CRC>, |
| 11 | _config: Config, | 9 | _config: Config, |
| 12 | } | 10 | } |
| 13 | 11 | ||
| @@ -80,11 +78,10 @@ pub enum PolySize { | |||
| 80 | 78 | ||
| 81 | impl<'d> Crc<'d> { | 79 | impl<'d> Crc<'d> { |
| 82 | /// Instantiates the CRC32 peripheral and initializes it to default values. | 80 | /// Instantiates the CRC32 peripheral and initializes it to default values. |
| 83 | pub fn new(peripheral: impl Peripheral<P = CRC> + 'd, config: Config) -> Self { | 81 | pub fn new(peripheral: Peri<'d, CRC>, config: Config) -> Self { |
| 84 | // Note: enable and reset come from RccPeripheral. | 82 | // Note: enable and reset come from RccPeripheral. |
| 85 | // reset to default values and enable CRC clock in RCC. | 83 | // reset to default values and enable CRC clock in RCC. |
| 86 | rcc::enable_and_reset::<CRC>(); | 84 | rcc::enable_and_reset::<CRC>(); |
| 87 | into_ref!(peripheral); | ||
| 88 | let mut instance = Self { | 85 | let mut instance = Self { |
| 89 | _peripheral: peripheral, | 86 | _peripheral: peripheral, |
| 90 | _config: config, | 87 | _config: config, |
