|
11 | 11 | #include "py/runtime.h" |
12 | 12 | #include "py/mperrno.h" |
13 | 13 |
|
| 14 | +#include <pbdrv/reset.h> |
14 | 15 | #include <pbio/util.h> |
15 | 16 |
|
16 | 17 | #include <pybricks/util_mp/pb_obj_helper.h> |
@@ -58,9 +59,32 @@ static mp_obj_t experimental_hello_world(size_t n_args, const mp_obj_t *pos_args |
58 | 59 | // See also experimental_globals_table below. This function object is added there to make it importable. |
59 | 60 | static MP_DEFINE_CONST_FUN_OBJ_KW(experimental_hello_world_obj, 0, experimental_hello_world); |
60 | 61 |
|
| 62 | +// pybricks.experimental.reset |
| 63 | +static mp_obj_t experimental_reset(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { |
| 64 | + PB_PARSE_ARGS_FUNCTION(n_args, pos_args, kw_args, |
| 65 | + PB_ARG_REQUIRED(reset_type)); |
| 66 | + |
| 67 | + mp_int_t reset_type = pb_obj_get_int(reset_type_in); |
| 68 | + |
| 69 | + pbdrv_reset(reset_type); |
| 70 | + |
| 71 | + return mp_const_none; |
| 72 | +} |
| 73 | +static MP_DEFINE_CONST_FUN_OBJ_KW(experimental_reset_obj, 0, experimental_reset); |
| 74 | + |
| 75 | +// pybricks.experimental.crash |
| 76 | +static mp_obj_t experimental_crash(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { |
| 77 | + __asm__ volatile (".word 0xffffffff"); |
| 78 | + |
| 79 | + return mp_const_none; |
| 80 | +} |
| 81 | +static MP_DEFINE_CONST_FUN_OBJ_KW(experimental_crash_obj, 0, experimental_crash); |
| 82 | + |
61 | 83 | static const mp_rom_map_elem_t experimental_globals_table[] = { |
62 | 84 | { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_experimental) }, |
63 | 85 | { MP_ROM_QSTR(MP_QSTR_hello_world), MP_ROM_PTR(&experimental_hello_world_obj) }, |
| 86 | + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&experimental_reset_obj) }, |
| 87 | + { MP_ROM_QSTR(MP_QSTR_crash), MP_ROM_PTR(&experimental_crash_obj) }, |
64 | 88 | }; |
65 | 89 | static MP_DEFINE_CONST_DICT(pb_module_experimental_globals, experimental_globals_table); |
66 | 90 |
|
|
0 commit comments