10000 Merge pull request #9055 from dhalbert/ctrl-c-spi-bus-device · bablokb/circuitpython@84e937f · GitHub
[go: up one dir, main page]

Skip to content

Commit 84e937f

Browse files
authored
Merge pull request adafruit#9055 from dhalbert/ctrl-c-spi-bus-device
Allow ctrl-c of adafruit_bus_device.spi_device lock hang
2 parents 7e7b2a4 + d148831 commit 84e937f

File tree

1 file changed

+6
-2
lines changed
  • shared-module/adafruit_bus_device/spi_device

1 file changed

+6
-2
lines changed

shared-module/adafruit_bus_device/spi_device/SPIDevice.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include "shared-bindings/busio/SPI.h"
2929
#include "shared-bindings/digitalio/DigitalInOut.h"
3030
#include "py/mperrno.h"
31-
#include "py/nlr.h"
3231
#include "py/runtime.h"
32+
#include "shared/runtime/interrupt_char.h"
3333

3434
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,
3535
bool cs_active_value, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks) {
@@ -49,7 +49,11 @@ mp_obj_t common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spid
4949
mp_load_method(self->spi, MP_QSTR_try_lock, dest);
5050

5151
while (!mp_obj_is_true(mp_call_method_n_kw(0, 0, dest))) {
52-
mp_handle_pending(true);
52+
RUN_BACKGROUND_TASKS;
53+
// Break out on ctrl-C.
54+
if (mp_hal_is_interrupted()) {
55+
mp_handle_pending(true);
56+
}
5357
}
5458
}
5559

0 commit comments

Comments
 (0)
0