@@ -35,6 +35,8 @@ StackType_t xStack_B[ STACK_SIZE ];
35
35
SemaphoreHandle_t xSemaphore = NULL ;
36
36
StaticSemaphore_t xMutexBuffer;
37
37
38
+ TaskHandle_t ledOnTask, ledOffTask;
39
+
38
40
void setup () {
39
41
SERIAL_PORT.begin (115200 );
40
42
pinMode (LED_BUILTIN, OUTPUT);
@@ -44,13 +46,22 @@ void setup() {
44
46
the xMutexBuffer variable. */
45
47
xSemaphore = xSemaphoreCreateMutexStatic ( &xMutexBuffer );
46
48
47
- xTaskCreateStatic (led_ON, " led_ON" , STACK_SIZE, NULL , configMAX_PRIORITIES - 1 , xStack_A, &xTaskBuffer_A);
48
- xTaskCreateStatic (led_OFF, " led_OFF" , STACK_SIZE, NULL , configMAX_PRIORITIES - 1 , xStack_B, &xTaskBuffer_B);
49
- }
49
+ ledOnTask = xTaskCreateStatic (led_ON, " led_ON" , STACK_SIZE, NULL , configMAX_PRIORITIES - 1 , xStack_A, &xTaskBuffer_A);
50
+ #ifdef ARDUINO_RASPBERRY_PI_PICO_W
51
+ // The PicoW WiFi chip controls the LED, and only core 0 can make calls to it safely
52
+ vTaskCoreAffinitySet (ledOnTask, 1 << 0 );
53
+ #endif
54
+ ledOffTask = xTaskCreateStatic (led_OFF, " led_OFF" , STACK_SIZE, NULL , configMAX_PRIORITIES - 1 , xStack_B, &xTaskBuffer_B);
55
+ #ifdef ARDUINO_RASPBERRY_PI_PICO_W
56
+ // The PicoW WiFi chip controls the LED, and only core 0 can make calls to it safely
57
+ vTaskCoreAffinitySet (ledOffTask, 1 << 0 );
58
+ #endif
59
+ }
50
60
51
61
void led_ON (void *pvParameters)
52
62
{
53
63
(void ) pvParameters;
64
+ delay (100 );
54
65
while (1 )
55
66
{
56
67
xSemaphoreTake ( xSemaphore, ( TickType_t ) portMAX_DELAY );
@@ -65,6 +76,7 @@ void led_ON(void *pvParameters)
65
76
void led_OFF (void *pvParameters)
66
77
{
67
78
(void ) pvParameters;
79
+ delay (100 );
68
80
while (1 )
69
81
{
70
82
xSemaphoreTake ( xSemaphore, ( TickType_t ) portMAX_DELAY );
0 commit comments