From 1edf9355aad06d54c3e151903f928e8f93e7d69f Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Tue, 27 Oct 2020 15:12:19 +0100 Subject: [PATCH] some minimal progress --- cube/Makefile | 76 ++++++++++++++++++++-------------------- cube/User/Inc/led.h | 9 +++++ cube/User/Inc/loopCtrl.h | 8 +++++ cube/User/Src/led.c | 10 ++++++ cube/User/Src/loopCtrl.c | 12 +++++++ cube/User/Src/main2.c | 64 +++++++++++++++------------------ 6 files changed, 106 insertions(+), 73 deletions(-) create mode 100644 cube/User/Inc/led.h create mode 100644 cube/User/Inc/loopCtrl.h create mode 100644 cube/User/Src/led.c create mode 100644 cube/User/Src/loopCtrl.c diff --git a/cube/Makefile b/cube/Makefile index 08d92c1..0f37ccb 100644 --- a/cube/Makefile +++ b/cube/Makefile @@ -1,4 +1,4 @@ -# Processed by ../tools/insertMyCode.sh +# Processed by ../tools/insertMyCode.sh ########################################################################################################################## # File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sun Oct 18 22:15:54 CEST 2020] ########################################################################################################################## @@ -36,36 +36,36 @@ BUILD_DIR = build # source ###################################### # C sources -C_SOURCES = \ -User/Src/main2.c hottislib/PontCoopScheduler.c \ -Core/Src/main.c \ -Core/Src/gpio.c \ -Core/Src/adc.c \ -Core/Src/spi.c \ -Core/Src/usart.c \ -Core/Src/stm32f1xx_it.c \ -Core/Src/stm32f1xx_hal_msp.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ +C_SOURCES = \ +User/Src/main2.c User/Src/led.c User/Src/loopCtrl.c hottislib/PontCoopScheduler.c \ +Core/Src/main.c \ +Core/Src/gpio.c \ +Core/Src/adc.c \ +Core/Src/spi.c \ +Core/Src/usart.c \ +Core/Src/stm32f1xx_it.c \ +Core/Src/stm32f1xx_hal_msp.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ Core/Src/system_stm32f1xx.c # ASM sources -ASM_SOURCES = \ +ASM_SOURCES = \ startup_stm32f103xe.s @@ -109,8 +109,8 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) AS_DEFS = # C defines -C_DEFS = \ --DUSE_HAL_DRIVER \ +C_DEFS = \ +-DUSE_HAL_DRIVER \ -DSTM32F103xE @@ -118,14 +118,14 @@ C_DEFS = \ AS_INCLUDES = # C includes -C_INCLUDES = \ --Ihottislib \ --IUser/Inc \ --ICore/Inc \ --IDrivers/STM32F1xx_HAL_Driver/Inc \ --IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ --IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ --IDrivers/CMSIS/Include \ +C_INCLUDES = \ +-Ihottislib \ +-IUser/Inc \ +-ICore/Inc \ +-IDrivers/STM32F1xx_HAL_Driver/Inc \ +-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ +-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ +-IDrivers/CMSIS/Include \ -IDrivers/CMSIS/Include diff --git a/cube/User/Inc/led.h b/cube/User/Inc/led.h new file mode 100644 index 0000000..5e47f4d --- /dev/null +++ b/cube/User/Inc/led.h @@ -0,0 +1,9 @@ +#ifndef _LED_H_ +#define _LED_H_ + +#include + +void ledRed(bool on); +void ledGreen(bool on); + +#endif // _LED_H_ diff --git a/cube/User/Inc/loopCtrl.h b/cube/User/Inc/loopCtrl.h new file mode 100644 index 0000000..3ea1653 --- /dev/null +++ b/cube/User/Inc/loopCtrl.h @@ -0,0 +1,8 @@ +#ifndef _LOOPCTRL_H_ +#define _LOOPCTRL_H_ + +void loopEnable(); +void loopDisable(); + + +#endif // _LOOPCTRL_H_ diff --git a/cube/User/Src/led.c b/cube/User/Src/led.c new file mode 100644 index 0000000..e896a67 --- /dev/null +++ b/cube/User/Src/led.c @@ -0,0 +1,10 @@ +#include +#include + +void ledRed(bool on) { + HAL_GPIO_WritePin(LED_Red_GPIO_Port, LED_Red_Pin, on ? GPIO_PIN_SET : GPIO_PIN_RESET); +} + +void ledGreen(bool on) { + HAL_GPIO_WritePin(LED_Green_GPIO_Port, LED_Green_Pin, on ? GPIO_PIN_SET : GPIO_PIN_RESET); +} diff --git a/cube/User/Src/loopCtrl.c b/cube/User/Src/loopCtrl.c new file mode 100644 index 0000000..1242f4a --- /dev/null +++ b/cube/User/Src/loopCtrl.c @@ -0,0 +1,12 @@ +#include +#include + +void loopEnable() { + HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_RESET); +} + +void loopDisable() { + HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_RESET); +} diff --git a/cube/User/Src/main2.c b/cube/User/Src/main2.c index 68b025c..9baf0f4 100644 --- a/cube/User/Src/main2.c +++ b/cube/User/Src/main2.c @@ -7,72 +7,66 @@ #include #include +#include +#include void my_setup_1() { - schInit(); - + schInit(); } void my_errorHandler() { - + ledRed(true); } void blinkRed(void *handle) { - HAL_GPIO_TogglePin(LED_Red_GPIO_Port, LED_Red_Pin); + static bool on = false; + ledRed(on); + on ^= true; } void blinkGreen(void *handle) { - HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin); + static bool on = false; + ledGreen(on); + on ^= true; } void helloWorld(void *handle) { - static char hello[] = "Hello World\n\r"; - HAL_UART_Transmit_IT(&debugUart, (uint8_t*) hello, strlen(hello)); + static char hello[] = "Hello World\n\r"; + HAL_UART_Transmit_IT(&debugUart, (uint8_t*) hello, strlen(hello)); } void helloMeterbus(void *handle) { - static char hello[] = "Hello Meterbus\n\r"; - HAL_UART_Transmit_IT(&mbusUart, (uint8_t*) hello, strlen(hello)); -} - -void enableLoop(void *handle) { - HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(Loop_Enable_GPIO_Port, Loop_Enable_Pin, GPIO_PIN_RESET); -} - -void disableLoop(void *handle) { - HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_RESET); + static char hello[] = "Hello Meterbus\n\r"; + HAL_UART_Transmit_IT(&mbusUart, (uint8_t*) hello, strlen(hello)); } void toggleLoop(void *handle) { - static bool state = false; + static bool state = false; - if (state) { - disableLoop(NULL); - } else { - enableLoop(NULL); - } - state ^= true; + if (state) { + loopDisable(); + } else { + loopEnable(); + } + state ^= true; } void my_setup_2() { - schAdd(blinkRed, NULL, 0, 500); - schAdd(blinkGreen, NULL, 0, 1000); - schAdd(helloWorld, NULL, 0, 5000); - // schAdd(enableLoop, NULL, 10000, 0); - // schAdd(disableLoop, NULL, 20000, 0); - schAdd(toggleLoop, NULL, 0, 10000); - schAdd(helloMeterbus, NULL, 0, 1000); + ledRed(false); + ledGreen(true); + + schAdd(helloWorld, NULL, 0, 5000); + schAdd(toggleLoop, NULL, 0, 10000); + schAdd(helloMeterbus, NULL, 0, 1000); } void my_loop() { - schExec(); + schExec(); } void SYSTICK_Callback() { - schUpdate(); + schUpdate(); }