blob: 983034239f4cfef2b01b9de8c1af6661cdd8c9dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/* -------------------------------------------
Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
------------------------------------------- */
#include <lib/boot.h>
#include <lib/string.h>
/// BUGS: 0
#define NB_NS16550_COM1 (NB_UART_BASE + 0x4500)
#define NB_NS16550_COM2 (NB_UART_BASE + 0x4600)
volatile ascii_char_t* const UART0DR = (ascii_char_t*) NB_NS16550_COM1;
/* this file handles the UART */
/// @brief Get character from UART.
/// @param
/// @return
utf_char_t cb_get_char(void) {
while (!(*(((volatile uint8_t*) UART0DR) + 0x05) & 0x01))
;
return (utf_char_t) *UART0DR;
}
/// @brief Put character into UART.
/// @param ch
void cb_put_char(utf_char_t ch) {
*UART0DR = (ascii_char_t) (ch);
}
/// @brief Put string in UART.
/// @param text the input text.
size_t cb_put_string(const char* text) {
while (*text != '\0') { /* Loop until end of string */
cb_put_char(*text); /* Transmit char */
text++; /* Next char */
}
return 0;
}
|