uart functionality (delay) + interrupt tested
[cortex-from-scratch] / lib.c
1 #include <stdbool.h>
2 #include <stddef.h>
3 #include <stdint.h>
4 #include <stm32.h>
5 //#include <mmap.h>
6
7 /* Temporary libc functions, which can later be 
8  * replaced by a *real* library */
9
10 char hexbuf[8] = {'0', '0','0', '0','0', '0','0', '0'};
11
12 void addrtohex(const uint32_t addr) {
13         char tmpbuf[6] = {'A', 'B', 'C', 'D', 'E', 'F'};
14         memset(&hexbuf, 0, sizeof(uint32_t) * 8);
15         uint32_t tmp = addr;
16
17         for (int i = 0; i < 8 ; i++) {
18                 tmp = addr;
19                 tmp = tmp >> (i * 4);
20                 tmp = tmp & 0xF;
21                 if ((tmp >= 0) && tmp < 10) {
22                         hexbuf[i] = (char) tmp + 48;
23                 }
24                 else {
25                         hexbuf[i] = tmpbuf[tmp - 10];
26                 }
27         }
28
29         uart_puts("ADDRESS: 0x");
30         for (int i = 7; i >= 0; i--) {
31                 uart_putc(hexbuf[i]);
32         }
33         uart_putc('\n');
34 }
35
36
37 void *malloc(size_t size) {
38
39
40
41 }
42
43 void free(void * ptr) {
44
45
46 }