25 lines
584 B
C
25 lines
584 B
C
#include <stdint.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include "stub.h"
|
|
#include <platform.h>
|
|
|
|
ssize_t _write(int fd, const void* ptr, size_t len);
|
|
|
|
ssize_t _write(int fd, const void* ptr, size_t len) {
|
|
const char * current = (const char *)ptr;
|
|
if (isatty(fd)) {
|
|
for (size_t jj = 0; jj < len; jj++) {
|
|
while (uart_get_tx_free(uart)==0) ;
|
|
uart_write(uart, current[jj]);
|
|
if (current[jj] == '\n') {
|
|
while (uart_get_tx_free(uart)==0) ;
|
|
uart_write(uart, '\r');
|
|
}
|
|
}
|
|
return len;
|
|
}
|
|
return _stub(EBADF);
|
|
}
|