1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

stdio_ethos: move to ethos_stdio

This commit is contained in:
Martine Lenders 2021-11-24 12:34:18 +01:00
parent b8dab00303
commit 568be105f2
No known key found for this signature in database
GPG Key ID: 2134D77A5336DD80
9 changed files with 80 additions and 18 deletions

View File

@ -48,6 +48,10 @@ ifneq (,$(filter ccs811_%,$(USEMODULE)))
USEMODULE += ccs811
endif
ifneq (,$(filter ethos_%,$(USEMODULE)))
USEMODULE += ethos
endif
ifneq (,$(filter hmc5883l_%,$(USEMODULE)))
USEMODULE += hmc5883l
endif

View File

@ -1 +1,7 @@
# exclude submodule sources from *.c wildcard source selection
SRC := $(filter-out stdio.c,$(wildcard *.c))
# enable submodules
SUBMODULES := 1
include $(RIOTBASE)/Makefile.base

View File

@ -3,3 +3,7 @@ USEMODULE += iolist
USEMODULE += netdev_eth
USEMODULE += random
USEMODULE += tsrb
ifneq (,$(filter ethos_stdio,$(USEMODULE)))
USEMODULE += isrpipe
endif

View File

@ -40,7 +40,7 @@
#ifdef MODULE_STDIO_ETHOS
#include "stdio_uart.h"
#include "isrpipe.h"
extern isrpipe_t stdio_uart_isrpipe;
extern isrpipe_t ethos_stdio_isrpipe;
#endif
#define ENABLE_DEBUG 0
@ -106,7 +106,7 @@ static void _handle_char(ethos_t *dev, char c)
#ifdef MODULE_STDIO_ETHOS
case ETHOS_FRAME_TYPE_TEXT:
dev->framesize++;
isrpipe_write_one(&stdio_uart_isrpipe, c);
isrpipe_write_one(&ethos_stdio_isrpipe, c);
#endif
}
}

61
drivers/ethos/stdio.c Normal file
View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2013 INRIA
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
* 2016 Eistec AB
* 2018-21 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.
*/
/**
* @{
*
* @file
* @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>
* @author Martine S. Lenders <m.lenders@fu-berlin.de>
*/
#include "ethos.h"
#include "isrpipe.h"
#include "stdio_uart.h"
extern ethos_t ethos;
static uint8_t _rx_buf_mem[STDIO_UART_RX_BUFSIZE];
isrpipe_t ethos_stdio_isrpipe = ISRPIPE_INIT(_rx_buf_mem);
static void _isrpipe_write(void *arg, uint8_t data)
{
isrpipe_write_one(arg, (char)data);
}
void stdio_init(void)
{
uart_init(ETHOS_UART, ETHOS_BAUDRATE, _isrpipe_write, &ethos_stdio_isrpipe);
#if MODULE_VFS
vfs_bind_stdio();
#endif
}
extern unsigned ethos_unstuff_readbyte(uint8_t *buf, uint8_t byte,
bool *escaped, uint8_t *frametype);
ssize_t stdio_read(void* buffer, size_t len)
{
return (ssize_t)isrpipe_read(&ethos_stdio_isrpipe, buffer, len);
}
ssize_t stdio_write(const void* buffer, size_t len)
{
ethos_send_frame(&ethos, (const uint8_t *)buffer, len, ETHOS_FRAME_TYPE_TEXT);
return len;
}
/** @} */

View File

@ -34,7 +34,7 @@ extern "C" {
#endif
/* if using ethos + stdio, use STDIO_UART values unless overridden */
#if IS_USED(MODULE_STDIO_ETHOS) || defined(DOXYGEN)
#if IS_USED(MODULE_ETHOS_STDIO) || defined(DOXYGEN)
#include "stdio_uart.h"
/**
* @defgroup drivers_ethos_config Ethernet-over-serial driver driver compile configuration

View File

@ -24,6 +24,7 @@ PSEUDOMODULES += dhcpv6_client_mud_url
PSEUDOMODULES += dhcpv6_relay
PSEUDOMODULES += dns_msg
PSEUDOMODULES += ecc_%
PSEUDOMODULES += ethos_stdio
PSEUDOMODULES += event_%
PSEUDOMODULES += event_timeout
PSEUDOMODULES += event_timeout_ztimer

View File

@ -24,9 +24,8 @@ ifneq (,$(filter stdio_rtt,$(USEMODULE)))
endif
ifneq (,$(filter stdio_ethos,$(USEMODULE)))
USEMODULE += ethos
USEMODULE += ethos_stdio
USEMODULE += stdin
USEMODULE += stdio_uart
endif
ifneq (,$(filter stdin,$(USEMODULE)))

View File

@ -35,11 +35,6 @@
#include "periph/uart.h"
#include "isrpipe.h"
#ifdef MODULE_STDIO_ETHOS
#include "ethos.h"
extern ethos_t ethos;
#endif
#if MODULE_VFS
#include "vfs.h"
#endif
@ -65,11 +60,7 @@ void stdio_init(void)
arg = NULL;
#endif
#ifdef MODULE_STDIO_ETHOS
uart_init(ETHOS_UART, ETHOS_BAUDRATE, cb, arg);
#else
uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, cb, arg);
#endif
#if MODULE_VFS
vfs_bind_stdio();
@ -89,10 +80,6 @@ ssize_t stdio_read(void* buffer, size_t count)
ssize_t stdio_write(const void* buffer, size_t len)
{
#ifdef MODULE_STDIO_ETHOS
ethos_send_frame(&ethos, (const uint8_t *)buffer, len, ETHOS_FRAME_TYPE_TEXT);
#else
uart_write(STDIO_UART_DEV, (const uint8_t *)buffer, len);
#endif
return len;
}