summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32/machine_hw_spi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ports/esp32/machine_hw_spi.c b/ports/esp32/machine_hw_spi.c
index 4b3d392cb..6eb83fc09 100644
--- a/ports/esp32/machine_hw_spi.c
+++ b/ports/esp32/machine_hw_spi.c
@@ -196,6 +196,10 @@ static void machine_hw_spi_init_internal(machine_hw_spi_obj_t *self, mp_arg_val_
changed = true;
}
+ if (args[ARG_bits].u_int != -1 && args[ARG_bits].u_int <= 0) {
+ mp_raise_ValueError(MP_ERROR_TEXT("invalid bits"));
+ }
+
if (args[ARG_bits].u_int != -1 && args[ARG_bits].u_int != self->bits) {
self->bits = args[ARG_bits].u_int;
changed = true;