rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
led.c
Go to the documentation of this file.
1/************************************************************************************//**
2* \file Demo/ARMCM4_STM32F4_Nucleo_F429ZI_GCC/Bootled.c
3* \brief LED driver source file.
4* \ingroup Boot_ARMCM4_STM32F4_Nucleo_F429ZI_GCC
5* \internal
6*----------------------------------------------------------------------------------------
7* C O P Y R I G H T
8*----------------------------------------------------------------------------------------
9* Copyright (c) 2021 by Feaser http://www.feaser.com All rights reserved
10*
11*----------------------------------------------------------------------------------------
12* L I C E N S E
13*----------------------------------------------------------------------------------------
14* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
15* modify it under the terms of the GNU General Public License as published by the Free
16* Software Foundation, either version 3 of the License, or (at your option) any later
17* version.
18*
19* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
20* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21* PURPOSE. See the GNU General Public License for more details.
22*
23* You have received a copy of the GNU General Public License along with OpenBLT. It
24* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
25*
26* \endinternal
27****************************************************************************************/
28
29/****************************************************************************************
30* Include files
31****************************************************************************************/
32#include "boot.h" /* bootloader generic header */
33#include "led.h" /* module header */
34#ifdef STM32F429xx
35#include "stm32f4xx.h" /* STM32 CPU and HAL header */
36#endif
37#ifdef STM32F767xx
38#include "stm32f7xx.h" /* STM32 CPU and HAL header */
39#endif
40#ifdef STM32H743xx
41#include "stm32h7xx.h" /* STM32 CPU and HAL header */
42#endif
43
44
45/****************************************************************************************
46* Local data declarations
47****************************************************************************************/
48/** \brief Holds the desired LED blink interval time. */
50
51
52/************************************************************************************//**
53** \brief Initializes the LED blink driver.
54** \param interval_ms Specifies the desired LED blink interval time in milliseconds.
55** \return none.
56**
57****************************************************************************************/
58void LedBlinkInit(blt_int16u interval_ms)
59{
60 /* store the interval time between LED toggles */
61 ledBlinkIntervalMs = interval_ms;
62} /*** end of LedBlinkInit ***/
63
64
65/************************************************************************************//**
66** \brief Task function for blinking the LED as a fixed timer interval.
67** \return none.
68**
69****************************************************************************************/
70void LedBlinkTask(void)
71{
72 static blt_bool ledOn = BLT_FALSE;
73 static blt_int32u nextBlinkEvent = 0;
74
75 /* check for blink event */
76 if (TimerGet() >= nextBlinkEvent)
77 {
78 /* toggle the LED state */
79 if (ledOn == BLT_FALSE)
80 {
81 ledOn = BLT_TRUE;
82 HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_SET);
83 }
84 else
85 {
86 ledOn = BLT_FALSE;
87 HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_RESET);
88 }
89 /* schedule the next blink event */
90 nextBlinkEvent = TimerGet() + ledBlinkIntervalMs;
91 }
92} /*** end of LedBlinkTask ***/
93
94
95/************************************************************************************//**
96** \brief Cleans up the LED blink driver. This is intended to be used upon program
97** exit.
98** \return none.
99**
100****************************************************************************************/
101void LedBlinkExit(void)
102{
103 /* turn the LED off */
104 HAL_GPIO_WritePin(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_PIN_RESET);
105} /*** end of LedBlinkExit ***/
106
107
108/*********************************** end of led.c **************************************/
void LedBlinkTask(void)
Task function for blinking the LED as a fixed timer interval.
Definition led.c:70
void LedBlinkInit(blt_int16u interval_ms)
Initializes the LED blink driver.
Definition led.c:58
void LedBlinkExit(void)
Cleans up the LED blink driver. This is intended to be used upon program exit.
Definition led.c:101
static blt_int16u ledBlinkIntervalMs
Holds the desired LED blink interval time.
Definition led.c:49
blt_int32u TimerGet()
unsigned short blt_int16u
Definition types.h:51
unsigned char blt_bool
Definition types.h:46
unsigned int blt_int32u
Definition types.h:53