diff --git a/autobar.c b/autobar.c index cc6e7ec..381e5f4 100644 --- a/autobar.c +++ b/autobar.c @@ -6,6 +6,11 @@ #include "pico/stdlib.h" +void gpio_put_explict(int pin, bool status) { + gpio_put(pin, status); + return; +} + void set_and_sleep(int pin, bool state, int sleep_duration); int main() { @@ -13,9 +18,7 @@ int main() { gpio_init(LED_PIN); gpio_set_dir(LED_PIN, GPIO_OUT); while (true) { - gpio_put(LED_PIN, 1); - sleep_ms(250); - gpio_put(LED_PIN, 0); - sleep_ms(250); + set_and_sleep(LED_PIN, 1, 1000); + set_and_sleep(LED_PIN, 0, 1000); } } diff --git a/libautobar/Cargo.toml b/libautobar/Cargo.toml index bb4a64b..eaa658d 100644 --- a/libautobar/Cargo.toml +++ b/libautobar/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "libautobar" -version = "0.1.0" +version = "0.0.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "autobar" +crate-type = ["staticlib"] [dependencies] diff --git a/libautobar/src/lib.rs b/libautobar/src/lib.rs index 1b4a90c..976c226 100644 --- a/libautobar/src/lib.rs +++ b/libautobar/src/lib.rs @@ -1,3 +1,26 @@ +#![no_std] + +use core::panic::PanicInfo; + +#[panic_handler] +fn panik(_panic_state: &PanicInfo) -> ! { + loop {} +} + +extern { + fn gpio_put_explict(pin: i32, status: bool) -> i32; + fn sleep_ms(time: i32) -> i32; +} + +#[no_mangle] +pub extern "C" fn set_and_sleep(pin: i32, status: bool, time: i32) -> () { + unsafe { + gpio_put_explict(pin, status); + sleep_ms(time); + } +} + +// this is just a mock test, supposed to pass #[cfg(test)] mod tests { #[test]