mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-06-09 00:49:25 +00:00
Reduce diff of usb-4.rs to usb-4-solution.rs
While comparing my solution to the given solution, I found the diff between the two files is larger than it should be. I believe the differences are completely unrelated to the usb-4 topics.
This commit is contained in:
parent
3582b93abd
commit
dfb8685d73
|
@ -8,14 +8,14 @@ use dk::{
|
||||||
use panic_log as _; // panic handler
|
use panic_log as _; // panic handler
|
||||||
|
|
||||||
// use one of these
|
// use one of these
|
||||||
use usb2::{GetDescriptor as Descriptor, StandardRequest as Request};
|
use usb2::{GetDescriptor as Descriptor, StandardRequest as Request, State};
|
||||||
|
|
||||||
#[rtic::app(device = dk)]
|
#[rtic::app(device = dk)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
struct Resources {
|
struct Resources {
|
||||||
usbd: USBD,
|
usbd: USBD,
|
||||||
ep0in: Ep0In,
|
ep0in: Ep0In,
|
||||||
state: usb2::State,
|
state: State,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
|
@ -26,7 +26,7 @@ const APP: () = {
|
||||||
|
|
||||||
init::LateResources {
|
init::LateResources {
|
||||||
usbd: board.usbd,
|
usbd: board.usbd,
|
||||||
state: usb2::State::Default,
|
state: State::Default,
|
||||||
ep0in: board.ep0in,
|
ep0in: board.ep0in,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn on_event(usbd: &USBD, ep0in: &mut Ep0In, state: &mut usb2::State, event: Event) {
|
fn on_event(usbd: &USBD, ep0in: &mut Ep0In, state: &mut State, event: Event) {
|
||||||
log::info!("USB: {:?} @ {:?}", event, dk::uptime());
|
log::info!("USB: {:?} @ {:?}", event, dk::uptime());
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
|
@ -56,13 +56,13 @@ fn on_event(usbd: &USBD, ep0in: &mut Ep0In, state: &mut usb2::State, event: Even
|
||||||
if ep0setup(usbd, ep0in, state).is_err() {
|
if ep0setup(usbd, ep0in, state).is_err() {
|
||||||
// unsupported or invalid request:
|
// unsupported or invalid request:
|
||||||
// TODO: add code to stall the endpoint
|
// TODO: add code to stall the endpoint
|
||||||
log::warn!("EP0: unexpected request; stalling the endpoint");
|
log::warn!("EP0IN: unexpected request; stalling the endpoint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ep0setup(usbd: &USBD, ep0in: &mut Ep0In, _state: &mut usb2::State) -> Result<(), ()> {
|
fn ep0setup(usbd: &USBD, ep0in: &mut Ep0In, _state: &mut State) -> Result<(), ()> {
|
||||||
let bmrequesttype = usbd.bmrequesttype.read().bits() as u8;
|
let bmrequesttype = usbd.bmrequesttype.read().bits() as u8;
|
||||||
let brequest = usbd.brequest.read().brequest().bits();
|
let brequest = usbd.brequest.read().brequest().bits();
|
||||||
let wlength = usbd::wlength(usbd);
|
let wlength = usbd::wlength(usbd);
|
||||||
|
|
Loading…
Reference in a new issue