3939//| Raises an exception if another ULP has been instantiated. This
4040//| ensures that is is only used by one piece of code at a time.
4141//|
42- //| :param Architecture arch: The ulp arch"""
42+ //| :param Architecture arch: The ulp arch. Only `FSM` architecture
43+ //| is currently supported."""
4344//| ...
4445STATIC 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 ) {
4546 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
148149
149150 for (mp_uint_t i = 0 ; i < num_pins ; i ++ ) {
150151 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 );
152155 const mcu_pin_obj_t * pin = ((const mcu_pin_obj_t * )pin_obj );
153156 if (pin -> number >= 32 ) {
154157 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
162165STATIC MP_DEFINE_CONST_FUN_OBJ_KW (espulp_ulp_run_obj , 2 , espulp_ulp_run );
163166
164167//| 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."""
166171//| ...
167172STATIC mp_obj_t espulp_ulp_halt (mp_obj_t self_in ) {
168173 espulp_ulp_obj_t * self = MP_OBJ_TO_PTR (self_in );
0 commit comments