Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cm510_controller_fw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
humanoides
cm510_controller_fw
Commits
1cc57c84
Commit
1cc57c84
authored
8 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added functions to read and write raw data from the serial console interface.
parent
e2b4a2ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
communications/include/serial_console.h
+2
-0
2 additions, 0 deletions
communications/include/serial_console.h
communications/src/serial_console.c
+46
-1
46 additions, 1 deletion
communications/src/serial_console.c
with
48 additions
and
1 deletion
communications/include/serial_console.h
+
2
−
0
View file @
1cc57c84
...
@@ -12,6 +12,8 @@ void serial_console_init(uint32_t baudrate);
...
@@ -12,6 +12,8 @@ void serial_console_init(uint32_t baudrate);
uint8_t
serial_console_get_num_data
(
void
);
uint8_t
serial_console_get_num_data
(
void
);
int
cm510_printf
(
const
char
*
fmt
,
...);
int
cm510_printf
(
const
char
*
fmt
,
...);
int
cm510_scanf
(
const
char
*
fmt
,
...
);
int
cm510_scanf
(
const
char
*
fmt
,
...
);
uint8_t
cm510_read
(
uint8_t
*
data
,
uint8_t
len
);
uint8_t
cm510_write
(
uint8_t
*
data
,
uint8_t
len
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
This diff is collapsed.
Click to expand it.
communications/src/serial_console.c
+
46
−
1
View file @
1cc57c84
...
@@ -48,7 +48,6 @@ void serial_console_set_baudrate(uint32_t baudrate)
...
@@ -48,7 +48,6 @@ void serial_console_set_baudrate(uint32_t baudrate)
int
serial_console_putchar
(
char
c
,
FILE
*
dev
)
int
serial_console_putchar
(
char
c
,
FILE
*
dev
)
{
{
if
(
c
==
'\n'
)
if
(
c
==
'\n'
)
{
{
serial_console_tx_buffer
[
serial_console_tx_write_ptr
]
=
'\r'
;
serial_console_tx_buffer
[
serial_console_tx_write_ptr
]
=
'\r'
;
...
@@ -156,3 +155,49 @@ int cm510_scanf(const char *fmt, ...)
...
@@ -156,3 +155,49 @@ int cm510_scanf(const char *fmt, ...)
return
done
;
return
done
;
}
}
uint8_t
cm510_read
(
uint8_t
*
data
,
uint8_t
len
)
{
uint8_t
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
serial_console_rx_num_data
>
0
)
{
data
[
i
]
=
serial_console_rx_buffer
[
serial_console_rx_read_ptr
];
serial_console_rx_read_ptr
=
(
serial_console_rx_read_ptr
+
1
)
%
SERIAL_CONSOLE_MAX_BUFFER_LEN
;
serial_console_rx_num_data
--
;
}
else
break
;
}
return
i
;
}
uint8_t
cm510_write
(
uint8_t
*
data
,
uint8_t
len
)
{
uint8_t
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
serial_console_sending
==
0x00
)
{
UDR1
=
data
[
i
];
serial_console_sending
=
0x01
;
}
else
{
if
(
serial_console_tx_num_data
<
SERIAL_CONSOLE_MAX_BUFFER_LEN
)
{
serial_console_tx_buffer
[
serial_console_tx_write_ptr
]
=
data
[
i
];
serial_console_tx_write_ptr
=
(
serial_console_tx_write_ptr
+
1
)
%
SERIAL_CONSOLE_MAX_BUFFER_LEN
;
serial_console_tx_num_data
++
;
}
else
break
;
}
}
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