mod bootloader;
use common::clock;
+use common::systick;
+use common::port;
+use common::gpio;
use common::usb_serial;
extern {
const APPLICATION_ADDR: u32 = 0x0;
+fn bootloader_requested() -> bool {
+ let start_ticks = systick::now();
+
+ while !systick::has_timeout_ms(start_ticks, 3000) {
+ if (gpio::get(gpio::GPIOE) & (1 << 24)) == 0 {
+ return true;
+ }
+ }
+
+ false
+}
+
#[no_mangle]
pub unsafe extern fn main() {
clock::configure();
+ systick::init();
+
+ // Configure lower left push button.
+ gpio::set_direction(gpio::GPIOE, 1 << 24, gpio::Direction::Input);
+ port::set_af(port::PORTE, 24, 1);
+ port::set_pull(port::PORTE, 24, port::Pull::Up);
- if true {
+ if bootloader_requested() {
usb_serial::init(0xf055, 0x635c);
let mut b = bootloader::Bootloader::new();
}
}
- jump_to_application(__application_addr);
+ jump_to_application(APPLICATION_ADDR);
}