refactor signaling with led and debug pins

This commit is contained in:
2020-11-01 22:15:04 +01:00
parent 99addddede
commit b7f32a6bf6
9 changed files with 53 additions and 103 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 Nov 01 15:55:46 CET 2020] # File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sun Nov 01 15:55:46 CET 2020]
########################################################################################################################## ##########################################################################################################################
@ -36,36 +36,36 @@ BUILD_DIR = build
# source # source
###################################### ######################################
# C sources # C sources
C_SOURCES = \ C_SOURCES = \
User/Src/frontend.c User/Src/led.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c hottislib/PontCoopScheduler.c \ User/Src/frontend.c User/Src/signal.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c hottislib/PontCoopScheduler.c \
Core/Src/main.c \ Core/Src/main.c \
Core/Src/gpio.c \ Core/Src/gpio.c \
Core/Src/adc.c \ Core/Src/adc.c \
Core/Src/spi.c \ Core/Src/spi.c \
Core/Src/usart.c \ Core/Src/usart.c \
Core/Src/stm32f1xx_it.c \ Core/Src/stm32f1xx_it.c \
Core/Src/stm32f1xx_hal_msp.c \ Core/Src/stm32f1xx_hal_msp.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.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.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.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.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.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_rcc_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.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_dma.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.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_pwr.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.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_flash_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.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_spi.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.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_tim_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
Core/Src/system_stm32f1xx.c Core/Src/system_stm32f1xx.c
# ASM sources # ASM sources
ASM_SOURCES = \ ASM_SOURCES = \
startup_stm32f103xe.s startup_stm32f103xe.s
@ -109,8 +109,8 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
AS_DEFS = AS_DEFS =
# C defines # C defines
C_DEFS = \ C_DEFS = \
-DUSE_HAL_DRIVER \ -DUSE_HAL_DRIVER \
-DSTM32F103xE -DSTM32F103xE
@ -118,14 +118,14 @@ C_DEFS = \
AS_INCLUDES = AS_INCLUDES =
# C includes # C includes
C_INCLUDES = \ C_INCLUDES = \
-Ihottislib \ -Ihottislib \
-IUser/Inc \ -IUser/Inc \
-ICore/Inc \ -ICore/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc \ -IDrivers/STM32F1xx_HAL_Driver/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
-IDrivers/CMSIS/Include \ -IDrivers/CMSIS/Include \
-IDrivers/CMSIS/Include -IDrivers/CMSIS/Include

View File

@ -9,5 +9,6 @@ void frontendInit();
void frontendAdcCallback(ADC_HandleTypeDef* hadc); void frontendAdcCallback(ADC_HandleTypeDef* hadc);
void frontendEnable(); void frontendEnable();
void frontendDisable(); void frontendDisable();
void frontendSetThreshold(int32_t threshold);
#endif // _FRONTEND_H_ #endif // _FRONTEND_H_

View File

@ -1,11 +0,0 @@
#ifndef _LED_H_
#define _LED_H_
#include <stdbool.h>
typedef enum { RED, GREEN } ledColor_t;
typedef enum { ON, OFF, TOGGLE } ledAction_t;
void led(ledColor_t color, ledAction_t action);
#endif // _LED_H_

View File

@ -10,7 +10,7 @@
static volatile int32_t frontendAdcThreshold = 240; static volatile int32_t frontendAdcThreshold = 0;
static volatile bool frontendEnabled = false; static volatile bool frontendEnabled = false;
@ -21,7 +21,7 @@ void frontendInit() {
logMsg("frontendInit, adc started"); logMsg("frontendInit, adc started");
} }
void frontendSetThreshold(uint16_t threshold) { void frontendSetThreshold(int32_t threshold) {
frontendAdcThreshold = threshold; frontendAdcThreshold = threshold;
} }

View File

