mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-06-10 09:29:26 +00:00
Merge pull request #139 from ferrous-systems/rm-git-deps
move away from git dependencies
This commit is contained in:
commit
15f011b21f
|
@ -8,7 +8,7 @@ version = "0.0.0"
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
consts = { path = "../common/consts" }
|
consts = { path = "../common/consts" }
|
||||||
quote = "1"
|
quote = "1"
|
||||||
usb2 = { git = "https://github.com/japaric/usb2" }
|
usb2 = "0.0.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
consts = { path = "../common/consts" }
|
consts = { path = "../common/consts" }
|
||||||
|
@ -20,7 +20,7 @@ heapless = "0.5.5"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
panic-log = { path = "../../common/panic-log" }
|
panic-log = { path = "../../common/panic-log" }
|
||||||
usb = { path = "../common/usb" }
|
usb = { path = "../common/usb" }
|
||||||
usb2 = { git = "https://github.com/japaric/usb2" }
|
usb2 = "0.0.1"
|
||||||
|
|
||||||
# optimize code in both profiles
|
# optimize code in both profiles
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn main() -> ! {
|
||||||
// single letter (byte) packet
|
// single letter (byte) packet
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn main() -> ! {
|
||||||
for source in b'A'..=b'B' {
|
for source in b'A'..=b'B' {
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn main() -> ! {
|
||||||
for source in 0..=127 {
|
for source in 0..=127 {
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn main() -> ! {
|
||||||
for source in 0..=127 {
|
for source in 0..=127 {
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
@ -79,7 +79,7 @@ fn main() -> ! {
|
||||||
/* # (NEW) Verify decrypted text */
|
/* # (NEW) Verify decrypted text */
|
||||||
packet.copy_from_slice(&buffer);
|
packet.copy_from_slice(&buffer);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn main() -> ! {
|
||||||
for plainletter in 0..=127 {
|
for plainletter in 0..=127 {
|
||||||
packet.copy_from_slice(&[plainletter]);
|
packet.copy_from_slice(&[plainletter]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
@ -79,7 +79,7 @@ fn main() -> ! {
|
||||||
);
|
);
|
||||||
|
|
||||||
/* # Verify decrypted text */
|
/* # Verify decrypted text */
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn main() -> ! {
|
||||||
// ^^^^^^^ NOTE complete ASCII range
|
// ^^^^^^^ NOTE complete ASCII range
|
||||||
packet.copy_from_slice(&[plainletter]);
|
packet.copy_from_slice(&[plainletter]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -51,7 +51,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
@ -83,7 +83,7 @@ fn main() -> ! {
|
||||||
/* # Verify decrypted text */
|
/* # Verify decrypted text */
|
||||||
packet.copy_from_slice(&buffer);
|
packet.copy_from_slice(&buffer);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn main() -> ! {
|
||||||
str::from_utf8(msg).expect("msg was not valid UTF-8 data")
|
str::from_utf8(msg).expect("msg was not valid UTF-8 data")
|
||||||
);
|
);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
log::info!(
|
log::info!(
|
||||||
"received: {}",
|
"received: {}",
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn main() -> ! {
|
||||||
"sending: {}",
|
"sending: {}",
|
||||||
str::from_utf8(msg).expect("message is not valid UTF-8")
|
str::from_utf8(msg).expect("message is not valid UTF-8")
|
||||||
);
|
);
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
// TODO try uncommenting this line
|
// TODO try uncommenting this line
|
||||||
// timer.delay(1_000);
|
// timer.delay(1_000);
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
packet.copy_from_slice(msg);
|
packet.copy_from_slice(msg);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
dk::exit();
|
dk::exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ version = "0.0.0"
|
||||||
cortex-m = "0.6.4"
|
cortex-m = "0.6.4"
|
||||||
cortex-m-rt = "0.6.13"
|
cortex-m-rt = "0.6.13"
|
||||||
embedded-hal = "0.2.3"
|
embedded-hal = "0.2.3"
|
||||||
hal = { package = "nrf52840-hal", git = "https://github.com/japaric/nrf-hal", branch = "radio" }
|
hal = { package = "nrf52840-hal", version = "0.12.1" }
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rtt-target = { version = "0.2.0", features = ["cortex-m"] }
|
rtt-target = { version = "0.2.0", features = ["cortex-m"] }
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,17 @@ use cortex_m::{asm, peripheral::NVIC};
|
||||||
use embedded_hal::digital::v2::{OutputPin as _, StatefulOutputPin};
|
use embedded_hal::digital::v2::{OutputPin as _, StatefulOutputPin};
|
||||||
#[cfg(feature = "beginner")]
|
#[cfg(feature = "beginner")]
|
||||||
pub use hal::ieee802154;
|
pub use hal::ieee802154;
|
||||||
pub use hal::target::{interrupt, Interrupt, NVIC_PRIO_BITS, RTC0};
|
pub use hal::pac::{interrupt, Interrupt, NVIC_PRIO_BITS, RTC0};
|
||||||
use hal::{
|
use hal::{
|
||||||
clocks::{self, Clocks},
|
clocks::{self, Clocks},
|
||||||
gpio::{p0, Level, Output, Pin, PushPull},
|
gpio::{p0, Level, Output, Pin, Port, PushPull},
|
||||||
rtc::{Rtc, RtcInterrupt},
|
rtc::{Rtc, RtcInterrupt},
|
||||||
timer::OneShot,
|
timer::OneShot,
|
||||||
};
|
};
|
||||||
use log::{LevelFilter, Log};
|
use log::{LevelFilter, Log};
|
||||||
use rtt_target::{rprintln, rtt_init_print};
|
use rtt_target::rprintln;
|
||||||
|
#[cfg(any(feature = "beginner", feature = "advanced"))]
|
||||||
|
use rtt_target::rtt_init_print;
|
||||||
|
|
||||||
#[cfg(feature = "advanced")]
|
#[cfg(feature = "advanced")]
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -79,8 +81,12 @@ impl Led {
|
||||||
pub fn on(&mut self) {
|
pub fn on(&mut self) {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"setting P{}.{} low (LED on)",
|
"setting P{}.{} low (LED on)",
|
||||||
if self.inner.port { '1' } else { '0' },
|
if self.inner.port() == Port::Port1 {
|
||||||
self.inner.pin
|
'1'
|
||||||
|
} else {
|
||||||
|
'0'
|
||||||
|
},
|
||||||
|
self.inner.pin()
|
||||||
);
|
);
|
||||||
|
|
||||||
// NOTE this operations returns a `Result` but never returns the `Err` variant
|
// NOTE this operations returns a `Result` but never returns the `Err` variant
|
||||||
|
@ -91,8 +97,12 @@ impl Led {
|
||||||
pub fn off(&mut self) {
|
pub fn off(&mut self) {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"setting P{}.{} high (LED off)",
|
"setting P{}.{} high (LED off)",
|
||||||
if self.inner.port { '1' } else { '0' },
|
if self.inner.port() == Port::Port1 {
|
||||||
self.inner.pin
|
'1'
|
||||||
|
} else {
|
||||||
|
'0'
|
||||||
|
},
|
||||||
|
self.inner.pin()
|
||||||
);
|
);
|
||||||
|
|
||||||
// NOTE this operations returns a `Result` but never returns the `Err` variant
|
// NOTE this operations returns a `Result` but never returns the `Err` variant
|
||||||
|
@ -121,7 +131,7 @@ impl Led {
|
||||||
|
|
||||||
/// A timer for creating blocking delays
|
/// A timer for creating blocking delays
|
||||||
pub struct Timer {
|
pub struct Timer {
|
||||||
inner: hal::Timer<hal::target::TIMER0, OneShot>,
|
inner: hal::Timer<hal::pac::TIMER0, OneShot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Timer {
|
impl Timer {
|
||||||
|
@ -159,7 +169,7 @@ impl Timer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ops::Deref for Timer {
|
impl ops::Deref for Timer {
|
||||||
type Target = hal::Timer<hal::target::TIMER0, OneShot>;
|
type Target = hal::Timer<hal::pac::TIMER0, OneShot>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.inner
|
&self.inner
|
||||||
|
@ -176,7 +186,7 @@ impl ops::DerefMut for Timer {
|
||||||
///
|
///
|
||||||
/// This return an `Err`or if called more than once
|
/// This return an `Err`or if called more than once
|
||||||
pub fn init() -> Result<Board, ()> {
|
pub fn init() -> Result<Board, ()> {
|
||||||
if let Some(periph) = hal::target::Peripherals::take() {
|
if let Some(periph) = hal::pac::Peripherals::take() {
|
||||||
// NOTE(static mut) this branch runs at most once
|
// NOTE(static mut) this branch runs at most once
|
||||||
#[cfg(feature = "advanced")]
|
#[cfg(feature = "advanced")]
|
||||||
static mut EP0IN_BUF: [u8; 64] = [0; 64];
|
static mut EP0IN_BUF: [u8; 64] = [0; 64];
|
||||||
|
@ -212,7 +222,7 @@ pub fn init() -> Result<Board, ()> {
|
||||||
|
|
||||||
log::debug!("Clocks configured");
|
log::debug!("Clocks configured");
|
||||||
|
|
||||||
let mut rtc = Rtc::new(periph.RTC0);
|
let mut rtc = Rtc::new(periph.RTC0, 0).unwrap();
|
||||||
rtc.enable_interrupt(RtcInterrupt::Overflow, None);
|
rtc.enable_interrupt(RtcInterrupt::Overflow, None);
|
||||||
rtc.enable_counter();
|
rtc.enable_counter();
|
||||||
// NOTE(unsafe) because this crate defines the `#[interrupt] fn RTC0` interrupt handler,
|
// NOTE(unsafe) because this crate defines the `#[interrupt] fn RTC0` interrupt handler,
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
//! Low level access to the nRF52840 peripheral
|
//! Low level access to the nRF52840 peripheral
|
||||||
|
|
||||||
pub use hal::target::{POWER, USBD};
|
pub use hal::pac::{POWER, USBD};
|
||||||
|
|
Loading…
Reference in a new issue