projects
/
gps-watch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bootloader: Rename bootloader.ld to bootloader-intermediate.ld.
[gps-watch.git]
/
src
/
bootloader
/
main.rs
diff --git
a/src/bootloader/main.rs
b/src/bootloader/main.rs
index 88a9a0bcf263c1cef50b517310bbd2fdbf8f6b88..d81da1532baa5b0b41f3a05f5f1adc7e1cf3d084 100644
(file)
--- a/
src/bootloader/main.rs
+++ b/
src/bootloader/main.rs
@@
-31,6
+31,9
@@
mod flash;
mod bootloader;
use common::clock;
mod bootloader;
use common::clock;
+use common::systick;
+use common::port;
+use common::gpio;
use common::usb_serial;
extern {
use common::usb_serial;
extern {
@@
-39,12
+42,30
@@
extern {
const APPLICATION_ADDR: u32 = 0x0;
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();
#[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(0x
1fc9, 0x0094
);
+ if
bootloader_requested()
{
+ usb_serial::init(0x
f055, 0x635c
);
let mut b = bootloader::Bootloader::new();
let mut b = bootloader::Bootloader::new();
@@
-52,5
+73,5
@@
pub unsafe extern fn main() {
}
}
}
}
- jump_to_application(
__application_addr
);
+ jump_to_application(
APPLICATION_ADDR
);
}
}