From 1379f122c19cd216a03d6653e8ec2ae18bda0af5 Mon Sep 17 00:00:00 2001 From: paul nehlich Date: Fri, 24 May 2024 14:55:11 +0200 Subject: [PATCH] rust_helper Files created --- mission/CMakeLists.txt | 2 +- mission/can_rust_helper.c | 4 ++++ mission/freeRTOS_rust_helper.c | 34 ---------------------------------- mission/gpio_rust_helper.c | 34 ++++++++++++++++++++++++++++++++++ mission/uart_rust_helper.c | 4 ++++ 5 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 mission/can_rust_helper.c create mode 100644 mission/gpio_rust_helper.c create mode 100644 mission/uart_rust_helper.c diff --git a/mission/CMakeLists.txt b/mission/CMakeLists.txt index d53a240..3e65182 100644 --- a/mission/CMakeLists.txt +++ b/mission/CMakeLists.txt @@ -1 +1 @@ -target_sources(${TARGET_NAME} PRIVATE main.c testIp.c freeRTOS_rust_helper.c) \ No newline at end of file +target_sources(${TARGET_NAME} PRIVATE main.c testIp.c freeRTOS_rust_helper.c can_rust_helper.c uart_rust_helper.c gpio_rust_helper.c) \ No newline at end of file diff --git a/mission/can_rust_helper.c b/mission/can_rust_helper.c new file mode 100644 index 0000000..84cc00f --- /dev/null +++ b/mission/can_rust_helper.c @@ -0,0 +1,4 @@ + +/************************************************************/ +/* CAN SETUP AND USAGE */ +/************************************************************/ \ No newline at end of file diff --git a/mission/freeRTOS_rust_helper.c b/mission/freeRTOS_rust_helper.c index 070cf18..0cb0b4e 100644 --- a/mission/freeRTOS_rust_helper.c +++ b/mission/freeRTOS_rust_helper.c @@ -102,37 +102,3 @@ uint8_t give_mutex(void * handle) { } - -/************************************************************/ -/* GPIO SETUP AND USAGE */ -/************************************************************/ - -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"); -} - - -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); -} - -void gpio_toggle_pin(uint32_t pin) { - static int pinvalue = 1; - pinvalue = pinvalue ^ 1; - XGpioPs_WritePin(&gpio, pin, pinvalue); -} \ No newline at end of file diff --git a/mission/gpio_rust_helper.c b/mission/gpio_rust_helper.c new file mode 100644 index 0000000..b7df115 --- /dev/null +++ b/mission/gpio_rust_helper.c @@ -0,0 +1,34 @@ + +/************************************************************/ +/* GPIO SETUP AND USAGE */ +/************************************************************/ + +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"); +} + + +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); +} + +void gpio_toggle_pin(uint32_t pin) { + static int pinvalue = 1; + pinvalue = pinvalue ^ 1; + XGpioPs_WritePin(&gpio, pin, pinvalue); +} \ No newline at end of file diff --git a/mission/uart_rust_helper.c b/mission/uart_rust_helper.c new file mode 100644 index 0000000..240d12b --- /dev/null +++ b/mission/uart_rust_helper.c @@ -0,0 +1,4 @@ + +/************************************************************/ +/* UART SETUP AND USAGE */ +/************************************************************/ \ No newline at end of file