Skip to content
Snippets Groups Projects

Pycardium Improvements

Merged rahix requested to merge rahix/pycardium-improvements into master
All threads resolved!
3 files
+ 58
38
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 53
31
@@ -32,54 +32,71 @@ int main(void)
pycardium_hal_init();
epic_uart_write_str(header, sizeof(header));
if (cnt < 0) {
printf("pycardium: Error fetching args: %d\n", cnt);
} else if (cnt > 0) {
epic_uart_write_str(header, sizeof(header));
/* Go to REPL instead. */
cnt = 0;
}
if (cnt > 0) {
printf(" Loading %s ...\n", script_name);
} else {
printf(" Entering REPL ...\n\n");
}
mp_stack_set_top(&__StackTop);
mp_stack_set_limit((mp_int_t)&__StackLimit);
while (1) {
gc_init(&__HeapBase + 1024 * 10, &__HeapLimit);
gc_init(&__HeapBase + 1024 * 10, &__HeapLimit);
mp_init();
mp_init();
readline_init0();
interrupt_init0();
readline_init0();
interrupt_init0();
/* request by badge.team */
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_ROM_QSTR(MP_QSTR_));
mp_obj_list_append(
mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib)
);
mp_obj_list_append(
mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps)
);
/* request by badge.team */
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_ROM_QSTR(MP_QSTR_));
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib));
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps));
if (cnt > 0) {
pyexec_file_if_exists(script_name);
if (cnt > 0) {
int ret = pyexec_file_if_exists(script_name);
if (ret == 0) {
/*
* The script was aborted via uncaught exception; Sadly
* we can't find out what happened so let's hope it was
* a KeyboardInterrupt and drop to REPL.
*
* In the future it might be interesting to rework this
* so any other exception will lead to epic_exit(1).
*/
epic_exec("");
}
epic_uart_write_str(header, sizeof(header));
for (;;) {
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
if (pyexec_raw_repl() != 0) {
break;
}
} else {
if (pyexec_friendly_repl() != 0) {
break;
}
/* The script ended execution normally; return to menu */
epic_exit(0);
}
for (;;) {
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
if (pyexec_raw_repl() != 0) {
break;
}
} else {
if (pyexec_friendly_repl() != 0) {
break;
}
}
mp_deinit();
}
mp_deinit();
epic_exit(0);
}
void HardFault_Handler(void)
@@ -87,6 +104,11 @@ void HardFault_Handler(void)
epic_exit(255);
}
void _exit(void)
{
epic_exit(254);
}
void gc_collect(void)
{
void *sp = (void *)__get_MSP();
Loading