reducing code duplication
This commit is contained in:
parent
9cae07cfd2
commit
ed40d0b0d5
|
@ -12,10 +12,8 @@ else
|
|||
BOARDINC += $(BOARDS_DIR)/microrusefi # For knock_config.h
|
||||
endif
|
||||
|
||||
ifeq ($(LED_CRITICAL_ERROR_BRAIN_PIN),)
|
||||
LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3
|
||||
endif
|
||||
|
||||
# see also openblt/board.mk STATUS_LED
|
||||
LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3
|
||||
|
||||
# *TEMPORARY* breaking TTL thus breaking Bluetooth for microRusEFI in order to enable SPI3 for SD card
|
||||
# *TODO* need to give people the horrible choice between Bluetooth via TTL or SD card via SPI :( horrible choice
|
||||
|
|
|
@ -14,3 +14,5 @@ BRDFLAGS = -DSTM32F429xx
|
|||
#| Specify library files |
|
||||
#|--------------------------------------------------------------------------------------|
|
||||
LIBS =
|
||||
|
||||
BRDFLAGS += -DSTATUS_LED_PORT=GPIOE -DSTATUS_LED_PIN=GPIO_PIN_3
|
|
@ -1,100 +0,0 @@
|
|||
/************************************************************************************//**
|
||||
* \file Demo/ARMCM4_STM32F4_Nucleo_F429ZI_GCC/Bootled.c
|
||||
* \brief LED driver source file.
|
||||
* \ingroup Boot_ARMCM4_STM32F4_Nucleo_F429ZI_GCC
|
||||
* \internal
|
||||
*----------------------------------------------------------------------------------------
|
||||
* C O P Y R I G H T
|
||||
*----------------------------------------------------------------------------------------
|
||||
* Copyright (c) 2021 by Feaser http://www.feaser.com All rights reserved
|
||||
*
|
||||
*----------------------------------------------------------------------------------------
|
||||
* L I C E N S E
|
||||
*----------------------------------------------------------------------------------------
|
||||
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You have received a copy of the GNU General Public License along with OpenBLT. It
|
||||
* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
|
||||
*
|
||||
* \endinternal
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Include files
|
||||
****************************************************************************************/
|
||||
#include "boot.h" /* bootloader generic header */
|
||||
#include "led.h" /* module header */
|
||||
#include "stm32f4xx.h" /* STM32 registers and drivers */
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Local data declarations
|
||||
****************************************************************************************/
|
||||
/** \brief Holds the desired LED blink interval time. */
|
||||
static blt_int16u ledBlinkIntervalMs;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Initializes the LED blink driver.
|
||||
** \param interval_ms Specifies the desired LED blink interval time in milliseconds.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void LedBlinkInit(blt_int16u interval_ms)
|
||||
{
|
||||
/* store the interval time between LED toggles */
|
||||
ledBlinkIntervalMs = interval_ms;
|
||||
} /*** end of LedBlinkInit ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Task function for blinking the LED as a fixed timer interval.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void LedBlinkTask(void)
|
||||
{
|
||||
static blt_bool ledOn = BLT_FALSE;
|
||||
static blt_int32u nextBlinkEvent = 0;
|
||||
|
||||
/* check for blink event */
|
||||
if (TimerGet() >= nextBlinkEvent)
|
||||
{
|
||||
/* toggle the LED state */
|
||||
if (ledOn == BLT_FALSE)
|
||||
{
|
||||
ledOn = BLT_TRUE;
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
ledOn = BLT_FALSE;
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
}
|
||||
/* schedule the next blink event */
|
||||
nextBlinkEvent = TimerGet() + ledBlinkIntervalMs;
|
||||
}
|
||||
} /*** end of LedBlinkTask ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Cleans up the LED blink driver. This is intended to be used upon program
|
||||
** exit.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void LedBlinkExit(void)
|
||||
{
|
||||
/* turn the LED off */
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
} /*** end of LedBlinkExit ***/
|
||||
|
||||
|
||||
/*********************************** end of led.c **************************************/
|
|
@ -9,6 +9,7 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F4)
|
|||
endif
|
||||
|
||||
DDEFS += -DEFI_USE_OSC=TRUE
|
||||
# see also openblt/board.mk STATUS_LED
|
||||
DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3
|
||||
DDEFS += -DFIRMWARE_ID=\"proteus\"
|
||||
DDEFS += $(VAR_DEF_ENGINE_TYPE)
|
||||
|
|
|
@ -22,3 +22,5 @@ endif
|
|||
#| Specify library files |
|
||||
#|--------------------------------------------------------------------------------------|
|
||||
LIBS =
|
||||
|
||||
BRDFLAGS += -DSTATUS_LED_PORT=GPIOE -DSTATUS_LED_PIN=GPIO_PIN_3
|
|
@ -1,40 +0,0 @@
|
|||
/************************************************************************************//**
|
||||
* \file Demo/ARMCM4_STM32F4_Nucleo_F429ZI_GCC/Boot/led.h
|
||||
* \brief LED driver header file.
|
||||
* \ingroup Boot_ARMCM4_STM32F4_Nucleo_F429ZI_GCC
|
||||
* \internal
|
||||
*----------------------------------------------------------------------------------------
|
||||
* C O P Y R I G H T
|
||||
*----------------------------------------------------------------------------------------
|
||||
* Copyright (c) 2021 by Feaser http://www.feaser.com All rights reserved
|
||||
*
|
||||
*----------------------------------------------------------------------------------------
|
||||
* L I C E N S E
|
||||
*----------------------------------------------------------------------------------------
|
||||
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You have received a copy of the GNU General Public License along with OpenBLT. It
|
||||
* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
|
||||
*
|
||||
* \endinternal
|
||||
****************************************************************************************/
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
/****************************************************************************************
|
||||
* Function prototypes
|
||||
****************************************************************************************/
|
||||
void LedBlinkInit(blt_int16u interval_ms);
|
||||
void LedBlinkTask(void);
|
||||
void LedBlinkExit(void);
|
||||
|
||||
|
||||
#endif /* LED_H */
|
||||
/*********************************** end of led.h **************************************/
|
|
@ -79,12 +79,12 @@ void LedBlinkTask(void)
|
|||
if (ledOn == BLT_FALSE)
|
||||
{
|
||||
ledOn = BLT_TRUE;
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
ledOn = BLT_FALSE;
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_RESET);
|
||||
}
|
||||
/* schedule the next blink event */
|
||||
nextBlinkEvent = TimerGet() + ledBlinkIntervalMs;
|
|
@ -81,6 +81,8 @@ PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/*.c)
|
|||
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/*.h)
|
||||
|
||||
PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/hooks.c
|
||||
PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/led.c
|
||||
PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/led.h
|
||||
|
||||
# CPU-dependent sources
|
||||
ifeq ($(PROJECT_CPU),ARCH_STM32F4)
|
||||
|
|
Loading…
Reference in New Issue