From c471de9179fa2f1b87d7ac4b65f877b79b76b0b8 Mon Sep 17 00:00:00 2001 From: paul nehlich Date: Tue, 18 Jun 2024 12:17:04 +0200 Subject: [PATCH] save all would be great --- mission/can_rust_helper.c | 2 -- mission/gpio_rust_helper.c | 73 +++++++++++++++++++------------------- mission_rust/src/lib.rs | 20 ++++++++++- structures.txt | 23 ++++++++++++ 4 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 structures.txt diff --git a/mission/can_rust_helper.c b/mission/can_rust_helper.c index 135ee4d..078d7f8 100644 --- a/mission/can_rust_helper.c +++ b/mission/can_rust_helper.c @@ -335,5 +335,3 @@ static int RecvFrame(XCanPs *InstancePtr) return Status; } - -# define FALSE 2U \ No newline at end of file diff --git a/mission/gpio_rust_helper.c b/mission/gpio_rust_helper.c index 186ad48..97ba906 100644 --- a/mission/gpio_rust_helper.c +++ b/mission/gpio_rust_helper.c @@ -8,54 +8,55 @@ if(TargetIsLinux) - -XGpioPs gpio; -void gpio_setup() { -} + + XGpioPs gpio; + void gpio_setup() { + } -void gpio_write_pin(uint32_t pin, uint32_t data) { -} + void gpio_write_pin(uint32_t pin, uint32_t data) { + } -uint32_t gpio_read_pin(uint32_t pin) { - return 1; -} + uint32_t gpio_read_pin(uint32_t pin) { + return 1; + } + + void gpio_toggle_pin(uint32_t pin) { + } -void gpio_toggle_pin(uint32_t pin) { -} endif() if(TargetIsZedboard TRUE) -XGpioPs gpio; -void gpio_setup() { - XGpioPs_Config config; - config.DeviceId = 4; // chosen by fair dice throw - config.BaseAddr = XPS_GPIO_BASEADDR; - s32 returncode = XGpioPs_CfgInitialize(&gpio, &config, XPS_GPIO_BASEADDR); - //printf("Configured XGPIO"); - XGpioPs_SetDirection(&gpio, 0, (1 << 7)); - XGpioPs_SetOutputEnable(&gpio, 0, (1 << 7)); - XGpioPs_WritePin(&gpio, 7, 1); - //printf("Blinking is initialized"); - XGpioPs_WritePin(&gpio, 7, 0); - //printf("Value written once"); -} + XGpioPs gpio; // Global! + void gpio_setup() { + XGpioPs_Config config; // Global! + config.DeviceId = 4; // chosen by fair dice throw // Global! + config.BaseAddr = XPS_GPIO_BASEADDR; // Global! + s32 returncode = XGpioPs_CfgInitialize(&gpio, &config, XPS_GPIO_BASEADDR); // Global! + //printf("Configured XGPIO"); + XGpioPs_SetDirection(&gpio, 0, (1 << 7)); + XGpioPs_SetOutputEnable(&gpio, 0, (1 << 7)); + XGpioPs_WritePin(&gpio, 7, 1); + //printf("Blinking is initialized"); + XGpioPs_WritePin(&gpio, 7, 0); + //printf("Value written once"); + } -void gpio_write_pin(uint32_t pin, uint32_t data) { - XGpioPs_WritePin(&gpio, pin, data); -} + void gpio_write_pin(uint32_t pin, uint32_t data) { + XGpioPs_WritePin(&gpio, pin, data); + } -uint32_t gpio_read_pin(uint32_t pin) { - return XGpioPs_ReadPin(&gpio, pin); -} + uint32_t gpio_read_pin(uint32_t pin) { + return XGpioPs_ReadPin(&gpio, pin); + } -void gpio_toggle_pin(uint32_t pin) { - static int pinvalue = 1; - pinvalue = pinvalue ^ 1; - XGpioPs_WritePin(&gpio, pin, pinvalue); -} + void gpio_toggle_pin(uint32_t pin) { + static int pinvalue = 1; + pinvalue = pinvalue ^ 1; + XGpioPs_WritePin(&gpio, pin, pinvalue); + } endif() \ No newline at end of file diff --git a/mission_rust/src/lib.rs b/mission_rust/src/lib.rs index 7d94ed7..71bc3cf 100644 --- a/mission_rust/src/lib.rs +++ b/mission_rust/src/lib.rs @@ -170,10 +170,17 @@ impl SystemObjectIF for HandlerSender { } } -fn mission() { +fn mission() { // lets call it "main()" sifln!("Mission enter"); + // When the IOs are initialized later.. what do we do here?! + setup_all_com_if { + + gpio_cookie.setup() // needs to register cookies -> ComIFs haben ObjectIDs -> Kennt ein ComIF alle seine Cookies? (Potentiell ja, weil sie dort erstellt werden) + + } + use crate::osal::*; unsafe { sifln!("Setup GPIO"); @@ -218,6 +225,17 @@ fn mission() { tasks: &mut [&mut t1, &mut t2], }; + + // Initialize all IOs + init_all_com_if { + for comIF in comIFs { + for cookie in comIF.get_cookies() { + cookie.init() + } + } + } + + // At last HERE all IOs must be configerued and ready for operations! task_executor.init_and_run(false); sifln!("Mission delay"); diff --git a/structures.txt b/structures.txt new file mode 100644 index 0000000..2d54ec4 --- /dev/null +++ b/structures.txt @@ -0,0 +1,23 @@ + + +C +BSP_z7 XGpio...c // Linux (FreeRTOS compiled for Linux! (Wollen wir!)) + mission-BSP gpio_rust_helper.c + FreeRTOS (/ RTEMS / Linux (haben wir nicht vor!)) (Für Hardwareabstractions egal!) + Rust + mod osal + mod safe_osal + FSRC + + + +BSP_z7 +FreeRTOS +mission + osal (-> FreeRTOS / Linux) + hal (-> BSP_z7 / BSP_ROMEO_OBC / Linux_Sockets_Simulator) +mission_rust + fsrc (-> osal (z.B TaskScheduler), hal (zB. trait ComIF)) + rfsw (-> fsrc ) + +