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

@ -19,9 +19,16 @@ set(TARGET_NAME ${CMAKE_PROJECT_NAME})
# Set path names # Set path names
set(FreeRTOS_PATH FreeRTOS-Kernel/) set(FreeRTOS_PATH FreeRTOS-Kernel/)
set(MISSION_PATH mission/) set(MISSION_PATH mission/)
set(FreeRTOS_CONFIG_PATH bsp_z7/freeRTOS)
set(BSP_PATH bsp_z7)
set(CMAKE_MODULE_PATH Findcommon.cmake) set(TargetIsLinux TRUE)
endif()
set(TargetIsZedboard TRUE)
set(FreeRTOS_CONFIG_PATH bsp_z7/freeRTOS)
set(BSP_PATH bsp_z7)
endif()
set (LWIP_DIR contrib/lwip) set (LWIP_DIR contrib/lwip)
@ -30,6 +37,12 @@ set (LWIP_DIR contrib/lwip)
# Configuration # Configuration
# ############################################################################## # ##############################################################################
if(${TargetIsLinux} TRUE)
add_compile_definitions(ZYNQ_USE_UART0)
endif()
set(ZYNQ_UART UART1 CACHE STRING "Which PS UART to use for stdout") set(ZYNQ_UART UART1 CACHE STRING "Which PS UART to use for stdout")
set_property(CACHE ZYNQ_UART PROPERTY STRINGS UART0 UART1) set_property(CACHE ZYNQ_UART PROPERTY STRINGS UART0 UART1)

View File

@ -335,3 +335,5 @@ static int RecvFrame(XCanPs *InstancePtr)
return Status; return Status;
} }
# define FALSE 2U

View File

@ -6,6 +6,27 @@
/* GPIO SETUP AND USAGE */ /* GPIO SETUP AND USAGE */
/************************************************************/ /************************************************************/
if(TargetIsLinux)
XGpioPs gpio;
void gpio_setup() {
}
void gpio_write_pin(uint32_t pin, uint32_t data) {
}
uint32_t gpio_read_pin(uint32_t pin) {
return 1;
}
void gpio_toggle_pin(uint32_t pin) {
}
endif()
if(TargetIsZedboard TRUE)
XGpioPs gpio; XGpioPs gpio;
void gpio_setup() { void gpio_setup() {
XGpioPs_Config config; XGpioPs_Config config;
@ -35,3 +56,6 @@ void gpio_toggle_pin(uint32_t pin) {
pinvalue = pinvalue ^ 1; pinvalue = pinvalue ^ 1;
XGpioPs_WritePin(&gpio, pin, pinvalue); XGpioPs_WritePin(&gpio, pin, pinvalue);
} }
endif()

View File

@ -57,14 +57,65 @@ extern "C" {
pub fn gpio_read_pin(pin: u32) -> u32; pub fn gpio_read_pin(pin: u32) -> u32;
pub fn gpio_toggle_pin(pin: u32) -> (); pub fn gpio_toggle_pin(pin: u32) -> ();
}
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 // 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; 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();
}
}
}

View File

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