From 81637f119b264f20b4100cfc6c2ca5fe36a4fbeb Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 1 Oct 2024 23:13:08 +0800 Subject: [PATCH] add helper to translate return values from io setup to udma clock channels this allows us to tease out the clock setting code from the pin setting code. probably will need to add more helpers for other peripherals as we continue through with this exercise. --- libs/cramium-hal/src/udma.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cramium-hal/src/udma.rs b/libs/cramium-hal/src/udma.rs index ad80f27ea..c713a42b9 100644 --- a/libs/cramium-hal/src/udma.rs +++ b/libs/cramium-hal/src/udma.rs @@ -52,6 +52,18 @@ pub enum PeriphId { impl Into for PeriphId { fn into(self) -> u32 { self as u32 } } + +impl From for PeriphId { + fn from(value: SpimChannel) -> Self { + match value { + SpimChannel::Channel0 => PeriphId::Spim0, + SpimChannel::Channel1 => PeriphId::Spim1, + SpimChannel::Channel2 => PeriphId::Spim2, + SpimChannel::Channel3 => PeriphId::Spim3, + } + } +} + #[repr(u32)] #[derive(Copy, Clone)] pub enum PeriphEventId {