wrote some ffi functions and interfaces
tested the fact that the rust library could be used in a embedded application
This commit is contained in:
@ -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]
|
||||
|
@ -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]
|
||||
|
Reference in New Issue
Block a user