Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b7c018d

Browse filesBrowse files
authored
Merge branch 'master' into esp32-s3-support
2 parents b4a0c48 + 4da1051 commit b7c018d
Copy full SHA for b7c018d

File tree

Expand file treeCollapse file tree

22 files changed

+754
-155
lines changed
Filter options
Expand file treeCollapse file tree

22 files changed

+754
-155
lines changed

‎boards.txt

Copy file name to clipboardExpand all lines: boards.txt
+150-1Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,155 @@ esp32.menu.DebugLevel.verbose.build.code_debug=5
691691

692692
##############################################################
693693

694+
esp32da.name=ESP32-WROOM-DA Module
695+
696+
esp32da.upload.tool=esptool_py
697+
esp32da.upload.maximum_size=1310720
698+
esp32da.upload.maximum_data_size=327680
699+
esp32da.upload.flags=
700+
esp32da.upload.extra_flags=
701+
702+
esp32da.serial.disableDTR=true
703+
esp32da.serial.disableRTS=true
704+
705+
esp32da.build.tarch=xtensa
706+
esp32da.build.bootloader_addr=0x1000
707+
esp32da.build.target=esp32
708+
esp32da.build.mcu=esp32
709+
esp32da.build.core=esp32
710+
esp32da.build.variant=esp32da
711+
esp32da.build.board=ESP32_WROOM_DA
712+
713+
esp32da.build.f_cpu=240000000L
714+
esp32da.build.flash_size=4MB
715+
esp32da.build.flash_freq=40m
716+
esp32da.build.flash_mode=dio
717+
esp32da.build.boot=dio
718+
esp32da.build.partitions=default
719+
esp32da.build.defines=
720+
esp32da.build.loop_core=
721+
esp32da.build.event_core=
722+
723+
esp32da.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
724+
esp32da.menu.PartitionScheme.default.build.partitions=default
725+
esp32da.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
726+
esp32da.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
727+
esp32da.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
728+
esp32da.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
729+
esp32da.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
730+
esp32da.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
731+
esp32da.menu.PartitionScheme.minimal.build.partitions=minimal
732+
esp32da.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
733+
esp32da.menu.PartitionScheme.no_ota.build.partitions=no_ota
734+
esp32da.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
735+
esp32da.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
736+
esp32da.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
737+
esp32da.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
738+
esp32da.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
739+
esp32da.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
740+
esp32da.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
741+
esp32da.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
742+
esp32da.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
743+
esp32da.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
744+
esp32da.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
745+
esp32da.menu.PartitionScheme.huge_app.build.partitions=huge_app
746+
esp32da.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
747+
esp32da.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
748+
esp32da.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
749+
esp32da.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
750+
esp32da.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
751+
esp32da.menu.PartitionScheme.fatflash.build.partitions=ffat
752+
esp32da.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
753+
esp32da.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
754+
esp32da.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
755+
esp32da.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
756+
esp32da.menu.PartitionScheme.rainmaker=RainMaker
757+
esp32da.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
758+
esp32da.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728
759+
760+
esp32da.menu.CPUFreq.240=240MHz (WiFi/BT)
761+
esp32da.menu.CPUFreq.240.build.f_cpu=240000000L
762+
esp32da.menu.CPUFreq.160=160MHz (WiFi/BT)
763+
esp32da.menu.CPUFreq.160.build.f_cpu=160000000L
764+
esp32da.menu.CPUFreq.80=80MHz (WiFi/BT)
765+
esp32da.menu.CPUFreq.80.build.f_cpu=80000000L
766+
esp32da.menu.CPUFreq.40=40MHz (40MHz XTAL)
767+
esp32da.menu.CPUFreq.40.build.f_cpu=40000000L
768+
esp32da.menu.CPUFreq.26=26MHz (26MHz XTAL)
769+
esp32da.menu.CPUFreq.26.build.f_cpu=26000000L
770+
esp32da.menu.CPUFreq.20=20MHz (40MHz XTAL)
771+
esp32da.menu.CPUFreq.20.build.f_cpu=20000000L
772+
esp32da.menu.CPUFreq.13=13MHz (26MHz XTAL)
773+
esp32da.menu.CPUFreq.13.build.f_cpu=13000000L
774+
esp32da.menu.CPUFreq.10=10MHz (40MHz XTAL)
775+
esp32da.menu.CPUFreq.10.build.f_cpu=10000000L
776+
777+
esp32da.menu.FlashMode.qio=QIO
778+
esp32da.menu.FlashMode.qio.build.flash_mode=dio
779+
esp32da.menu.FlashMode.qio.build.boot=qio
780+
esp32da.menu.FlashMode.dio=DIO
781+
esp32da.menu.FlashMode.dio.build.flash_mode=dio
782+
esp32da.menu.FlashMode.dio.build.boot=dio
783+
esp32da.menu.FlashMode.qout=QOUT
784+
esp32da.menu.FlashMode.qout.build.flash_mode=dout
785+
esp32da.menu.FlashMode.qout.build.boot=qout
786+
esp32da.menu.FlashMode.dout=DOUT
787+
esp32da.menu.FlashMode.dout.build.flash_mode=dout
788+
esp32da.menu.FlashMode.dout.build.boot=dout
789+
790+
esp32da.menu.FlashFreq.80=80MHz
791+
esp32da.menu.FlashFreq.80.build.flash_freq=80m
792+
esp32da.menu.FlashFreq.40=40MHz
793+
esp32da.menu.FlashFreq.40.build.flash_freq=40m
794+
795+
esp32da.menu.FlashSize.4M=4MB (32Mb)
796+
esp32da.menu.FlashSize.4M.build.flash_size=4MB
797+
esp32da.menu.FlashSize.8M=8MB (64Mb)
798+
esp32da.menu.FlashSize.8M.build.flash_size=8MB
799+
esp32da.menu.FlashSize.8M.build.partitions=default_8MB
800+
esp32da.menu.FlashSize.16M=16MB (128Mb)
801+
esp32da.menu.FlashSize.16M.build.flash_size=16MB
802+
803+
esp32da.menu.UploadSpeed.921600=921600
804+
esp32da.menu.UploadSpeed.921600.upload.speed=921600
805+
esp32da.menu.UploadSpeed.115200=115200
806+
esp32da.menu.UploadSpeed.115200.upload.speed=115200
807+
esp32da.menu.UploadSpeed.256000.windows=256000
808+
esp32da.menu.UploadSpeed.256000.upload.speed=256000
809+
esp32da.menu.UploadSpeed.230400.windows.upload.speed=256000
810+
esp32da.menu.UploadSpeed.230400=230400
811+
esp32da.menu.UploadSpeed.230400.upload.speed=230400
812+
esp32da.menu.UploadSpeed.460800.linux=460800
813+
esp32da.menu.UploadSpeed.460800.macosx=460800
814+
esp32da.menu.UploadSpeed.460800.upload.speed=460800
815+
esp32da.menu.UploadSpeed.512000.windows=512000
816+
esp32da.menu.UploadSpeed.512000.upload.speed=512000
817+
818+
esp32da.menu.LoopCore.1=Core 1
819+
esp32da.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1
820+
esp32da.menu.LoopCore.0=Core 0
821+
esp32da.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0
822+
823+
esp32da.menu.EventsCore.1=Core 1
824+
esp32da.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
825+
esp32da.menu.EventsCore.0=Core 0
826+
esp32da.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0
827+
828+
esp32da.menu.DebugLevel.none=None
829+
esp32da.menu.DebugLevel.none.build.code_debug=0
830+
esp32da.menu.DebugLevel.error=Error
831+
esp32da.menu.DebugLevel.error.build.code_debug=1
832+
esp32da.menu.DebugLevel.warn=Warn
833+
esp32da.menu.DebugLevel.warn.build.code_debug=2
834+
esp32da.menu.DebugLevel.info=Info
835+
esp32da.menu.DebugLevel.info.build.code_debug=3
836+
esp32da.menu.DebugLevel.debug=Debug
837+
esp32da.menu.DebugLevel.debug.build.code_debug=4
838+
esp32da.menu.DebugLevel.verbose=Verbose
839+
esp32da.menu.DebugLevel.verbose.build.code_debug=5
840+
841+
##############################################################
842+
694843
esp32wrover.name=ESP32 Wrover Module
695844

