jacksonmowry 3166ce7957 change 'carrige' to 'carriage' | 2 yıl önce | |
---|---|---|
.. | ||
Makefile | 5 yıl önce | |
Makefile.clang | 2 yıl önce | |
Makefile.gcc | 2 yıl önce | |
OLVASSEL.md | 6 yıl önce | |
README.md | 4 yıl önce | |
gpio.h | 6 yıl önce | |
kernel8.img | 4 yıl önce | |
link.ld | 6 yıl önce | |
main.c | 6 yıl önce | |
start.S | 3 yıl önce | |
uart.c | 2 yıl önce | |
uart.h | 6 yıl önce |
It is time for the famous Hello World example. We're going to write on the UART1 first, as it's easier to program as it has a fixed clocked frequency.
NOTE: qemu does not redirect UART1 to terminal by default, only UART0, so you have to use -serial null -serial stdio
.
We have a new header file. This defines the base MMIO address, and the GPIO controller's addresses. This file going to be very popular, as many devices need it.
A very minimal implementation.
uart_init()
initializes the device and maps it to the GPIO ports.
uart_send(c)
sends a character over the serial line.
uart_getc()
receives a character. The carrige return character (13) will be converted into a newline character (10).
uart_puts(s)
prints out a string. On newline, a carrige return character will also be sent (13 + 10).
First, we have to call the uart initialization code. Then, it'll return "Hello World!". If you've purchased an USB serial cable, you should see it on minicom's screen. After that every character typed in minicom will be echoed back. If you haven't turned off local echo, that means you'll see every pressed key twice.