Add option to select the core used for Arduino and it's events

This commit is contained in:
me-no-dev
2020-08-16 17:52:09 +03:00
parent e25ef9e6d0
commit 0ac788f666
6 changed files with 31 additions and 4 deletions

View File

@ -9,6 +9,8 @@ menu.PartitionScheme=Partition Scheme
menu.DebugLevel=Core Debug Level
menu.PSRAM=PSRAM
menu.Revision=Board Revision
menu.LoopCore=Arduino Runs On
menu.EventsCore=Events Run On
##############################################################
### DO NOT PUT BOARDS ABOVE THE OFFICIAL ESPRESSIF BOARDS! ###
@ -194,6 +196,8 @@ esp32.build.flash_mode=dio
esp32.build.boot=dio
esp32.build.partitions=default
esp32.build.defines=
esp32.build.loop_core=
esp32.build.event_core=
esp32.menu.PSRAM.disabled=Disabled
esp32.menu.PSRAM.disabled.build.defines=
@ -295,6 +299,16 @@ esp32.menu.UploadSpeed.460800.upload.speed=460800
esp32.menu.UploadSpeed.512000.windows=512000
esp32.menu.UploadSpeed.512000.upload.speed=512000
esp32.menu.LoopCore.1=Core 1
esp32.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1
esp32.menu.LoopCore.0=Core 0
esp32.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0
esp32.menu.EventsCore.1=Core 1
esp32.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
esp32.menu.EventsCore.0=Core 0
esp32.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0
esp32.menu.DebugLevel.none=None
esp32.menu.DebugLevel.none.build.code_debug=0
esp32.menu.DebugLevel.error=Error

View File

@ -113,6 +113,9 @@ protected:
extern void serialEventRun(void) __attribute__((weak));
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
#ifndef ARDUINO_SERIAL_PORT
#define ARDUINO_SERIAL_PORT 0
#endif
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
#include "USB.h"
#include "USBCDC.h"

View File

@ -52,6 +52,14 @@ extern "C" {
#define ARDUINO_ISR_FLAG (0)
#endif
#ifndef ARDUINO_RUNNING_CORE
#define ARDUINO_RUNNING_CORE CONFIG_ARDUINO_RUNNING_CORE
#endif
#ifndef ARDUINO_EVENT_RUNNING_CORE
#define ARDUINO_EVENT_RUNNING_CORE CONFIG_ARDUINO_EVENT_RUNNING_CORE
#endif
//forward declaration from freertos/portmacro.h
void vPortYield(void);
void yield(void);

View File

@ -44,7 +44,7 @@ extern "C" void app_main()
#endif
loopTaskWDTEnabled = false;
initArduino();
xTaskCreateUniversal(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
xTaskCreateUniversal(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
}
#endif

View File

@ -45,7 +45,7 @@ extern "C" {
} //extern "C"
#include "esp32-hal-log.h"
#include "esp32-hal.h"
#include <vector>
#include "sdkconfig.h"
@ -475,7 +475,7 @@ static bool _start_network_event_task(){
}
if(!_arduino_event_task_handle){
xTaskCreateUniversal(_arduino_event_task, "arduino_events", 4096, NULL, ESP_TASKD_EVENT_PRIO - 1, &_arduino_event_task_handle, CONFIG_ARDUINO_EVENT_RUNNING_CORE);
xTaskCreateUniversal(_arduino_event_task, "arduino_events", 4096, NULL, ESP_TASKD_EVENT_PRIO - 1, &_arduino_event_task_handle, ARDUINO_EVENT_RUNNING_CORE);
if(!_arduino_event_task_handle){
log_e("Network Event Task Start Failed!");
return false;

View File

@ -90,7 +90,9 @@ build.flash_mode=dio
build.boot=bootloader
build.code_debug=0
build.defines=
build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.defines} {build.extra_flags.{build.mcu}}
build.loop_core=
build.event_core=
build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.loop_core} {build.event_core} {build.defines} {build.extra_flags.{build.mcu}}
# Check if custom partitions exist
recipe.hooks.prebuild.1.pattern=bash -c "[ ! -f {build.source.path}/partitions.csv ] || cp -f {build.source.path}/partitions.csv {build.path}/partitions.csv"