blob: cc14f2af622bcb62ea2a38ff22a3b3e0d8b00686 (
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
|
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include "platform.h"
#include "soc/uart.h"
/* Read from a file. */
ssize_t
_read(int fd, void *ptr, size_t len)
{
if ((fd != STDIN_FILENO) || !eos_uart_enabled()) {
errno = ENOSYS;
return -1;
}
char *current = ptr;
for (size_t i = 0; i < len; i++) {
volatile uint32_t r;
while ((r = UART0_REG(UART_REG_RXFIFO)) & 0x80000000);
current[i] = r & 0xFF;
}
return len;
}
|