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
dd70231b
Commit
dd70231b
authored
8 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
sys: uart_stdio: make use of isrpipe
parent
b89d81fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile.dep
+1
-1
1 addition, 1 deletion
Makefile.dep
sys/uart_stdio/uart_stdio.c
+6
-27
6 additions, 27 deletions
sys/uart_stdio/uart_stdio.c
with
7 additions
and
28 deletions
Makefile.dep
+
1
−
1
View file @
dd70231b
...
@@ -373,7 +373,7 @@ ifneq (,$(filter rtt_stdio,$(USEMODULE)))
...
@@ -373,7 +373,7 @@ ifneq (,$(filter rtt_stdio,$(USEMODULE)))
endif
endif
ifneq
(,$(filter uart_stdio,$(USEMODULE)))
ifneq
(,$(filter uart_stdio,$(USEMODULE)))
USEMODULE
+=
t
sr
b
USEMODULE
+=
i
sr
pipe
endif
endif
ifneq
(,$(filter isrpipe,$(USEMODULE)))
ifneq
(,$(filter isrpipe,$(USEMODULE)))
...
...
This diff is collapsed.
Click to expand it.
sys/uart_stdio/uart_stdio.c
+
6
−
27
View file @
dd70231b
...
@@ -24,15 +24,12 @@
...
@@ -24,15 +24,12 @@
*/
*/
#include
<stdio.h>
#include
<stdio.h>
#include
"uart_stdio.h"
#include
"tsrb.h"
#include
"uart_stdio.h"
#include
"thread.h"
#include
"mutex.h"
#include
"irq.h"
#include
"board.h"
#include
"board.h"
#include
"periph/uart.h"
#include
"periph/uart.h"
#include
"isrpipe.h"
#ifdef USE_ETHOS_FOR_STDIO
#ifdef USE_ETHOS_FOR_STDIO
#include
"ethos.h"
#include
"ethos.h"
...
@@ -42,39 +39,21 @@ extern ethos_t ethos;
...
@@ -42,39 +39,21 @@ extern ethos_t ethos;
#define ENABLE_DEBUG 0
#define ENABLE_DEBUG 0
#include
"debug.h"
#include
"debug.h"
/**
* @brief use mutex for waiting on incoming UART chars
*/
static
mutex_t
_rx_mutex
=
MUTEX_INIT
;
static
char
_rx_buf_mem
[
UART_STDIO_RX_BUFSIZE
];
static
char
_rx_buf_mem
[
UART_STDIO_RX_BUFSIZE
];
static
tsrb_t
_rx_buf
=
TSRB_INIT
(
_rx_buf_mem
);
static
isrpipe_t
_isrpipe
=
ISRPIPE_INIT
(
_rx_buf_mem
);
/**
* @brief Receive a new character from the UART and put it into the receive buffer
*/
void
uart_stdio_rx_cb
(
void
*
arg
,
uint8_t
data
)
{
(
void
)
arg
;
tsrb_add_one
(
&
_rx_buf
,
(
uint8_t
)
data
);
mutex_unlock
(
&
_rx_mutex
);
}
void
uart_stdio_init
(
void
)
void
uart_stdio_init
(
void
)
{
{
#ifndef USE_ETHOS_FOR_STDIO
#ifndef USE_ETHOS_FOR_STDIO
uart_init
(
UART_STDIO_DEV
,
UART_STDIO_BAUDRATE
,
uart_
stdio_rx_cb
,
NULL
);
uart_init
(
UART_STDIO_DEV
,
UART_STDIO_BAUDRATE
,
(
uart_
rx_cb_t
)
isrpipe_write_one
,
&
_isrpipe
);
#else
#else
uart_init
(
ETHOS_UART
,
ETHOS_BAUDRATE
,
uart_
stdio_rx_cb
,
NULL
);
uart_init
(
ETHOS_UART
,
ETHOS_BAUDRATE
,
(
uart_
rx_cb_t
)
isrpipe_write_one
,
&
_isrpipe
);
#endif
#endif
}
}
int
uart_stdio_read
(
char
*
buffer
,
int
count
)
int
uart_stdio_read
(
char
*
buffer
,
int
count
)
{
{
int
res
;
return
isrpipe_read
(
&
_isrpipe
,
buffer
,
count
);
while
(
!
(
res
=
tsrb_get
(
&
_rx_buf
,
buffer
,
count
)))
{
mutex_lock
(
&
_rx_mutex
);
}
return
res
;
}
}
int
uart_stdio_write
(
const
char
*
buffer
,
int
len
)
int
uart_stdio_write
(
const
char
*
buffer
,
int
len
)
...
...
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