Skip to content

Commit d45c618

Browse files
authored
Merge branch 'master' into Update_noglobfix
2 parents 3126124 + e368295 commit d45c618

File tree

74 files changed

+10019
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+10019
-551
lines changed

.github/ISSUE_TEMPLATE/Issue-report.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ body:
4040
label: Version
4141
description: What version of Arduino ESP32 are you running? If possible, consider updating to the latest version.
4242
options:
43-
- latest stable Release (if not listed below)
44-
- latest development Release Candidate (RC-X)
43+
- Please select a version from the list below
4544
- latest master (checkout manually)
4645
- v3.3.4
4746
- v3.3.3
@@ -62,26 +61,7 @@ body:
6261
- v3.0.2
6362
- v3.0.1
6463
- v3.0.0
65-
- v2.0.17
66-
- v2.0.16
67-
- v2.0.15
68-
- v2.0.14
69-
- v2.0.13
70-
- v2.0.12
71-
- v2.0.11
72-
- v2.0.10
73-
- v2.0.9
74-
- v2.0.8
75-
- v2.0.7
76-
- v2.0.6
77-
- v2.0.5
78-
- v2.0.4
79-
- v2.0.3
80-
- v2.0.2
81-
- v2.0.1
82-
- v2.0.0
83-
- v1.0.6
84-
- other
64+
- Older versions
8565
validations:
8666
required: true
8767
- type: dropdown

