Skip to content

Commit

Permalink
refactor(riot-rs-embassy): rename MTU to ETHERNET_MTU
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories committed Dec 18, 2023
1 parent 8db91bc commit a5088e1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/riot-rs-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,28 @@ async fn usb_task(mut device: UsbDevice<'static, UsbDriver>) -> ! {

#[cfg(feature = "net")]
//
// usb net begin
#[cfg(feature = "net")]
const MTU: usize = 1514;
// net begin
const ETHERNET_MTU: usize = 1514;

#[cfg(feature = "net")]
use embassy_net::{Stack, StackResources};
// net end
//

//
// usb net begin
#[cfg(feature = "usb_ethernet")]
use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner};

#[cfg(feature = "usb_ethernet")]
#[embassy_executor::task]
async fn usb_ncm_task(class: Runner<'static, UsbDriver, MTU>) -> ! {
async fn usb_ncm_task(class: Runner<'static, UsbDriver, ETHERNET_MTU>) -> ! {
class.run().await
}

#[cfg(feature = "usb_ethernet")]
#[embassy_executor::task]
async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! {
async fn net_task(stack: &'static Stack<Device<'static, ETHERNET_MTU>>) -> ! {
stack.run().await
}
// usb net end
Expand Down Expand Up @@ -233,8 +236,10 @@ async fn init_task(peripherals: arch::Peripherals) {
#[cfg(feature = "usb_ethernet")]
let device = {
use embassy_usb::class::cdc_ncm::embassy_net::State as NetState;
let (runner, device) = usb_cdc_ecm
.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr);
let (runner, device) = usb_cdc_ecm.into_embassy_net_device::<ETHERNET_MTU, 4, 4>(
make_static!(NetState::new()),
our_mac_addr,
);

spawner.spawn(usb_ncm_task(runner)).unwrap();

Expand Down

0 comments on commit a5088e1

Please sign in to comment.