-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
executable file
·122 lines (113 loc) · 3.43 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <util/delay.h>
#include "SystemInformation.h"
#include "Driver/Uart/Uart.h"
#include "Core/CoreScheduler/CoreScheduler.h"
#include "Core/CoreMemory/CoreMemory.h"
#include "Core/CoreTimer/CoreTimer.h"
extern Data_1Byte* CoreMemory_PhysicalMemorySpace;
CoreMemory_Space* space1;
Data_1Byte inputData = 0;
//A Big Bug When ID > 32 It Will NOT Triger
Data_1Byte jobIndex[10] = {
0,7,9,12,15,19,32,33,64,65
};
void CommandIn(Data_1Byte input){
//Uart_Transmit(Uart_Uart1DeviceIdentify, input);
CoreScheduler_NeedToWork(jobIndex[input]);
}
void BasicFunction(Data_1Byte input){
Uart_Transmit(Uart_Uart1DeviceIdentify, input);
Data_1Byte i;
for(i = 0; i < input; i++){
_delay_ms(300.0f);
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xAA);
}
}
void Function0(void){
Data_1Byte i;
for(i = 0; i < CoreMemory_ExternalMemorySize; i++){
Uart_Transmit(Uart_Uart1DeviceIdentify, CoreMemory_PhysicalMemorySpace[i]);
}
}
void Function1(void) {
CoreMemory_DropMemory();
}
void Function2(void) {
space1 = CoreMemory_CreateSpace(CoreMemory_SpaceTypeCircularBuffer, 10, 1);
CoreMemory_SetInterrupt(space1, CoreMemory_EventHandlerTypeEmpty, jobIndex[7]);
CoreMemory_SetInterrupt(space1, CoreMemory_EventHandlerTypeFull, jobIndex[8]);
CoreMemory_SetInterrupt(space1, CoreMemory_EventHandlerTypeCross, jobIndex[9]);
if(space1 == NULL){
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xC7);
}
else{
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xB8);
}
}
void Function3(void) {
inputData++;
if(CoreMemory_Push(space1, 0, &inputData) == FALSE){
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xFF);
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xC7);
}
}
void Function4(void) {
Data_1Byte output = 0x12;
if(CoreMemory_Pop(space1, 0, &output) == FALSE){
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xFF);
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xC7);
}
else{
Uart_Transmit(Uart_Uart1DeviceIdentify, output);
}
}
void Function5(void) { BasicFunction(5); }
void Function6(void) { BasicFunction(6); }
void Function7(void) {
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xFF);
Uart_Transmit(Uart_Uart1DeviceIdentify, 0x01);
}
void Function8(void) {
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xFF);
Uart_Transmit(Uart_Uart1DeviceIdentify, 0x02);
}
void Function9(void) {
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xFF);
//Uart_Transmit(Uart_Uart1DeviceIdentify, 0x03);
}
int main(void ){
Uart_Init();
CoreScheduler_Init();
CoreScheduler_RegisterJob(jobIndex[0], Function0);
CoreScheduler_RegisterJob(jobIndex[1], Function1);
CoreScheduler_RegisterJob(jobIndex[2], Function2);
CoreScheduler_RegisterJob(jobIndex[3], Function3);
CoreScheduler_RegisterJob(jobIndex[4], Function4);
CoreScheduler_RegisterJob(jobIndex[5], Function5);
CoreScheduler_RegisterJob(jobIndex[6], Function6);
CoreScheduler_RegisterJob(jobIndex[7], Function7);
CoreScheduler_RegisterJob(jobIndex[8], Function8);
CoreScheduler_RegisterJob(jobIndex[9], Function9);
#if defined(CoreScheduler_EnableCheckRetrig)
//Data_1Byte i;
//for(i = 0; i < 10; i++) CoreScheduler_AllowRetrigger(jobIndex[i], (i % 2 == 0)?TRUE:FALSE);
#endif
Uart_Uart1RXCompleteInterruptFunction = CommandIn;
CoreMemory_Init();
if(CoreMemory_MemorySpaceVerify()){
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xB8);
}
else{
Uart_Transmit(Uart_Uart1DeviceIdentify, 0xC7);
}
CoreTimer_Init();
CoreTimer_EnableBaseTimer(TRUE);
CoreScheduler_RunLoop();
while(1);
return 0;
}
/*
ISR(TIMER2_OVF_vect){
//Uart_Transmit(Uart_Uart1DeviceIdentify, 'N');
}
*/