espulp: update docs and fix halt() for esp32
This commit is contained in:
parent
b5b13f5356
commit
fb4da28f61
2 changed files with 24 additions and 10 deletions
|
|
@ -39,7 +39,8 @@
|
|||
//| Raises an exception if another ULP has been instantiated. This
|
||||
//| ensures that is is only used by one piece of code at a time.
|
||||
//|
|
||||
//| :param Architecture arch: The ulp arch"""
|
||||
//| :param Architecture arch: The ulp arch. Only `FSM` architecture
|
||||
//| is currently supported."""
|
||||
//| ...
|
||||
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) {
|
||||
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
|
|||
|
||||
for (mp_uint_t i = 0; i < num_pins; i++) {
|
||||
mp_obj_t pin_obj = mp_obj_subscr(pins_in, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL);
|
||||
validate_obj_is_free_pin(pin_obj, MP_QSTR_pin);
|
||||
// common-hal checks that pin is free (that way a possible "ULP already running" error
|
||||
// is triggered before a possible "Pin in use" error, if ulp.run is called twice with the same pins).
|
||||
validate_obj_is_pin(pin_obj, MP_QSTR_pin);
|
||||
const mcu_pin_obj_t *pin = ((const mcu_pin_obj_t *)pin_obj);
|
||||
if (pin->number >= 32) {
|
||||
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
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(espulp_ulp_run_obj, 2, espulp_ulp_run);
|
||||
|
||||
//| def halt(self) -> None:
|
||||
//| """Halts the running program and releases the pins given in `run()`."""
|
||||
//| """Halts the running program and releases the pins given in `run()`.
|
||||
//| Note: for the FSM ULP, a running ULP program is not actually interupted.
|
||||
//| Instead, only the wakeup timer is stopped."""
|
||||
//| ...
|
||||
STATIC mp_obj_t espulp_ulp_halt(mp_obj_t self_in) {
|
||||
espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
|
|
|||
|
|
@ -131,13 +131,22 @@ void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t
|
|||
}
|
||||
|
||||
void common_hal_espulp_ulp_halt(espulp_ulp_obj_t *self) {
|
||||
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
|
||||
if (self->arch == RISCV) {
|
||||
ulp_riscv_timer_stop();
|
||||
ulp_riscv_halt();
|
||||
}
|
||||
#endif
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_TIMER_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN);
|
||||
switch (self->arch) {
|
||||
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
|
||||
case FSM:
|
||||
ulp_timer_stop();
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
|
||||
case RISCV:
|
||||
ulp_riscv_timer_stop();
|
||||
ulp_riscv_halt();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
// Release pins we were using.
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue