fix crash on user code exit
This commit is contained in:
parent
0d3e81f969
commit
b56645808c
@ -26,9 +26,7 @@
|
|||||||
|
|
||||||
#include "common-hal/ps2io/Ps2.h"
|
#include "common-hal/ps2io/Ps2.h"
|
||||||
|
|
||||||
#include "py/runtime.h"
|
|
||||||
#include "supervisor/port.h"
|
#include "supervisor/port.h"
|
||||||
#include "shared-bindings/ps2io/Ps2.h"
|
|
||||||
#include "shared-bindings/microcontroller/__init__.h"
|
#include "shared-bindings/microcontroller/__init__.h"
|
||||||
|
|
||||||
#define STATE_IDLE 0
|
#define STATE_IDLE 0
|
||||||
@ -259,6 +257,10 @@ void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self) {
|
|||||||
self->data_pin = GPIO_NUM_MAX;
|
self->data_pin = GPIO_NUM_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ps2_reset(void) {
|
||||||
|
gpio_uninstall_isr_service();
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t* self) {
|
uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t* self) {
|
||||||
return self->bufcount;
|
return self->bufcount;
|
||||||
}
|
}
|
||||||
|
@ -55,4 +55,6 @@ typedef struct {
|
|||||||
uint8_t cmd_response;
|
uint8_t cmd_response;
|
||||||
} ps2io_ps2_obj_t;
|
} ps2io_ps2_obj_t;
|
||||||
|
|
||||||
|
void ps2_reset(void);
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H
|
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "common-hal/busio/I2C.h"
|
#include "common-hal/busio/I2C.h"
|
||||||
#include "common-hal/busio/SPI.h"
|
#include "common-hal/busio/SPI.h"
|
||||||
#include "common-hal/busio/UART.h"
|
#include "common-hal/busio/UART.h"
|
||||||
|
#include "common-hal/ps2io/Ps2.h"
|
||||||
#include "common-hal/pulseio/PulseIn.h"
|
#include "common-hal/pulseio/PulseIn.h"
|
||||||
#include "common-hal/pwmio/PWMOut.h"
|
#include "common-hal/pwmio/PWMOut.h"
|
||||||
#include "common-hal/watchdog/WatchDogTimer.h"
|
#include "common-hal/watchdog/WatchDogTimer.h"
|
||||||
@ -104,6 +105,10 @@ void reset_port(void) {
|
|||||||
analogout_reset();
|
analogout_reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CIRCUITPY_PS2IO
|
||||||
|
ps2_reset();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CIRCUITPY_PULSEIO
|
#if CIRCUITPY_PULSEIO
|
||||||
esp32s2_peripherals_rmt_reset();
|
esp32s2_peripherals_rmt_reset();
|
||||||
pulsein_reset();
|
pulsein_reset();
|
||||||
|
@ -116,8 +116,9 @@ STATIC void check_for_deinit(ps2io_ps2_obj_t *self) {
|
|||||||
//| ...
|
//| ...
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||||
(void)n_args;
|
mp_check_self(MP_OBJ_IS_TYPE(args[0], &ps2io_ps2_type));
|
||||||
common_hal_ps2io_ps2_deinit(args[0]);
|
ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||||
|
common_hal_ps2io_ps2_deinit(self);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_ps2_obj___exit__);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_ps2_obj___exit__);
|
||||||
|
Loading…
Reference in New Issue
Block a user