SYSCALL cleanup and ivt rewrite
[cortex-from-scratch] / main.c
1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
2  * 
3  * $LOG$
4  * 2019/7/20 - ROBIN KRENS      
5  * Initial version 
6  * 
7  * $DESCRIPTION$
8  * Main initialize basic components of the board
9  * and jumps to a terminal
10  *
11  * */
12
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include <stdint.h>
16
17 #include <sys/robsys.h> 
18 #include <sys/mmap.h>
19
20 #include <lib/regfunc.h>
21 #include <lib/pool.h>
22 #include <lib/stdio.h>
23 #include <lib/string.h>
24 #include <lib/tinyprintf.h>
25
26 #include <drivers/uart.h>
27 #include <drivers/led.h>
28 //#include <drivers/tm1637.h>
29 //#include <drivers/at24c.h>
30 //#include <drivers/tsensor.h>
31 //#include <drivers/mk450_joystick.h>
32 #include <drivers/st7735s.h>
33
34
35 #include <lib/syscall.h>
36
37
38 void main()
39 {
40
41         /* Initialize the clock system, */
42         clock_init();
43
44         /* Setup the interrupt vector table */
45         ivt_init();
46
47         /* Initialze basic input and output over serial */
48         uart_init();
49
50         /* TFT screen */
51         // tft_init();
52         
53         /* Cortex M* integrated systick, can be replaced
54          * by the more accurate RTC.
55         systick_init();
56         */
57         
58         /* Set up a very small libc library */
59         init_printf(NULL, putc);
60
61         /* Heap init */
62         //kheap_init();
63         //printf("%p\n", get_kheap());
64         
65         /* Display some basic info at startup */
66         sysinfo();
67
68         /* On board LEDs*/
69         led_init();
70
71         /* Real time clock */
72         //rtc_init();
73
74 //      printf("press any key to start\n");
75 //      asm volatile ("wfi");
76
77         syscall_init();
78         theos_test(0xA1, 0xA2);
79
80         /* Eeprom Driver
81         eeprom_at24c_init();
82         eeprom_test();
83         */
84         
85         /* LED Segment Driver */
86         //tm1637_init();
87
88         /* ASM Blocking routine */
89         //for (int i = 0; i < 1000; i++)
90         //      _block(10000);
91
92         /* TEMP SENSOR 
93         tsensor_printid();
94         uint16_t temp = tsensor_get_temp();
95         printf("Current temperature: %d °C\n", temp); */
96
97         /* ADC Joystick module */
98         // mk450_init();        
99
100
101         /* Start up terminal */
102         terminal();
103         
104         /* Should not be here, endless loop */
105         for(;;) {
106
107         }
108 }