Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: stmhal: Very early version of machine module for stmhal. #1493

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions stmhal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ SRC_C = \
pyexec.c \
help.c \
input.c \
modmachine.c \
modpyb.c \
modstm.c \
moduos.c \
Expand Down
18 changes: 1 addition & 17 deletions stmhal/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,11 @@ void MP_WEAK __assert_func(const char *file, int line, const char *func, const c
}
#endif

STATIC mp_obj_t pyb_main(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_opt, MP_ARG_INT, {.u_int = 0} }
};

if (MP_OBJ_IS_STR(pos_args[0])) {
MP_STATE_PORT(pyb_config_main) = pos_args[0];

// parse args
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
MP_STATE_VM(mp_optimise_value) = args[0].u_int;
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(pyb_main_obj, 1, pyb_main);

static const char fresh_boot_py[] =
"# boot.py -- run on boot-up\r\n"
"# can run arbitrary Python, but best to keep it minimal\r\n"
"\r\n"
"import machine\r\n"
"import pyb\r\n"
"#pyb.main('main.py') # main script to run after this one\r\n"
"#pyb.usb_mode('CDC+MSC') # act as a serial and a storage device\r\n"
Expand Down