File tree Expand file tree Collapse file tree
ports/espressif/common-hal/busio Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,11 +157,17 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
157157 return true;
158158}
159159
160- bool common_hal_busio_spi_try_lock (busio_spi_obj_t * self ) {
160+ // Wait as long as needed for the lock. This is used by SD card access from USB.
161+ // Overrides the default busy-wait implementation in shared-bindings/busio/SPI.c
162+ bool common_hal_busio_spi_wait_for_lock (busio_spi_obj_t * self , uint32_t timeout_ms ) {
161163 if (common_hal_busio_spi_deinited (self )) {
162164 return false;
163165 }
164- return xSemaphoreTake (self -> mutex , 0 ) == pdTRUE ;
166+ return xSemaphoreTake (self -> mutex , pdMS_TO_TICKS (timeout_ms )) == pdTRUE ;
167+ }
168+
169+ bool common_hal_busio_spi_try_lock (busio_spi_obj_t * self ) {
170+ return common_hal_busio_spi_wait_for_lock (self , 0 );
165171}
166172
167173bool common_hal_busio_spi_has_lock (busio_spi_obj_t * self ) {
You can’t perform that action at this time.
0 commit comments