aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/cryp
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/cryp
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/cryp')
-rw-r--r--embassy-stm32/src/cryp/mod.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/embassy-stm32/src/cryp/mod.rs b/embassy-stm32/src/cryp/mod.rs
index 54d2c30e5..fba3c0fd7 100644
--- a/embassy-stm32/src/cryp/mod.rs
+++ b/embassy-stm32/src/cryp/mod.rs
@@ -4,13 +4,13 @@ use core::cmp::min;
4use core::marker::PhantomData; 4use core::marker::PhantomData;
5use core::ptr; 5use core::ptr;
6 6
7use embassy_hal_internal::{into_ref, PeripheralRef}; 7use embassy_hal_internal::{Peri, PeripheralType};
8use embassy_sync::waitqueue::AtomicWaker; 8use embassy_sync::waitqueue::AtomicWaker;
9 9
10use crate::dma::{ChannelAndRequest, TransferOptions}; 10use crate::dma::{ChannelAndRequest, TransferOptions};
11use crate::interrupt::typelevel::Interrupt; 11use crate::interrupt::typelevel::Interrupt;
12use crate::mode::{Async, Blocking, Mode}; 12use crate::mode::{Async, Blocking, Mode};
13use crate::{interrupt, pac, peripherals, rcc, Peripheral}; 13use crate::{interrupt, pac, peripherals, rcc};
14 14
15const DES_BLOCK_SIZE: usize = 8; // 64 bits 15const DES_BLOCK_SIZE: usize = 8; // 64 bits
16const AES_BLOCK_SIZE: usize = 16; // 128 bits 16const AES_BLOCK_SIZE: usize = 16; // 128 bits
@@ -988,7 +988,7 @@ pub enum Direction {
988 988
989/// Crypto Accelerator Driver 989/// Crypto Accelerator Driver
990pub struct Cryp<'d, T: Instance, M: Mode> { 990pub struct Cryp<'d, T: Instance, M: Mode> {
991 _peripheral: PeripheralRef<'d, T>, 991 _peripheral: Peri<'d, T>,
992 _phantom: PhantomData<M>, 992 _phantom: PhantomData<M>,
993 indma: Option<ChannelAndRequest<'d>>, 993 indma: Option<ChannelAndRequest<'d>>,
994 outdma: Option<ChannelAndRequest<'d>>, 994 outdma: Option<ChannelAndRequest<'d>>,
@@ -997,11 +997,10 @@ pub struct Cryp<'d, T: Instance, M: Mode> {
997impl<'d, T: Instance> Cryp<'d, T, Blocking> { 997impl<'d, T: Instance> Cryp<'d, T, Blocking> {
998 /// Create a new CRYP driver in blocking mode. 998 /// Create a new CRYP driver in blocking mode.
999 pub fn new_blocking( 999 pub fn new_blocking(
1000 peri: impl Peripheral<P = T> + 'd, 1000 peri: Peri<'d, T>,
1001 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, 1001 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
1002 ) -> Self { 1002 ) -> Self {
1003 rcc::enable_and_reset::<T>(); 1003 rcc::enable_and_reset::<T>();
1004 into_ref!(peri);
1005 let instance = Self { 1004 let instance = Self {
1006 _peripheral: peri, 1005 _peripheral: peri,
1007 _phantom: PhantomData, 1006 _phantom: PhantomData,
@@ -1461,13 +1460,12 @@ impl<'d, T: Instance, M: Mode> Cryp<'d, T, M> {
1461impl<'d, T: Instance> Cryp<'d, T, Async> { 1460impl<'d, T: Instance> Cryp<'d, T, Async> {
1462 /// Create a new CRYP driver. 1461 /// Create a new CRYP driver.
1463 pub fn new( 1462 pub fn new(
1464 peri: impl Peripheral<P = T> + 'd, 1463 peri: Peri<'d, T>,
1465 indma: impl Peripheral<P = impl DmaIn<T>> + 'd, 1464 indma: Peri<'d, impl DmaIn<T>>,
1466 outdma: impl Peripheral<P = impl DmaOut<T>> + 'd, 1465 outdma: Peri<'d, impl DmaOut<T>>,
1467 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, 1466 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
1468 ) -> Self { 1467 ) -> Self {
1469 rcc::enable_and_reset::<T>(); 1468 rcc::enable_and_reset::<T>();
1470 into_ref!(peri, indma, outdma);
1471 let instance = Self { 1469 let instance = Self {
1472 _peripheral: peri, 1470 _peripheral: peri,
1473 _phantom: PhantomData, 1471 _phantom: PhantomData,
@@ -1879,7 +1877,7 @@ trait SealedInstance {
1879 1877
1880/// CRYP instance trait. 1878/// CRYP instance trait.
1881#[allow(private_bounds)] 1879#[allow(private_bounds)]
1882pub trait Instance: SealedInstance + Peripheral<P = Self> + crate::rcc::RccPeripheral + 'static + Send { 1880pub trait Instance: SealedInstance + PeripheralType + crate::rcc::RccPeripheral + 'static + Send {
1883 /// Interrupt for this CRYP instance. 1881 /// Interrupt for this CRYP instance.
1884 type Interrupt: interrupt::typelevel::Interrupt; 1882 type Interrupt: interrupt::typelevel::Interrupt;
1885} 1883}