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
fc386475
Commit
fc386475
authored
10 years ago
by
Thomas Eichinger
Browse files
Options
Downloads
Patches
Plain Diff
stm32f3: be UART0 aware
parent
aefa8183
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/stm32f3/syscalls.c
+22
-2
22 additions, 2 deletions
cpu/stm32f3/syscalls.c
with
22 additions
and
2 deletions
cpu/stm32f3/syscalls.c
+
22
−
2
View file @
fc386475
...
@@ -37,28 +37,42 @@
...
@@ -37,28 +37,42 @@
#include
"irq.h"
#include
"irq.h"
#include
"periph/uart.h"
#include
"periph/uart.h"
#ifdef MODULE_UART0
#include
"board_uart0.h"
#endif
/**
/**
* @brief manage the heap
* @brief manage the heap
*/
*/
extern
uint32_t
_end
;
/* address of last used memory cell */
extern
uint32_t
_end
;
/* address of last used memory cell */
caddr_t
heap_top
=
(
caddr_t
)
&
_end
+
4
;
caddr_t
heap_top
=
(
caddr_t
)
&
_end
+
4
;
#ifndef MODULE_UART0
/**
/**
* @brief use mutex for waiting on incoming UART chars
* @brief use mutex for waiting on incoming UART chars
*/
*/
static
mutex_t
uart_rx_mutex
;
static
mutex_t
uart_rx_mutex
;
static
char
rx_buf_mem
[
STDIO_BUFSIZE
];
static
char
rx_buf_mem
[
STDIO_BUFSIZE
];
static
ringbuffer_t
rx_buf
;
static
ringbuffer_t
rx_buf
;
#endif
/**
/**
* @brief Receive a new character from the UART and put it into the receive buffer
* @brief Receive a new character from the UART and put it into the receive buffer
*/
*/
void
rx_cb
(
void
*
arg
,
char
data
)
void
rx_cb
(
void
*
arg
,
char
data
)
{
{
#ifndef MODULE_UART0
(
void
)
arg
;
(
void
)
arg
;
ringbuffer_add_one
(
&
rx_buf
,
data
);
ringbuffer_add_one
(
&
rx_buf
,
data
);
mutex_unlock
(
&
uart_rx_mutex
);
mutex_unlock
(
&
uart_rx_mutex
);
#else
if
(
uart0_handler_pid
)
{
uart0_handle_incoming
(
data
);
uart0_notify_thread
();
}
#endif
}
}
/**
/**
...
@@ -66,10 +80,11 @@ void rx_cb(void *arg, char data)
...
@@ -66,10 +80,11 @@ void rx_cb(void *arg, char data)
*/
*/
void
_init
(
void
)
void
_init
(
void
)
{
{
#ifndef MODULE_UART0
mutex_init
(
&
uart_rx_mutex
);
mutex_init
(
&
uart_rx_mutex
);
ringbuffer_init
(
&
rx_buf
,
rx_buf_mem
,
STDIO_BUFSIZE
);
ringbuffer_init
(
&
rx_buf
,
rx_buf_mem
,
STDIO_BUFSIZE
);
uart_init
(
STDIO
,
STDIO_BAUDRATE
,
rx_cb
,
0
,
0
);
#endif
}
uart_init
(
STDIO
,
STDIO_BAUDRATE
,
rx_cb
,
0
,
0
);
}
/**
/**
* @brief Free resources on NewLib de-initialization, not used for RIOT
* @brief Free resources on NewLib de-initialization, not used for RIOT
...
@@ -174,10 +189,15 @@ int _open_r(struct _reent *r, const char *name, int mode)
...
@@ -174,10 +189,15 @@ int _open_r(struct _reent *r, const char *name, int mode)
*/
*/
int
_read_r
(
struct
_reent
*
r
,
int
fd
,
void
*
buffer
,
unsigned
int
count
)
int
_read_r
(
struct
_reent
*
r
,
int
fd
,
void
*
buffer
,
unsigned
int
count
)
{
{
#ifndef MODULE_UART0
while
(
rx_buf
.
avail
==
0
)
{
while
(
rx_buf
.
avail
==
0
)
{
mutex_lock
(
&
uart_rx_mutex
);
mutex_lock
(
&
uart_rx_mutex
);
}
}
return
ringbuffer_get
(
&
rx_buf
,
(
char
*
)
buffer
,
rx_buf
.
avail
);
return
ringbuffer_get
(
&
rx_buf
,
(
char
*
)
buffer
,
rx_buf
.
avail
);
#else
r
->
_errno
=
ENODEV
;
return
-
1
;
#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