Verified Commit 69775a15 authored by Rahix's avatar Rahix
Browse files

feat(epicardium): Display all output on CDC-ACM

Closes #67

Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent 4b465ff4
Pipeline #2020 passed with stages
in 52 seconds
...@@ -85,6 +85,7 @@ elf = executable( ...@@ -85,6 +85,7 @@ elf = executable(
include_directories: [freertos_includes], include_directories: [freertos_includes],
link_args: [ link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map', '-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
'-Wl,--defsym=_write=_write_epicardium',
], ],
) )
......
...@@ -49,7 +49,7 @@ int epic_uart_read_char(void) ...@@ -49,7 +49,7 @@ int epic_uart_read_char(void)
*/ */
int epic_uart_read_str(char *buf, size_t cnt) int epic_uart_read_str(char *buf, size_t cnt)
{ {
int i = 0; size_t i = 0;
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
if (xQueueReceive(read_queue, &buf[i], 0) != pdTRUE) { if (xQueueReceive(read_queue, &buf[i], 0) != pdTRUE) {
...@@ -60,6 +60,24 @@ int epic_uart_read_str(char *buf, size_t cnt) ...@@ -60,6 +60,24 @@ int epic_uart_read_str(char *buf, size_t cnt)
return i; return i;
} }
long _write_epicardium(int fd, const char *buf, size_t cnt)
{
/*
* Only print one line at a time. Insert `\r` between lines so they are
* properly displayed on the serial console.
*/
size_t i, last = 0;
for (i = 0; i < cnt; i++) {
if (buf[i] == '\n') {
epic_uart_write_str(&buf[last], i - last);
epic_uart_write_str("\r", 1);
last = i;
}
}
epic_uart_write_str(&buf[last], cnt - last);
return cnt;
}
/* Interrupt handler needed for SDK UART implementation */ /* Interrupt handler needed for SDK UART implementation */
void UART0_IRQHandler(void) void UART0_IRQHandler(void)
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment