Skip to content

Commit

Permalink
Merge pull request #9055 from dhalbert/ctrl-c-spi-bus-device
Browse files Browse the repository at this point in the history
Allow ctrl-c of adafruit_bus_device.spi_device lock hang
  • Loading branch information
tannewt committed Mar 18, 2024
2 parents 7e7b2a4 + d148831 commit 84e937f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shared-module/adafruit_bus_device/spi_device/SPIDevice.c
Expand Up @@ -28,8 +28,8 @@
#include "shared-bindings/busio/SPI.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "py/mperrno.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "shared/runtime/interrupt_char.h"

void common_hal_adafruit_bus_device_spidevice_construct(adafruit_bus_device_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs,
bool cs_active_value, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks) {
Expand All @@ -49,7 +49,11 @@ mp_obj_t common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spid
mp_load_method(self->spi, MP_QSTR_try_lock, dest);

while (!mp_obj_is_true(mp_call_method_n_kw(0, 0, dest))) {
mp_handle_pending(true);
RUN_BACKGROUND_TASKS;
// Break out on ctrl-C.
if (mp_hal_is_interrupted()) {
mp_handle_pending(true);
}
}
}

Expand Down

0 comments on commit 84e937f

Please sign in to comment.