diff options
author | Friedrich Beckmann <friedrich.beckmann@gmx.de> | 2025-06-01 18:19:13 +0200 |
---|---|---|
committer | Friedrich Beckmann <friedrich.beckmann@gmx.de> | 2025-06-01 18:19:13 +0200 |
commit | f79e80f4b71b3a38f0bed6c166bf41238eca7781 (patch) | |
tree | e22650e303948227e5efebd0d23c0819823dec5f /blinky/src/main.rs | |
parent | 04882fa1544dcd5f01c2f382c0efc498d2ab93cd (diff) |
blinky: add direct register access and uncomment prime search
Diffstat (limited to 'blinky/src/main.rs')
-rw-r--r-- | blinky/src/main.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/blinky/src/main.rs b/blinky/src/main.rs index c027b11..a72c0c5 100644 --- a/blinky/src/main.rs +++ b/blinky/src/main.rs @@ -31,6 +31,10 @@ use rp_pico::hal::pac; // higher-level drivers. use rp_pico::hal; +// Direct register access +//use core::ptr::write_volatile; + +/* Prime search functions fn is_prime (a : u64) -> bool { if a % 2 == 0 {return false}; for i in (3..a.isqrt()).step_by(2) { @@ -47,6 +51,7 @@ fn find_next_smaller_prime(mut x : u64) -> u64 { while !is_prime(x) {x = x - 2}; return x; } +*/ /// Entry point to our bare-metal application. /// @@ -97,14 +102,20 @@ fn main() -> ! { // Set the LED to be an output let mut led_pin = pins.led.into_push_pull_output(); + // Define the SIO:GPIO_OUT_CLK Register address. See RP2040 Datasheet Chapter 2.3.1.7 + //const REG : *mut u32 = (0xd0000018) as *mut u32; + // Blink the LED at 1 Hz loop { led_pin.set_high().unwrap(); delay.delay_ms(500); - if find_next_smaller_prime(1<<36) > 5 { - led_pin.set_high().unwrap(); - } + //if find_next_smaller_prime(1<<36) > 5 { + // led_pin.set_high().unwrap(); + //} led_pin.set_low().unwrap(); + //unsafe { + // write_volatile(REG, 1<<25); + //} delay.delay_ms(500); } } |