Skip to content

Commit eb2ed23

Browse files
committed
2 parents 88946ab + d92ee5c commit eb2ed23

22 files changed

+402
-84
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
run:
2323
shell: bash
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v3
2626
with:
2727
submodules: true
28-
- uses: actions/setup-python@v2
28+
- uses: actions/setup-python@v4
2929
with:
3030
python-version: '3.x'
3131
- name: Build

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: Build GitHub Pages
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
- name: Copy Files
2121
env:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/hil.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
chunks: ${{ steps.gen-chunks.outputs.chunks }}
2626
steps:
2727
- name: Checkout Repository
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2929

3030
- name: Generate Chunks matrix
3131
id: gen-chunks
@@ -52,7 +52,7 @@ jobs:
5252

5353
steps:
5454
- name: Checkout Repository
55-
uses: actions/checkout@v2
55+
uses: actions/checkout@v3
5656

5757
- name: Build sketches
5858
run: |
@@ -84,7 +84,7 @@ jobs:
8484

8585
steps:
8686
- name: Checkout repository
87-
uses: actions/checkout@v2
87+
uses: actions/checkout@v3
8888

8989
- name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts
9090
uses: actions/download-artifact@v2

.github/workflows/push.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: Check cmake file
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
- run: bash ./.github/scripts/check-cmakelists.sh
2323

2424
# Ubuntu
@@ -30,13 +30,13 @@ jobs:
3030
chunk: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
3131

3232
steps:
33-
- uses: actions/checkout@v2
34-
- uses: actions/setup-python@v2
33+
- uses: actions/checkout@v3
34+
- uses: actions/setup-python@v4
3535
with:
3636
python-version: '3.x'
3737
- name: Cache tools
3838
id: cache-linux
39-
uses: actions/cache@v2
39+
uses: actions/cache@v3
4040
with:
4141
path: |
4242
./tools/dist
@@ -56,8 +56,8 @@ jobs:
5656
os: [windows-latest, macOS-latest]
5757

5858
steps:
59-
- uses: actions/checkout@v2
60-
- uses: actions/setup-python@v2
59+
- uses: actions/checkout@v3
60+
- uses: actions/setup-python@v4
6161
with:
6262
python-version: '3.x'
6363
- name: Build Sketches
@@ -72,8 +72,8 @@ jobs:
7272
os: [ubuntu-latest, windows-latest, macOS-latest]
7373

7474
steps:
75-
- uses: actions/checkout@v2
76-
- uses: actions/setup-python@v2
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-python@v4
7777
with:
7878
python-version: '3.x'
7979
- name: Build Sketches
@@ -93,7 +93,7 @@ jobs:
9393
container: espressif/idf:${{ matrix.idf_ver }}
9494
steps:
9595
- name: Check out arduino-esp32 as a component
96-
uses: actions/checkout@v2
96+
uses: actions/checkout@v3
9797
with:
9898
submodules: recursive
9999
path: components/arduino-esp32

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
with:
1515
fetch-depth: 0
16-
- uses: actions/setup-python@v2
16+
- uses: actions/setup-python@v4
1717
with:
1818
python-version: '3.x'
1919
- name: Build Release

.github/workflows/upload-idf-component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
upload_components:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
with:
1212
submodules: "recursive"
1313

boards.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11515,6 +11515,31 @@ heltec_wifi_lora_32.build.boot=dio
1151511515
heltec_wifi_lora_32.build.partitions=default
1151611516
heltec_wifi_lora_32.build.defines=-D{build.band} -DLoRaWAN_DEBUG_LEVEL={build.LoRaWanDebugLevel} -DACTIVE_REGION=LORAMAC_{build.band} {build.psram}
1151711517

