This commit is contained in:
Daniil Gentili 2022-06-20 20:17:19 +02:00
parent 478cddd82e
commit 59025d1c7d
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 23 additions and 28 deletions

View File

@ -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);
void uart_init(void);
void uart_send(char c);
char uart_recv();
void uart_send_string(const char *str);

View File

@ -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());
}*/
}

View File

@ -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]);
}
}