696845
esp32wrover.upload.tool=esptool_py
@@ -6479,7 +6628,7 @@ adafruit_qtpy_esp32c3.menu.DebugLevel.verbose=Verbose
64796628
adafruit_qtpy_esp32c3.menu.DebugLevel.verbose.build.code_debug=5
64806629

64816630

6482-
adafruit_qtpy_esp32_pico.name=Adafruit QT Py ESP32 Pico
6631+
adafruit_qtpy_esp32_pico.name=Adafruit QT Py ESP32
64836632

64846633
adafruit_qtpy_esp32_pico.upload.tool=esptool_py
64856634
adafruit_qtpy_esp32_pico.upload.maximum_size=1310720

‎cores/esp32/HardwareSerial.cpp

Copy file name to clipboardExpand all lines: cores/esp32/HardwareSerial.cpp
+150-9Lines changed: 150 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "HardwareSerial.h"
88
#include "soc/soc_caps.h"
99
#include "driver/uart.h"
10+
#include "freertos/queue.h"
1011

1112
#ifndef SOC_RX0
1213
#if CONFIG_IDF_TARGET_ESP32
@@ -111,7 +112,131 @@ void serialEventRun(void)
111112
}
112113
#endif
113114

114-
HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL), _rxBufferSize(256) {}
115+
#if !CONFIG_DISABLE_HAL_LOCKS
116+
#define HSERIAL_MUTEX_LOCK() do {} while (xSemaphoreTake(_lock, portMAX_DELAY) != pdPASS)
117+
#define HSERIAL_MUTEX_UNLOCK() xSemaphoreGive(_lock)
118+
#else
119+
#define HSERIAL_MUTEX_LOCK()
120+
#define HSERIAL_MUTEX_UNLOCK()
121+
#endif
122+
123+
HardwareSerial::HardwareSerial(int uart_nr) :
124+
_uart_nr(uart_nr),
125+
_uart(NULL),
126+
_rxBufferSize(256),
127+
_onReceiveCB(NULL),
128+
_onReceiveErrorCB(NULL),
129+
_eventTask(NULL)
130+
#if !CONFIG_DISABLE_HAL_LOCKS
131+
,_lock(NULL)
132+
#endif
133+
{
134+
#if !CONFIG_DISABLE_HAL_LOCKS
135+
if(_lock == NULL){
136+
_lock = xSemaphoreCreateMutex();
137+
if(_lock == NULL){
138+
log_e("xSemaphoreCreateMutex failed");
139+
return;
140+
}
141+
}
142+
#endif
143+
}
144+
145+
HardwareSerial::~HardwareSerial()
146+
{
147+
end();
148+
#if !CONFIG_DISABLE_HAL_LOCKS
149+
if(_lock != NULL){
150+
vSemaphoreDelete(_lock);
151+
}
152+
#endif
153+
}
154+
155+
156+
void HardwareSerial::_createEventTask(void *args)
157+
{
158+
// Creating UART event Task
159+
xTaskCreate(_uartEventTask, "uart_event_task", 2048, this, configMAX_PRIORITIES - 1, &_eventTask);
160+
if (_eventTask == NULL) {
161+
log_e(" -- UART%d Event Task not Created!", _uart_nr);
162+
}
163+
}
164+
165+
void HardwareSerial::_destroyEventTask(void)
166+
{
167+
if (_eventTask != NULL) {
168+
vTaskDelete(_eventTask);
169+
_eventTask = NULL;
170+
}
171+
}
172+
173+
void HardwareSerial::onReceiveError(OnReceiveErrorCb function)
174+
{
175+
HSERIAL_MUTEX_LOCK();
176+
// function may be NULL to cancel onReceive() from its respective task
177+
_onReceiveErrorCB = function;
178+
// this can be called after Serial.begin(), therefore it shall create the event task
179+
if (function != NULL && _uart != NULL && _eventTask == NULL) {
180+
_createEventTask(this);
181+
}
182+
HSERIAL_MUTEX_UNLOCK();
183+
}
184+
185+
void HardwareSerial::onReceive(OnReceiveCb function)
186+
{
187+
HSERIAL_MUTEX_LOCK();
188+
// function may be NULL to cancel onReceive() from its respective task
189+
_onReceiveCB = function;
190+
// this can be called after Serial.begin(), therefore it shall create the event task
191+
if (function != NULL && _uart != NULL && _eventTask == NULL) {
192+
_createEventTask(this);
193+
}
194+
HSERIAL_MUTEX_UNLOCK();
195+
}
196+
197+
void HardwareSerial::_uartEventTask(void *args)
198+
{
199+
HardwareSerial *uart = (HardwareSerial *)args;
200+
uart_event_t event;
201+
QueueHandle_t uartEventQueue = NULL;
202+
uartGetEventQueue(uart->_uart, &uartEventQueue);
203+
if (uartEventQueue != NULL) {
204+
for(;;) {
205+
//Waiting for UART event.
206+
if(xQueueReceive(uartEventQueue, (void * )&event, (portTickType)portMAX_DELAY)) {
207+
switch(event.type) {
208+
case UART_DATA:
209+
if(uart->_onReceiveCB && uart->available() > 0) uart->_onReceiveCB();
210+
break;
211+
case UART_FIFO_OVF:
212+
log_w("UART%d FIFO Overflow. Consider adding Hardware Flow Control to your Application.", uart->_uart_nr);
213+
if(uart->_onReceiveErrorCB) uart->_onReceiveErrorCB(UART_FIFO_OVF_ERROR);
214+
break;
215+
case UART_BUFFER_FULL:
216+
log_w("UART%d Buffer Full. Consider encreasing your buffer size of your Application.", uart->_uart_nr);
217+
if(uart->_onReceiveErrorCB) uart->_onReceiveErrorCB(UART_BUFFER_FULL_ERROR);
218+
break;
219+
case UART_BREAK:
220+
log_w("UART%d RX break.", uart->_uart_nr);
221+
if(uart->_onReceiveErrorCB) uart->_onReceiveErrorCB(UART_BREAK_ERROR);
222+
break;
223+
case UART_PARITY_ERR:
224+
log_w("UART%d parity error.", uart->_uart_nr);
225+
if(uart->_onReceiveErrorCB) uart->_onReceiveErrorCB(UART_PARITY_ERROR);
226+
break;
227+
case UART_FRAME_ERR:
228+
log_w("UART%d frame error.", uart->_uart_nr);
229+
if(uart->_onReceiveErrorCB) uart->_onReceiveErrorCB(UART_FRAME_ERROR);
230+
break;
231+
default:
232+
log_w("UART%d unknown event type %d.", uart->_uart_nr, event.type);
233+
break;
234+
}
235+
}
236+
}
237+
}
238+
vTaskDelete(NULL);
239+
}
115240

