mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #9503 from haukepetersen/opt_stdio_cleanup
sys/stdio: cleanup of STDIO abstraction
This commit is contained in:
commit
a6c7b0a61b
@ -373,8 +373,8 @@ ifneq (,$(filter newlib,$(USEMODULE)))
|
||||
ifeq (,$(filter newlib_syscalls_%,$(USEMODULE)))
|
||||
USEMODULE += newlib_syscalls_default
|
||||
endif
|
||||
ifeq (,$(filter rtt_stdio,$(USEMODULE)))
|
||||
USEMODULE += uart_stdio
|
||||
ifeq (,$(filter stdio_rtt,$(USEMODULE)))
|
||||
USEMODULE += stdio_uart
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -386,11 +386,11 @@ ifneq (,$(filter posix_sockets,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rtt_stdio,$(USEMODULE)))
|
||||
ifneq (,$(filter stdio_rtt,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter uart_stdio,$(USEMODULE)))
|
||||
ifneq (,$(filter stdio_uart,$(USEMODULE)))
|
||||
USEMODULE += isrpipe
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
endif
|
||||
|
@ -54,7 +54,7 @@ void board_init(void);
|
||||
/**
|
||||
* @brief Use the 2nd UART for STDIO on this board
|
||||
*/
|
||||
#define UART_STDIO_DEV UART_DEV(1)
|
||||
#define STDIO_UART_DEV UART_DEV(1)
|
||||
|
||||
/**
|
||||
* @name xtimer configuration
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
||||
* baudrate to 9600 for this board
|
||||
* @{
|
||||
*/
|
||||
#define UART_STDIO_BAUDRATE (9600U)
|
||||
#define STDIO_UART_BAUDRATE (9600U)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -38,8 +38,8 @@ extern "C" {
|
||||
* @name Set the default baudrate to 500K for this board
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART_STDIO_BAUDRATE
|
||||
# define UART_STDIO_BAUDRATE (500000U)
|
||||
#ifndef STDIO_UART_BAUDRATE
|
||||
# define STDIO_UART_BAUDRATE (500000U)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "cpu.h"
|
||||
#include "irq.h"
|
||||
#include "board.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_base.h"
|
||||
#include "periph_conf.h"
|
||||
#include "msp430.h"
|
||||
#include "debug.h"
|
||||
@ -199,6 +199,6 @@ void board_init(void)
|
||||
|
||||
msp430_set_cpu_speed(CLOCK_CORECLOCK);
|
||||
|
||||
/* finally initialize STDIO over UART */
|
||||
uart_stdio_init();
|
||||
/* finally initialize STDIO */
|
||||
stdio_init();
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "bc.h"
|
||||
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
#include "periph/gpio.h"
|
||||
#include "periph/uart.h"
|
||||
@ -35,14 +35,14 @@
|
||||
/**
|
||||
* @brief Ensure that the correct UART is used.
|
||||
*/
|
||||
#if ((UART_STDIO_DEV) != (UART_DEV(0)))
|
||||
#if ((STDIO_UART_DEV) != (UART_DEV(0)))
|
||||
#error "The BC requires UART_DEV(0)."
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Ensure that the correct baud rate is used.
|
||||
*/
|
||||
#if ((UART_STDIO_BAUDRATE) != 115200)
|
||||
#if ((STDIO_UART_BAUDRATE) != 115200)
|
||||
#error "The BC requires a baud rate of 115200."
|
||||
#endif
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "cpu.h"
|
||||
#include "irq.h"
|
||||
#include "assert.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
#include "periph_conf.h"
|
||||
|
||||
enum {
|
||||
@ -98,5 +98,5 @@ void board_init(void)
|
||||
irq_restore(state);
|
||||
|
||||
/* initialize STDIO over UART */
|
||||
uart_stdio_init();
|
||||
stdio_init();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ export CPU = fe310
|
||||
export CPU_MODEL = fe310
|
||||
|
||||
# Uses UART0 for stdio input/output (comment out to disable)
|
||||
USEMODULE += uart_stdio
|
||||
USEMODULE += stdio_uart
|
||||
|
||||
# set default port depending on operating system
|
||||
PORT_LINUX ?= /dev/ttyUSB1
|
||||
|
@ -40,8 +40,8 @@ extern "C" {
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART_STDIO_BAUDRATE
|
||||
#define UART_STDIO_BAUDRATE (38400U) /**< Sets Baudrate for e.g. Shell */
|
||||
#ifndef STDIO_UART_BAUDRATE
|
||||
#define STDIO_UART_BAUDRATE (38400U) /**< Sets Baudrate for e.g. Shell */
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -57,7 +57,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief Use the USART1 for STDIO on this board
|
||||
*/
|
||||
#define UART_STDIO_DEV UART_DEV(1)
|
||||
#define STDIO_UART_DEV UART_DEV(1)
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
|
||||
|
@ -39,15 +39,15 @@ extern "C" {
|
||||
* baudrate to 9600 for this board
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART_STDIO_BAUDRATE
|
||||
#define UART_STDIO_BAUDRATE (9600U)
|
||||
#ifndef STDIO_UART_BAUDRATE
|
||||
#define STDIO_UART_BAUDRATE (9600U)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Use the UART 1 for STDIO on this board
|
||||
*/
|
||||
#define UART_STDIO_DEV (UART_DEV(1))
|
||||
#define STDIO_UART_DEV (UART_DEV(1))
|
||||
|
||||
/**
|
||||
* @name xtimer configuration values
|
||||
|
@ -35,7 +35,7 @@
|
||||
/**
|
||||
* @brief Use the UART1 for STDIO on this board
|
||||
*/
|
||||
#define UART_STDIO_DEV UART_DEV(1)
|
||||
#define STDIO_UART_DEV UART_DEV(1)
|
||||
|
||||
/**
|
||||
* @name xtimer configuration
|
||||
|
@ -66,14 +66,14 @@ extern "C" {
|
||||
/**
|
||||
* @brief Use the USART2 for STDIO on this board
|
||||
*/
|
||||
#define UART_STDIO_DEV UART_DEV(0)
|
||||
#define STDIO_UART_DEV UART_DEV(0)
|
||||
|
||||
/**
|
||||
* @name Override with ROBOTIS Bluetooth antenna baudrate for STDIO
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART_STDIO_BAUDRATE
|
||||
#define UART_STDIO_BAUDRATE (921600UL)
|
||||
#ifndef STDIO_UART_BAUDRATE
|
||||
#define STDIO_UART_BAUDRATE (921600UL)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
CPU_MODEL = nrf52832xxaa
|
||||
|
||||
# for this board, we are using Segger's RTT as default terminal interface
|
||||
USEMODULE += rtt_stdio
|
||||
USEMODULE += stdio_rtt
|
||||
TERMPROG = $(RIOTTOOLS)/jlink/jlink.sh
|
||||
TERMFLAGS = term_rtt
|
||||
|
||||
|
@ -61,7 +61,7 @@ void board_init(void);
|
||||
/**
|
||||
* @brief Use the 2nd UART for STDIO on this board
|
||||
*/
|
||||
#define UART_STDIO_DEV UART_DEV(1)
|
||||
#define STDIO_UART_DEV UART_DEV(1)
|
||||
|
||||
/**
|
||||
* @name xtimer configuration
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "board.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
void uart_init(void);
|
||||
|
||||
@ -122,8 +122,8 @@ void board_init(void)
|
||||
telosb_ports_init();
|
||||
msp430_init_dco();
|
||||
|
||||
/* initialize STDIO over UART */
|
||||
uart_stdio_init();
|
||||
/* initialize STDIO */
|
||||
stdio_init();
|
||||
|
||||
/* enable interrupts */
|
||||
__bis_SR_register(GIE);
|
||||
|
@ -43,8 +43,8 @@ extern "C" {
|
||||
* @name Override default baudrate for STDIO
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART_STDIO_BAUDRATE
|
||||
#define UART_STDIO_BAUDRATE (9600)
|
||||
#ifndef STDIO_UART_BAUDRATE
|
||||
#define STDIO_UART_BAUDRATE (9600)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
CPU_MODEL = nrf52832xxaa
|
||||
|
||||
# for this board, we are using Segger's RTT as default terminal interface
|
||||
USEMODULE += rtt_stdio
|
||||
USEMODULE += stdio_rtt
|
||||
TERMPROG = $(RIOTTOOLS)/jlink/jlink.sh
|
||||
TERMFLAGS = term_rtt
|
||||
|
||||
|
@ -31,7 +31,7 @@ extern "C" {
|
||||
* @brief As the CPU is too slow to handle 115200 baud, we set the default
|
||||
* baudrate to 9600 for this board
|
||||
*/
|
||||
#define UART_STDIO_BAUDRATE (9600U)
|
||||
#define STDIO_UART_BAUDRATE (9600U)
|
||||
|
||||
/**
|
||||
* @brief Use the UART 0 for STDIO on this board, if the XBee socket is not
|
||||
@ -39,9 +39,9 @@ extern "C" {
|
||||
*/
|
||||
#ifdef XBEE_UART
|
||||
#if XBEE_UART == 0
|
||||
#define UART_STDIO_DEV (UART_DEV(1))
|
||||
#define STDIO_UART_DEV (UART_DEV(1))
|
||||
#else
|
||||
#define UART_STDIO_DEV (UART_DEV(0))
|
||||
#define STDIO_UART_DEV (UART_DEV(0))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "board.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
static void z1_ports_init(void)
|
||||
{
|
||||
@ -215,8 +215,8 @@ void board_init(void)
|
||||
/* initializes DCO */
|
||||
msp430_init_dco();
|
||||
|
||||
/* initialize STDIO over UART */
|
||||
uart_stdio_init();
|
||||
/* initialize STDIO */
|
||||
stdio_init();
|
||||
|
||||
/* enable interrupts */
|
||||
__bis_SR_register(GIE);
|
||||
|
@ -14,8 +14,8 @@ export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e r
|
||||
export USEMODULE += atmega_common_periph
|
||||
export USEMODULE += periph_common
|
||||
|
||||
# the atmel port uses uart_stdio
|
||||
export USEMODULE += uart_stdio
|
||||
# the atmel port uses stdio_uart
|
||||
export USEMODULE += stdio_uart
|
||||
|
||||
# include module specific includes
|
||||
export INCLUDES += -I$(RIOTCPU)/atmega_common/include -isystem$(RIOTCPU)/atmega_common/include/vendor
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
static int _uart_putchar(char c, FILE *stream);
|
||||
static int _uart_getchar(FILE *stream);
|
||||
@ -29,7 +29,7 @@ static FILE _uart_stdin = FDEV_SETUP_STREAM(NULL, _uart_getchar, _FDEV_SETUP_REA
|
||||
static int _uart_putchar(char c, FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
uart_stdio_write(&c, 1);
|
||||
stdio_write(&c, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -37,13 +37,13 @@ static int _uart_getchar(FILE *stream)
|
||||
{
|
||||
(void) stream;
|
||||
char c;
|
||||
uart_stdio_read(&c, 1);
|
||||
stdio_read(&c, 1);
|
||||
return (int)c;
|
||||
}
|
||||
|
||||
void atmega_stdio_init(void)
|
||||
{
|
||||
uart_stdio_init();
|
||||
stdio_init();
|
||||
|
||||
stdout = &_uart_stdout;
|
||||
stdin = &_uart_stdin;
|
||||
|
@ -18,8 +18,8 @@
|
||||
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
*
|
||||
*
|
||||
* Support static BAUD rate calculation using UART_STDIO_BAUDRATE.
|
||||
* Set UART_STDIO_BAUDRATE to the desired baud rate and pass it as a -D argument
|
||||
* Support static BAUD rate calculation using STDIO_UART_BAUDRATE.
|
||||
* Set STDIO_UART_BAUDRATE to the desired baud rate and pass it as a -D argument
|
||||
* at compliation time (e.g. in the boards Makefile.include file).
|
||||
* UART_BAUD_TOL can be set to guarantee a BAUD rate tolerance at compile time or
|
||||
* to switch to double speed transmission (U2X) to achieve a lower tolerance.
|
||||
@ -48,9 +48,9 @@
|
||||
#define BAUD_TOL 2
|
||||
#endif
|
||||
|
||||
#if defined(UART_STDIO_BAUDRATE)
|
||||
#if defined(STDIO_UART_BAUDRATE)
|
||||
/* BAUD and F_CPU are required by setbaud.h to calculated BRR */
|
||||
#define BAUD UART_STDIO_BAUDRATE
|
||||
#define BAUD STDIO_UART_BAUDRATE
|
||||
#define F_CPU CLOCK_CORECLOCK
|
||||
#include <util/setbaud.h>
|
||||
#endif
|
||||
@ -90,9 +90,9 @@ static void _set_brr(uart_t uart, uint32_t baudrate)
|
||||
{
|
||||
uint16_t brr;
|
||||
|
||||
#if defined(UART_STDIO_BAUDRATE)
|
||||
#if defined(STDIO_UART_BAUDRATE)
|
||||
/* UBRR_VALUE and USE_2X are statically computed from <util/setbaud.h> */
|
||||
if (baudrate == UART_STDIO_BAUDRATE) {
|
||||
if (baudrate == STDIO_UART_BAUDRATE) {
|
||||
_update_brr(uart, UBRR_VALUE, USE_2X);
|
||||
return;
|
||||
}
|
||||
|
@ -22,8 +22,8 @@
|
||||
#ifdef MODULE_VFS
|
||||
#include <fcntl.h>
|
||||
#include "vfs.h"
|
||||
#elif defined(MODULE_UART_STDIO)
|
||||
#include "uart_stdio.h"
|
||||
#elif defined(MODULE_STDIO_UART)
|
||||
#include "stdio_uart.h"
|
||||
#endif
|
||||
|
||||
int open(const char *name, int flags, ...)
|
||||
@ -136,9 +136,9 @@ ssize_t read(int fd, void *dest, size_t count)
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
#elif defined(MODULE_UART_STDIO)
|
||||
#elif defined(MODULE_STDIO_UART)
|
||||
if (fd == 0) {
|
||||
return uart_stdio_read(dest, count);
|
||||
return stdio_read(dest, count);
|
||||
}
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
@ -160,9 +160,9 @@ ssize_t write(int fd, const void *src, size_t count)
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
#elif defined(MODULE_UART_STDIO)
|
||||
#elif defined(MODULE_STDIO_UART)
|
||||
if (fd == 0) {
|
||||
return uart_stdio_write(src, count);
|
||||
return stdio_write(src, count);
|
||||
}
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "thread.h"
|
||||
#include "irq.h"
|
||||
#include "cpu.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
extern char _heap_start; /* Heap markers from fe310.ld file */
|
||||
extern char _heap_end;
|
||||
@ -38,9 +38,9 @@ char *heap_top = &_heap_start + 4;
|
||||
*/
|
||||
void nanostubs_init(void)
|
||||
{
|
||||
#if defined(MODULE_UART_STDIO)
|
||||
#if defined(MODULE_STDIO_UART)
|
||||
/* STDIO redirected to UART, no line buffering */
|
||||
uart_stdio_init();
|
||||
stdio_init();
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
#endif
|
||||
}
|
||||
@ -82,9 +82,9 @@ int _open(const char *name, int flags, int mode)
|
||||
|
||||
_ssize_t _read(int fd, void *buffer, size_t count)
|
||||
{
|
||||
#if defined(MODULE_UART_STDIO)
|
||||
#if defined(MODULE_STDIO_UART)
|
||||
if (fd == STDIN_FILENO) {
|
||||
return uart_stdio_read(buffer, count);
|
||||
return stdio_read(buffer, count);
|
||||
}
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
@ -99,9 +99,9 @@ _ssize_t _read(int fd, void *buffer, size_t count)
|
||||
|
||||
_ssize_t _write(int fd, const void *data, size_t count)
|
||||
{
|
||||
#if defined(MODULE_UART_STDIO)
|
||||
#if defined(MODULE_STDIO_UART)
|
||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||
return uart_stdio_write(data, count);
|
||||
return stdio_write(data, count);
|
||||
}
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -1,3 +1,3 @@
|
||||
include $(RIOTCPU)/msp430_common/Makefile.include
|
||||
|
||||
export USEMODULE += periph periph_common uart_stdio
|
||||
export USEMODULE += periph periph_common stdio_uart
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
/**
|
||||
* @brief Get one character from STDIO - used by the libc
|
||||
@ -29,7 +29,7 @@
|
||||
int getchar(void)
|
||||
{
|
||||
char c;
|
||||
uart_stdio_read(&c, 1);
|
||||
stdio_read(&c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ int getchar(void)
|
||||
int putchar(int c)
|
||||
{
|
||||
char _c = c;
|
||||
return uart_stdio_write(&_c, 1);
|
||||
return stdio_write(&_c, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ int putchar(int c)
|
||||
ssize_t write(int fildes, const void *buf, size_t nbyte)
|
||||
{
|
||||
if (fildes == STDOUT_FILENO) {
|
||||
return uart_stdio_write(buf, nbyte);
|
||||
return stdio_write(buf, nbyte);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
|
@ -34,9 +34,9 @@
|
||||
#include "net/ethernet.h"
|
||||
|
||||
#ifdef USE_ETHOS_FOR_STDIO
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
#include "isrpipe.h"
|
||||
extern isrpipe_t uart_stdio_isrpipe;
|
||||
extern isrpipe_t stdio_uart_isrpipe;
|
||||
#endif
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
@ -102,7 +102,7 @@ static void _handle_char(ethos_t *dev, char c)
|
||||
#ifdef USE_ETHOS_FOR_STDIO
|
||||
case ETHOS_FRAME_TYPE_TEXT:
|
||||
dev->framesize++;
|
||||
isrpipe_write_one(&uart_stdio_isrpipe, c);
|
||||
isrpipe_write_one(&stdio_uart_isrpipe, c);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* if using ethos + stdio, use UART_STDIO values unless overridden */
|
||||
/* if using ethos + stdio, use STDIO_UART values unless overridden */
|
||||
#ifdef USE_ETHOS_FOR_STDIO
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
#ifndef ETHOS_UART
|
||||
#define ETHOS_UART UART_STDIO_DEV
|
||||
#define ETHOS_UART STDIO_UART_DEV
|
||||
#endif
|
||||
#ifndef ETHOS_BAUDRATE
|
||||
#define ETHOS_BAUDRATE UART_STDIO_BAUDRATE
|
||||
#define ETHOS_BAUDRATE STDIO_UART_BAUDRATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
// For some boards RIOT defines a macro assigning the required baudrate of the
|
||||
// serial link. If this macro is not set, the default baudrate is set to
|
||||
// 115200.
|
||||
#ifdef UART_STDIO_BAUDRATE
|
||||
#define SERIAL_BAUDRATE UART_STDIO_BAUDRATE
|
||||
#ifdef STDIO_UART_BAUDRATE
|
||||
#define SERIAL_BAUDRATE STDIO_UART_BAUDRATE
|
||||
#else
|
||||
#define SERIAL_BAUDRATE 115200
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "net/gnrc/netif/ethernet.h"
|
||||
|
||||
/**
|
||||
* @brief global ethos object, used by uart_stdio
|
||||
* @brief global ethos object, used by stdio_uart
|
||||
*/
|
||||
ethos_t ethos;
|
||||
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Michael Andersen <m.andersen@berkeley.edu>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup sys_rtt_stdio SEGGER RTT stdio
|
||||
* @ingroup sys
|
||||
*
|
||||
* @brief stdio init/read/write functions for SEGGER RTT. This is
|
||||
* designed to shadow the functions in uart_stdio
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
*
|
||||
* @author Michael Andersen <m.andersen@cs.berkeley.edu>
|
||||
*/
|
||||
#ifndef RTT_STDIO_H
|
||||
#define RTT_STDIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief initialize the module. This is a noop.
|
||||
*/
|
||||
void uart_stdio_init(void);
|
||||
|
||||
/**
|
||||
* @brief read @p len bytes from stdio uart into @p buffer
|
||||
*
|
||||
* @param[out] buffer buffer to read into
|
||||
* @param[in] len nr of bytes to read
|
||||
*
|
||||
* @return nr of bytes read
|
||||
* @return <0 on error
|
||||
*/
|
||||
int uart_stdio_read(char* buffer, int len);
|
||||
|
||||
/**
|
||||
* @brief write @p len bytes from @p buffer into uart
|
||||
*
|
||||
* @param[in] buffer buffer to read from
|
||||
* @param[in] len nr of bytes to write
|
||||
*
|
||||
* @return nr of bytes written
|
||||
* @return <0 on error
|
||||
*/
|
||||
int uart_stdio_write(const char* buffer, int len);
|
||||
|
||||
/**
|
||||
* @brief enable stdin polling, at a power consumption cost. This is enabled
|
||||
* by default unless RTT_STDIO_DISABLE_STDIN is defined.
|
||||
*/
|
||||
void rtt_stdio_enable_stdin(void);
|
||||
|
||||
/**
|
||||
* @brief enable stdout blocking and free space polling. This must be done
|
||||
* with caution because if there is no RTT client attached, all
|
||||
* writes to stdout will block indefinitely. This can be enabled
|
||||
* automatically by defining RTT_STDIO_ENABLE_BLOCKING_STDOUT
|
||||
*/
|
||||
void rtt_stdio_enable_blocking_stdout(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
#endif /* RTT_STDIO_H */
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2018 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
@ -7,63 +8,42 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup sys_uart_stdio UART stdio
|
||||
* @defgroup sys_stdio STDIO abstraction
|
||||
* @ingroup sys
|
||||
*
|
||||
* @brief stdio init/read/write functions for UARTs
|
||||
* @brief Simple standard input/output (STDIO) abstraction for RIOT
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
#ifndef UART_STDIO_H
|
||||
#define UART_STDIO_H
|
||||
|
||||
/* Boards may override the default STDIO UART device */
|
||||
#include <stdint.h>
|
||||
#include "board.h"
|
||||
#ifndef STDIO_BASE_H
|
||||
#define STDIO_BASE_H
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef UART_STDIO_DEV
|
||||
/**
|
||||
* @brief UART device to use for STDIO
|
||||
*/
|
||||
#define UART_STDIO_DEV UART_DEV(0)
|
||||
#endif
|
||||
|
||||
#ifndef UART_STDIO_BAUDRATE
|
||||
/**
|
||||
* @brief Baudrate for STDIO
|
||||
*/
|
||||
#define UART_STDIO_BAUDRATE (115200)
|
||||
#endif
|
||||
|
||||
#ifndef UART_STDIO_RX_BUFSIZE
|
||||
/**
|
||||
* @brief Buffer size for STDIO
|
||||
*/
|
||||
#define UART_STDIO_RX_BUFSIZE (64)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief initialize the module
|
||||
*/
|
||||
void uart_stdio_init(void);
|
||||
void stdio_init(void);
|
||||
|
||||
/**
|
||||
* @brief read @p len bytes from stdio uart into @p buffer
|
||||
*
|
||||
* @param[out] buffer buffer to read into
|
||||
* @param[in] len nr of bytes to read
|
||||
* @param[in] max_len nr of bytes to read
|
||||
*
|
||||
* @return nr of bytes read
|
||||
* @return <0 on error
|
||||
*/
|
||||
int uart_stdio_read(char* buffer, int len);
|
||||
ssize_t stdio_read(void* buffer, size_t max_len);
|
||||
|
||||
/**
|
||||
* @brief write @p len bytes from @p buffer into uart
|
||||
@ -74,10 +54,10 @@ int uart_stdio_read(char* buffer, int len);
|
||||
* @return nr of bytes written
|
||||
* @return <0 on error
|
||||
*/
|
||||
int uart_stdio_write(const char* buffer, int len);
|
||||
ssize_t stdio_write(const void* buffer, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
#endif /* UART_STDIO_H */
|
||||
#endif /* STDIO_BASE_H */
|
51
sys/include/stdio_rtt.h
Normal file
51
sys/include/stdio_rtt.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Michael Andersen <m.andersen@berkeley.edu>
|
||||
* 2018 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup sys_stdio_rtt STDIO over SEGGER RTT
|
||||
* @ingroup sys
|
||||
*
|
||||
* @brief STDIO mapping for running the STDIO over SEGGER's RTT interface
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
*
|
||||
* @author Michael Andersen <m.andersen@cs.berkeley.edu>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef STDIO_RTT_H
|
||||
#define STDIO_RTT_H
|
||||
|
||||
#include "stdio_base.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief enable stdin polling, at a power consumption cost. This is enabled
|
||||
* by default unless STDIO_RTT_DISABLE_STDIN is defined.
|
||||
*/
|
||||
void rtt_stdio_enable_stdin(void);
|
||||
|
||||
/**
|
||||
* @brief enable stdout blocking and free space polling. This must be done
|
||||
* with caution because if there is no RTT client attached, all
|
||||
* writes to stdout will block indefinitely. This can be enabled
|
||||
* automatically by defining STDIO_RTT_ENABLE_BLOCKING_STDOUT
|
||||
*/
|
||||
void rtt_stdio_enable_blocking_stdout(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* STDIO_RTT_H */
|
59
sys/include/stdio_uart.h
Normal file
59
sys/include/stdio_uart.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2018 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup sys_stdio_uart STDIO over UART
|
||||
* @ingroup sys
|
||||
*
|
||||
* @brief Standard input/output backend using UART
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef STDIO_UART_H
|
||||
#define STDIO_UART_H
|
||||
|
||||
/* Boards may override the default STDIO UART device */
|
||||
#include "board.h"
|
||||
#include "stdio_base.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_DEV
|
||||
/**
|
||||
* @brief UART device to use for STDIO
|
||||
*/
|
||||
#define STDIO_UART_DEV UART_DEV(0)
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_BAUDRATE
|
||||
/**
|
||||
* @brief Baudrate for STDIO
|
||||
*/
|
||||
#define STDIO_UART_BAUDRATE (115200)
|
||||
#endif
|
||||
|
||||
#ifndef STDIO_UART_RX_BUFSIZE
|
||||
/**
|
||||
* @brief Buffer size for STDIO
|
||||
*/
|
||||
#define STDIO_UART_RX_BUFSIZE (64)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
||||
#endif /* STDIO_UART_H */
|
@ -45,7 +45,7 @@
|
||||
#include "vfs.h"
|
||||
#endif
|
||||
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_base.h"
|
||||
|
||||
#include <sys/times.h>
|
||||
|
||||
@ -69,7 +69,7 @@ char *heap_top = &_sheap + 4;
|
||||
*/
|
||||
void _init(void)
|
||||
{
|
||||
uart_stdio_init();
|
||||
stdio_init();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -389,7 +389,7 @@ int _unlink_r(struct _reent *r, const char *path)
|
||||
/*
|
||||
* Fallback read function
|
||||
*
|
||||
* All input is read from uart_stdio regardless of fd number. The function will
|
||||
* All input is read from stdio_uart regardless of fd number. The function will
|
||||
* block until a byte is actually read.
|
||||
*
|
||||
* Note: the read function does not buffer - data will be lost if the function is not
|
||||
@ -399,20 +399,20 @@ _ssize_t _read_r(struct _reent *r, int fd, void *buffer, size_t count)
|
||||
{
|
||||
(void)r;
|
||||
(void)fd;
|
||||
return uart_stdio_read(buffer, count);
|
||||
return stdio_read(buffer, count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fallback write function
|
||||
*
|
||||
* All output is directed to uart_stdio, independent of the given file descriptor.
|
||||
* All output is directed to stdio_uart, independent of the given file descriptor.
|
||||
* The write call will further block until the byte is actually written to the UART.
|
||||
*/
|
||||
_ssize_t _write_r(struct _reent *r, int fd, const void *data, size_t count)
|
||||
{
|
||||
(void) r;
|
||||
(void) fd;
|
||||
return uart_stdio_write(data, count);
|
||||
return stdio_write(data, count);
|
||||
}
|
||||
|
||||
/* Stubs to avoid linking errors, these functions do not have any effect */
|
||||
|
@ -11,7 +11,7 @@ and enables stdio on platforms that do not have a UART.
|
||||
To use this module, add
|
||||
|
||||
```
|
||||
USEMODULE += rtt_stdio
|
||||
USEMODULE += stdio_rtt
|
||||
```
|
||||
|
||||
to your makefile. By default the module will drop bytes written to stdout if the
|
||||
@ -19,7 +19,7 @@ buffer is full. If you know for certain that the debugger is attached, you
|
||||
can obtain lossless stdout by adding
|
||||
|
||||
```
|
||||
CFLAGS += -DRTT_STDIO_ENABLE_BLOCKING_STDOUT
|
||||
CFLAGS += -DSTDIO_RTT_ENABLE_BLOCKING_STDOUT
|
||||
```
|
||||
|
||||
to your makefile. Note well that if you do NOT plug in the debugger and run
|
||||
@ -41,5 +41,5 @@ can increase the number of unnecessary wakeups from sleep. To disable stdin,
|
||||
add this to your makefile:
|
||||
|
||||
```
|
||||
CFLAGS += -DRTT_STDIO_DISABLE_STDIN
|
||||
CFLAGS += -DSTDIO_RTT_DISABLE_STDIN
|
||||
```
|
@ -67,10 +67,8 @@
|
||||
* @file
|
||||
* @brief SEGGER RTT stdio implementation
|
||||
*
|
||||
* This file implements UART read/write functions, but it
|
||||
* is actually a virtual UART backed by a ringbuffer that
|
||||
* complies with SEGGER RTT. It is designed to shadow
|
||||
* uart_stdio that is used by newlib.
|
||||
* This file implements RIOTs STDIO interface and works with a ringbuffer that
|
||||
* complies with SEGGER RTT.
|
||||
*
|
||||
* @author Michael Andersen <m.andersen@cs.berkeley.edu>
|
||||
*
|
||||
@ -84,8 +82,8 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <rtt_stdio.h>
|
||||
|
||||
#include "stdio_rtt.h"
|
||||
#include "thread.h"
|
||||
#include "mutex.h"
|
||||
#include "xtimer.h"
|
||||
@ -319,12 +317,12 @@ static ssize_t rtt_stdio_vfs_write(vfs_file_t *filp, const void *src, size_t nby
|
||||
|
||||
#endif
|
||||
|
||||
void uart_stdio_init(void) {
|
||||
#ifndef RTT_STDIO_DISABLE_STDIN
|
||||
void stdio_init(void) {
|
||||
#ifndef STDIO_RTT_DISABLE_STDIN
|
||||
stdin_enabled = 1;
|
||||
#endif
|
||||
|
||||
#ifdef RTT_STDIO_ENABLE_BLOCKING_STDOUT
|
||||
#ifdef STDIO_RTT_ENABLE_BLOCKING_STDOUT
|
||||
blocking_stdout = 1;
|
||||
#endif
|
||||
|
||||
@ -363,8 +361,8 @@ void rtt_stdio_enable_blocking_stdout(void) {
|
||||
actually have an RTT console (because we are deployed on
|
||||
a battery somewhere) then we REALLY don't want to poll
|
||||
especially since we are not expecting to EVER get input. */
|
||||
int uart_stdio_read(char* buffer, int count) {
|
||||
int res = rtt_read(buffer, count);
|
||||
ssize_t stdio_read(void* buffer, size_t count) {
|
||||
int res = rtt_read((void *)buffer, (uint16_t)count);
|
||||
if (res == 0) {
|
||||
if (!stdin_enabled) {
|
||||
mutex_lock(&_rx_mutex);
|
||||
@ -379,15 +377,16 @@ int uart_stdio_read(char* buffer, int count) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return (ssize_t)res;
|
||||
}
|
||||
|
||||
int uart_stdio_write(const char* buffer, int len) {
|
||||
int written = rtt_write(buffer, len);
|
||||
ssize_t stdio_write(const void* in, size_t len) {
|
||||
const char *buffer = (const char *)in;
|
||||
int written = rtt_write(buffer, (unsigned)len);
|
||||
xtimer_ticks32_t last_wakeup = xtimer_now();
|
||||
while (blocking_stdout && written < len) {
|
||||
while (blocking_stdout && ((size_t)written < len)) {
|
||||
xtimer_periodic_wakeup(&last_wakeup, STDIO_POLL_INTERVAL);
|
||||
written += rtt_write(&buffer[written], len-written);
|
||||
}
|
||||
return written;
|
||||
return (ssize_t)written;
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
* Copyright (C) 2013 INRIA
|
||||
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* 2016 Eistec AB
|
||||
* 2018 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
@ -9,18 +10,19 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup sys
|
||||
* @ingroup sys
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief UART stdio implementation
|
||||
* @brief STDIO over UART implementation
|
||||
*
|
||||
* This file implements a UART callback and read/write functions.
|
||||
* This file implements a UART callback and the STDIO read/write functions
|
||||
*
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @author Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
@ -31,7 +33,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "periph/uart.h"
|
||||
@ -49,73 +51,73 @@ extern ethos_t ethos;
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
static char _rx_buf_mem[UART_STDIO_RX_BUFSIZE];
|
||||
isrpipe_t uart_stdio_isrpipe = ISRPIPE_INIT(_rx_buf_mem);
|
||||
static char _rx_buf_mem[STDIO_UART_RX_BUFSIZE];
|
||||
isrpipe_t stdio_uart_isrpipe = ISRPIPE_INIT(_rx_buf_mem);
|
||||
|
||||
#if MODULE_VFS
|
||||
static ssize_t uart_stdio_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes);
|
||||
static ssize_t uart_stdio_vfs_write(vfs_file_t *filp, const void *src, size_t nbytes);
|
||||
static ssize_t stdio_uart_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes);
|
||||
static ssize_t stdio_uart_vfs_write(vfs_file_t *filp, const void *src, size_t nbytes);
|
||||
|
||||
/**
|
||||
* @brief VFS file operation table for stdin/stdout/stderr
|
||||
*/
|
||||
static vfs_file_ops_t uart_stdio_vfs_ops = {
|
||||
.read = uart_stdio_vfs_read,
|
||||
.write = uart_stdio_vfs_write,
|
||||
static vfs_file_ops_t stdio_uart_vfs_ops = {
|
||||
.read = stdio_uart_vfs_read,
|
||||
.write = stdio_uart_vfs_write,
|
||||
};
|
||||
|
||||
static ssize_t uart_stdio_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes)
|
||||
static ssize_t stdio_uart_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes)
|
||||
{
|
||||
int fd = filp->private_data.value;
|
||||
if (fd != STDIN_FILENO) {
|
||||
return -EBADF;
|
||||
}
|
||||
return uart_stdio_read(dest, nbytes);
|
||||
return stdio_read(dest, nbytes);
|
||||
}
|
||||
|
||||
static ssize_t uart_stdio_vfs_write(vfs_file_t *filp, const void *src, size_t nbytes)
|
||||
static ssize_t stdio_uart_vfs_write(vfs_file_t *filp, const void *src, size_t nbytes)
|
||||
{
|
||||
int fd = filp->private_data.value;
|
||||
if (fd == STDIN_FILENO) {
|
||||
return -EBADF;
|
||||
}
|
||||
return uart_stdio_write(src, nbytes);
|
||||
return stdio_write(src, nbytes);
|
||||
}
|
||||
#endif
|
||||
|
||||
void uart_stdio_init(void)
|
||||
void stdio_init(void)
|
||||
{
|
||||
#ifndef USE_ETHOS_FOR_STDIO
|
||||
uart_init(UART_STDIO_DEV, UART_STDIO_BAUDRATE, (uart_rx_cb_t) isrpipe_write_one, &uart_stdio_isrpipe);
|
||||
uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, (uart_rx_cb_t) isrpipe_write_one, &stdio_uart_isrpipe);
|
||||
#else
|
||||
uart_init(ETHOS_UART, ETHOS_BAUDRATE, (uart_rx_cb_t) isrpipe_write_one, &uart_stdio_isrpipe);
|
||||
uart_init(ETHOS_UART, ETHOS_BAUDRATE, (uart_rx_cb_t) isrpipe_write_one, &stdio_uart_isrpipe);
|
||||
#endif
|
||||
#if MODULE_VFS
|
||||
int fd;
|
||||
fd = vfs_bind(STDIN_FILENO, O_RDONLY, &uart_stdio_vfs_ops, (void *)STDIN_FILENO);
|
||||
fd = vfs_bind(STDIN_FILENO, O_RDONLY, &stdio_uart_vfs_ops, (void *)STDIN_FILENO);
|
||||
if (fd < 0) {
|
||||
/* How to handle errors on init? */
|
||||
}
|
||||
fd = vfs_bind(STDOUT_FILENO, O_WRONLY, &uart_stdio_vfs_ops, (void *)STDOUT_FILENO);
|
||||
fd = vfs_bind(STDOUT_FILENO, O_WRONLY, &stdio_uart_vfs_ops, (void *)STDOUT_FILENO);
|
||||
if (fd < 0) {
|
||||
/* How to handle errors on init? */
|
||||
}
|
||||
fd = vfs_bind(STDERR_FILENO, O_WRONLY, &uart_stdio_vfs_ops, (void *)STDERR_FILENO);
|
||||
fd = vfs_bind(STDERR_FILENO, O_WRONLY, &stdio_uart_vfs_ops, (void *)STDERR_FILENO);
|
||||
if (fd < 0) {
|
||||
/* How to handle errors on init? */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int uart_stdio_read(char* buffer, int count)
|
||||
ssize_t stdio_read(void* buffer, size_t count)
|
||||
{
|
||||
return isrpipe_read(&uart_stdio_isrpipe, buffer, count);
|
||||
return (ssize_t)isrpipe_read(&stdio_uart_isrpipe, (char *)buffer, count);
|
||||
}
|
||||
|
||||
int uart_stdio_write(const char* buffer, int len)
|
||||
ssize_t stdio_write(const void* buffer, size_t len)
|
||||
{
|
||||
#ifndef USE_ETHOS_FOR_STDIO
|
||||
uart_write(UART_STDIO_DEV, (const uint8_t *)buffer, (size_t)len);
|
||||
uart_write(STDIO_UART_DEV, (const uint8_t *)buffer, len);
|
||||
#else
|
||||
ethos_send_frame(ðos, (const uint8_t *)buffer, len, ETHOS_FRAME_TYPE_TEXT);
|
||||
#endif
|
@ -871,7 +871,7 @@ static inline int _allocate_fd(int fd)
|
||||
if ((fd == STDIN_FILENO) || (fd == STDOUT_FILENO) || (fd == STDERR_FILENO)) {
|
||||
/* Do not auto-allocate the stdio file descriptor numbers to
|
||||
* avoid conflicts between normal file system users and stdio
|
||||
* drivers such as uart_stdio, rtt_stdio which need to be able
|
||||
* drivers such as stdio_uart, stdio_rtt which need to be able
|
||||
* to bind to these specific file descriptor numbers. */
|
||||
continue;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "dynamixel.h"
|
||||
#include "shell.h"
|
||||
#include "shell_commands.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
#include "board.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
@ -101,7 +101,7 @@ static int parse_uart(char *arg)
|
||||
printf("Error: Invalid UART_DEV device specified (%u).\n", uart);
|
||||
return -1;
|
||||
}
|
||||
else if (UART_DEV(uart) == UART_STDIO_DEV) {
|
||||
else if (UART_DEV(uart) == STDIO_UART_DEV) {
|
||||
printf("Error: The selected UART_DEV(%u) is used for the shell!\n", uart);
|
||||
return -2;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "feetech.h"
|
||||
#include "shell.h"
|
||||
#include "shell_commands.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -86,7 +86,7 @@ static int parse_uart(char *arg)
|
||||
printf("Error: Invalid UART_DEV device specified (%u).\n", uart);
|
||||
return -1;
|
||||
}
|
||||
else if (UART_DEV(uart) == UART_STDIO_DEV) {
|
||||
else if (UART_DEV(uart) == STDIO_UART_DEV) {
|
||||
printf("Error: The selected UART_DEV(%u) is used for the shell!\n", uart);
|
||||
return -2;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ of the Bee-like module to your board:
|
||||
NOTE: when you use an Arduino Wireless Proto shield, the RN2483/RN2903 module
|
||||
can potentially be connected to the same UART as RIOTs standard out. This is the
|
||||
case for Arduino UNO, and most of the Nucleo 64 boards.
|
||||
In this case you must redefine `UART_STDIO_DEV` to another UART interface in
|
||||
In this case you must redefine `STDIO_UART_DEV` to another UART interface in
|
||||
the `board.h` and connect a UART-to-USB adapter to that UART.
|
||||
This is not the case with Arduino-zero or some Nucleo144 boards.
|
||||
|
||||
|
@ -9,7 +9,7 @@ module to your board:
|
||||
- GND
|
||||
|
||||
NOTE: when you use an Arduino Xbee shield, the Xbee module is connected to the
|
||||
same UART as RIOTs standard out. In this case you must redefine UART_STDIO_DEV to
|
||||
same UART as RIOTs standard out. In this case you must redefine STDIO_UART_DEV to
|
||||
another UART interface in the board.h and connect a UART-to-USB adapter to that
|
||||
UART.
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "msg.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "periph/uart.h"
|
||||
#include "uart_stdio.h"
|
||||
#include "stdio_uart.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#define SHELL_BUFSIZE (128U)
|
||||
@ -39,8 +39,8 @@
|
||||
|
||||
#define POWEROFF_DELAY (250U * US_PER_MS) /* quarter of a second */
|
||||
|
||||
#ifndef UART_STDIO_DEV
|
||||
#define UART_STDIO_DEV (UART_UNDEF)
|
||||
#ifndef STDIO_UART_DEV
|
||||
#define STDIO_UART_DEV (UART_UNDEF)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@ -60,7 +60,7 @@ static int parse_dev(char *arg)
|
||||
printf("Error: Invalid UART_DEV device specified (%u).\n", dev);
|
||||
return -1;
|
||||
}
|
||||
else if (UART_DEV(dev) == UART_STDIO_DEV) {
|
||||
else if (UART_DEV(dev) == STDIO_UART_DEV) {
|
||||
printf("Error: The selected UART_DEV(%u) is used for the shell!\n", dev);
|
||||
return -2;
|
||||
}
|
||||
@ -196,14 +196,14 @@ int main(void)
|
||||
"NOTE: all strings need to be '\\n' terminated!\n");
|
||||
|
||||
/* do sleep test for UART used as STDIO. There is a possibility that the
|
||||
* value given in UART_STDIO_DEV is not a numeral (depends on the CPU
|
||||
* value given in STDIO_UART_DEV is not a numeral (depends on the CPU
|
||||
* implementation), so we rather break the output by printing a
|
||||
* non-numerical value instead of breaking the UART device descriptor */
|
||||
sleep_test(UART_STDIO_DEV, UART_STDIO_DEV);
|
||||
sleep_test(STDIO_UART_DEV, STDIO_UART_DEV);
|
||||
|
||||
puts("\nUART INFO:");
|
||||
printf("Available devices: %i\n", UART_NUMOF);
|
||||
printf("UART used for STDIO (the shell): UART_DEV(%i)\n\n", UART_STDIO_DEV);
|
||||
printf("UART used for STDIO (the shell): UART_DEV(%i)\n\n", STDIO_UART_DEV);
|
||||
|
||||
/* initialize ringbuffers */
|
||||
for (unsigned i = 0; i < UART_NUMOF; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user