@ -1,39 +0,0 @@
#include <main.h>
#include <led.h>
#include <stdint.h>
#include <stdlib.h>
#include <stm32f103xe.h>
void led(ledColor_t color, ledAction_t action) {
GPIO_TypeDef *port = NULL;
uint16_t pin = 0;
switch (color) {
case RED:
port = LED_Red_GPIO_Port;
pin = LED_Red_Pin;
break;
case GREEN:
port = LED_Green_GPIO_Port;
pin = LED_Green_Pin;
break;
}
if (port != NULL) {
switch (action) {
case ON:
HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET);
break;
case OFF:
HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET);
break;
case TOGGLE:
HAL_GPIO_TogglePin(port, pin);
break;
}
}
}

View File

@ -1,7 +1,7 @@
#ifndef TEST #ifndef TEST
#include <main.h> #include <main.h>
#include <usart.h> #include <usart.h>
#include <led.h> #include <signal.h>
#include <PontCoopScheduler.h> #include <PontCoopScheduler.h>
#endif #endif
@ -56,7 +56,7 @@ int logExec() {
#ifndef TEST #ifndef TEST
static void flashGreenLed(void *handle) { static void flashGreenLed(void *handle) {
led(GREEN, TOGGLE); signal(LED_GREEN, TOGGLE);
} }
#endif // TEST #endif // TEST

View File

@ -1,6 +1,6 @@
#include <main.h> #include <main.h>
#include <loopCtrl.h> #include <loopCtrl.h>
#include <led.h> #include <signal.h>
bool loopActive = false; bool loopActive = false;
@ -20,7 +20,7 @@ void loopDisable() {
void loopStatusCallback() { void loopStatusCallback() {
GPIO_PinState status = HAL_GPIO_ReadPin(Loop_Status_GPIO_Port, Loop_Status_Pin); GPIO_PinState status = HAL_GPIO_ReadPin(Loop_Status_GPIO_Port, Loop_Status_Pin);
if (status == GPIO_PIN_SET) { if (status == GPIO_PIN_SET) {
led(RED, ON); signal(LED_RED, ON);
loopActive = false; loopActive = false;
} }
} }

View File

@ -9,20 +9,19 @@
#include <PontCoopScheduler.h> #include <PontCoopScheduler.h>
#include <led.h> #include <signal.h>
#include <loopCtrl.h> #include <loopCtrl.h>
#include <mbusComm.h> #include <mbusComm.h>
#include <logger.h> #include <logger.h>
#include <frontend.h> #include <frontend.h>
void my_setup_1() { void my_setup_1() {
schInit(); schInit();
logInit(); logInit();
} }
void my_errorHandler() { void my_errorHandler() {
led(RED, ON); signal(LED_RED, ON);
} }
void helloMeterbus(void *handle) { void helloMeterbus(void *handle) {
@ -34,17 +33,17 @@ void helloMeterbus(void *handle) {
void my_setup_2() { void my_setup_2() {
led(RED, OFF); signal(LED_RED, OFF);
led(GREEN, ON); signal(LED_GREEN, ON);
frontendInit(); frontendInit();
frontendSetThreshold(240);
schAdd(helloMeterbus, NULL, 0, 1000); schAdd(helloMeterbus, NULL, 0, 1000);
} }
void my_loop() { void my_loop() {
HAL_GPIO_TogglePin(Debug_Signal_2_GPIO_Port, Debug_Signal_2_Pin); signal(DEBUG_1, TOGGLE);
schExec(); schExec();
logExec(); logExec();

View File

@ -3,7 +3,7 @@
#include <PontCoopScheduler.h> #include <PontCoopScheduler.h>
#include <mbusComm.h> #include <mbusComm.h>
#include <loopCtrl.h> #include <loopCtrl.h>
#include <led.h> #include <signal.h>
#include <logger.h> #include <logger.h>
#include <frontend.h> #include <frontend.h>
@ -48,7 +48,7 @@ static void handleRequestEngine(void *handle) {
case SEND_CONT: case SEND_CONT:
logMsg("hre state SEND_CONT"); logMsg("hre state SEND_CONT");
led(RED, OFF); signal(LED_RED, OFF);
if (! loopActive) { if (! loopActive) {
logMsg("hre enabling loop, try %d", localMbusCommHandle->retryCnt); logMsg("hre enabling loop, try %d", localMbusCommHandle->retryCnt);
localMbusCommHandle->retryCnt++; localMbusCommHandle->retryCnt++;