bootloader: configure PTE24 for push button use.
[gps-watch.git] / src / bootloader / main.rs
index fbd3aa0c01c03d6bbe34352e97b5349920f1a6ad..2e43b67eb9dc3762f3301d39d07ecdc79090fe45 100644 (file)
 
 extern crate common;
 
+mod flash;
+mod bootloader;
+
 use common::clock;
+use common::systick;
+use common::port;
+use common::gpio;
 use common::usb_serial;
 
+extern {
+    fn jump_to_application(address: u32);
+}
+
+const APPLICATION_ADDR: u32 = 0x0;
+
 #[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 {
-        usb_serial::init();
+        usb_serial::init(0xf055, 0x635c);
+
+        let mut b = bootloader::Bootloader::new();
 
-        loop {
+        while b.run() {
         }
     }
+
+    jump_to_application(__application_addr);
 }