Skip to content

Commit 9c2fd8d

Browse files
committed
Add sample application for using second esp32 core
1 parent c898bd9 commit 9c2fd8d

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

samples/Esp32_Dual_Core/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#####################################################################
2+
#### Please don't change this file. Use component.mk instead ####
3+
#####################################################################
4+
5+
ifndef SMING_HOME
6+
$(error SMING_HOME is not set: please configure it as an environment variable)
7+
endif
8+
9+
include $(SMING_HOME)/project.mk

samples/Esp32_Dual_Core/README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ESP32 Dual Core
2+
===============
3+
4+
Basic example of using second core of Esp32 chip.
5+
6+
Code should be in IRAM and avoid accessing flash, especially the filing system.
7+
8+
Sming is NOT thread-safe!
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <SmingCore.h>
2+
3+
void handleNotification(uint32_t param)
4+
{
5+
Serial << "NOTIFY " << param << endl;
6+
}
7+
8+
// Code to run on second CPU
9+
void IRAM_ATTR app2_main(void*)
10+
{
11+
static unsigned count;
12+
13+
for(;;) {
14+
System.queueCallback(handleNotification, count);
15+
++count;
16+
delay(500);
17+
}
18+
}
19+
20+
void init()
21+
{
22+
Serial.begin(SERIAL_BAUD_RATE);
23+
Serial.systemDebugOutput(true);
24+
25+
Serial.println(_F("ESP32 dual-core demo."));
26+
27+
const unsigned stackSize = 2048;
28+
const unsigned priority = 5;
29+
xTaskCreatePinnedToCore(app2_main, "Sming2", stackSize, nullptr, priority, nullptr, 1);
30+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
COMPONENT_SOC := esp32
2+
3+
DISABLE_NETWORK := 1
4+
5+
SDK_CUSTOM_CONFIG := esp32-dual-core.cfg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_FREERTOS_UNICORE=n

0 commit comments

Comments
 (0)