-
Notifications
You must be signed in to change notification settings - Fork 0
/
main5.c
56 lines (55 loc) · 1.59 KB
/
main5.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
#include "stm32f4xx.h" // Device header
#include "FreeRTOSConfig.h" // ARM.FreeRTOS::RTOS:Config
#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core
#include "task.h" // ARM.FreeRTOS::RTOS:Core
void task2(void* pvParameters)
{
int OD_R = GPIO_ODR_ODR_8|GPIO_ODR_ODR_9;
for(;;)
{
GPIOA -> ODR |= OD_R;
vTaskDelay(50);
GPIOA -> ODR &= ~OD_R;
OD_R = OD_R >> 1;
if (OD_R == 0)
{
OD_R = GPIO_ODR_ODR_8|GPIO_ODR_ODR_9;
}
}
}
void task_one_diod_blinking(void* pvParameters)
{
char m = 0;
for(;;)
{
GPIOA -> ODR ^= GPIO_ODR_ODR_10;
vTaskDelay(500);
m++;
if(m==2*4)
{
xTaskCreate(task2, "task2", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
}
if (m == 2*6)
{
m = 0;
vTaskDelete(xTaskGetHandle("task2"));
vTaskDelay(2000);
}
}
}
int main(void)
{
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; //Turning on GPIOA
GPIOA->MODER |= GPIO_MODER_MODER0_0; //turning A0 to output
GPIOA->MODER |= GPIO_MODER_MODER1_0; //turning A1 to output
GPIOA->MODER |= GPIO_MODER_MODER2_0; //turning A2 to output
GPIOA->MODER |= GPIO_MODER_MODER3_0; //turning A3 to output
GPIOA->MODER |= GPIO_MODER_MODER4_0; //turning A4 to output
GPIOA->MODER |= GPIO_MODER_MODER5_0; //turning A5 to output
GPIOA->MODER |= GPIO_MODER_MODER8_0; //turning A8 to output
GPIOA->MODER |= GPIO_MODER_MODER9_0; //turning A9 to output
GPIOA->MODER |= GPIO_MODER_MODER10_0; //turning A10 to output for one diod
xTaskCreate(task_one_diod_blinking, "task_one_diod_blinking", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
vTaskStartScheduler();
while(1);
}