Skip to content

Commit f27c694

Browse files
Switch puzzle-fw to use RTIC as well
1 parent 20f464e commit f27c694

File tree

4 files changed

+650
-457
lines changed

4 files changed

+650
-457
lines changed

nrf52-code/boards/dongle/src/lib.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -230,51 +230,6 @@ impl core::fmt::Write for &Ringbuffer {
230230
}
231231
}
232232

233-
/// The global type for sharing things with an interrupt handler
234-
pub struct GlobalIrqState<T> {
235-
inner: critical_section::Mutex<core::cell::RefCell<Option<T>>>,
236-
}
237-
238-
impl<T> GlobalIrqState<T> {
239-
/// Create a new, empty, object
240-
pub const fn new() -> GlobalIrqState<T> {
241-
GlobalIrqState {
242-
inner: critical_section::Mutex::new(core::cell::RefCell::new(None)),
243-
}
244-
}
245-
246-
/// Load a value into the global
247-
///
248-
/// Returns the old value, if any
249-
pub fn load(&self, value: T) -> Option<T> {
250-
critical_section::with(|cs| self.inner.borrow(cs).replace(Some(value)))
251-
}
252-
}
253-
254-
/// The local type for sharing things with an interrupt handler
255-
pub struct LocalIrqState<T> {
256-
inner: Option<T>,
257-
}
258-
259-
impl<T> LocalIrqState<T> {
260-
/// Create a new, empty, object
261-
pub const fn new() -> LocalIrqState<T> {
262-
LocalIrqState { inner: None }
263-
}
264-
265-
/// Grab a mutable reference to the contents.
266-
///
267-
/// If the value is empty, the contents are taken from a mutex-locked global
268-
/// variable. That global must have been initialised before calling this
269-
/// function. If not, this function panics.
270-
pub fn get_or_init_with(&mut self, global: &GlobalIrqState<T>) -> &mut T {
271-
let result = self.inner.get_or_insert_with(|| {
272-
critical_section::with(|cs| global.inner.borrow(cs).replace(None).unwrap())
273-
});
274-
result
275-
}
276-
}
277-
278233
/// The ways that initialisation can fail
279234
#[derive(Debug, Copy, Clone, defmt::Format)]
280235
pub enum Error {

nrf52-code/puzzle-fw/Cargo.lock

Lines changed: 168 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nrf52-code/puzzle-fw/Cargo.toml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,15 @@ version = "0.0.0"
77

88
[dependencies]
99
consts = { path = "../consts" }
10-
cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]}
11-
cortex-m-rt = "0.7.5"
12-
critical-section = "1.2.0"
10+
defmt = "0.3.10"
11+
defmt-rtt = "0.4.1"
1312
dongle = { path = "../boards/dongle" }
14-
embedded-hal = "1.0"
15-
heapless = "0.8"
16-
usb-device = "0.3"
17-
usbd-hid = "0.8"
18-
usbd-serial = "0.2"
13+
heapless = { version = "0.8.0", features = ["defmt-03"] }
14+
rtic = { version = "2.1.2", features = ["thumbv7-backend"] }
15+
rtic-monotonics = { version = "2.0.3", features = ["cortex-m-systick"] }
16+
usb-device = { version = "0.3.2", features = ["defmt"] }
17+
usbd-hid = { version = "0.8.2", features = ["defmt"] }
18+
usbd-serial = "0.2.2"
1919

2020
[build-dependencies]
2121
rand = "0.8.5"
22-
23-
# optimize code in both profiles
24-
[profile.dev]
25-
codegen-units = 1
26-
debug = 2
27-
debug-assertions = true # !
28-
incremental = false
29-
lto = "fat"
30-
opt-level = 'z' # !
31-
overflow-checks = false
32-
33-
[profile.release]
34-
codegen-units = 1
35-
debug = 2
36-
debug-assertions = false
37-
incremental = false
38-
lto = "fat"
39-
opt-level = 3
40-
overflow-checks = false

0 commit comments

Comments
 (0)