some minimal progress

This commit is contained in:
Wolfgang Hottgenroth 2020-10-27 15:12:19 +01:00
parent 5aa62d9f38
commit 1edf9355aa
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
6 changed files with 106 additions and 73 deletions

View File

@ -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

9
cube/User/Inc/led.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef _LED_H_
#define _LED_H_
#include <stdbool.h>
void ledRed(bool on);
void ledGreen(bool on);
#endif // _LED_H_

8
cube/User/Inc/loopCtrl.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef _LOOPCTRL_H_
#define _LOOPCTRL_H_
void loopEnable();
void loopDisable();
#endif // _LOOPCTRL_H_

10
cube/User/Src/led.c Normal file
View File

@ -0,0 +1,10 @@
#include <main.h>
#include <led.h>
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);
}

12
cube/User/Src/loopCtrl.c Normal file
View File

@ -0,0 +1,12 @@
#include <main.h>
#include <loopCtrl.h>
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);
}

View File

@ -7,72 +7,66 @@
#include <main.h>
#include <usart.h>
#include <led.h>
#include <loopCtrl.h>
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();
}