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
aefa8183
Commit
aefa8183
authored
10 years ago
by
Thomas Eichinger
Browse files
Options
Downloads
Patches
Plain Diff
stm32f4: be UART0 aware
parent
8fc2e61e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
boards/stm32f4discovery/include/board.h
+1
-0
1 addition, 0 deletions
boards/stm32f4discovery/include/board.h
cpu/stm32f4/periph/uart.c
+0
-1
0 additions, 1 deletion
cpu/stm32f4/periph/uart.c
cpu/stm32f4/syscalls.c
+49
-10
49 additions, 10 deletions
cpu/stm32f4/syscalls.c
with
50 additions
and
11 deletions
boards/stm32f4discovery/include/board.h
+
1
−
0
View file @
aefa8183
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
*/
*/
#define STDIO UART_0
#define STDIO UART_0
#define STDIO_BAUDRATE (115200U)
#define STDIO_BAUDRATE (115200U)
#define STDIO_BUFSIZE (64U)
/** @} */
/** @} */
/**
/**
...
...
This diff is collapsed.
Click to expand it.
cpu/stm32f4/periph/uart.c
+
0
−
1
View file @
aefa8183
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
/* guard file in case no UART device was specified */
/* guard file in case no UART device was specified */
#if UART_NUMOF
#if UART_NUMOF
/**
/**
* @brief Each UART device has to store two callbacks.
* @brief Each UART device has to store two callbacks.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
cpu/stm32f4/syscalls.c
+
49
−
10
View file @
aefa8183
...
@@ -34,18 +34,54 @@
...
@@ -34,18 +34,54 @@
#include
"irq.h"
#include
"irq.h"
#include
"periph/uart.h"
#include
"periph/uart.h"
#ifdef MODULE_UART0
#include
"board_uart0.h"
#endif
/**
/**
* manage the heap
* 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
*/
static
mutex_t
uart_rx_mutex
;
static
char
rx_buf_mem
[
STDIO_BUFSIZE
];
static
ringbuffer_t
rx_buf
;
#endif
/**
* @brief Receive a new character from the UART and put it into the receive buffer
*/
void
rx_cb
(
void
*
arg
,
char
data
)
{
#ifndef MODULE_UART0
(
void
)
arg
;
ringbuffer_add_one
(
&
rx_buf
,
data
);
mutex_unlock
(
&
uart_rx_mutex
);
#else
if
(
uart0_handler_pid
)
{
uart0_handle_incoming
(
data
);
uart0_notify_thread
();
}
#endif
}
/**
/**
* @brief Initialize NewLib, called by __libc_init_array() from the startup script
* @brief Initialize NewLib, called by __libc_init_array() from the startup script
*/
*/
void
_init
(
void
)
void
_init
(
void
)
{
{
uart_init_blocking
(
STDIO
,
STDIO_BAUDRATE
);
#ifndef MODULE_UART0
mutex_init
(
&
uart_rx_mutex
);
ringbuffer_init
(
&
rx_buf
,
rx_buf_mem
,
STDIO_BUFSIZE
);
#endif
uart_init
(
STDIO
,
STDIO_BAUDRATE
,
rx_cb
,
0
,
0
);
}
}
/**
/**
...
@@ -151,11 +187,12 @@ int _open_r(struct _reent *r, const char *name, int mode)
...
@@ -151,11 +187,12 @@ 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
)
{
{
char
c
;
#ifndef MODULE_UART0
char
*
buff
=
(
char
*
)
buffer
;
while
(
rx_buf
.
avail
==
0
)
{
uart_read_blocking
(
STDIO
,
&
c
);
mutex_lock
(
&
uart_rx_mutex
);
buff
[
0
]
=
c
;
}
return
1
;
return
ringbuffer_get
(
&
rx_buf
,
(
char
*
)
buffer
,
rx_buf
.
avail
);
#endif
}
}
/**
/**
...
@@ -175,11 +212,13 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
...
@@ -175,11 +212,13 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
*/
*/
int
_write_r
(
struct
_reent
*
r
,
int
fd
,
const
void
*
data
,
unsigned
int
count
)
int
_write_r
(
struct
_reent
*
r
,
int
fd
,
const
void
*
data
,
unsigned
int
count
)
{
{
char
*
c
=
(
char
*
)
data
;
int
i
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
uart_write_blocking
(
STDIO
,
c
[
i
]);
while
(
i
<
count
)
{
uart_write_blocking
(
STDIO
,
((
char
*
)
data
)[
i
++
]);
}
}
return
count
;
return
i
;
}
}
/**
/**
...
...
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