mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-04-29 07:08:56 +00:00
rustfmt
This commit is contained in:
parent
f8b38e1d88
commit
02e9012e8e
|
@ -1,7 +1,6 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
||||
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||
use firmware as _;
|
||||
|
||||
|
@ -10,12 +9,10 @@ mod app {
|
|||
use cortex_m::asm;
|
||||
|
||||
#[local]
|
||||
struct MyLocalResources {
|
||||
}
|
||||
struct MyLocalResources {}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -50,7 +47,11 @@ mod app {
|
|||
// ^^^^^^^^^^ bitfield name
|
||||
defmt::println!("USBREGSTATUS.VBUSDETECT: {}", vbusdetect);
|
||||
|
||||
(MySharedResources {}, MyLocalResources {}, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -16,8 +16,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -35,11 +34,10 @@ mod app {
|
|||
power,
|
||||
counter: 0, // <- initialize the new resource
|
||||
},
|
||||
init::Monotonics()
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#[idle]
|
||||
fn idle(_cx: idle::Context) -> ! {
|
||||
loop {
|
||||
|
|
|
@ -15,9 +15,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -29,7 +27,11 @@ mod app {
|
|||
|
||||
defmt::println!("USBDETECTED interrupt enabled");
|
||||
|
||||
(MySharedResources {}, MyLocalResources {power}, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources { power },
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
||||
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||
use firmware as _;
|
||||
|
||||
|
@ -10,20 +9,21 @@ mod app {
|
|||
use cortex_m::asm;
|
||||
|
||||
#[local]
|
||||
struct MyLocalResources {
|
||||
}
|
||||
struct MyLocalResources {}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
dk::init().unwrap();
|
||||
|
||||
defmt::println!("Hello");
|
||||
(MySharedResources {}, MyLocalResources {}, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
||||
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||
use firmware as _;
|
||||
|
||||
|
@ -19,9 +18,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -33,7 +30,11 @@ mod app {
|
|||
|
||||
defmt::println!("USBD initialized");
|
||||
|
||||
(MySharedResources {}, MyLocalResources {usbd: board.usbd }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources { usbd: board.usbd },
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd])]
|
||||
|
@ -63,5 +64,3 @@ mod app {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -31,7 +30,11 @@ mod app {
|
|||
|
||||
defmt::println!("USBD initialized");
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources { usbd: board.usbd },
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd])]
|
||||
|
@ -58,5 +61,3 @@ mod app {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -28,7 +27,11 @@ mod app {
|
|||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources { usbd: board.usbd },
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd])]
|
||||
|
@ -107,4 +110,3 @@ mod app {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
|
||||
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||
use firmware as _;
|
||||
|
||||
|
@ -20,9 +19,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -30,7 +27,11 @@ mod app {
|
|||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources { usbd: board.usbd },
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd])]
|
||||
|
@ -104,4 +105,3 @@ mod app {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -30,7 +28,14 @@ mod app {
|
|||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd, ep0in: board.ep0in, }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {
|
||||
usbd: board.usbd,
|
||||
ep0in: board.ep0in,
|
||||
},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd, ep0in])]
|
||||
|
@ -92,7 +97,8 @@ mod app {
|
|||
idVendor: consts::VID,
|
||||
};
|
||||
let desc_bytes = desc.bytes();
|
||||
let resp = &desc_bytes[..core::cmp::min(desc_bytes.len(), usize::from(length))];
|
||||
let resp =
|
||||
&desc_bytes[..core::cmp::min(desc_bytes.len(), usize::from(length))];
|
||||
ep0in.start(&resp, usbd);
|
||||
}
|
||||
Request::SetAddress { .. } => {
|
||||
|
@ -110,6 +116,4 @@ mod app {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,16 +19,21 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
let board = dk::init().unwrap();
|
||||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd, ep0in: board.ep0in, }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {
|
||||
usbd: board.usbd,
|
||||
ep0in: board.ep0in,
|
||||
},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd, ep0in])]
|
||||
|
@ -96,6 +101,4 @@ mod app {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,22 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
let board = dk::init().unwrap();
|
||||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd, ep0in: board.ep0in, state: State::Default, }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {
|
||||
usbd: board.usbd,
|
||||
ep0in: board.ep0in,
|
||||
state: State::Default,
|
||||
},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd, ep0in, state])]
|
||||
|
@ -186,6 +192,4 @@ mod app {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||
use firmware as _;
|
||||
|
||||
|
||||
#[rtic::app(device = dk, peripherals = false)]
|
||||
mod app {
|
||||
|
||||
|
@ -27,8 +26,7 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
}
|
||||
struct MySharedResources {}
|
||||
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
|
@ -36,7 +34,15 @@ mod app {
|
|||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd, ep0in: board.ep0in, state: State::Default, }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {
|
||||
usbd: board.usbd,
|
||||
ep0in: board.ep0in,
|
||||
state: State::Default,
|
||||
},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd, ep0in, state])]
|
||||
|
@ -137,6 +143,4 @@ mod app {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,22 @@ mod app {
|
|||
}
|
||||
|
||||
#[shared]
|
||||
struct MySharedResources {
|
||||
|
||||
}
|
||||
struct MySharedResources {}
|
||||
#[init]
|
||||
fn init(_cx: init::Context) -> (MySharedResources, MyLocalResources, init::Monotonics) {
|
||||
let board = dk::init().unwrap();
|
||||
|
||||
usbd::init(board.power, &board.usbd);
|
||||
|
||||
(MySharedResources {}, MyLocalResources { usbd: board.usbd, ep0in: board.ep0in, state: State::Default, }, init::Monotonics())
|
||||
(
|
||||
MySharedResources {},
|
||||
MyLocalResources {
|
||||
usbd: board.usbd,
|
||||
ep0in: board.ep0in,
|
||||
state: State::Default,
|
||||
},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = USBD, local = [usbd, ep0in, state])]
|
||||
|
@ -234,6 +240,4 @@ mod app {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue