|
|
@@ -43,7 +43,8 @@
|
|
|
#include <py/frozenmod.h>
|
|
|
#include <lib/mp-readline/readline.h>
|
|
|
#include <lib/utils/pyexec.h>
|
|
|
-#include "rtt_getchar.h"
|
|
|
+#include "mpgetcharport.h"
|
|
|
+#include "mpputsnport.h"
|
|
|
|
|
|
#if MICROPY_ENABLE_COMPILER
|
|
|
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
|
|
@@ -68,12 +69,12 @@ static char *heap = RT_NULL;
|
|
|
void mpy_main(const char *filename) {
|
|
|
int stack_dummy;
|
|
|
stack_top = (void *)&stack_dummy;
|
|
|
- rt_uint16_t old_flag;
|
|
|
|
|
|
- rtt_getchar_init();
|
|
|
+ mp_getchar_init();
|
|
|
+ mp_putsn_init();
|
|
|
|
|
|
if (rt_thread_self()->stack_size < 4096) {
|
|
|
- rt_kprintf("The stack (%.*s) size for executing MicroPython must be >=4096\n", RT_NAME_MAX, rt_thread_self()->name);
|
|
|
+ mp_printf(&mp_plat_print, "The stack (%.*s) size for executing MicroPython must be >=4096\n", RT_NAME_MAX, rt_thread_self()->name);
|
|
|
}
|
|
|
|
|
|
#if MICROPY_PY_THREAD
|
|
|
@@ -87,7 +88,7 @@ void mpy_main(const char *filename) {
|
|
|
#if MICROPY_ENABLE_GC
|
|
|
heap = rt_malloc(MICROPY_HEAP_SIZE);
|
|
|
if (!heap) {
|
|
|
- rt_kprintf("No memory for MicroPython Heap!\n");
|
|
|
+ mp_printf(&mp_plat_print, "No memory for MicroPython Heap!\n");
|
|
|
return;
|
|
|
}
|
|
|
gc_init(heap, heap + MICROPY_HEAP_SIZE);
|
|
|
@@ -103,14 +104,9 @@ void mpy_main(const char *filename) {
|
|
|
mp_obj_list_init(mp_sys_argv, 0);
|
|
|
readline_init0();
|
|
|
|
|
|
- /* Save the open flag */
|
|
|
- old_flag = rt_console_get_device()->open_flag;
|
|
|
- /* clean the stream flag. stream flag will automatically append '\r' */
|
|
|
- rt_console_get_device()->open_flag &= ~RT_DEVICE_FLAG_STREAM;
|
|
|
-
|
|
|
if (filename) {
|
|
|
#ifndef MICROPYTHON_USING_UOS
|
|
|
- rt_kprintf("Please enable uos module in sys module option first.\n");
|
|
|
+ mp_printf(&mp_plat_print, "Please enable uos module in sys module option first.\n");
|
|
|
#else
|
|
|
pyexec_file(filename);
|
|
|
#endif
|
|
|
@@ -133,7 +129,7 @@ void mpy_main(const char *filename) {
|
|
|
}
|
|
|
#endif /* MICROPYTHON_USING_UOS */
|
|
|
|
|
|
- rt_kprintf("\n");
|
|
|
+ mp_printf(&mp_plat_print, "\n");
|
|
|
for (;;) {
|
|
|
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
|
|
|
if (pyexec_raw_repl() != 0) {
|
|
|
@@ -147,9 +143,6 @@ void mpy_main(const char *filename) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /* restore the open flag */
|
|
|
- rt_console_get_device()->open_flag = old_flag;
|
|
|
-
|
|
|
gc_sweep_all();
|
|
|
|
|
|
mp_deinit();
|
|
|
@@ -160,7 +153,8 @@ void mpy_main(const char *filename) {
|
|
|
|
|
|
rt_free(heap);
|
|
|
|
|
|
- rtt_getchar_deinit();
|
|
|
+ mp_putsn_deinit();
|
|
|
+ mp_getchar_deinit();
|
|
|
}
|
|
|
|
|
|
#if !MICROPY_PY_MODUOS_FILE
|
|
|
@@ -170,13 +164,13 @@ mp_import_stat_t mp_import_stat(const char *path) {
|
|
|
#endif
|
|
|
|
|
|
NORETURN void nlr_jump_fail(void *val) {
|
|
|
- DEBUG_printf("nlr_jump_fail\n");
|
|
|
+ mp_printf(MICROPY_ERROR_PRINTER, "nlr_jump_fail\n");
|
|
|
while (1);
|
|
|
}
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
|
|
|
- rt_kprintf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
|
|
|
+ mp_printf(MICROPY_ERROR_PRINTER, "Assertion '%s' failed, at file %s:%d\n", expr, file, line);
|
|
|
RT_ASSERT(0);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -192,7 +186,7 @@ int DEBUG_printf(const char *format, ...)
|
|
|
va_start(args, format);
|
|
|
/* must use vprintf to print */
|
|
|
rt_vsprintf(log_buf, format, args);
|
|
|
- rt_kprintf("%s", log_buf);
|
|
|
+ mp_printf(&mp_plat_print, "%s", log_buf);
|
|
|
va_end(args);
|
|
|
|
|
|
return 0;
|