stm32/i2c: use one static per instance instead of an array.
This commit is contained in:
@ -21,9 +21,10 @@ pub enum Error {
|
||||
}
|
||||
|
||||
pub(crate) mod sealed {
|
||||
use super::*;
|
||||
pub trait Instance: crate::rcc::RccPeripheral {
|
||||
fn regs() -> crate::pac::i2c::I2c;
|
||||
fn state_number() -> usize;
|
||||
fn state() -> &'static State;
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,24 +37,6 @@ pin_trait!(SdaPin, Instance);
|
||||
dma_trait!(RxDma, Instance);
|
||||
dma_trait!(TxDma, Instance);
|
||||
|
||||
macro_rules! i2c_state {
|
||||
(I2C1) => {
|
||||
0
|
||||
};
|
||||
(I2C2) => {
|
||||
1
|
||||
};
|
||||
(I2C3) => {
|
||||
2
|
||||
};
|
||||
(I2C4) => {
|
||||
3
|
||||
};
|
||||
(I2C5) => {
|
||||
4
|
||||
};
|
||||
}
|
||||
|
||||
crate::pac::interrupts!(
|
||||
($inst:ident, i2c, $block:ident, EV, $irq:ident) => {
|
||||
impl sealed::Instance for peripherals::$inst {
|
||||
@ -61,8 +44,9 @@ crate::pac::interrupts!(
|
||||
crate::pac::$inst
|
||||
}
|
||||
|
||||
fn state_number() -> usize {
|
||||
i2c_state!($inst)
|
||||
fn state() -> &'static State {
|
||||
static STATE: State = State::new();
|
||||
&STATE
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user