mirror of
https://github.com/iceHtwoO/novaOS.git
synced 2026-04-17 04:32:27 +00:00
Enable GPIO Pull Up and Down
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user