11518+
heltec_wifi_lora_32.menu.PartitionScheme.default=Regular 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
11519+
heltec_wifi_lora_32.menu.PartitionScheme.default.build.partitions=default
11520+
heltec_wifi_lora_32.menu.PartitionScheme.defaultffat=Regular 4MB with ffat (1.2MB APP/1.5MB FATFS)
11521+
heltec_wifi_lora_32.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
11522+
heltec_wifi_lora_32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
11523+
heltec_wifi_lora_32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
11524+
heltec_wifi_lora_32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
11525+
heltec_wifi_lora_32.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
11526+
heltec_wifi_lora_32.menu.PartitionScheme.minimal.build.partitions=minimal
11527+
heltec_wifi_lora_32.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
11528+
heltec_wifi_lora_32.menu.PartitionScheme.huge_app.build.partitions=huge_app
11529+
heltec_wifi_lora_32.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
11530+
heltec_wifi_lora_32.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
11531+
heltec_wifi_lora_32.menu.PartitionScheme.no_ota.build.partitions=no_ota
11532+
heltec_wifi_lora_32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
11533+
heltec_wifi_lora_32.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
11534+
heltec_wifi_lora_32.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
11535+
heltec_wifi_lora_32.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
11536+
heltec_wifi_lora_32.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
11537+
heltec_wifi_lora_32.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
11538+
heltec_wifi_lora_32.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
11539+
heltec_wifi_lora_32.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
11540+
heltec_wifi_lora_32.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
11541+
heltec_wifi_lora_32.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
11542+
1151811543
heltec_wifi_lora_32.menu.PSRAM.disabled=Disabled
1151911544
heltec_wifi_lora_32.menu.PSRAM.disabled.build.psram=
1152011545
heltec_wifi_lora_32.menu.PSRAM.disabled.build.extra_libs=

cores/esp32/HardwareSerial.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ _eventTask(NULL)
145145
#if !CONFIG_DISABLE_HAL_LOCKS
146146
,_lock(NULL)
147147
#endif
148+
,_rxPin(-1)
149+
,_txPin(-1)
150+
,_ctsPin(-1)
151+
,_rtsPin(-1)
148152
{
149153
#if !CONFIG_DISABLE_HAL_LOCKS
150154
if(_lock == NULL){
@@ -384,7 +388,8 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
384388

385389
// Set UART RX timeout
386390
uartSetRxTimeout(_uart, _rxTimeout);
387-
391+
_rxPin = rxPin;
392+
_txPin = txPin;
388393
HSERIAL_MUTEX_UNLOCK();
389394
}
390395

@@ -403,6 +408,8 @@ void HardwareSerial::end(bool fullyTerminate)
403408
if (uartGetDebug() == _uart_nr) {
404409
uartSetDebug(0);
405410
}
411+
uartDetachPins(_uart, _rxPin, _txPin, _ctsPin, _rtsPin);
412+
_rxPin = _txPin = _ctsPin = _rtsPin = -1;
406413
}
407414
delay(10);
408415
uartEnd(_uart);
@@ -507,10 +514,19 @@ void HardwareSerial::setRxInvert(bool invert)
507514
void HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
508515
{
509516
if(_uart == NULL) {
510-
log_e("setPins() shall be called after begin() - nothing done");
517+
log_e("setPins() shall be called after begin() - nothing done\n");
511518
return;
512519
}
513-
uartSetPins(_uart, rxPin, txPin, ctsPin, rtsPin);
520+
521+
// uartSetPins() checks if pins are valid for each function and for the SoC
522+
if (uartSetPins(_uart, rxPin, txPin, ctsPin, rtsPin)) {
523+
_txPin = _txPin >= 0 ? txPin : _txPin;
524+
_rxPin = _rxPin >= 0 ? rxPin : _rxPin;
525+
_rtsPin = _rtsPin >= 0 ? rtsPin : _rtsPin;
526+
_ctsPin = _ctsPin >= 0 ? ctsPin : _ctsPin;
527+
} else {
528+
log_e("Error when setting Serial port Pins. Invalid Pin.\n");
529+
}
514530
}
515531

516532
// Enables or disables Hardware Flow Control using RTS and/or CTS pins (must use setAllPins() before)

cores/esp32/HardwareSerial.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class HardwareSerial: public Stream
176176
#if !CONFIG_DISABLE_HAL_LOCKS
177177
SemaphoreHandle_t _lock;
178178
#endif
179+
int8_t _rxPin, _txPin, _ctsPin, _rtsPin;
179180

180181
void _createEventTask(void *args);
181182
void _destroyEventTask(void);

