Skip to content

Commit 15b22a7

Browse files
committed
main: moved static_init from dma, usart, exti to the main
1 parent 1db9304 commit 15b22a7

4 files changed

Lines changed: 12 additions & 18 deletions

File tree

boards/nucleo_u545re_q/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,18 @@ unsafe fn start() -> (
136136
>();
137137

138138
// Create Individual Drivers
139-
let exti = stm32u545::exti::init();
140-
let dma1 = stm32u545::dma::init();
141-
let usart1 = stm32u545::usart::init();
139+
let exti = static_init!(
140+
stm32u545::exti::Exti<'static>,
141+
stm32u545::exti::Exti::new(stm32u545::exti::EXTI_BASE)
142+
);
143+
let dma1 = static_init!(
144+
stm32u545::dma::Dma,
145+
stm32u545::dma::Dma::new(stm32u545::dma::DMA1_BASE)
146+
);
147+
let usart1 = static_init!(
148+
stm32u545::usart::Usart<'static>,
149+
stm32u545::usart::Usart::new(stm32u545::usart::USART1_BASE)
150+
);
142151

143152
// Link DMA to USART1
144153
usart1.set_dma(dma1, 0, 1);

chips/stm32u5xx/src/dma.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,3 @@ impl Dma {
147147
ch.f_cr.set(0x0000FFFF);
148148
}
149149
}
150-
151-
/// Factory function to create the DMA1 driver.
152-
pub unsafe fn init() -> &'static Dma {
153-
kernel::static_init!(Dma, Dma::new(DMA1_BASE))
154-
}

chips/stm32u5xx/src/exti.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,3 @@ impl<'a> Exti<'a> {
142142
(self.registers.rpr1.get() | self.registers.fpr1.get()) & (1 << (line as u32)) != 0
143143
}
144144
}
145-
146-
/// Factory function to create the EXTI driver.
147-
pub unsafe fn init() -> &'static Exti<'static> {
148-
kernel::static_init!(Exti<'static>, Exti::new(EXTI_BASE))
149-
}

chips/stm32u5xx/src/usart.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,3 @@ impl<'a> uart::Receive<'a> for Usart<'a> {
297297
Err(kernel::ErrorCode::NOSUPPORT)
298298
}
299299
}
300-
301-
/// Factory function to create the USART1 driver.
302-
pub unsafe fn init() -> &'static Usart<'static> {
303-
kernel::static_init!(Usart, Usart::new(USART1_BASE))
304-
}

0 commit comments

Comments
 (0)