Skip to content

Commit 8b0db80

Browse files
committed
Fix SPI readinto with negative start or end
1 parent 987d9a3 commit 8b0db80

File tree

1 file changed

+1
-1
lines changed
  • shared-bindings/busio

1 file changed

+1
-1
lines changed

shared-bindings/busio/SPI.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
333333
// Compute bounds in terms of elements, not bytes.
334334
int stride_in_bytes = mp_binary_get_size('@', bufinfo.typecode, NULL);
335335
int32_t start = args[ARG_start].u_int;
336-
size_t length = bufinfo.len;
336+
size_t length = bufinfo.len / stride_in_bytes;
337337
normalize_buffer_bounds(&start, args[ARG_end].u_int, &length);
338338

339339
// Treat start and length in terms of bytes from now on.

0 commit comments

Comments
 (0)