Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fpletz
firmware
Commits
8765f08c
Verified
Commit
8765f08c
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
feat(serial): Add epic_uart_read_str() API-call
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
32808693
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/epicardium.h
+16
-3
16 additions, 3 deletions
epicardium/epicardium.h
epicardium/modules/serial.c
+16
-0
16 additions, 0 deletions
epicardium/modules/serial.c
with
32 additions
and
3 deletions
epicardium/epicardium.h
+
16
−
3
View file @
8765f08c
...
...
@@ -31,7 +31,7 @@ typedef unsigned int size_t;
#define API_SYSTEM_EXEC 0x2
/* TODO */
#define API_UART_WRITE_STR 0x3
#define API_UART_READ_CHAR 0x4
#define API_UART_READ_STR 0x5
/* TODO */
#define API_UART_READ_STR 0x5
#define API_STREAM_READ 0x6
#define API_INTERRUPT_ENABLE 0x7
#define API_INTERRUPT_DISABLE 0x8
...
...
@@ -136,14 +136,27 @@ API(API_UART_WRITE_STR, void epic_uart_write_str(
));
/**
* Try reading a single character from any connected serial device.
*
* Try reading a single character from any connected serial device. If nothing
* is available, :c:func:`epic_uart_read_char` returns ``(-1)``.
* If nothing is available, :c:func:`epic_uart_read_char` returns ``(-1)``.
*
* :return: The byte or ``(-1)`` if no byte was available.
*/
API
(
API_UART_READ_CHAR
,
int
epic_uart_read_char
(
void
));
/**
* Read as many characters as possible from the UART queue.
*
* :c:func:`epic_uart_read_str` will not block if no new data is available. For
* an example, see :c:func:`epic_isr_uart_rx`.
*
* :param char* buf: Buffer to be filled with incoming data.
* :param size_t cnt: Size of ``buf``.
* :returns: Number of bytes read. Can be ``0`` if no data was available.
* Might be a negative value if an error occured.
*/
API
(
API_UART_READ_STR
,
int
epic_uart_read_str
(
char
*
buf
,
size_t
cnt
));
/**
* **Interrupt Service Routine**
*
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/serial.c
+
16
−
0
View file @
8765f08c
...
...
@@ -43,6 +43,22 @@ int epic_uart_read_char(void)
return
(
-
1
);
}
/*
* API-call to read data from the queue.
*/
int
epic_uart_read_str
(
char
*
buf
,
size_t
cnt
)
{
int
i
=
0
;
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
if
(
xQueueReceive
(
read_queue
,
&
buf
[
i
],
0
)
!=
pdTRUE
)
{
break
;
}
}
return
i
;
}
/* Interrupt handler needed for SDK UART implementation */
void
UART0_IRQHandler
(
void
)
{
...
...
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