Enable GPIO Pull Up and Down

This commit is contained in:
2025-05-21 20:49:07 +02:00
parent 83adfc9311
commit 70eb41b3d5
6 changed files with 57 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ fn panic(_panic: &PanicInfo) -> ! {
#[no_mangle]
#[link_section = ".text._start"]
pub unsafe extern "C" fn _start() {
// Set the stack pointer
asm!("ldr x0, =0x8004000", "mov sp, x0");
main();
}
@@ -29,19 +30,25 @@ pub unsafe extern "C" fn _start() {
extern "C" fn main() {
uart::configure_uart();
unsafe {
// Set ACT Led to Outout
let _ = set_gpio_state(29, gpio::GPIOState::Output);
// Set GPIO Pins to UART
let _ = set_gpio_state(14, gpio::GPIOState::Alternative0);
let _ = set_gpio_state(15, gpio::GPIOState::Alternative0);
}
// Delay so clock speed can stabilize
unsafe { delay_nops(50000) }
delay_nops(50000);
uart::print("Hello World!\n");
sleep(500_000);
loop {
let _ = gpio_high(29);
unsafe { sleep(500_000) } // 0.5s
sleep(500_000); // 0.5s
let _ = gpio_low(29);
unsafe { sleep(500_000) } // 0.5s
sleep(500_000) // 0.5s
}
}