mk450: code clean up and documentation
[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/stdio.h>
22 #include <lib/tinyprintf.h>
23
24 #include <drivers/uart.h>
25 #include <drivers/led.h>
26 //#include <drivers/tm1637.h>
27 //#include <drivers/at24c.h>
28 //#include <drivers/tsensor.h>
29 #include <drivers/mk450_joystick.h>
30
31 void main()
32 {
33
34         /* Initialize the clock system, */
35         clock_init();
36
37         /* Setup the interrupt vector table */
38         ivt_init();
39
40         /* Initialze basic input and output over serial */
41         uart_init();
42
43         /* Cortex M* integrated systick, can be replaced
44          * by the more accurate RTC.
45         systick_init();
46         */
47         
48
49         /* Set up a very small libc library */
50         init_printf(NULL, putc);
51
52         /* Display some basic info at startup */
53         sysinfo();
54
55         /* On board LEDs*/
56         led_init();
57
58         /* Real time clock */
59         rtc_init();
60
61         /* Eeprom Driver
62         eeprom_at24c_init();
63         eeprom_test();
64         */
65         
66         /* LED Segment Driver */
67         //tm1637_init();
68
69         /* ASM Blocking routine */
70         //for (int i = 0; i < 1000; i++)
71         //      _block(10000);
72
73         /* TEMP SENSOR 
74         tsensor_printid();
75         uint16_t temp = tsensor_get_temp();
76         printf("Current temperature: %d °C\n", temp); */
77
78         /* ADC Joystick module */
79         mk450_init();   
80
81         /* Start up terminal */
82         terminal();
83         
84         /* Should not be here, endless loop */
85         for(;;) {
86
87         }
88 }