cores/esp32/esp32-hal-uart.c

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "soc/soc_caps.h"
2424
#include "soc/uart_struct.h"
2525

26+
#include "hal/gpio_hal.h"
27+
#include "esp_rom_gpio.h"
28+
2629
static int s_uart_debug_nr = 0;
2730

2831
struct uart_struct_t {
@@ -69,6 +72,40 @@ static uart_t _uart_bus_array[] = {
6972

7073
#endif
7174

75+
// IDF UART has no detach function. As consequence, after ending a UART, the previous pins continue
76+
// to work as RX/TX. It can be verified by changing the UART pins and writing to the UART. Output can
77+
// be seen in the previous pins and new pins as well.
78+
// Valid pin UART_PIN_NO_CHANGE is defined to (-1)
79+
// Negative Pin Number will keep it unmodified, thus this function can detach individual pins
80+
void uartDetachPins(uart_t* uart, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
81+
{
82+
if(uart == NULL) {
83+
return;
84+
}
85+
86+
UART_MUTEX_LOCK();
87+
if (txPin >= 0) {
88+
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[txPin], PIN_FUNC_GPIO);
89+
esp_rom_gpio_connect_out_signal(txPin, SIG_GPIO_OUT_IDX, false, false);
90+
}
91+
92+
if (rxPin >= 0) {
93+
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rxPin], PIN_FUNC_GPIO);
94+
esp_rom_gpio_connect_in_signal(GPIO_FUNC_IN_LOW, UART_PERIPH_SIGNAL(uart->num, SOC_UART_RX_PIN_IDX), false);
95+
}
96+
97+
if (rtsPin >= 0) {
98+
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rtsPin], PIN_FUNC_GPIO);
99+
esp_rom_gpio_connect_out_signal(rtsPin, SIG_GPIO_OUT_IDX, false, false);
100+
}
101+
102+
if (ctsPin >= 0) {
103+
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[ctsPin], PIN_FUNC_GPIO);
104+
esp_rom_gpio_connect_in_signal(GPIO_FUNC_IN_LOW, UART_PERIPH_SIGNAL(uart->num, SOC_UART_CTS_PIN_IDX), false);
105+
}
106+
UART_MUTEX_UNLOCK();
107+
}
108+
72109
// solves issue https://github.com/espressif/arduino-esp32/issues/6032
73110
// baudrate must be multiplied when CPU Frequency is lower than APB 80MHz
74111
uint32_t _get_effective_baudrate(uint32_t baudrate)
@@ -108,15 +145,16 @@ bool uartIsDriverInstalled(uart_t* uart)
108145

109146
// Valid pin UART_PIN_NO_CHANGE is defined to (-1)
110147
// Negative Pin Number will keep it unmodified, thus this function can set individual pins
111-
void uartSetPins(uart_t* uart, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
148+
bool uartSetPins(uart_t* uart, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
112149
{
113150
if(uart == NULL) {
114-
return;
151+
return false;
115152
}
116153
UART_MUTEX_LOCK();
117154
// IDF uart_set_pin() will issue necessary Error Message and take care of all GPIO Number validation.
118-
uart_set_pin(uart->num, txPin, rxPin, rtsPin, ctsPin);
155+
bool retCode = uart_set_pin(uart->num, txPin, rxPin, rtsPin, ctsPin) == ESP_OK;
119156
UART_MUTEX_UNLOCK();
157+
return retCode;
120158
}
121159

122160
//

cores/esp32/esp32-hal-uart.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ int uartGetDebug();
9191

9292
bool uartIsDriverInstalled(uart_t* uart);
9393

94-
// Negative Pin Number will keep it unmodified, thus this function can set individual pins
95-
void uartSetPins(uart_t* uart, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin);
94+
// Negative Pin Number will keep it unmodified, thus this function can set/reset individual pins
95+
bool uartSetPins(uart_t* uart, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin);
96+
void uartDetachPins(uart_t* uart, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin);
9697

9798
// Enables or disables HW Flow Control function -- needs also to set CTS and/or RTS pins
9899
void uartSetHwFlowCtrlMode(uart_t *uart, uint8_t mode, uint8_t threshold);

0 commit comments

Comments
 (0)