.github/scripts/sketch_utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
155155
esp32c3_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
156156
esp32c6_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
157157
esp32h2_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
158-
esp32p4_opts=$(echo "PSRAM=enabled,USBMode=default,$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
158+
esp32p4_opts=$(echo "PSRAM=enabled,USBMode=default,ChipVariant=postv3,$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
159159
esp32c5_opts=$(echo "PSRAM=enabled,$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
160160

161161
# Select the common part of the FQBN based on the target. The rest will be

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,18 @@ set(ARDUINO_LIBRARY_Matter_SRCS
191191
libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp
192192
libraries/Matter/src/MatterEndpoints/MatterFan.cpp
193193
libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp
194+
libraries/Matter/src/MatterEndpoints/MatterTemperatureControlledCabinet.cpp
194195
libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp
195196
libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp
197+
libraries/Matter/src/MatterEndpoints/MatterWaterLeakDetector.cpp
198+
libraries/Matter/src/MatterEndpoints/MatterWaterFreezeDetector.cpp
199+
libraries/Matter/src/MatterEndpoints/MatterRainSensor.cpp
196200
libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp
197201
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp
198202
libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp
203+
libraries/Matter/src/MatterEndpoints/MatterDimmablePlugin.cpp
199204
libraries/Matter/src/MatterEndpoints/MatterThermostat.cpp
205+
libraries/Matter/src/MatterEndpoints/MatterWindowCovering.cpp
200206
libraries/Matter/src/Matter.cpp
201207
libraries/Matter/src/MatterEndPoint.cpp)
202208

boards.txt

Lines changed: 330 additions & 0 deletions
Large diffs are not rendered by default.

cores/esp32/HardwareSerial.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,31 @@ HardwareSerial Serial5(5);
6161
extern void HWCDCSerialEvent(void) __attribute__((weak));
6262
#endif
6363

64+
// C-callable helper used by HAL when pins are detached and the high-level
65+
// HardwareSerial instance must be finalized.
66+
extern "C" void hal_uart_notify_pins_detached(int uart_num) {
67+
log_d("hal_uart_notify_pins_detached: Notifying HardwareSerial for UART%d", uart_num);
68+
switch (uart_num) {
69+
case 0: Serial0.end(); break;
70+
#if SOC_UART_NUM > 1
71+
case 1: Serial1.end(); break;
72+
#endif
73+
#if SOC_UART_NUM > 2
74+
case 2: Serial2.end(); break;
75+
#endif
76+
#if SOC_UART_NUM > 3
77+
case 3: Serial3.end(); break;
78+
#endif
79+
#if SOC_UART_NUM > 4
80+
case 4: Serial4.end(); break;
81+
#endif
82+
#if SOC_UART_NUM > 5
83+
case 5: Serial5.end(); break;
84+
#endif
85+
default: log_e("hal_uart_notify_pins_detached: UART%d not handled!", uart_num); break;
86+
}
87+
}
88+
6489
#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
6590
// Used by Hardware Serial for USB CDC events
6691
extern void USBSerialEvent(void) __attribute__((weak));
@@ -483,9 +508,6 @@ void HardwareSerial::end() {
483508
// including any tasks or debug message channel (log_x()) - but not for IDF log messages!
484509
_onReceiveCB = NULL;
485510
_onReceiveErrorCB = NULL;
486-
if (uartGetDebug() == _uart_nr) {
487-
uartSetDebug(0);
488-
}
489511
_rxFIFOFull = 0;
490512
uartEnd(_uart_nr); // fully detach all pins and delete the UART driver
491513
_destroyEventTask(); // when IDF uart driver is deleted, _eventTask must finish too

cores/esp32/chip-debug-report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static void printPerimanInfo(void) {
291291

292292
void printBeforeSetupInfo(void) {
293293
#if ARDUINO_USB_CDC_ON_BOOT
294-
Serial.begin(0);
294+
Serial.begin();
295295
Serial.setDebugOutput(true);
296296
uint8_t t = 0;
297297
while (!Serial && (t++ < 200)) {

cores/esp32/esp32-hal-uart.c

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
static int s_uart_debug_nr = 0; // UART number for debug output
4343
#define REF_TICK_BAUDRATE_LIMIT 250000 // this is maximum UART badrate using REF_TICK as clock
4444

45+
/* C prototype for the notifier implemented in HardwareSerial.cpp */
46+
extern void hal_uart_notify_pins_detached(int uart_num);
47+
4548
struct uart_struct_t {
4649

4750
#if !CONFIG_DISABLE_HAL_LOCKS
@@ -282,29 +285,67 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
282285
// Peripheral Manager detach callback for each specific UART PIN
283286
static bool _uartDetachBus_RX(void *busptr) {
284287
// sanity check - it should never happen
285-
assert(busptr && "_uartDetachBus_RX bus NULL pointer.");
288+
if (busptr == NULL) {
289+
log_e("_uartDetachBus_RX: busptr is NULL");
290+
return false;
291+
}
286292
uart_t *bus = (uart_t *)busptr;
293+
if (bus->_rxPin < 0) {
294+
log_d("_uartDetachBus_RX: RX pin already detached for UART%d", bus->num);
295+
return true;
296+
}
297+
if (bus->_txPin < 0) { // both rx and tx pins are detached, terminate the uart driver
298+
log_d("_uartDetachBus_RX: both RX and TX pins detached for UART%d, terminating driver", bus->num);
299+
hal_uart_notify_pins_detached(bus->num);
300+
return true;
301+
}
287302
return _uartDetachPins(bus->num, bus->_rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
288303
}
289304

290305
static bool _uartDetachBus_TX(void *busptr) {
291306
// sanity check - it should never happen
292-
assert(busptr && "_uartDetachBus_TX bus NULL pointer.");
307+
if (busptr == NULL) {
308+
log_e("_uartDetachBus_TX: busptr is NULL");
309+
return false;
310+
}
293311
uart_t *bus = (uart_t *)busptr;
312+
if (bus->_txPin < 0) {
313+
log_d("_uartDetachBus_TX: TX pin already detached for UART%d", bus->num);
314+
return true;
315+
}
316+
if (bus->_rxPin < 0) { // both rx and tx pins are detached, terminate the uart driver
317+
log_d("_uartDetachBus_TX: both RX and TX pins detached for UART%d, terminating driver", bus->num);
318+
hal_uart_notify_pins_detached(bus->num);
319+
return true;
320+
}
294321
return _uartDetachPins(bus->num, UART_PIN_NO_CHANGE, bus->_txPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
295322
}
296323

297324
static bool _uartDetachBus_CTS(void *busptr) {
298325
// sanity check - it should never happen
299-
assert(busptr && "_uartDetachBus_CTS bus NULL pointer.");
326+
if (busptr == NULL) {
327+
log_e("_uartDetachBus_CTS: busptr is NULL");
328+
return false;
329+
}
300330
uart_t *bus = (uart_t *)busptr;
331+
if (bus->_ctsPin < 0) {
332+
log_d("_uartDetachBus_CTS: CTS pin already detached for UART%d", bus->num);
333+
return true;
334+
}
301335
return _uartDetachPins(bus->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, bus->_ctsPin, UART_PIN_NO_CHANGE);
302336
}
303337

304338
static bool _uartDetachBus_RTS(void *busptr) {
305339
// sanity check - it should never happen
306-
assert(busptr && "_uartDetachBus_RTS bus NULL pointer.");
340+
if (busptr == NULL) {
341+
log_e("_uartDetachBus_RTS: busptr is NULL");
342+
return false;
343+
}
307344
uart_t *bus = (uart_t *)busptr;
345+
if (bus->_rtsPin < 0) {
346+
log_d("_uartDetachBus_RTS: RTS pin already detached for UART%d", bus->num);
347+
return true;
348+
}
308349
return _uartDetachPins(bus->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, bus->_rtsPin);
309350
}
310351

@@ -629,6 +670,16 @@ bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, in
629670
//log_v("setting UART%d pins: prev->new RX(%d->%d) TX(%d->%d) CTS(%d->%d) RTS(%d->%d)", uart_num,
630671
// uart->_rxPin, rxPin, uart->_txPin, txPin, uart->_ctsPin, ctsPin, uart->_rtsPin, rtsPin); vTaskDelay(10);
631672

673+
// mute bus detaching callbacks to avoid terminating the UART driver when both RX and TX pins are detached
674+
peripheral_bus_deinit_cb_t rxDeinit = perimanGetBusDeinit(ESP32_BUS_TYPE_UART_RX);
675+
peripheral_bus_deinit_cb_t txDeinit = perimanGetBusDeinit(ESP32_BUS_TYPE_UART_TX);
676+
peripheral_bus_deinit_cb_t ctsDeinit = perimanGetBusDeinit(ESP32_BUS_TYPE_UART_CTS);
677+
peripheral_bus_deinit_cb_t rtsDeinit = perimanGetBusDeinit(ESP32_BUS_TYPE_UART_RTS);
678+
perimanClearBusDeinit(ESP32_BUS_TYPE_UART_RX);
679+
perimanClearBusDeinit(ESP32_BUS_TYPE_UART_TX);
680+
perimanClearBusDeinit(ESP32_BUS_TYPE_UART_CTS);
681+
perimanClearBusDeinit(ESP32_BUS_TYPE_UART_RTS);
682+
632683
// First step: detaches all previous UART pins
633684
bool rxPinChanged = rxPin >= 0 && rxPin != uart->_rxPin;
634685
if (rxPinChanged) {
@@ -660,6 +711,21 @@ bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, in
660711
if (rtsPinChanged) {
661712
retCode &= _uartAttachPins(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, rtsPin);
662713
}
714+
715+
// restore bus detaching callbacks
716+
if (rxDeinit != NULL) {
717+
perimanSetBusDeinit(ESP32_BUS_TYPE_UART_RX, rxDeinit);
718+
}
719+
if (txDeinit != NULL) {
720+
perimanSetBusDeinit(ESP32_BUS_TYPE_UART_TX, txDeinit);
721+
}
722+
if (ctsDeinit != NULL) {
723+
perimanSetBusDeinit(ESP32_BUS_TYPE_UART_CTS, ctsDeinit);
724+
}
725+
if (rtsDeinit != NULL) {
726+
perimanSetBusDeinit(ESP32_BUS_TYPE_UART_RTS, rtsDeinit);
727+
}
728+
663729
UART_MUTEX_UNLOCK();
664730

665731
if (!retCode) {
@@ -986,6 +1052,9 @@ void uartEnd(uint8_t uart_num) {
9861052
if (uart_is_driver_installed(uart_num)) {
9871053
uart_driver_delete(uart_num);
9881054
}
1055+
if (uartGetDebug() == uart_num) {
1056+
uartSetDebug(0);
1057+
}
9891058
UART_MUTEX_UNLOCK();
9901059
}
9911060

docs/en/api/serial.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ with additional features for advanced use cases.
2323
* **Event callbacks**: Receive and error event callbacks
2424
* **Configurable buffers**: Adjustable RX and TX buffer sizes
2525

26+
.. note::
27+
In case that both pins, RX and TX are detached from UART, the driver will be stopped.
28+
Detaching may occur when, for instance, starting another peripheral using RX and TX pins, such as Wire.begin(RX0, TX0).
29+
2630
UART Availability
2731
-----------------
2832

docs/en/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Currently, the default FQBNs are:
174174
* ``espressif:esp32:esp32c3``
175175
* ``espressif:esp32:esp32c6``
176176
* ``espressif:esp32:esp32h2``
177-
* ``espressif:esp32:esp32p4:USBMode=default``
177+
* ``espressif:esp32:esp32p4:USBMode=default,ChipVariant=postv3``
178178

179179
There are two ways to alter the FQBNs used to compile the sketches: by using the ``fqbn`` or ``fqbn_append`` fields in the ``ci.yml`` file.
180180

0 commit comments

Comments
 (0)