Skip to content

Commit 7c41394

Browse files
committed
Improve M2 Bootloader LED Handling
Added busy-wait delay for visible LED blinking - Turn on LED at bootloader start for debugging - Used cortex_m::asm::nop() for safer delay loops - Improved comments and code readability - Prepared code for future enhancements like timers and UART debug
1 parent 7596c3f commit 7c41394

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

app/src/main.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
1-
//! M2 Bootloader RUST
2-
//! ------------------
1+
//! M2 Bootloader RUST APP Module
2+
//! ------------------------------
33
//! License : Dual License
44
//! - Apache 2.0 for open-source / personal use
55
//! - Commercial license required for closed-source use
66
//! Author : Md Mahbubur Rahman
77
//! URL : <https://m-a-h-b-u-b.github.io>
8-
//! GitHub : <https://github.com/m-a-h-b-u-b/M2-Bootloader-RUST>
9-
8+
//! GitHub : <https://github.com/m-a-h-b-u-b/M2-Bootloader-Rust>
109
1110
#![no_std]
1211
#![no_main]
1312

13+
use cortex_m::asm;
1414
use cortex_m_rt::entry;
1515
mod peripherals;
1616

17+
/// Entry point for the bootloader
1718
#[entry]
1819
fn main() -> ! {
20+
// Initialize system peripherals (LED, timers, etc.)
1921
peripherals::init_led();
2022

23+
// Optional: indicate bootloader start
24+
peripherals::led_on();
25+
2126
loop {
27+
// Toggle LED with a delay for visible blinking
2228
peripherals::toggle_led();
29+
delay();
30+
}
31+
}
32+
33+
/// Simple busy-wait delay
34+
#[inline(always)]
35+
fn delay() {
36+
// Adjust the count depending on the target MCU clock speed
37+
for _ in 0..5_000_000 {
38+
asm::nop();
2339
}
24-
}
40+
}

0 commit comments

Comments
 (0)