46
46
47
47
using namespace ace_button ;
48
48
49
+ UBaseType_t uxCoreAffinityMask0 = (1 << 0 ); // Core 0
50
+ UBaseType_t uxCoreAffinityMask1 = (1 << 1 ); // Core 1
51
+
49
52
HardwareConfig board_config;
50
53
51
54
Adafruit_DRV2605 vibe;
@@ -66,6 +69,7 @@ ButtonConfig* buttonConfig;
66
69
67
70
CircularBuffer<float , 50 > voltageBuffer;
68
71
CircularBuffer<int , 8 > potBuffer;
72
+ # define PIN_NEOPIXEL 10
69
73
70
74
Adafruit_NeoPixel pixels (1 , PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
71
75
uint32_t led_color = LED_RED; // current LED color
@@ -90,7 +94,9 @@ SemaphoreHandle_t tftSemaphore;
90
94
91
95
void watchdogTask (void * parameter) {
92
96
for (;;) {
97
+ #ifndef OPENPPG_DEBUG
93
98
watchdog_update ();
99
+ #endif
94
100
vTaskDelay (pdMS_TO_TICKS (100 )); // Delay for 100ms
95
101
}
96
102
}
@@ -162,6 +168,7 @@ void loadHardwareConfig() {
162
168
button_top = new AceButton (board_config.button_top );
163
169
buttonConfig = button_top->getButtonConfig ();
164
170
}
171
+
165
172
void setupSerial () {
166
173
Serial.begin (115200 );
167
174
SerialESC.begin (ESC_BAUD_RATE);
@@ -209,11 +216,13 @@ void setupAnalogRead() {
209
216
}
210
217
211
218
void setupWatchdog () {
212
- #ifdef M0_PIO
213
- Watchdog.enable (5000 );
214
- #elif RP_PIO
215
- watchdog_enable (4000 , 1 );
216
- #endif
219
+ #ifndef OPENPPG_DEBUG
220
+ #ifdef M0_PIO
221
+ Watchdog.enable (5000 );
222
+ #elif RP_PIO
223
+ watchdog_enable (4000 , 1 );
224
+ #endif
225
+ #endif // OPENPPG_DEBUG
217
226
}
218
227
219
228
@@ -259,15 +268,14 @@ void setup() {
259
268
setLEDColor (LED_GREEN);
260
269
}
261
270
262
- // set up all the threads/tasks
271
+ // set up all the main threads/tasks with core 0 affinity
263
272
void setupTasks () {
264
-
265
- xTaskCreate (blinkLEDTask, " blinkLed" , 200 , NULL , 1 , &blinkLEDTaskHandle);
266
- xTaskCreate (throttleTask, " throttle" , 1000 , NULL , 3 , &throttleTaskHandle);
267
- xTaskCreate (telemetryTask, " telemetry" , 1000 , NULL , 2 , &telemetryTaskHandle);
268
- xTaskCreate (trackPowerTask, " trackPower" , 500 , NULL , 2 , &trackPowerTaskHandle);
269
- xTaskCreate (updateDisplayTask, " updateDisplay" , 2000 , NULL , 1 , &updateDisplayTaskHandle);
270
- xTaskCreate (watchdogTask, " watchdog" , 1000 , NULL , 4 , &watchdogTaskHandle);
273
+ xTaskCreateAffinitySet (blinkLEDTask, " blinkLed" , 200 , NULL , 1 , uxCoreAffinityMask1, &blinkLEDTaskHandle);
274
+ xTaskCreateAffinitySet (throttleTask, " throttle" , 1000 , NULL , 3 , uxCoreAffinityMask0, &throttleTaskHandle);
275
+ xTaskCreateAffinitySet (telemetryTask, " TelemetryTask" , 2048 , NULL , 2 , uxCoreAffinityMask0, &telemetryTaskHandle);
276
+ xTaskCreateAffinitySet (trackPowerTask, " trackPower" , 500 , NULL , 2 , uxCoreAffinityMask0, &trackPowerTaskHandle);
277
+ xTaskCreateAffinitySet (updateDisplayTask, " updateDisplay" , 2000 , NULL , 1 , uxCoreAffinityMask0, &updateDisplayTaskHandle);
278
+ xTaskCreateAffinitySet (watchdogTask, " watchdog" , 1000 , NULL , 4 , uxCoreAffinityMask0, &watchdogTaskHandle);
271
279
272
280
if (updateDisplayTaskHandle != NULL ) {
273
281
vTaskSuspend (updateDisplayTaskHandle); // Suspend the task immediately after creation
0 commit comments