-
Notifications
You must be signed in to change notification settings - Fork 1
/
led_display.c
70 lines (50 loc) · 1.37 KB
/
led_display.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* Alarm program for the course "Programming embedded systems"
*/
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
//#include "semphr.h"
#include "queue.h"
#include "setup.h"
#include "assert.h"
//#include "GLCD.h"
#include "stm3210c_eval_ioe.h"
#include "stm32f10x_gpio.h"
#include "global.h"
#include "led_display.h"
u8 toUseLED;
u8 blinkingLED;
/*-----------------------------------------------------------*/
/**
* Light up one or more of the LEDs, to show that we are alive
*/
static void LEDTask(void *params) {
u32 rv;
//cycle period = 2000 msec
int cycleDelay = 2000;
int blinkingDelay = 900;
for (;;) {
//turn out old colour
GPIOD->BRR |= 0x0002098;
if (blinkingLED) vTaskDelay(blinkingDelay / portTICK_RATE_MS);
//switch on current colour
rv = 0;
//yellow
if (toUseLED & 0x01) rv = GPIO_Pin_13;
//red
if (toUseLED & 0x02) rv |= GPIO_Pin_3;
//blue
if (toUseLED & 0x04) rv |= GPIO_Pin_4;
//green - not working
//if (toUseLED & 0x08) rv |= GPIO_Pin_7;
GPIOD->BSRR |= rv;
vTaskDelay((cycleDelay - (blinkingDelay * blinkingLED)) / portTICK_RATE_MS);
}
}
/**
* Start the LED task - showing different LED colours for different status
*/
void setupLED(unsigned portBASE_TYPE uxPriority) {
xTaskCreate(LEDTask, "LEDTask", 100, NULL, uxPriority, NULL);
}