forked from feilipu/miniAVRfreeRTOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
54 lines (42 loc) · 1.2 KB
/
main.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
/**
* @file main.c
*
* @author Tiago Lobao
*
* @brief Blink example based on the example for atmega328p
* https://github.com/feilipu/avrfreertos/blob/master/UnoBlink/main.c
*
*/
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
/*-----------------------------------------------------------*/
static void TaskBlinkLED(void *pvParameters);
/*-----------------------------------------------------------*/
int main(void)
{
xTaskCreate(
TaskBlinkLED
, (const char *)"GreenLED"
, 256
, NULL
, 3
, NULL );
vTaskStartScheduler();
}
/*-----------------------------------------------------------*/
static void TaskBlinkLED(void *pvParameters) // Main Green LED Flash
{
(void) pvParameters;
TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();
DDRB |= _BV(DDB5);
for(;;)
{
PORTB |= _BV(PORTB5); // main (red PB5) LED on. Arduino LED on
vTaskDelayUntil( &xLastWakeTime, ( 500 / portTICK_PERIOD_MS ) );
PORTB &= ~_BV(PORTB5); // main (red PB5) LED off. Arduino LED off
vTaskDelayUntil( &xLastWakeTime, ( 500 / portTICK_PERIOD_MS ) );
}
}
/*---------------------------------------------------------------------------*/