39
39
//| Raises an exception if another ULP has been instantiated. This
40
40
//| ensures that is is only used by one piece of code at a time.
41
41
//|
42
- //| :param Architecture arch: The ulp arch"""
42
+ //| :param Architecture arch: The ulp arch. Only `FSM` architecture
43
+ //| is currently supported."""
43
44
//| ...
44
45
STATIC mp_obj_t espulp_ulp_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
45
46
enum { ARG_arch };
@@ -148,7 +149,9 @@ STATIC mp_obj_t espulp_ulp_run(size_t n_args, const mp_obj_t *pos_args, mp_map_t
148
149
149
150
for (mp_uint_t i = 0 ; i < num_pins ; i ++ ) {
150
151
mp_obj_t pin_obj = mp_obj_subscr (pins_in , MP_OBJ_NEW_SMALL_INT (i ), MP_OBJ_SENTINEL );
151
- validate_obj_is_free_pin (pin_obj , MP_QSTR_pin );
152
+ // common-hal checks that pin is free (that way a possible "ULP already running" error
153
+ // is triggered before a possible "Pin in use" error, if ulp.run is called twice with the same pins).
154
+ validate_obj_is_pin (pin_obj , MP_QSTR_pin );
152
155
const mcu_pin_obj_t * pin = ((const mcu_pin_obj_t * )pin_obj );
153
156
if (pin -> number >= 32 ) {
154
157
raise_ValueError_invalid_pin ();
@@ -162,7 +165,9 @@ STATIC mp_obj_t espulp_ulp_run(size_t n_args, const mp_obj_t *pos_args, mp_map_t
162
165
STATIC MP_DEFINE_CONST_FUN_OBJ_KW (espulp_ulp_run_obj , 2 , espulp_ulp_run );
163
166
164
167
//| def halt(self) -> None:
165
- //| """Halts the running program and releases the pins given in `run()`."""
168
+ //| """Halts the running program and releases the pins given in `run()`.
169
+ //| Note: for the FSM ULP, a running ULP program is not actually interupted.
170
+ //| Instead, only the wakeup timer is stopped."""
166
171
//| ...
167
172
STATIC mp_obj_t espulp_ulp_halt (mp_obj_t self_in ) {
168
173
espulp_ulp_obj_t * self = MP_OBJ_TO_PTR (self_in );
0 commit comments