Skip to content

Commit f4ca293

Browse files
authored
Merge pull request adafruit#9545 from tannewt/fix_funhouse_wifi
Fix FreeRTOS weirdness on Funhouse
2 parents 4d88d73 + 28f3d91 commit f4ca293

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ports/espressif/common-hal/busio/SPI.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
129129

130130
// Wait for any other users of this to finish.
131131
while (!common_hal_busio_spi_try_lock(self)) {
132+
RUN_BACKGROUND_TASKS;
132133
}
133134

134135
// Mark us as deinit early in case we are used in an interrupt.
@@ -139,7 +140,10 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
139140
spi_bus_remove_device(spi_handle[self->host_id]);
140141
spi_bus_free(self->host_id);
141142

143+
// Release the mutex before we delete it. Otherwise FreeRTOS gets unhappy.
144+
xSemaphoreGive(self->mutex);
142145
vSemaphoreDelete(self->mutex);
146+
self->mutex = NULL;
143147

144148
common_hal_reset_pin(self->MOSI);
145149
common_hal_reset_pin(self->MISO);
@@ -166,7 +170,7 @@ bool common_hal_busio_spi_try_lock(busio_spi_obj_t *self) {
166170
}
167171

168172
bool common_hal_busio_spi_has_lock(busio_spi_obj_t *self) {
169-
return xSemaphoreGetMutexHolder(self->mutex) == xTaskGetCurrentTaskHandle();
173+
return self->mutex != NULL && xSemaphoreGetMutexHolder(self->mutex) == xTaskGetCurrentTaskHandle();
170174
}
171175

172176
void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {

supervisor/shared/status_leds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ void status_led_deinit() {
196196

197197
#elif defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)
198198
#if CIRCUITPY_BITBANG_APA102
199+
shared_module_bitbangio_spi_unlock(&status_apa102);
199200
shared_module_bitbangio_spi_deinit(&status_apa102);
200201
#else
202+
common_hal_busio_spi_unlock(&status_apa102);
201203
common_hal_busio_spi_deinit(&status_apa102);
202204
#endif
203205

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy