Skip to content

Commit

Permalink
Merge pull request #49 from openppg/pico-probe
Browse files Browse the repository at this point in the history
Single core operations, debugging
  • Loading branch information
zjwhitehead authored Jun 25, 2024
2 parents 62a7ae9 + b75c0d2 commit 1ff357c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
11 changes: 7 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,32 @@ platform = https://github.com/openppg/platform-raspberrypi.git#de3a06a0d358567da
board = sparkfun_promicrorp2040
framework = arduino
board_build.core = earlephilhower
build_flags = -DRP_PIO -DUSE_TINYUSB
build_flags = -DRP_PIO -DUSE_TINYUSB ;-DOPENPPG_DEBUG
test_framework = unity
board_build.f_cpu = 125000000L ; 125 MHz (default)
monitor_filters =
time

; configure filesystem size. Default 0 Mbyte.
; Out of 16Mbyte available
board_build.filesystem_size = 14M ; 14 Mbyte for filesystem and 2 Mbyte for program
src_folder = sp140
debug_tool = cmsis-dap
;upload_protocol = cmsis-dap
extra_scripts = pre:extra_script.py
lib_deps =
Wire
Adafruit TinyUSB Library
SPI
[email protected]
ArduinoJson@6.19.4
ArduinoJson@6.21.4
[email protected] ; deprecated
[email protected]
adafruit/Adafruit [email protected]
adafruit/Adafruit BMP3XX [email protected].4
adafruit/Adafruit BMP3XX [email protected].5
adafruit/Adafruit DRV2605 [email protected]
adafruit/Adafruit ST7735 and ST7789 [email protected]
adafruit/Adafruit [email protected].0
adafruit/Adafruit [email protected].2
https://github.com/rlogiacco/[email protected]
Adafruit GFX [email protected]
lib_ignore =
Expand Down
2 changes: 1 addition & 1 deletion src/sp140/extra-data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void parse_usb_serial() {
return; // run only the command
}

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

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

Expand Down
34 changes: 21 additions & 13 deletions src/sp140/sp140.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@

using namespace ace_button;

UBaseType_t uxCoreAffinityMask0 = (1 << 0); // Core 0
UBaseType_t uxCoreAffinityMask1 = (1 << 1); // Core 1

HardwareConfig board_config;

Adafruit_DRV2605 vibe;
Expand All @@ -66,6 +69,7 @@ ButtonConfig* buttonConfig;

CircularBuffer<float, 50> voltageBuffer;
CircularBuffer<int, 8> potBuffer;
# define PIN_NEOPIXEL 10

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

void watchdogTask(void* parameter) {
for (;;) {
#ifndef OPENPPG_DEBUG
watchdog_update();
#endif
vTaskDelay(pdMS_TO_TICKS(100)); // Delay for 100ms
}
}
Expand Down Expand Up @@ -162,6 +168,7 @@ void loadHardwareConfig() {
button_top = new AceButton(board_config.button_top);
buttonConfig = button_top->getButtonConfig();
}

void setupSerial() {
Serial.begin(115200);
SerialESC.begin(ESC_BAUD_RATE);
Expand Down Expand Up @@ -209,11 +216,13 @@ void setupAnalogRead() {
}

void setupWatchdog() {
#ifdef M0_PIO
Watchdog.enable(5000);
#elif RP_PIO
watchdog_enable(4000, 1);
#endif
#ifndef OPENPPG_DEBUG
#ifdef M0_PIO
Watchdog.enable(5000);
#elif RP_PIO
watchdog_enable(4000, 1);
#endif
#endif // OPENPPG_DEBUG
}


Expand Down Expand Up @@ -259,15 +268,14 @@ void setup() {
setLEDColor(LED_GREEN);
}

// set up all the threads/tasks
// set up all the main threads/tasks with core 0 affinity
void setupTasks() {

xTaskCreate(blinkLEDTask, "blinkLed", 200, NULL, 1, &blinkLEDTaskHandle);
xTaskCreate(throttleTask, "throttle", 1000, NULL, 3, &throttleTaskHandle);
xTaskCreate(telemetryTask, "telemetry", 1000, NULL, 2, &telemetryTaskHandle);
xTaskCreate(trackPowerTask, "trackPower", 500, NULL, 2, &trackPowerTaskHandle);
xTaskCreate(updateDisplayTask, "updateDisplay", 2000, NULL, 1, &updateDisplayTaskHandle);
xTaskCreate(watchdogTask, "watchdog", 1000, NULL, 4, &watchdogTaskHandle);
xTaskCreateAffinitySet(blinkLEDTask, "blinkLed", 200, NULL, 1, uxCoreAffinityMask1, &blinkLEDTaskHandle);
xTaskCreateAffinitySet(throttleTask, "throttle", 1000, NULL, 3, uxCoreAffinityMask0, &throttleTaskHandle);
xTaskCreateAffinitySet(telemetryTask, "TelemetryTask", 2048, NULL, 2, uxCoreAffinityMask0, &telemetryTaskHandle);
xTaskCreateAffinitySet(trackPowerTask, "trackPower", 500, NULL, 2, uxCoreAffinityMask0, &trackPowerTaskHandle);
xTaskCreateAffinitySet(updateDisplayTask, "updateDisplay", 2000, NULL, 1, uxCoreAffinityMask0, &updateDisplayTaskHandle);
xTaskCreateAffinitySet(watchdogTask, "watchdog", 1000, NULL, 4, uxCoreAffinityMask0, &watchdogTaskHandle);

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

0 comments on commit 1ff357c

Please sign in to comment.