From 59025d1c7d43048cb0231ae24ad9bc3359989837 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 20 Jun 2022 20:17:19 +0200 Subject: [PATCH] Cleanup --- include/mini_uart.h | 13 ++++--------- src/kernel.c | 28 ++++++++++++++-------------- src/{mini_uart0.c => mini_uart.c} | 10 +++++----- 3 files changed, 23 insertions(+), 28 deletions(-) rename src/{mini_uart0.c => mini_uart.c} (92%) diff --git a/include/mini_uart.h b/include/mini_uart.h index f8a98b1..ea400a5 100644 --- a/include/mini_uart.h +++ b/include/mini_uart.h @@ -1,11 +1,6 @@ #pragma once -void uart0_init(void); -void uart0_send(char c); -char uart0_recv(); -void uart0_send_string(const char *str); - -void uart1_init(void); -void uart1_send(char c); -char uart1_recv(); -void uart1_send_string(const char *str); \ No newline at end of file +void uart_init(void); +void uart_send(char c); +char uart_recv(); +void uart_send_string(const char *str); diff --git a/src/kernel.c b/src/kernel.c index 3e1c9a4..e6447bc 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -5,38 +5,38 @@ #define ARM_IDVAL 0x364D5241 void uart_hex(int i) { - uart0_send_string("0x"); + uart_send_string("0x"); for (int x = 0; x < 8; x++) { int c = 48 + ((i & 0xF0000000) >> 28); if (c == 48+10) { - uart0_send('A'); + uart_send('A'); } else if (c == 48+11) { - uart0_send('B'); + uart_send('B'); } else if (c == 48+12) { - uart0_send('C'); + uart_send('C'); } else if (c == 48+13) { - uart0_send('D'); + uart_send('D'); } else if (c == 48+14) { - uart0_send('E'); + uart_send('E'); } else if (c == 48+15) { - uart0_send('F'); + uart_send('F'); } else { - uart0_send(c); + uart_send(c); } i <<= 4; } - uart0_send_string("\r\n"); + uart_send_string("\r\n"); } void kernel_main(void) { - /*while(get32(ARM_ID) != ARM_IDVAL); + while(get32(ARM_ID) != ARM_IDVAL); delay(500); - uart0_init(); - delay(1000);*/ - uart0_send_string("Hello, world!\r\n"); + uart_init(); + delay(1000); + uart_send_string("Hello, world!\r\n"); /*while (1) { - uart0_send(uart0_recv()); + uart_send(uart_recv()); }*/ } diff --git a/src/mini_uart0.c b/src/mini_uart.c similarity index 92% rename from src/mini_uart0.c rename to src/mini_uart.c index 68266c3..6294e98 100644 --- a/src/mini_uart0.c +++ b/src/mini_uart.c @@ -27,7 +27,7 @@ #define CM_UARTCTL_FRAC_SET 0x00000200 #define CM_UARTCTL_ENAB_SET 0x00000010 -void uart0_init(void) +void uart_init(void) { unsigned int selector; @@ -56,20 +56,20 @@ void uart0_init(void) put32(UART_CR, 0x301); } -void uart0_send(char c) +void uart_send(char c) { while(get32(UART_FR) & (1<<5)); put32(UART_DR, c); } -char uart0_recv() +char uart_recv() { while(get32(UART_FR) & (1<<4)); return put32(UART_DR) & 0xFF; } -void uart0_send_string(const char *str) +void uart_send_string(const char *str) { for (int i = 0; str[i] != '\0'; i++) { - uart0_send(str[i]); + uart_send(str[i]); } } \ No newline at end of file