Fix spiff and stdin_uart_interrupt overiding the same read function
This commit is contained in:
parent
2994a566a6
commit
3eb784b758
3 changed files with 16 additions and 17 deletions
|
|
@ -59,14 +59,9 @@ __attribute__((weak)) long _write_r(struct _reent *r, int fd, const char *ptr, i
|
||||||
}
|
}
|
||||||
|
|
||||||
/* syscall implementation for stdio read from UART */
|
/* syscall implementation for stdio read from UART */
|
||||||
__attribute__((weak)) long _read_r( struct _reent *r, int fd, char *ptr, int len )
|
__attribute__((weak)) long _read_stdin_r(struct _reent *r, int fd, char *ptr, int len)
|
||||||
{
|
{
|
||||||
int ch, i;
|
int ch, i;
|
||||||
|
|
||||||
if(fd != r->_stdin->_file) {
|
|
||||||
r->_errno = EBADF;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
uart_rxfifo_wait(0, 1);
|
uart_rxfifo_wait(0, 1);
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
ch = uart_getc_nowait(0);
|
ch = uart_getc_nowait(0);
|
||||||
|
|
@ -76,6 +71,15 @@ __attribute__((weak)) long _read_r( struct _reent *r, int fd, char *ptr, int len
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) long _read_r( struct _reent *r, int fd, char *ptr, int len )
|
||||||
|
{
|
||||||
|
if(fd != r->_stdin->_file) {
|
||||||
|
r->_errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return _read_stdin_r(r, fd, ptr, len);
|
||||||
|
}
|
||||||
|
|
||||||
/* Stub syscall implementations follow, to allow compiling newlib functions that
|
/* Stub syscall implementations follow, to allow compiling newlib functions that
|
||||||
pull these in via various codepaths
|
pull these in via various codepaths
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -141,21 +141,16 @@ long _write_r(struct _reent *r, int fd, const char *ptr, int len )
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function is weakly defined in core/newlib_syscalls.c
|
||||||
|
long _read_stdin_r(struct _reent *r, int fd, char *ptr, int len);
|
||||||
|
|
||||||
// This implementation replaces implementation in core/newlib_syscals.c
|
// This implementation replaces implementation in core/newlib_syscals.c
|
||||||
long _read_r( struct _reent *r, int fd, char *ptr, int len )
|
long _read_r( struct _reent *r, int fd, char *ptr, int len )
|
||||||
{
|
{
|
||||||
int ch, i;
|
|
||||||
|
|
||||||
if(fd != r->_stdin->_file) {
|
if(fd != r->_stdin->_file) {
|
||||||
return SPIFFS_read(&fs, (spiffs_file)fd, ptr, len);
|
return SPIFFS_read(&fs, (spiffs_file)fd, ptr, len);
|
||||||
}
|
}
|
||||||
uart_rxfifo_wait(0, 1);
|
return _read_stdin_r(r, fd, ptr, len);
|
||||||
for(i = 0; i < len; i++) {
|
|
||||||
ch = uart_getc_nowait(0);
|
|
||||||
if (ch < 0) break;
|
|
||||||
ptr[i] = ch;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _open_r(struct _reent *r, const char *pathname, int flags, int mode)
|
int _open_r(struct _reent *r, const char *pathname, int flags, int mode)
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,9 @@ uint32_t uart0_num_char(void)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _read_r in core/newlib_syscalls.c will be skipped by the linker in favour
|
// _read_stdin_r in core/newlib_syscalls.c will be skipped by the linker in favour
|
||||||
// of this function
|
// of this function
|
||||||
long _read_r(struct _reent *r, int fd, char *ptr, int len)
|
long _read_stdin_r(struct _reent *r, int fd, char *ptr, int len)
|
||||||
{
|
{
|
||||||
if (!inited) uart0_rx_init();
|
if (!inited) uart0_rx_init();
|
||||||
for(int i = 0; i < len; i++) {
|
for(int i = 0; i < len; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue