Skip to content

Commit 1ff357c

Browse files
authored
Merge pull request #49 from openppg/pico-probe
Single core operations, debugging
2 parents 62a7ae9 + b75c0d2 commit 1ff357c

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

platformio.ini

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,32 @@ platform = https://github.com/openppg/platform-raspberrypi.git#de3a06a0d358567da
5050
board = sparkfun_promicrorp2040
5151
framework = arduino
5252
board_build.core = earlephilhower
53-
build_flags = -DRP_PIO -DUSE_TINYUSB
53+
build_flags = -DRP_PIO -DUSE_TINYUSB ;-DOPENPPG_DEBUG
5454
test_framework = unity
55+
board_build.f_cpu = 125000000L ; 125 MHz (default)
5556
monitor_filters =
5657
time
5758

5859
; configure filesystem size. Default 0 Mbyte.
5960
; Out of 16Mbyte available
6061
board_build.filesystem_size = 14M ; 14 Mbyte for filesystem and 2 Mbyte for program
6162
src_folder = sp140
63+
debug_tool = cmsis-dap
64+
;upload_protocol = cmsis-dap
6265
extra_scripts = pre:extra_script.py
6366
lib_deps =
6467
Wire
6568
Adafruit TinyUSB Library
6669
SPI
6770
68-
ArduinoJson@6.19.4
71+
ArduinoJson@6.21.4
6972
[email protected] ; deprecated
7073
7174
adafruit/Adafruit [email protected]
72-
adafruit/Adafruit BMP3XX [email protected].4
75+
adafruit/Adafruit BMP3XX [email protected].5
7376
adafruit/Adafruit DRV2605 [email protected]
7477
adafruit/Adafruit ST7735 and ST7789 [email protected]
75-
adafruit/Adafruit [email protected].0
78+
adafruit/Adafruit [email protected].2
7679
https://github.com/rlogiacco/[email protected]
7780
Adafruit GFX [email protected]
7881
lib_ignore =

src/sp140/extra-data.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void parse_usb_serial() {
103103
return; // run only the command
104104
}
105105

106-
if (doc["major_v"] < 5) return;
106+
if (doc["major_v"] < 5) return; // ignore old versions
107107

108108
vTaskSuspend(updateDisplayTaskHandle); // Prevent display from updating while we're changing settings
109109

src/sp140/sp140.ino

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646

4747
using namespace ace_button;
4848

49+
UBaseType_t uxCoreAffinityMask0 = (1 << 0); // Core 0
50+
UBaseType_t uxCoreAffinityMask1 = (1 << 1); // Core 1
51+
4952
HardwareConfig board_config;
5053

5154
Adafruit_DRV2605 vibe;
@@ -66,6 +69,7 @@ ButtonConfig* buttonConfig;
6669

6770
CircularBuffer<float, 50> voltageBuffer;
6871
CircularBuffer<int, 8> potBuffer;
72+
# define PIN_NEOPIXEL 10
6973

7074
Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
7175
uint32_t led_color = LED_RED; // current LED color
@@ -90,7 +94,9 @@ SemaphoreHandle_t tftSemaphore;
9094

9195
void watchdogTask(void* parameter) {
9296
for (;;) {
97+
#ifndef OPENPPG_DEBUG
9398
watchdog_update();
99+
#endif
94100
vTaskDelay(pdMS_TO_TICKS(100)); // Delay for 100ms
95101
}
96102
}
@@ -162,6 +168,7 @@ void loadHardwareConfig() {
162168
button_top = new AceButton(board_config.button_top);
163169
buttonConfig = button_top->getButtonConfig();
164170
}
171+
165172
void setupSerial() {
166173
Serial.begin(115200);
167174
SerialESC.begin(ESC_BAUD_RATE);
@@ -209,11 +216,13 @@ void setupAnalogRead() {
209216
}
210217

211218
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
217226
}
218227

219228

@@ -259,15 +268,14 @@ void setup() {
259268
setLEDColor(LED_GREEN);
260269
}
261270

262-
// set up all the threads/tasks
271+
// set up all the main threads/tasks with core 0 affinity
263272
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);
271279

272280
if (updateDisplayTaskHandle != NULL) {
273281
vTaskSuspend(updateDisplayTaskHandle); // Suspend the task immediately after creation

0 commit comments

Comments
 (0)