stm32/eth_v2: update to new embassy-net trait, remove PeripheralMutex.

This commit is contained in:
Dario Nieuwenhuis
2022-12-12 02:04:33 +01:00
parent 8f30652109
commit 3005ee0178
4 changed files with 289 additions and 487 deletions

View File

@ -7,7 +7,7 @@ use embassy_executor::Spawner;
use embassy_net::tcp::TcpSocket;
use embassy_net::{Ipv4Address, Stack, StackResources};
use embassy_stm32::eth::generic_smi::GenericSMI;
use embassy_stm32::eth::{Ethernet, State};
use embassy_stm32::eth::{Ethernet, PacketQueue};
use embassy_stm32::peripherals::ETH;
use embassy_stm32::rng::Rng;
use embassy_stm32::time::mhz;
@ -22,11 +22,12 @@ macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
let (x,) = STATIC_CELL.init(($val,));
x
}};
}
type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>;
type Device = Ethernet<'static, ETH, GenericSMI>;
#[embassy_executor::task]
async fn net_task(stack: &'static Stack<Device>) -> ! {
@ -51,25 +52,23 @@ async fn main(spawner: Spawner) -> ! {
let eth_int = interrupt::take!(ETH);
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
let device = unsafe {
Ethernet::new(
singleton!(State::new()),
p.ETH,
eth_int,
p.PA1,
p.PA2,
p.PC1,
p.PA7,
p.PC4,
p.PC5,
p.PG13,
p.PB13,
p.PG11,
GenericSMI,
mac_addr,
0,
)
};
let device = Ethernet::new(
singleton!(PacketQueue::<16, 16>::new()),
p.ETH,
eth_int,
p.PA1,
p.PA2,
p.PC1,
p.PA7,
p.PC4,
p.PC5,
p.PG13,
p.PB13,
p.PG11,
GenericSMI,
mac_addr,
0,
);
let config = embassy_net::ConfigStrategy::Dhcp;
//let config = embassy_net::ConfigStrategy::Static(embassy_net::Config {

View File

@ -7,7 +7,7 @@ use embassy_executor::Spawner;
use embassy_net::tcp::client::{TcpClient, TcpClientState};
use embassy_net::{Stack, StackResources};
use embassy_stm32::eth::generic_smi::GenericSMI;
use embassy_stm32::eth::{Ethernet, State};
use embassy_stm32::eth::{Ethernet, PacketQueue};
use embassy_stm32::peripherals::ETH;
use embassy_stm32::rng::Rng;
use embassy_stm32::time::mhz;
@ -23,11 +23,12 @@ macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
let (x,) = STATIC_CELL.init(($val,));
x
}};
}
type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>;
type Device = Ethernet<'static, ETH, GenericSMI>;
#[embassy_executor::task]
async fn net_task(stack: &'static Stack<Device>) -> ! {
@ -52,25 +53,23 @@ async fn main(spawner: Spawner) -> ! {
let eth_int = interrupt::take!(ETH);
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
let device = unsafe {
Ethernet::new(
singleton!(State::new()),
p.ETH,
eth_int,
p.PA1,
p.PA2,
p.PC1,
p.PA7,
p.PC4,
p.PC5,
p.PG13,
p.PB13,
p.PG11,
GenericSMI,
mac_addr,
0,
)
};
let device = Ethernet::new(
singleton!(PacketQueue::<16, 16>::new()),
p.ETH,
eth_int,
p.PA1,
p.PA2,
p.PC1,
p.PA7,
p.PC4,
p.PC5,
p.PG13,
p.PB13,
p.PG11,
GenericSMI,
mac_addr,
0,
);
let config = embassy_net::ConfigStrategy::Dhcp;
//let config = embassy_net::ConfigStrategy::Static(embassy_net::Config {