does not compile, probably, just some notes.

This commit is contained in:
paul nehlich
2024-06-18 12:16:21 +02:00
parent d0a9ea16b9
commit 08b4bf2ad7
5 changed files with 100 additions and 10 deletions

View File

@ -57,16 +57,67 @@ extern "C" {
pub fn gpio_read_pin(pin: u32) -> u32;
pub fn gpio_toggle_pin(pin: u32) -> ();
// CAN Samples
pub fn canps_poll_example() -> i32;
}
pub mod can {
use core::fmt::Error;
pub fn read_data() -> Result<i32, Error>
{
if (unsafe {can_unsafe::canps_get_status().is_initialized == false}) {
return Err(Error);
}
unsafe {
Ok(can_unsafe::canps_poll_example())
}
}
mod can_unsafe {
extern "C" {
// CAN Samples
pub fn canps_setup() -> i32;
pub fn canps_send_data() -> i32;
pub fn canps_read_data() -> i32;
pub fn canps_get_status() -> canps_status;
pub fn canps_poll_example() -> i32;
}
#[repr(C)]
pub struct canps_status {
pub is_initialized: bool
}
}
}
// RustFSW
// -> hal::can
// -> hal::can::unsafe //
// -> mission/can_rust_helper.c //
// -> BSP/XCanPS
mod safe_osal {
/*
* Is safe. Trust me, I'm an engineer.
*/
pub fn gpio_setup() {
unsafe {
crate::osal::gpio_setup();
}
}
}
pub fn task_delete_self() {
unsafe {

View File

@ -186,7 +186,7 @@ fn mission() {
sifln!("Call canps poll example()");
canps_poll_example();
can::unsafe::canps_poll_example();
}
sifln!("Called canps poll example()");