Skip to content

Commit 9164629

Browse files
committed
espressif: Fix queueing background tasks from other core
1 parent b8f3d23 commit 9164629

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ports/espressif/mpconfigport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,11 @@
7474
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (0)
7575
#endif
7676

77+
// Protect the background queue with a lock because both cores may modify it.
78+
#include "freertos/FreeRTOS.h"
79+
#include "freertos/task.h"
80+
extern portMUX_TYPE background_task_mutex;
81+
#define CALLBACK_CRITICAL_BEGIN (taskENTER_CRITICAL(&background_task_mutex))
82+
#define CALLBACK_CRITICAL_END (taskEXIT_CRITICAL(&background_task_mutex))
83+
7784
#endif // MICROPY_INCLUDED_ESPRESSIF_MPCONFIGPORT_H

ports/espressif/supervisor/port.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,3 +522,5 @@ extern void app_main(void);
522522
void app_main(void) {
523523
main();
524524
}
525+
526+
portMUX_TYPE background_task_mutex = portMUX_INITIALIZER_UNLOCKED;

0 commit comments

Comments
 (0)