-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c~
63 lines (53 loc) · 1.49 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
55
56
57
58
59
60
61
62
63
#include "include.h"
#define LED1TURN() (GPIOA->ODR ^ 1<<8)
#define LED2TURN() (GPIOD->ODR ^ 1<<2)
// extern OS_TCB OSTCBTbl[OS_MAX_TASKS]; // (OS Task Control Block Table)
// extern OS_STK TASK_IDLE_STK[TASK_STACK_SIZE]; //("TaskIdle" Stack)
// extern OS_TCB *OSTCBCur; // Pointer to the current running task(OS Task Control Block Current)
// extern OS_TCB *OSTCBNext; // Pointer to the next running task(OS Task Control Block Next)
// extern INT8U OSTaskNext; // Index of the next task
// extern INT32U TaskTickLeft; // Refer to the time ticks left for the current task
// extern INT32U TimeMS;
// extern INT32U TaskTimeSlice;
OS_STK Task1Stk[TASK_STACK_SIZE];
OS_STK Task2Stk[TASK_STACK_SIZE];
void Task1(void *p_arg);
void Task2(void *p_arg);
void LedInit(void);
int main(void)
{
LedInit();
OSTaskCreate(Task1, (void*)0, (OS_STK*)&Task1Stk[TASK_STACK_SIZE-1]);
OSTaskCreate(Task2, (void*)0, (OS_STK*)&Task2Stk[TASK_STACK_SIZE-1]);
SysTickInit(5);
OSStart();
}
void LedInit(void)
{
RCC->APB2ENR |= 1<<2;
RCC->APB2ENR |= 1<<5;
//GPIOE->CRH&=0X0000FFFF;
//GPIOE->CRH|=0X33330000;
GPIOA->CRH &= 0xfffffff0;
GPIOA->CRH |= 0x00000003;
//GPIOA->ODR &= 0xfffffeff;
GPIOA->ODR |= 1<<8;
GPIOD->CRL &= 0xfffff0ff;
GPIOD->CRL |= 0x00000300;
//GPIOD->ODR &= 0xfffffffd;
GPIOD->ODR |= 1<<2;
}
void Task1(void *p_arg)
{
while(1) {
delayMs(2000);
LED1TURN();
}
}
void Task2(void *p_arg)
{
while(1) {
delayMs(1000);
LED2TURN();
}
}