fernly/serial.c
Sean Cross 685824f56e fernly: Initial commit
This is an initial commit of the code.  It just does prints "Hello, world!"
2014-06-12 12:58:06 +08:00

20 lines
365 B
C

#include <stdint.h>
#include "serial.h"
int uart_putc(uint8_t c) {
uint32_t *uart_ldr = (uint32_t *)0xa0080014;
uint32_t *uart_sbr = (uint32_t *)0xa0080000;
/* Wait for UART to be empty */
while (! (*uart_ldr & 0x20));
*uart_sbr = c;
return 0;
}
int uart_puts(char *s) {
while(*s) {
if (*s == '\n')
uart_putc('\r');
uart_putc(*s++);
}
return 0;
}