22 lines
502 B
C
22 lines
502 B
C
#include "platform.h"
|
|
#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;
|
|
ssize_t result = 0;
|
|
if (isatty(fd)) {
|
|
for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len) &&
|
|
(get_uart_rx_tx_reg_rx_avail(uart) > 0);
|
|
current++) {
|
|
*current = uart_read(uart);
|
|
result++;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
return EOF;
|
|
}
|