adds proper device based r/w to tgc_vp
This commit is contained in:
parent
3b95d0a7cd
commit
c3d9e5fa6f
8
env/moonlight/bsp_read.c
vendored
8
env/moonlight/bsp_read.c
vendored
@ -1,3 +1,4 @@
|
|||||||
|
#include "platform.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -5,14 +6,15 @@
|
|||||||
|
|
||||||
ssize_t _bsp_read(int fd, void *ptr, size_t len) {
|
ssize_t _bsp_read(int fd, void *ptr, size_t len) {
|
||||||
uint8_t *current = (uint8_t *)ptr;
|
uint8_t *current = (uint8_t *)ptr;
|
||||||
volatile uint32_t *uart_rx = (uint32_t *)0xFFFF0000;
|
|
||||||
ssize_t result = 0;
|
ssize_t result = 0;
|
||||||
if (isatty(fd)) {
|
if (isatty(fd)) {
|
||||||
for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len);
|
for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len) &&
|
||||||
|
(get_uart_rx_tx_reg_rx_avail(uart) > 0);
|
||||||
current++) {
|
current++) {
|
||||||
*current = *uart_rx;
|
*current = uart_read(uart);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return EOF;
|
return EOF;
|
||||||
|
7
env/moonlight/bsp_write.c
vendored
7
env/moonlight/bsp_write.c
vendored
@ -1,5 +1,6 @@
|
|||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -9,10 +10,12 @@ ssize_t _bsp_write(int fd, const void *ptr, size_t len) {
|
|||||||
const uint8_t *current = (const uint8_t *)ptr;
|
const uint8_t *current = (const uint8_t *)ptr;
|
||||||
if (isatty(fd)) {
|
if (isatty(fd)) {
|
||||||
for (size_t jj = 0; jj < len; jj++) {
|
for (size_t jj = 0; jj < len; jj++) {
|
||||||
*((uint32_t *)0xFFFF0000) = current[jj];
|
uart_write(uart, current[jj]);
|
||||||
|
if (current[jj] == '\n') {
|
||||||
|
uart_write(uart, '\r');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -36,5 +36,6 @@ foreach(FILE ${LIB_SOURCES})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_library(wrap STATIC ${LIB_SOURCES} ../env/${BOARD_BASE}/bsp_write.c ../env/${BOARD_BASE}/bsp_read.c)
|
add_library(wrap STATIC ${LIB_SOURCES} ../env/${BOARD_BASE}/bsp_write.c ../env/${BOARD_BASE}/bsp_read.c)
|
||||||
|
target_include_directories(wrap PUBLIC ../include)
|
||||||
target_link_options(wrap INTERFACE ${WRAP_ARGS})
|
target_link_options(wrap INTERFACE ${WRAP_ARGS})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user