aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml7
-rw-r--r--README.md8
-rw-r--r--anyfmt/Cargo.toml10
-rw-r--r--anyfmt/src/lib.rs149
-rw-r--r--embassy-nrf/Cargo.toml19
-rw-r--r--embassy-nrf/src/gpiote.rs5
-rw-r--r--embassy-nrf/src/interrupt.rs5
-rw-r--r--embassy-nrf/src/qspi.rs47
-rw-r--r--embassy-nrf/src/uarte.rs2
-rw-r--r--embassy/Cargo.toml7
-rw-r--r--embassy/src/executor/executor.rs3
-rw-r--r--embassy/src/flash.rs3
-rw-r--r--embassy/src/io/error.rs3
-rw-r--r--embassy/src/rand.rs4
-rw-r--r--embassy/src/time/duration.rs3
-rw-r--r--embassy/src/time/instant.rs3
-rw-r--r--embassy/src/time/mod.rs4
-rw-r--r--embassy/src/util/drop_bomb.rs2
-rw-r--r--embassy/src/util/portal.rs2
-rw-r--r--embassy/src/util/signal.rs2
-rw-r--r--examples/Cargo.toml11
-rw-r--r--examples/src/bin/qspi.rs3
-rw-r--r--examples/src/example_common.rs2
-rwxr-xr-xtest-build.sh6
24 files changed, 79 insertions, 231 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 7336a2870..3ad62f18d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@
3members = [ 3members = [
4 "embassy", 4 "embassy",
5 "embassy-nrf", 5 "embassy-nrf",
6 "anyfmt", 6 "embassy-macros",
7 "examples", 7 "examples",
8] 8]
9 9
@@ -11,11 +11,6 @@ exclude = [
11 "third_party" 11 "third_party"
12] 12]
13 13
14[patch.crates-io]
15panic-probe = { git = "https://github.com/knurling-rs/probe-run", branch="main" }
16defmt-rtt = { git = "https://github.com/knurling-rs/defmt", branch="main" }
17defmt = { git = "https://github.com/knurling-rs/defmt", branch="main" }
18
19[profile.dev] 14[profile.dev]
20codegen-units = 1 15codegen-units = 1
21debug = 2 16debug = 2
diff --git a/README.md b/README.md
index 0162011f4..6f7470cf5 100644
--- a/README.md
+++ b/README.md
@@ -52,14 +52,6 @@ cargo install --git https://github.com/knurling-rs/probe-run --branch main --fea
52cargo run --bin rtc_async 52cargo run --bin rtc_async
53``` 53```
54 54
55## Using on your project
56
57`embassy` requires git version of a few dependencies.
58
59When using `embassy` in your own project, make sure you copy over the `[patch.crates-io]` section from root `Cargo.toml`.
60
61This will no longer needed after the first crates.io release.
62
63## Minimum supported Rust version (MSRV) 55## Minimum supported Rust version (MSRV)
64 56
65`rustc 1.48.0-nightly (1fd5b9d51 2020-09-20)` 57`rustc 1.48.0-nightly (1fd5b9d51 2020-09-20)`
diff --git a/anyfmt/Cargo.toml b/anyfmt/Cargo.toml
deleted file mode 100644
index 3ee7c167b..000000000
--- a/anyfmt/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
1[package]
2name = "anyfmt"
3version = "0.1.0"
4authors = ["Dario Nieuwenhuis <[email protected]>"]
5edition = "2018"
6
7
8[dependencies]
9defmt = { version = "0.1.0", optional = true }
10log = { version = "0.4.11", optional = true }
diff --git a/anyfmt/src/lib.rs b/anyfmt/src/lib.rs
deleted file mode 100644
index 3286cc27b..000000000
--- a/anyfmt/src/lib.rs
+++ /dev/null
@@ -1,149 +0,0 @@
1#![no_std]
2
3pub mod export {
4 #[cfg(feature = "defmt")]
5 pub use defmt;
6 #[cfg(feature = "log")]
7 pub use log;
8}
9
10#[cfg(feature = "log")]
11#[macro_export]
12macro_rules! log {
13 (trace, $($arg:expr),*) => { $crate::export::log::trace!($($arg),*); };
14 (debug, $($arg:expr),*) => { $crate::export::log::debug!($($arg),*); };
15 (info, $($arg:expr),*) => { $crate::export::log::info!($($arg),*); };
16 (warn, $($arg:expr),*) => { $crate::export::log::warn!($($arg),*); };
17 (error, $($arg:expr),*) => { $crate::export::log::error!($($arg),*); };
18}
19
20#[cfg(feature = "defmt")]
21#[macro_export]
22macro_rules! log {
23 (trace, $($arg:expr),*) => { $crate::export::defmt::trace!($($arg),*); };
24 (debug, $($arg:expr),*) => { $crate::export::defmt::debug!($($arg),*); };
25 (info, $($arg:expr),*) => { $crate::export::defmt::info!($($arg),*); };
26 (warn, $($arg:expr),*) => { $crate::export::defmt::warn!($($arg),*); };
27 (error, $($arg:expr),*) => { $crate::export::defmt::error!($($arg),*); };
28}
29
30#[cfg(not(any(feature = "log", feature = "defmt")))]
31#[macro_export]
32macro_rules! log {
33 ($level:ident, $($arg:expr),*) => {{}};
34}
35
36#[macro_export]
37macro_rules! trace {
38 ($($arg:expr),*) => (log!(trace, $($arg),*));
39}
40
41#[macro_export]
42macro_rules! debug {
43 ($($arg:expr),*) => ($crate::log!(debug, $($arg),*));
44}
45
46#[macro_export]
47macro_rules! info {
48 ($($arg:expr),*) => ($crate::log!(info, $($arg),*));
49}
50
51#[macro_export]
52macro_rules! warn {
53 ($($arg:expr),*) => ($crate::log!(warn, $($arg),*));
54}
55
56#[macro_export]
57macro_rules! error {
58 ($($arg:expr),*) => ($crate::log!(error, $($arg),*));
59}
60
61#[macro_export]
62macro_rules! expect {
63 ($arg:expr, $msg:expr) => {
64 match $crate::Try::into_result($arg) {
65 ::core::result::Result::Ok(t) => t,
66 ::core::result::Result::Err(e) => {
67 $crate::panic!("{:?}: {:?}", $crate::intern!($msg), e);
68 }
69 }
70 };
71}
72
73#[cfg(feature = "defmt")]
74#[macro_export]
75macro_rules! intern {
76 ($arg:expr) => {
77 $crate::export::defmt::intern!($arg)
78 };
79}
80
81#[cfg(not(feature = "defmt"))]
82#[macro_export]
83macro_rules! intern {
84 ($arg:expr) => {
85 $arg
86 };
87}
88
89#[macro_export]
90macro_rules! unwrap {
91 ($arg:expr) => {
92 expect!($arg, "Unwrap failed")
93 };
94}
95
96#[macro_export]
97macro_rules! panic {
98 () => {
99 $crate::panic!("panic")
100 };
101 ($($arg:expr),*) => {{
102 $crate::log!(error, $($arg),*);
103 ::core::panic!()
104 }};
105}
106
107#[macro_export]
108macro_rules! assert {
109 ($cond:expr) => {
110 $crate::assert!($cond, "assertion failed");
111 };
112 ($cond:expr, $($arg:expr),*) => {
113 {
114 if !$cond {
115 $crate::panic!($($arg),*);
116 }
117 }
118 };
119}
120
121#[derive(Debug, Copy, Clone, Eq, PartialEq)]
122#[cfg_attr(feature = "defmt", derive(defmt::Format))]
123pub struct NoneError;
124
125pub trait Try {
126 type Ok;
127 type Error;
128 fn into_result(self) -> Result<Self::Ok, Self::Error>;
129}
130
131impl<T> Try for Option<T> {
132 type Ok = T;
133 type Error = NoneError;
134
135 #[inline]
136 fn into_result(self) -> Result<T, NoneError> {
137 self.ok_or(NoneError)
138 }
139}
140
141impl<T, E> Try for Result<T, E> {
142 type Ok = T;
143 type Error = E;
144
145 #[inline]
146 fn into_result(self) -> Self {
147 self
148 }
149}
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index 6cf23aa79..d1538908d 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -21,13 +21,10 @@ defmt-error = [ ]
21[dependencies] 21[dependencies]
22embassy = { version = "0.1.0", path = "../embassy" } 22embassy = { version = "0.1.0", path = "../embassy" }
23 23
24anyfmt = { version = "0.1.0", path = "../anyfmt" } 24defmt = { version = "0.1.2" }
25defmt = { version = "0.1.0", optional = true } 25cortex-m-rt = "0.6.13"
26 26cortex-m = { version = "0.6.4" }
27cortex-m-rt = "0.6.12"
28cortex-m = { version = "0.6.3" }
29embedded-hal = { version = "0.2.4" } 27embedded-hal = { version = "0.2.4" }
30bare-metal = { version = "0.2.0", features = ["const-fn"] }
31 28
32nrf52810-pac = { version = "0.9.0", optional = true } 29nrf52810-pac = { version = "0.9.0", optional = true }
33nrf52811-pac = { version = "0.9.1", optional = true } 30nrf52811-pac = { version = "0.9.1", optional = true }
@@ -35,8 +32,8 @@ nrf52832-pac = { version = "0.9.0", optional = true }
35nrf52833-pac = { version = "0.9.0", optional = true } 32nrf52833-pac = { version = "0.9.0", optional = true }
36nrf52840-pac = { version = "0.9.0", optional = true } 33nrf52840-pac = { version = "0.9.0", optional = true }
37 34
38nrf52810-hal = { version = "0.11.0", optional = true } 35nrf52810-hal = { version = "0.12.0", optional = true }
39#nrf52811-hal = { version = "0.11.0", optional = true } # doesn't exist yet 36#nrf52811-hal = { version = "0.12.0", optional = true } # doesn't exist yet
40nrf52832-hal = { version = "0.11.0", optional = true } 37nrf52832-hal = { version = "0.12.0", optional = true }
41nrf52833-hal = { version = "0.11.0", optional = true } 38nrf52833-hal = { version = "0.12.0", optional = true }
42nrf52840-hal = { version = "0.11.0", optional = true } 39nrf52840-hal = { version = "0.12.0", optional = true }
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index 9626d3299..bb15cca66 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -1,8 +1,8 @@
1use anyfmt::{panic, *};
2use core::cell::Cell; 1use core::cell::Cell;
3use core::future::Future; 2use core::future::Future;
4use core::ptr; 3use core::ptr;
5use core::task::{Context, Poll}; 4use core::task::{Context, Poll};
5use defmt::{panic, *};
6use embassy::util::Signal; 6use embassy::util::Signal;
7 7
8use crate::hal::gpio::{Input, Level, Output, Pin, Port}; 8use crate::hal::gpio::{Input, Level, Output, Pin, Port};
@@ -51,8 +51,7 @@ pub enum OutputChannelPolarity {
51 Toggle, 51 Toggle,
52} 52}
53 53
54#[derive(Debug, Copy, Clone, Eq, PartialEq)] 54#[derive(Debug, Copy, Clone, Eq, PartialEq, defmt::Format)]
55#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56pub enum NewChannelError { 55pub enum NewChannelError {
57 NoFreeChannels, 56 NoFreeChannels,
58} 57}
diff --git a/embassy-nrf/src/interrupt.rs b/embassy-nrf/src/interrupt.rs
index 8918b13ee..384426ea2 100644
--- a/embassy-nrf/src/interrupt.rs
+++ b/embassy-nrf/src/interrupt.rs
@@ -10,10 +10,9 @@ use crate::pac::{NVIC, NVIC_PRIO_BITS};
10// Re-exports 10// Re-exports
11pub use crate::pac::Interrupt; 11pub use crate::pac::Interrupt;
12pub use crate::pac::Interrupt::*; // needed for cortex-m-rt #[interrupt] 12pub use crate::pac::Interrupt::*; // needed for cortex-m-rt #[interrupt]
13pub use bare_metal::{CriticalSection, Mutex}; 13pub use cortex_m::interrupt::{CriticalSection, Mutex};
14 14
15#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] 15#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, defmt::Format)]
16#[cfg_attr(feature = "defmt", derive(defmt::Format))]
17#[repr(u8)] 16#[repr(u8)]
18pub enum Priority { 17pub enum Priority {
19 Level0 = 0, 18 Level0 = 0,
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index 367a1d2d3..75cbe7ddc 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -1,4 +1,5 @@
1use core::future::Future; 1use core::future::Future;
2use defmt::{assert, assert_eq, panic, *};
2 3
3use crate::hal::gpio::{Output, Pin as GpioPin, Port as GpioPort, PushPull}; 4use crate::hal::gpio::{Output, Pin as GpioPin, Port as GpioPort, PushPull};
4use crate::pac::{Interrupt, QSPI}; 5use crate::pac::{Interrupt, QSPI};
@@ -32,12 +33,18 @@ pub struct Pins {
32 pub io3: Option<GpioPin<Output<PushPull>>>, 33 pub io3: Option<GpioPin<Output<PushPull>>>,
33} 34}
34 35
36pub struct DeepPowerDownConfig {
37 pub enter_time: u16,
38 pub exit_time: u16,
39}
40
35pub struct Config { 41pub struct Config {
36 pub pins: Pins, 42 pub pins: Pins,
37 pub xip_offset: u32, 43 pub xip_offset: u32,
38 pub read_opcode: ReadOpcode, 44 pub read_opcode: ReadOpcode,
39 pub write_opcode: WriteOpcode, 45 pub write_opcode: WriteOpcode,
40 pub write_page_size: WritePageSize, 46 pub write_page_size: WritePageSize,
47 pub deep_power_down: Option<DeepPowerDownConfig>,
41} 48}
42 49
43pub struct Qspi { 50pub struct Qspi {
@@ -96,15 +103,27 @@ impl Qspi {
96 } 103 }
97 }); 104 });
98 105
99 qspi.ifconfig0.write(|w| { 106 qspi.ifconfig0.write(|mut w| {
100 let w = w.addrmode().variant(AddressMode::_24BIT); 107 w = w.addrmode().variant(AddressMode::_24BIT);
101 let w = w.dpmenable().disable(); 108 if config.deep_power_down.is_some() {
102 let w = w.ppsize().variant(config.write_page_size); 109 w = w.dpmenable().enable();
103 let w = w.readoc().variant(config.read_opcode); 110 } else {
104 let w = w.writeoc().variant(config.write_opcode); 111 w = w.dpmenable().disable();
112 }
113 w = w.ppsize().variant(config.write_page_size);
114 w = w.readoc().variant(config.read_opcode);
115 w = w.writeoc().variant(config.write_opcode);
105 w 116 w
106 }); 117 });
107 118
119 if let Some(dpd) = &config.deep_power_down {
120 qspi.dpmdur.write(|mut w| unsafe {
121 w = w.enter().bits(dpd.enter_time);
122 w = w.exit().bits(dpd.exit_time);
123 w
124 })
125 }
126
108 qspi.ifconfig1.write(|w| { 127 qspi.ifconfig1.write(|w| {
109 let w = unsafe { w.sckdelay().bits(80) }; 128 let w = unsafe { w.sckdelay().bits(80) };
110 let w = w.dpmen().exit(); 129 let w = w.dpmen().exit();
@@ -125,13 +144,28 @@ impl Qspi {
125 qspi.events_ready.reset(); 144 qspi.events_ready.reset();
126 145
127 // Enable READY interrupt 146 // Enable READY interrupt
147 SIGNAL.reset();
128 qspi.intenset.write(|w| w.ready().set()); 148 qspi.intenset.write(|w| w.ready().set());
129 interrupt::set_priority(Interrupt::QSPI, interrupt::Priority::Level7); 149 interrupt::set_priority(Interrupt::QSPI, interrupt::Priority::Level7);
150 interrupt::unpend(Interrupt::QSPI);
130 interrupt::enable(Interrupt::QSPI); 151 interrupt::enable(Interrupt::QSPI);
131 152
132 Self { inner: qspi } 153 Self { inner: qspi }
133 } 154 }
134 155
156 pub fn sleep(&mut self) {
157 info!("flash: sleeping");
158 info!("flash: state = {:?}", self.inner.status.read().bits());
159 self.inner.ifconfig1.modify(|r, w| w.dpmen().enter());
160 info!("flash: state = {:?}", self.inner.status.read().bits());
161 cortex_m::asm::delay(1000000);
162 info!("flash: state = {:?}", self.inner.status.read().bits());
163
164 self.inner
165 .tasks_deactivate
166 .write(|w| w.tasks_deactivate().set_bit());
167 }
168
135 pub fn custom_instruction<'a>( 169 pub fn custom_instruction<'a>(
136 &'a mut self, 170 &'a mut self,
137 opcode: u8, 171 opcode: u8,
@@ -318,6 +352,7 @@ unsafe fn QSPI() {
318 let p = crate::pac::Peripherals::steal().QSPI; 352 let p = crate::pac::Peripherals::steal().QSPI;
319 if p.events_ready.read().events_ready().bit_is_set() { 353 if p.events_ready.read().events_ready().bit_is_set() {
320 p.events_ready.reset(); 354 p.events_ready.reset();
355 info!("qspi ready");
321 SIGNAL.signal(()); 356 SIGNAL.signal(());
322 } 357 }
323} 358}
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 530895073..0f2030c98 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -28,7 +28,7 @@ pub use uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity};
28use embassy::io::{AsyncBufRead, AsyncWrite, Result}; 28use embassy::io::{AsyncBufRead, AsyncWrite, Result};
29use embassy::util::WakerStore; 29use embassy::util::WakerStore;
30 30
31use anyfmt::{assert, panic, *}; 31use defmt::{assert, panic, todo, *};
32 32
33//use crate::trace; 33//use crate::trace;
34 34
diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml
index 6c9309763..832b06fd7 100644
--- a/embassy/Cargo.toml
+++ b/embassy/Cargo.toml
@@ -13,12 +13,11 @@ defmt-warn = []
13defmt-error = [] 13defmt-error = []
14 14
15[dependencies] 15[dependencies]
16anyfmt = { version = "0.1.0", path = "../anyfmt" } 16defmt = { version = "0.1.0" }
17defmt = { version = "0.1.0", optional = true }
18 17
19cortex-m = "0.6.3" 18cortex-m = "0.6.4"
20futures = { version = "0.3.5", default-features = false } 19futures = { version = "0.3.5", default-features = false }
21pin-project = { version = "0.4.23", default-features = false } 20pin-project = { version = "1.0.2", default-features = false }
22futures-intrusive = { version = "0.3.1", default-features = false } 21futures-intrusive = { version = "0.3.1", default-features = false }
23embassy-macros = { version = "0.1.0", path = "../embassy-macros"} 22embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
24 23
diff --git a/embassy/src/executor/executor.rs b/embassy/src/executor/executor.rs
index 4d73cf9f0..ff3a8517c 100644
--- a/embassy/src/executor/executor.rs
+++ b/embassy/src/executor/executor.rs
@@ -63,8 +63,7 @@ pub struct Task<F: Future + 'static> {
63 future: UninitCell<F>, // Valid if STATE_RUNNING 63 future: UninitCell<F>, // Valid if STATE_RUNNING
64} 64}
65 65
66#[derive(Copy, Clone, Debug)] 66#[derive(Copy, Clone, Debug, defmt::Format)]
67#[cfg_attr(feature = "defmt", derive(defmt::Format))]
68pub enum SpawnError { 67pub enum SpawnError {
69 Busy, 68 Busy,
70} 69}
diff --git a/embassy/src/flash.rs b/embassy/src/flash.rs
index ca9fb5952..5d62e3b64 100644
--- a/embassy/src/flash.rs
+++ b/embassy/src/flash.rs
@@ -1,7 +1,6 @@
1use core::future::Future; 1use core::future::Future;
2 2
3#[derive(Copy, Clone, Debug, Eq, PartialEq)] 3#[derive(Copy, Clone, Debug, Eq, PartialEq, defmt::Format)]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5pub enum Error { 4pub enum Error {
6 Failed, 5 Failed,
7 AddressMisaligned, 6 AddressMisaligned,
diff --git a/embassy/src/io/error.rs b/embassy/src/io/error.rs
index 8bad0cdb1..8bbdae7f8 100644
--- a/embassy/src/io/error.rs
+++ b/embassy/src/io/error.rs
@@ -2,8 +2,7 @@
2/// 2///
3/// This list is intended to grow over time and it is not recommended to 3/// This list is intended to grow over time and it is not recommended to
4/// exhaustively match against it. 4/// exhaustively match against it.
5#[derive(Debug, Clone, Copy, PartialEq, Eq)] 5#[derive(Debug, Clone, Copy, PartialEq, Eq, defmt::Format)]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7pub enum Error { 6pub enum Error {
8 /// An entity was not found, often a file. 7 /// An entity was not found, often a file.
9 NotFound, 8 NotFound,
diff --git a/embassy/src/rand.rs b/embassy/src/rand.rs
index dbabb6f2b..3db164cf1 100644
--- a/embassy/src/rand.rs
+++ b/embassy/src/rand.rs
@@ -1,4 +1,4 @@
1use anyfmt::*; 1use defmt::*;
2 2
3pub trait Rand { 3pub trait Rand {
4 fn rand(&self, buf: &mut [u8]); 4 fn rand(&self, buf: &mut [u8]);
@@ -11,5 +11,5 @@ pub unsafe fn set_rand(rand: &'static dyn Rand) {
11} 11}
12 12
13pub fn rand(buf: &mut [u8]) { 13pub fn rand(buf: &mut [u8]) {
14 unsafe { expect!(RAND, "No rand set").rand(buf) } 14 unsafe { unwrap!(RAND, "No rand set").rand(buf) }
15} 15}
diff --git a/embassy/src/time/duration.rs b/embassy/src/time/duration.rs
index 8135961ea..715d4155f 100644
--- a/embassy/src/time/duration.rs
+++ b/embassy/src/time/duration.rs
@@ -3,8 +3,7 @@ use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
3 3
4use super::TICKS_PER_SECOND; 4use super::TICKS_PER_SECOND;
5 5
6#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] 6#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, defmt::Format)]
7#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8pub struct Duration { 7pub struct Duration {
9 pub(crate) ticks: u64, 8 pub(crate) ticks: u64,
10} 9}
diff --git a/embassy/src/time/instant.rs b/embassy/src/time/instant.rs
index 75098081f..a7f268e1a 100644
--- a/embassy/src/time/instant.rs
+++ b/embassy/src/time/instant.rs
@@ -5,8 +5,7 @@ use core::ops::{Add, AddAssign, Sub, SubAssign};
5use super::TICKS_PER_SECOND; 5use super::TICKS_PER_SECOND;
6use super::{now, Duration}; 6use super::{now, Duration};
7 7
8#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] 8#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, defmt::Format)]
9#[cfg_attr(feature = "defmt", derive(defmt::Format))]
10pub struct Instant { 9pub struct Instant {
11 ticks: u64, 10 ticks: u64,
12} 11}
diff --git a/embassy/src/time/mod.rs b/embassy/src/time/mod.rs
index a3792e3c8..0d97a789e 100644
--- a/embassy/src/time/mod.rs
+++ b/embassy/src/time/mod.rs
@@ -8,7 +8,7 @@ pub use instant::Instant;
8pub use timer::Timer; 8pub use timer::Timer;
9pub use traits::*; 9pub use traits::*;
10 10
11use anyfmt::*; 11use defmt::*;
12 12
13// TODO allow customizing, probably via Cargo features `tick-hz-32768` or something. 13// TODO allow customizing, probably via Cargo features `tick-hz-32768` or something.
14pub const TICKS_PER_SECOND: u64 = 32768; 14pub const TICKS_PER_SECOND: u64 = 32768;
@@ -20,5 +20,5 @@ pub unsafe fn set_clock(clock: &'static dyn Clock) {
20} 20}
21 21
22pub(crate) fn now() -> u64 { 22pub(crate) fn now() -> u64 {
23 unsafe { expect!(CLOCK, "No clock set").now() } 23 unsafe { unwrap!(CLOCK, "No clock set").now() }
24} 24}
diff --git a/embassy/src/util/drop_bomb.rs b/embassy/src/util/drop_bomb.rs
index 0ef051cf4..d33591fc2 100644
--- a/embassy/src/util/drop_bomb.rs
+++ b/embassy/src/util/drop_bomb.rs
@@ -1,5 +1,5 @@
1use anyfmt::panic;
2use core::mem; 1use core::mem;
2use defmt::panic;
3 3
4pub struct DropBomb { 4pub struct DropBomb {
5 _private: (), 5 _private: (),
diff --git a/embassy/src/util/portal.rs b/embassy/src/util/portal.rs
index 8f5d812f4..6eecf52cd 100644
--- a/embassy/src/util/portal.rs
+++ b/embassy/src/util/portal.rs
@@ -1,8 +1,8 @@
1use anyfmt::panic;
2use core::cell::UnsafeCell; 1use core::cell::UnsafeCell;
3use core::future::Future; 2use core::future::Future;
4use core::mem; 3use core::mem;
5use core::mem::MaybeUninit; 4use core::mem::MaybeUninit;
5use defmt::panic;
6 6
7use crate::util::*; 7use crate::util::*;
8 8
diff --git a/embassy/src/util/signal.rs b/embassy/src/util/signal.rs
index e2cd3a80f..45205368d 100644
--- a/embassy/src/util/signal.rs
+++ b/embassy/src/util/signal.rs
@@ -1,8 +1,8 @@
1use anyfmt::panic;
2use core::cell::UnsafeCell; 1use core::cell::UnsafeCell;
3use core::future::Future; 2use core::future::Future;
4use core::mem; 3use core::mem;
5use core::task::{Context, Poll, Waker}; 4use core::task::{Context, Poll, Waker};
5use defmt::panic;
6 6
7pub struct Signal<T> { 7pub struct Signal<T> {
8 state: UnsafeCell<State<T>>, 8 state: UnsafeCell<State<T>>,
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 719f73269..71d0bbd77 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -17,17 +17,16 @@ defmt-error = []
17 17
18 18
19[dependencies] 19[dependencies]
20embassy = { version = "0.1.0", path = "../embassy", features = ["defmt"] } 20embassy = { version = "0.1.0", path = "../embassy", features = ["defmt-trace"] }
21embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", features = ["defmt", "defmt-trace", "52840"] } 21embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", features = ["defmt-trace", "52840"] }
22anyfmt = { version = "0.1.0", path = "../anyfmt", features = ["defmt"] }
23 22
24defmt = "0.1.0" 23defmt = "0.1.2"
25defmt-rtt = "0.1.0" 24defmt-rtt = "0.1.0"
26 25
27cortex-m = { version = "0.6.3" } 26cortex-m = { version = "0.6.3" }
28cortex-m-rt = "0.6.12" 27cortex-m-rt = "0.6.12"
29embedded-hal = { version = "0.2.4" } 28embedded-hal = { version = "0.2.4" }
30panic-probe = "0.1.0" 29panic-probe = "0.1.0"
31nrf52840-hal = { version = "0.11.0" } 30nrf52840-hal = { version = "0.12.0" }
32futures = { version = "0.3.7", default-features = false, features = ["async-await"] } 31futures = { version = "0.3.8", default-features = false, features = ["async-await"] }
33cortex-m-rtic = { git = "https://github.com/rtic-rs/cortex-m-rtic", branch = "master"} 32cortex-m-rtic = { git = "https://github.com/rtic-rs/cortex-m-rtic", branch = "master"}
diff --git a/examples/src/bin/qspi.rs b/examples/src/bin/qspi.rs
index a7f668ca7..644018e2d 100644
--- a/examples/src/bin/qspi.rs
+++ b/examples/src/bin/qspi.rs
@@ -6,8 +6,8 @@
6mod example_common; 6mod example_common;
7use example_common::*; 7use example_common::*;
8 8
9use anyfmt::panic;
10use cortex_m_rt::entry; 9use cortex_m_rt::entry;
10use defmt::{assert_eq, panic, *};
11use nrf52840_hal::gpio; 11use nrf52840_hal::gpio;
12 12
13use embassy::executor::{task, Executor}; 13use embassy::executor::{task, Executor};
@@ -65,6 +65,7 @@ async fn run() {
65 write_opcode: qspi::WriteOpcode::PP4IO, 65 write_opcode: qspi::WriteOpcode::PP4IO,
66 xip_offset: 0, 66 xip_offset: 0,
67 write_page_size: qspi::WritePageSize::_256BYTES, 67 write_page_size: qspi::WritePageSize::_256BYTES,
68 deep_power_down: None,
68 }; 69 };
69 70
70 let mut q = qspi::Qspi::new(p.QSPI, config); 71 let mut q = qspi::Qspi::new(p.QSPI, config);
diff --git a/examples/src/example_common.rs b/examples/src/example_common.rs
index 1a12fa69a..60bb02082 100644
--- a/examples/src/example_common.rs
+++ b/examples/src/example_common.rs
@@ -4,7 +4,7 @@ use defmt_rtt as _; // global logger
4use nrf52840_hal as _; 4use nrf52840_hal as _;
5use panic_probe as _; 5use panic_probe as _;
6 6
7pub use anyfmt::*; 7pub use defmt::*;
8 8
9use core::sync::atomic::{AtomicUsize, Ordering}; 9use core::sync::atomic::{AtomicUsize, Ordering};
10 10
diff --git a/test-build.sh b/test-build.sh
index 34a56782b..66128ddc2 100755
--- a/test-build.sh
+++ b/test-build.sh
@@ -7,15 +7,11 @@ set -euxo pipefail
7 7
8# embassy 8# embassy
9(cd embassy; cargo build --target thumbv7em-none-eabihf) 9(cd embassy; cargo build --target thumbv7em-none-eabihf)
10(cd embassy; cargo build --target thumbv7em-none-eabihf --features defmt,anyfmt/defmt)
11(cd embassy; cargo build --target thumbv7em-none-eabihf --features anyfmt/log)
12 10
13# embassy-nrf 11# embassy-nrf
14(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52810) 12(cd embassy-nrf; cargo build --target thumbv7em-none-eabi --features 52810)
15#(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52811) # nrf52811-hal doesn't exist yet 13#(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52811) # nrf52811-hal doesn't exist yet
16(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52832) 14(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52832)
17(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52833) 15(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52833)
18(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52840) 16(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52840)
19 17
20(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52840,anyfmt/log)
21(cd embassy-nrf; cargo build --target thumbv7em-none-eabihf --features 52840,defmt,embassy/defmt,anyfmt/defmt)