refactor signaling with led and debug pins
This commit is contained in:
@ -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]
|
||||
##########################################################################################################################
|
||||
@ -36,36 +36,36 @@ BUILD_DIR = build
|
||||
# source
|
||||
######################################
|
||||
# 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 \
|
||||
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/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/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,5 +9,6 @@ void frontendInit();
|
||||
void frontendAdcCallback(ADC_HandleTypeDef* hadc);
|
||||
void frontendEnable();
|
||||
void frontendDisable();
|
||||
void frontendSetThreshold(int32_t threshold);
|
||||
|
||||
#endif // _FRONTEND_H_
|
@ -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_
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
static volatile int32_t frontendAdcThreshold = 240;
|
||||
static volatile int32_t frontendAdcThreshold = 0;
|
||||
static volatile bool frontendEnabled = false;
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ void frontendInit() {
|
||||
logMsg("frontendInit, adc started");
|
||||
}
|
||||
|
||||
void frontendSetThreshold(uint16_t threshold) {
|
||||
void frontendSetThreshold(int32_t threshold) {
|
||||
frontendAdcThreshold = threshold;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#ifndef TEST
|
||||
#include <main.h>
|
||||
#include <usart.h>
|
||||
#include <led.h>
|
||||
#include <signal.h>
|
||||
#include <PontCoopScheduler.h>
|
||||
#endif
|
||||
|
||||
@ -56,7 +56,7 @@ int logExec() {
|
||||
|
||||
#ifndef TEST
|
||||
static void flashGreenLed(void *handle) {
|
||||
led(GREEN, TOGGLE);
|
||||
signal(LED_GREEN, TOGGLE);
|
||||
}
|
||||
#endif // TEST
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <main.h>
|
||||
#include <loopCtrl.h>
|
||||
#include <led.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
bool loopActive = false;
|
||||
@ -20,7 +20,7 @@ void loopDisable() {
|
||||
void loopStatusCallback() {
|
||||
GPIO_PinState status = HAL_GPIO_ReadPin(Loop_Status_GPIO_Port, Loop_Status_Pin);
|
||||
if (status == GPIO_PIN_SET) {
|
||||
led(RED, ON);
|
||||
signal(LED_RED, ON);
|
||||
loopActive = false;
|
||||
}
|
||||
}
|
@ -9,20 +9,19 @@
|
||||
|
||||
#include <PontCoopScheduler.h>
|
||||
|
||||
#include <led.h>
|
||||
#include <signal.h>
|
||||
#include <loopCtrl.h>
|
||||
#include <mbusComm.h>
|
||||
#include <logger.h>
|
||||
#include <frontend.h>
|
||||
|
||||
|
||||
void my_setup_1() {
|
||||
schInit();
|
||||
logInit();
|
||||
}
|
||||
|
||||
void my_errorHandler() {
|
||||
led(RED, ON);
|
||||
signal(LED_RED, ON);
|
||||
}
|
||||
|
||||
void helloMeterbus(void *handle) {
|
||||
@ -34,17 +33,17 @@ void helloMeterbus(void *handle) {
|
||||
|
||||
|
||||
void my_setup_2() {
|
||||
led(RED, OFF);
|
||||
led(GREEN, ON);
|
||||
signal(LED_RED, OFF);
|
||||
signal(LED_GREEN, ON);
|
||||
|
||||
frontendInit();
|
||||
frontendSetThreshold(240);
|
||||
|
||||
schAdd(helloMeterbus, NULL, 0, 1000);
|
||||
}
|
||||
|
||||
void my_loop() {
|
||||
HAL_GPIO_TogglePin(Debug_Signal_2_GPIO_Port, Debug_Signal_2_Pin);
|
||||
|
||||
signal(DEBUG_1, TOGGLE);
|
||||
|
||||
schExec();
|
||||
logExec();
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <PontCoopScheduler.h>
|
||||
#include <mbusComm.h>
|
||||
#include <loopCtrl.h>
|
||||
#include <led.h>
|
||||
#include <signal.h>
|
||||
#include <logger.h>
|
||||
#include <frontend.h>
|
||||
|
||||
@ -48,7 +48,7 @@ static void handleRequestEngine(void *handle) {
|
||||
|
||||
case SEND_CONT:
|
||||
logMsg("hre state SEND_CONT");
|
||||
led(RED, OFF);
|
||||
signal(LED_RED, OFF);
|
||||
if (! loopActive) {
|
||||
logMsg("hre enabling loop, try %d", localMbusCommHandle->retryCnt);
|
||||
localMbusCommHandle->retryCnt++;
|
||||
|
Reference in New Issue
Block a user