MNRS-BM-BSP/env/iss/bsp_read.c

20 lines
449 B
C
Raw Normal View History

#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
ssize_t _bsp_read(int fd, void *ptr, size_t len) {
uint8_t *current = (uint8_t *)ptr;
volatile uint32_t *uart_rx = (uint32_t *)0xFFFF0000;
ssize_t result = 0;
if (isatty(fd)) {
for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len);
current++) {
*current = *uart_rx;
result++;
}
return result;
}
return EOF;
}