116241
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd)
117242
{
@@ -120,6 +245,14 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
120245
return;
121246
}
122247

248+
#if !CONFIG_DISABLE_HAL_LOCKS
249+
if(_lock == NULL){
250+
log_e("MUTEX Lock failed. Can't begin.");
251+
return;
252+
}
253+
#endif
254+
255+
HSERIAL_MUTEX_LOCK();
123256
// First Time or after end() --> set default Pins
124257
if (!uartIsDriverInstalled(_uart)) {
125258
switch (_uart_nr) {
@@ -172,26 +305,34 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
172305
_uart = NULL;
173306
}
174307
}
175-
}
176-
177-
void HardwareSerial::onReceive(void(*function)(void))
178-
{
179-
uartOnReceive(_uart, function);
308+
// create a task to deal with Serial Events when, for example, calling begin() twice to change the baudrate,
309+
// or when setting the callback before calling begin()
310+
if (_uart != NULL && (_onReceiveCB != NULL || _onReceiveErrorCB != NULL) && _eventTask == NULL) {
311+
_createEventTask(this);
312+
}
313+
HSERIAL_MUTEX_UNLOCK();
180314
}
181315

182316
void HardwareSerial::updateBaudRate(unsigned long baud)
183317
{
184318
uartSetBaudRate(_uart, baud);
185319
}
186320

187-
void HardwareSerial::end(bool turnOffDebug)
321+
void HardwareSerial::end(bool fullyTerminate)
188322
{
189-
if(turnOffDebug && uartGetDebug() == _uart_nr) {
190-
uartSetDebug(0);
323+
// default Serial.end() will completely disable HardwareSerial,
324+
// including any tasks or debug message channel (log_x()) - but not for IDF log messages!
325+
if(fullyTerminate) {
326+
_onReceiveCB = NULL;
327+
_onReceiveErrorCB = NULL;
328+
if (uartGetDebug() == _uart_nr) {
329+
uartSetDebug(0);
330+
}
191331
}
192332
delay(10);
193333
uartEnd(_uart);
194334
_uart = 0;
335+
_destroyEventTask();
195336
}
196337

197338
void HardwareSerial::setDebugOutput(bool en)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.