From 7399c4a6daf52cf767ee2fb1db77ab81014bde1f Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 6 Oct 2024 02:44:16 +0800 Subject: [PATCH] add mapping for i2c channels to global clocks; fix typo --- libs/cramium-hal/src/udma/mod.rs | 11 +++++++++++ libs/cramium-hal/src/udma/spim.rs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/cramium-hal/src/udma/mod.rs b/libs/cramium-hal/src/udma/mod.rs index 4717c1a6f..10cda9c77 100644 --- a/libs/cramium-hal/src/udma/mod.rs +++ b/libs/cramium-hal/src/udma/mod.rs @@ -71,6 +71,17 @@ impl From for PeriphId { } } +impl From for PeriphId { + fn from(value: I2cChannel) -> Self { + match value { + I2cChannel::Channel0 => PeriphId::I2c0, + I2cChannel::Channel1 => PeriphId::I2c1, + I2cChannel::Channel2 => PeriphId::I2c2, + I2cChannel::Channel3 => PeriphId::I2c3, + } + } +} + #[repr(u32)] #[derive(Copy, Clone)] pub enum PeriphEventId { diff --git a/libs/cramium-hal/src/udma/spim.rs b/libs/cramium-hal/src/udma/spim.rs index 147dd5a5d..fe7ad456a 100644 --- a/libs/cramium-hal/src/udma/spim.rs +++ b/libs/cramium-hal/src/udma/spim.rs @@ -241,7 +241,7 @@ impl Spim { 4096, xous::MemoryFlags::R | xous::MemoryFlags::W, ) - .expect("couldn't map serial port"); + .expect("couldn't map spim port"); let csr = CSR::new(csr_range.as_mut_ptr() as *mut u32); let clk_div = sys_clk_freq / (2 * spi_clk_freq);