From f79e80f4b71b3a38f0bed6c166bf41238eca7781 Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Sun, 1 Jun 2025 18:19:13 +0200 Subject: blinky: add direct register access and uncomment prime search --- blinky/src/main.rs | 17 ++++++++++++++--- 1 file 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); } } -- cgit v1.2.3