Skip to content

Commit

Permalink
fix toboot_config example
Browse files Browse the repository at this point in the history
  • Loading branch information
fudanchii committed Oct 22, 2019
1 parent 01a2f8f commit b50078b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions examples/blink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ use tomu::{prelude::*, Tomu};
fn main() -> ! {
let mut tomu = Tomu::take().unwrap();

// constrain CMU and split into device clocks
// so we can enable gpio with its owned clock
let clk_mgmt = tomu.CMU.constrain().split();
let gpio = tomu.GPIO.split(clk_mgmt.gpio).pins();

// create tomu's led instance from gpio pin
let leds = led::LEDs::new(gpio.pa0.into(), gpio.pb7.into());

let mut red = leds.red;
Expand Down
15 changes: 13 additions & 2 deletions examples/toboot_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ use cortex_m_rt::entry;

use tomu::{prelude::*, Tomu};

// this will cause tomu to always enter user application,
// short the 2 pins on the corner while inserting tomu to
// enter bootloader.
toboot_config! {
config: [autorun_enable],
}
Expand All @@ -21,8 +24,16 @@ toboot_config! {
fn main() -> ! {
let mut tomu = Tomu::take().unwrap();

tomu.leds.red.off();
tomu.leds.green.on();
let clk_mgmt = tomu.CMU.constrain().split();
let gpio = tomu.GPIO.split(clk_mgmt.gpio).pins();

let leds = led::LEDs::new(gpio.pa0.into(), gpio.pb7.into());

let mut red = leds.red;
let mut green = leds.green;

red.off();
green.on();

loop {
tomu.watchdog.feed();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub struct Tomu {
/// efm32 peripheral: RTC
pub RTC: efm32::RTC,

/// efm32 periphral: SYSTICK
/// efm32 peripheral: SYSTICK
pub SYST: efm32::SYST,

/// efm32 peripheral: TIMER0
Expand Down

0 comments on commit b50078b

Please sign in to comment.