Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
d55616a7
Commit
d55616a7
authored
6 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
sys/stdio: s/uart_stdio/stdio_uart/
parent
717e84f7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile.dep
+2
-2
2 additions, 2 deletions
Makefile.dep
sys/include/stdio_uart.h
+59
-0
59 additions, 0 deletions
sys/include/stdio_uart.h
sys/stdio_uart/Makefile
+0
-0
0 additions, 0 deletions
sys/stdio_uart/Makefile
sys/stdio_uart/stdio_uart.c
+27
-25
27 additions, 25 deletions
sys/stdio_uart/stdio_uart.c
with
88 additions
and
27 deletions
Makefile.dep
+
2
−
2
View file @
d55616a7
...
...
@@ -374,7 +374,7 @@ ifneq (,$(filter newlib,$(USEMODULE)))
USEMODULE
+=
newlib_syscalls_default
endif
ifeq
(,$(filter rtt_stdio,$(USEMODULE)))
USEMODULE
+=
uart_
stdio
USEMODULE
+=
stdio
_uart
endif
endif
...
...
@@ -390,7 +390,7 @@ ifneq (,$(filter rtt_stdio,$(USEMODULE)))
USEMODULE
+=
xtimer
endif
ifneq
(,$(filter
uart_
stdio,$(USEMODULE)))
ifneq
(,$(filter stdio
_uart
,$(USEMODULE)))
USEMODULE
+=
isrpipe
FEATURES_REQUIRED
+=
periph_uart
endif
...
...
This diff is collapsed.
Click to expand it.
sys/include/
uart_
stdio.h
→
sys/include/stdio
_uart
.h
+
59
−
0
View file @
d55616a7
/*
* 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,77 +8,52 @@
*/
/**
* @defgroup sys_
uart_stdio UART stdio
* @defgroup sys_
stdio_uart STDIO over UART
* @ingroup sys
*
* @brief
stdio init/read/write functions for
UART
s
* @brief
Standard input/output backend using
UART
*
* @{
* @file
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef UART_STDIO_H
#define UART_STDIO_H
#ifndef STDIO_UART_H
#define STDIO_UART_H
/* Boards may override the default STDIO UART device */
#include
<stdint.h>
#include
"board.h"
#include
"stdio_base.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#ifndef
UART_
STDIO_DEV
#ifndef STDIO
_UART
_DEV
/**
* @brief UART device to use for STDIO
*/
#define
UART_
STDIO_DEV
UART_DEV(0)
#define STDIO_
UART_
DEV UART_DEV(0)
#endif
#ifndef
UART_
STDIO_BAUDRATE
#ifndef STDIO
_UART
_BAUDRATE
/**
* @brief Baudrate for STDIO
*/
#define
UART_
STDIO_BAUDRATE
(115200)
#define STDIO_
UART_
BAUDRATE (115200)
#endif
#ifndef
UART_
STDIO_RX_BUFSIZE
#ifndef STDIO
_UART
_RX_BUFSIZE
/**
* @brief Buffer size for STDIO
*/
#define
UART_
STDIO_RX_BUFSIZE
(64)
#define STDIO
_UART
_RX_BUFSIZE (64)
#endif
/**
* @brief initialize the module
*/
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
);
#ifdef __cplusplus
}
#endif
/** @} */
#endif
/*
UART_
STDIO_H */
#endif
/* STDIO
_UART
_H */
This diff is collapsed.
Click to expand it.
sys/
uart_
stdio/Makefile
→
sys/stdio
_uart
/Makefile
+
0
−
0
View file @
d55616a7
File moved
This diff is collapsed.
Click to expand it.
sys/
uart_
stdio
/
uart
_
stdio.c
→
sys/stdio
_
uart
/
stdio
_uart
.c
+
27
−
25
View file @
d55616a7
...
...
@@ -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
_uart
_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
_uart
_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
,
in
t
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
,
in
t
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
(
&
ethos
,
(
const
uint8_t
*
)
buffer
,
len
,
ETHOS_FRAME_TYPE_TEXT
);
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment