Skip to content

Commit

Permalink
stmhal: Early version of machine module for stmhal.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhylands committed Oct 19, 2015
1 parent 8ee153f commit 8a917ff
Show file tree
Hide file tree
Showing 7 changed files with 524 additions and 379 deletions.
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

0 comments on commit 8a917ff

Please sign in to comment.