Skip to content

Commit

Permalink
allow static_mut_refs - even morer
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Dec 14, 2024
1 parent 113fad5 commit 3f6ac3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/ethernet-rtic-nucleo-h723zg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ mod app {

let mac_addr = smoltcp::wire::EthernetAddress::from_bytes(&MAC_ADDRESS);
let (eth_dma, eth_mac) = unsafe {
#[allow(static_mut_refs)] // TODO: Fix this
DES_RING.write(ethernet::DesRing::new());

ethernet::new(
Expand All @@ -181,6 +182,7 @@ mod app {
rmii_txd0,
rmii_txd1,
),
#[allow(static_mut_refs)] // TODO: Fix this
DES_RING.assume_init_mut(),
mac_addr,
ccdr.peripheral.ETH1MAC,
Expand All @@ -198,6 +200,7 @@ mod app {

// unsafe: mutable reference to static storage, we only do this once
let store = unsafe {
#[allow(static_mut_refs)] // TODO: Fix this
let store_ptr = STORE.as_mut_ptr();

// Initialise the socket_storage field. Using `write` instead of
Expand All @@ -208,6 +211,7 @@ mod app {

// Now that all fields are initialised we can safely use
// assume_init_mut to return a mutable reference to STORE
#[allow(static_mut_refs)] // TODO: Fix this
STORE.assume_init_mut()
};

Expand Down
4 changes: 4 additions & 0 deletions examples/ethernet-rtic-stm32h735g-dk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ mod app {

let mac_addr = smoltcp::wire::EthernetAddress::from_bytes(&MAC_ADDRESS);
let (eth_dma, eth_mac) = unsafe {
#[allow(static_mut_refs)] // TODO: Fix this
DES_RING.write(ethernet::DesRing::new());

ethernet::new(
Expand All @@ -175,6 +176,7 @@ mod app {
rmii_txd0,
rmii_txd1,
),
#[allow(static_mut_refs)] // TODO: Fix this
DES_RING.assume_init_mut(),
mac_addr,
ccdr.peripheral.ETH1MAC,
Expand All @@ -192,6 +194,7 @@ mod app {

// unsafe: mutable reference to static storage, we only do this once
let store = unsafe {
#[allow(static_mut_refs)] // TODO: Fix this
let store_ptr = STORE.as_mut_ptr();

// Initialise the socket_storage field. Using `write` instead of
Expand All @@ -202,6 +205,7 @@ mod app {

// Now that all fields are initialised we can safely use
// assume_init_mut to return a mutable reference to STORE
#[allow(static_mut_refs)] // TODO: Fix this
STORE.assume_init_mut()
};

Expand Down

0 comments on commit 3f6ac3f

Please sign in to comment.