update interrupt handling
This commit is contained in:
parent
bab41afce7
commit
0d3e81f969
@ -55,18 +55,18 @@ static void IRAM_ATTR ps2_interrupt_handler(void *self_in);
|
|||||||
static void ps2_set_config(ps2io_ps2_obj_t* self) {
|
static void ps2_set_config(ps2io_ps2_obj_t* self) {
|
||||||
// turn on falling edge interrupt
|
// turn on falling edge interrupt
|
||||||
gpio_set_intr_type(self->clk_pin, GPIO_INTR_NEGEDGE);
|
gpio_set_intr_type(self->clk_pin, GPIO_INTR_NEGEDGE);
|
||||||
gpio_isr_register(ps2_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle);
|
gpio_install_isr_service(ESP_INTR_FLAG_IRAM);
|
||||||
gpio_intr_enable(self->clk_pin);
|
gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void disable_interrupt(ps2io_ps2_obj_t* self) {
|
static void disable_interrupt(ps2io_ps2_obj_t* self) {
|
||||||
// turn off fallling edge interrupt
|
// turn off fallling edge interrupt
|
||||||
gpio_intr_disable(self->clk_pin);
|
gpio_isr_handler_remove(self->clk_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resume_interrupt(ps2io_ps2_obj_t* self) {
|
static void resume_interrupt(ps2io_ps2_obj_t* self) {
|
||||||
self->state = STATE_IDLE;
|
self->state = STATE_IDLE;
|
||||||
gpio_intr_enable(self->clk_pin);
|
gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clk_hi(ps2io_ps2_obj_t* self) {
|
static void clk_hi(ps2io_ps2_obj_t* self) {
|
||||||
@ -252,10 +252,7 @@ void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self) {
|
|||||||
if (common_hal_ps2io_ps2_deinited(self)) {
|
if (common_hal_ps2io_ps2_deinited(self)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self->handle) {
|
gpio_uninstall_isr_service();
|
||||||
esp_intr_free(self->handle);
|
|
||||||
self->handle = NULL;
|
|
||||||
}
|
|
||||||
reset_pin_number(self->clk_pin);
|
reset_pin_number(self->clk_pin);
|
||||||
reset_pin_number(self->data_pin);
|
reset_pin_number(self->data_pin);
|
||||||
self->clk_pin = GPIO_NUM_MAX;
|
self->clk_pin = GPIO_NUM_MAX;
|
||||||
|
@ -53,8 +53,6 @@ typedef struct {
|
|||||||
|
|
||||||
bool waiting_cmd_response;
|
bool waiting_cmd_response;
|
||||||
uint8_t cmd_response;
|
uint8_t cmd_response;
|
||||||
|
|
||||||
intr_handle_t handle;
|
|
||||||
} ps2io_ps2_obj_t;
|
} ps2io_ps2_obj_t;
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H
|
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H
|
||||||
|
Loading…
Reference in New Issue
Block a user