common: Initialize PeripheralMutex state with closure to ensure it's done in-place.

This commit is contained in:
Dario Nieuwenhuis
2021-08-02 20:13:41 +02:00
parent e238079d7d
commit 3f28bb6c77
4 changed files with 28 additions and 29 deletions

View File

@ -78,10 +78,8 @@ impl<'d, P: PHY, const TX: usize, const RX: usize> Ethernet<'d, P, TX, RX> {
tx_d1.configure();
tx_en.configure();
let inner = Inner::new(peri);
// NOTE(unsafe) We are ourselves not leak-safe.
let state = PeripheralMutex::new_unchecked(&mut state.0, inner, interrupt);
let state = PeripheralMutex::new_unchecked(interrupt, &mut state.0, || Inner::new(peri));
// NOTE(unsafe) We have exclusive access to the registers
let dma = ETH.ethernet_dma();