shared-bindings: Prevent check_lock from being optimized away. (#240)

Fixes #229
This commit is contained in:
Scott Shawcroft 2017-09-06 14:49:30 -07:00 committed by Dan Halbert
parent acbca44512
commit 6467e3d40b
2 changed files with 2 additions and 0 deletions

View File

@ -110,6 +110,7 @@ STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) {
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_i2c___exit___obj, 4, 4, busio_i2c_obj___exit__);
static void check_lock(busio_i2c_obj_t *self) {
asm("");
if (!common_hal_busio_i2c_has_lock(self)) {
mp_raise_RuntimeError("Function requires lock.");
}

View File

@ -126,6 +126,7 @@ STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) {
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_spi_obj___exit___obj, 4, 4, busio_spi_obj___exit__);
static void check_lock(busio_spi_obj_t *self) {
asm("");
if (!common_hal_busio_spi_has_lock(self)) {
mp_raise_RuntimeError("Function requires lock");
}