From c24bb3a4505fd552e41d2e61f464dc1c742d5c2b Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 7 Jun 2025 02:42:25 +0800 Subject: [PATCH] add irq_status_bits() trait and enum for selecting Irq bank multiple IRQs related to the UDMA will eventually get mapped into the global IRQ handler for UDMA. Create an enum type that will help us differentiate this and add a trait that returns the raw bits for a given IRQ type. Probably a fancier wrapper should be made to interptet the IRQ bits but unfortunately there isn't a uniform pattern to the IRQ mappings, it's pretty much whatever fit into the IRQ space based on the underlying function. At the moment not even sure if this is the right register to be chasing, so we'll use this for probing that aspect and then get fancy later, maybe. --- libs/cramium-api/src/udma.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/cramium-api/src/udma.rs b/libs/cramium-api/src/udma.rs index cd23c7a53..b11550aad 100644 --- a/libs/cramium-api/src/udma.rs +++ b/libs/cramium-api/src/udma.rs @@ -233,6 +233,11 @@ pub enum EventChannel { Channel3 = 24, } +#[derive(Debug, Copy, Clone, num_derive::FromPrimitive)] +pub enum IrqBank { + I2c, +} + /// Use a trait that will allow us to share code between both `std` and `no-std` implementations pub trait UdmaGlobalConfig { fn clock(&self, peripheral: PeriphId, enable: bool); @@ -243,4 +248,5 @@ pub trait UdmaGlobalConfig { to_channel: EventChannel, ); fn reset(&self, peripheral: PeriphId); + fn irq_status_bits(&self, bank: IrqBank) -> u32; }