raising and failing edge capture on TIM4
[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 intialize basic components of the boards
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/tsensor.h>
28
29 //void sleep() {
30 //
31 //      __asm__ __volatile__("wfe");
32 //
33 //}
34
35 void main()
36 {
37         clock_init();
38         ivt_init();
39         uart_init();
40 //      cputs("ROBSYS LOADING...\n");
41         systick_init();
42 //      tsensor_output(0xFFFF, 0x7FFF);
43
44         init_printf(NULL, putc);
45         // SPEED_TEST
46 /*      cputs("START TEST (8MHz) \n");
47         int a;
48         for (int i = 0; i < 20000000; i++) {
49                 a + 2;  
50         }
51         a = 0;
52         cputs("END TEST\n");
53         
54         //! 
55         clock_init();
56
57         cputs("START TEST (??MHz) \n");
58         for (int i = 0; i < 20000000; i++) {
59                 a + 2;  
60         }
61         cputs("END TEST\n"); */
62         sysinfo();
63
64
65         tsensor_input(5000);
66
67         led_init();
68         rtc_init();
69
70 //      tm1637_init();
71 //      tm1637_start();
72
73         //uint32_t test = hextoreg("12345678");
74                 
75 //      cputs(regtohex(test));
76
77         //extern void stub();
78         //stub();
79         //__asm__ __volatile__ ("ldc p1, cr1, r0");
80
81 /*      while(1) {
82                 int r;
83                 for (int i = 0; i < 50000; i++) {
84                         r = 0;  
85                 }
86                 led_on();
87                 for (int i = 0; i < 50000; i++) {
88                         r = 0;  
89                 }
90                 led_off();
91         } */
92         terminal();
93
94         for(;;) {
95
96         }
97 }