-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
executable file
·141 lines (119 loc) · 3.04 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* @file main.c
*
* @date 23.06.2019
* @author twatorowski ([email protected])
*
* @brief main application file
*/
#include "compiler.h"
#include "vectors.h"
#include "dev/analog.h"
#include "dev/cpuclock.h"
#include "dev/dma.h"
#include "dev/fpu.h"
#include "dev/gpio.h"
#include "dev/led.h"
#include "dev/seed.h"
#include "dev/spi_dev.h"
#include "dev/spi.h"
#include "dev/swi2c_dev.h"
#include "dev/swi2c.h"
#include "dev/usart_dev.h"
#include "dev/usart.h"
#include "dev/usb_core.h"
#include "dev/usb_eem.h"
#include "dev/usb_vcp.h"
#include "dev/usb.h"
#include "net/dhcp/server.h"
#include "net/mdns/server.h"
#include "net/tcpip/tcpip.h"
#include "net/uhttpsrv/uhttpsrv.h"
#include "sys/heap.h"
#include "sys/queue.h"
#include "sys/sem.h"
#include "sys/sleep.h"
#include "sys/yield.h"
#include "util/jenkins.h"
#include "util/string.h"
#include "www/api.h"
#include "www/website.h"
#include "www/ws.h"
#define DEBUG DLVL_INFO
#include "debug.h"
#include "coredump.h"
// TODO:
/*
* 1. dhcp client
* 2. dns client
* 3. mqtt
*/
/* program main function, must return int so that gcc does not complain in
* pedantic mode (-Wmain) */
void Main(void *arg);
/* program init function, called before main (with interrupts disabled) */
void Init(void)
{
/* initialize dynamic memory */
Heap_Init();
/* initialize system timer */
Time_Init();
/* start the context switcher */
Yield_Init();
/* create the entry task */
Yield_Task(Main, 0, 2048);
/* this shall initialize the scheduler */
Yield_Start();
}
/* program main function */
void Main(void *arg)
{
/* start the fpu */
FPU_Init();
/* configure the system clock */
CpuClock_Init();
/* initialize gpio */
GPIO_Init();
/* initialize dma controller */
DMA_Init();
/* initialize adc */
Analog_Init();
/* initialize pseudo random number generator */
Seed_Init();
/* initialize usart driver */
USART_Init();
/* initialize usart devices */
USARTDev_Init();
/* initialize leds */
Led_Init();
/* drive the led */
Led_SetState(1, LED_BLU);
/* initialize usb status */
USB_Init();
/* initialize core logic */
USBCore_Init();
/* start the serial port */
USBVCP_Init();
/* and the network interface */
USBEEM_Init();
/* initialize tcp/ip stack */
TCPIP_Init();
/* start the dhcp server */
DHCPSrv_Init();
/* start the mdns server */
MDNSSrv_Init();
/* initialize common logic to all http servers */
UHTTPSrv_Init();
/* initialize http website server */
HTTPSrvWebsite_Init();
/* initialize http api server */
HTTPSrvApi_Init();
/* start the websocket server */
WebSocketSrv_Init();
/* print a welcome message */
dprintf(DLVL_INFO, "Welcome to Yield OS\n", 0);
/* print the coredump if present */
CoreDump_PrintDump(1);
/* infinite loop */
for (;; Yield());
}