Skip to content

Commit

Permalink
keyboard: use SCB::system_reset2
Browse files Browse the repository at this point in the history
  • Loading branch information
hdhoang committed Mar 27, 2019
1 parent 7f62a63 commit 700351f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ cortex-m-semihosting = "0.3.1"
nb = "0.1.1"
vcell = "0.1.0"

[patch.crates-io.cortex-m]
# for SCB::system_reset2
git = "https://github.com/hdhoang/cortex-m"
branch = "static-system_reset2"

[dependencies.rtfm]
package = "cortex-m-rtfm"
version = "0.4.2"
Expand Down
10 changes: 3 additions & 7 deletions src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::led::Led;
use crate::usb::Usb;
use bit_field::{BitArray, BitField};
use core::marker::Unsize;
//use stm32l1::stm32l151::SCB;
use stm32l1::stm32l151::SCB;

pub struct Keyboard {
layers: Layers,
Expand Down Expand Up @@ -51,7 +51,6 @@ impl Keyboard {
state: &KeyState,
bluetooth: &mut Bluetooth<BUFFER>,
led: &mut Led<BUFFER>,
// scb: &mut SCB,
usb: &mut Usb,
) where
BUFFER: Unsize<[u8]>,
Expand All @@ -69,11 +68,8 @@ impl Keyboard {
if pressed || changed {
let action = self.get_action(key);
if pressed && Action::Reset == action {
crate::heprintln!(
"figure out how to acquire SCB to call
scb.system_reset()"
)
.ok();
crate::heprintln!("system reset").ok();
SCB::system_reset2()
}
if pressed && Action::UsbToggle == action {
self.send_usb_report = !self.send_usb_report;
Expand Down
3 changes: 0 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const APP: () = {
static mut BLUETOOTH: Bluetooth<[u8; 0x80]> = ();
static mut LED: Led<[u8; 0x80]> = ();
static mut KEY_MATRIX: KeyMatrix = ();
// static mut SCB: stm32l1::stm32l151::SCB = ();
static mut SYST: stm32l1::stm32l151::SYST = ();
static mut EXTI: stm32l1::stm32l151::EXTI = ();
static mut USB: Usb = ();
Expand Down Expand Up @@ -130,7 +129,6 @@ const APP: () = {
BLUETOOTH: bluetooth,
KEY_MATRIX: key_matrix,
LED: led,
// SCB: core.SCB.as_ref(),
SYST: core.SYST,
EXTI: device.EXTI,
USB: usb,
Expand All @@ -144,7 +142,6 @@ const APP: () = {
&resources.KEY_MATRIX.state,
&mut resources.BLUETOOTH,
&mut resources.LED,
// &mut resources.SCB,
&mut resources.USB,
);
}
Expand Down

0 comments on commit 700351f

Please sign in to comment.