-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c38b73d
commit f194002
Showing
4 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
#define CONFIG_H_ | ||
|
||
#define KSTACK_BASE 0x88000000 | ||
#define UART0_BASE 0x10000000 | ||
|
||
#endif // CONFIG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef UART_H_ | ||
#define UART_H_ | ||
|
||
void uart_putc(char c); | ||
|
||
#endif // UART_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <attribs.h> | ||
#include <config.h> | ||
#include <types.h> | ||
|
||
#define UART_RBR 0 | ||
#define UART_THR 0 | ||
#define UART_DLL 0 | ||
#define UART_IER 1 | ||
#define UART_DLM 1 | ||
#define UART_IIR 2 | ||
#define UART_FCR 2 | ||
#define UART_LCR 3 | ||
#define UART_MCR 4 | ||
#define UART_LSR 5 | ||
#define UART_MSR 6 | ||
#define UART_SCR 7 | ||
|
||
#define UART_LSR_THRE 0x20 | ||
|
||
#define uart_read_reg(reg) *((volatile u8 *) UART0_BASE + reg) | ||
#define uart_write_reg(reg, val) *((volatile u8 *) UART0_BASE + reg) = val | ||
|
||
void uart_putc(char c) { | ||
while (!(uart_read_reg(UART_LSR) & UART_LSR_THRE)) | ||
; | ||
uart_write_reg(UART_THR, c); | ||
} |