Skip to content

Commit fea3d9b

Browse files
committed
Added a definition for using RTOS delay milliseconds function.
1 parent cd08a18 commit fea3d9b

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

devices/STM32F4.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
/* Includes from GLCD */
4242
#include "glcd.h"
4343

44+
/* Includes for RTOS */
45+
#ifdef GLCD_USE_RTOS
46+
#include "BRTOS.h"
47+
#endif
48+
4449
void delay_ms(uint32_t ms);
4550

4651
//#define BACKLIGHT_INVERT // Uncomment if LED backlight turn on with low value
@@ -272,21 +277,16 @@ void glcd_reset(void)
272277
GLCD_SELECT();
273278
GLCD_RESET_LOW();
274279

275-
uint32_t count = 0;
276-
const uint32_t utime = 120000;
277-
do
278-
{
279-
count++;
280-
}
281-
while (count < utime);
282280

283-
//delay_ms(GLCD_RESET_TIME);
281+
delay_ms(GLCD_RESET_TIME);
284282
//DelayTask(GLCD_RESET_TIME);
285283
GLCD_RESET_HIGH();
286284
GLCD_DESELECT();
287285
}
288286

289287
void delay_ms(uint32_t ms){
288+
289+
#ifndef GLCD_USE_RTOS
290290
uint32_t count = 0;
291291
uint32_t ms_counter = 0;
292292
do{
@@ -298,6 +298,9 @@ void delay_ms(uint32_t ms){
298298
while (count < utime);
299299
ms_counter++;
300300
}while(ms_counter < ms);
301+
#else
302+
GLCD_RTOS_DELAY_FCN // Call the delay function defined in the header file.
303+
#endif
301304
}
302305

303306

devices/STM32F4.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@
106106
#define GLCD_RESET_LOW() GPIO_ResetBits(CONTROLLER_SPI_RST_PORT,CONTROLLER_SPI_RST_PIN)
107107
#define GLCD_RESET_HIGH() GPIO_SetBits(CONTROLLER_SPI_RST_PORT,CONTROLLER_SPI_RST_PIN)
108108

109+
/* RTOS delay function
110+
* Enable the following define to use a RTOS.
111+
* Update the call to the millisecond delay with the one of
112+
* your RTOS and add the includes in STM32F4.c */
113+
#define GLCD_USE_RTOS
114+
115+
#ifdef GLCD_USE_RTOS
116+
#define GLCD_RTOS_DELAY_FCN DelayTask(ms);
117+
#endif
109118
/* Function prototypes: */
110119
void glcd_enable_backlight(FunctionalState state);
111120
#ifdef USE_TIMER_PWM

0 commit comments

Comments
 (0)