Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
5c6cc3e9
Verified
Commit
5c6cc3e9
authored
Jul 24, 2019
by
Rahix
Browse files
fix(pycardium): Fix stupid string cooker
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
e728833c
Changes
2
Hide whitespace changes
Inline
Side-by-side
pycardium/mphalport.c
View file @
5c6cc3e9
#include
<stdint.h>
#include
<stdarg.h>
#include
<stdio.h>
#include
<string.h>
#include
"py/lexer.h"
#include
"py/mpconfig.h"
...
...
@@ -27,12 +28,36 @@ int mp_hal_stdin_rx_chr(void)
return
(
int
)
epic_uart_read_chr
();
}
/* Send string
of given length
*/
/* Send
a
string */
void
mp_hal_stdout_tx_strn
(
const
char
*
str
,
mp_uint_t
len
)
{
epic_uart_write_str
(
str
,
len
);
}
/* Send a string, but replace \n with \n\r */
void
mp_hal_stdout_tx_strn_cooked
(
const
char
*
str
,
size_t
len
)
{
/*
* 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
<
len
;
i
++
)
{
if
(
str
[
i
]
==
'\n'
)
{
epic_uart_write_str
(
&
str
[
last
],
i
-
last
);
epic_uart_write_str
(
"
\r
"
,
1
);
last
=
i
;
}
}
epic_uart_write_str
(
&
str
[
last
],
len
-
last
);
}
/* Send a zero-terminated string */
void
mp_hal_stdout_tx_str
(
const
char
*
str
)
{
mp_hal_stdout_tx_strn
(
str
,
strlen
(
str
));
}
/* Used by MicroPython for debug output */
int
DEBUG_printf
(
const
char
*
fmt
,
...)
{
...
...
@@ -90,6 +115,11 @@ void mp_hal_delay_us(mp_uint_t us)
mxc_delay
(
us
);
}
mp_uint_t
mp_hal_ticks_ms
(
void
)
{
return
0
;
}
/******************************************************************************
* Fatal Errors
*/
...
...
pycardium/mphalport.h
View file @
5c6cc3e9
#include
"py/mpconfig.h"
/* TODO: Replace this with a proper implementation */
static
inline
mp_uint_t
mp_hal_ticks_ms
(
void
)
{
return
0
;
}
void
mp_hal_set_interrupt_char
(
char
c
);
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment