-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.c
70 lines (52 loc) · 1.17 KB
/
boot.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
/*
* boot.c
*
* Created on: Sep 5, 2021
* Author: Princ
*/
#include "STD_TYPES.h"
#include "ATMEGA32_REGISTERS.h"
#include "DIO_int.h"
#include "LCD_int.h"
#include <avr/delay.h>
#define LCD_CFG_PORT u8PORTC
#define LCD_VIEW_PORT u8PORTD
#define LCD_CFG_START_PIN 0
#define TASKS_NUM 5
typedef enum {Dormant, Ready, Running, Waiting, ISR, Delay, Empty} STATES;
u8 task_index=0;
typedef struct{
u8 id;
u8 periodicity;
u8 priority;
u8 firstDelay;
pFunc *function;
STATES state;
}OS_tasks;
OS_tasks tasks[TASKS_NUM] = {0,0,0,0,0,Empty};
void LCD_Boot(){
LCD_vidInit(LCD_CFG_PORT, LCD_VIEW_PORT, LCD_CFG_START_PIN);
LCD_NewMessage("LCD: boot ok!");
}
void OS_boot(){
LCD_Boot();
LCD_NewMessage("OS: boot ok!");
}
void OS_add_task(u8 id, u8 priority, pFunc *function, u8 periodicity, u8 firstDelay){
for(int i=0; i<TASKS_NUM; i++){
if (tasks[i].state == Empty){
task_index = i;
break;
}
}
tasks[++task_index].id = id;
tasks[task_index].priority = priority;
tasks[task_index].function = function;
tasks[task_index].periodicity = periodicity;
tasks[task_index].firstDelay = firstDelay;
}
int main(){
OS_boot();
LCD_NewMessage("test");
return 0;
}