Skip to content

Commit 5566d91

Browse files
committed
Merge remote-tracking branch 'remotes/upstream/master'
2 parents 67c1948 + 80a7d60 commit 5566d91

File tree

230 files changed

+6818
-3303
lines changed

Some content is hidden

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

230 files changed

+6818
-3303
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
21
tools/xtensa-esp32-elf
32
tools/dist
43
tools/esptool
54
tools/esptool.exe
5+
tools/mkspiffs/mkspiffs
6+
tools/mkspiffs/mkspiffs.exe

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libraries/BLE"]
2+
path = libraries/BLE
3+
url = https://github.com/nkolban/ESP32_BLE_Arduino.git

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ script:
1919
- mkdir espressif
2020
- cd espressif
2121
- ln -s $TRAVIS_BUILD_DIR esp32
22-
- cd esp32/tools
22+
- cd esp32
23+
- git submodule update --init --recursive
24+
- cd tools
2325
- python get.py
2426
- export PATH="$HOME/arduino_ide:$TRAVIS_BUILD_DIR/tools/xtensa-esp32-elf/bin:$PATH"
2527
- which arduino

Kconfig

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ config ARDUHAL_LOG_COLORS
6666
Enable ANSI terminal color codes in bootloader output.
6767
In order to view these, your terminal program must support ANSI color codes.
6868

69+
config ARDUHAL_ESP_LOG
70+
bool "Forward ESP_LOGx to Arduino log output"
71+
default "n"
72+
help
73+
This option will redefine the ESP_LOGx macros to Arduino's log_x macros.
74+
To enable for your application, add the follwing after your includes:
75+
#ifdef ARDUINO_ARCH_ESP32
76+
#include "esp32-hal-log.h"
77+
#endif
78+
6979
endmenu
7080

7181
config AUTOCONNECT_WIFI

Makefile.projbuild

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ endif
99
BOOT_APP_BIN_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH)
1010
ESPTOOL_ALL_FLASH_ARGS += $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH)
1111

12-
CPPFLAGS += -DARDUINO=180 -DESP32=1 -DARDUINO_ARCH_ESP32=1
12+
CPPFLAGS += -DARDUINO=10800 -DESP32=1 -DARDUINO_ARCH_ESP32=1
1313

1414
boot-app0:
1515
@echo "Rebooting to APP0"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Most of the framework is implemented. Most noticable is the missing analogWrite.
2424
+ [Instructions for Mac](docs/arduino-ide/mac.md)
2525
+ [Instructions for Debian/Ubuntu Linux](docs/arduino-ide/debian_ubuntu.md)
2626
+ [Instructions for Fedora](docs/arduino-ide/fedora.md)
27+
+ [Instructions for openSUSE](docs/arduino-ide/opensuse.md)
2728
- [Using PlatformIO](docs/platformio.md)
2829
- [Building with make](docs/make.md)
2930
- [Using as ESP-IDF component](docs/esp-idf_component.md)

boards.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ menu.FlashSize=Flash Size
55
menu.DebugLevel=Core Debug Level
66

77

8+
89
##############################################################
910

1011
lolin32.name=WEMOS LOLIN32
@@ -52,6 +53,8 @@ lolin32.menu.UploadSpeed.512000.upload.speed=512000
5253

5354
lolin32_lite.name=WEMOS LOLIN32 Lite
5455

56+
57+
5558
lolin32_lite.upload.tool=esptool
5659
lolin32_lite.upload.maximum_size=1310720
5760
lolin32_lite.upload.maximum_data_size=294912
@@ -81,3 +84,4 @@ lolin32_lite.menu.UploadSpeed.256000.upload.speed=256000
8184
lolin32_lite.menu.UploadSpeed.115200=115200
8285
lolin32_lite.menu.UploadSpeed.115200.upload.speed=115200
8386

87+

cores/esp32/Arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "freertos/task.h"
3434
#include "freertos/semphr.h"
3535
#include "esp32-hal.h"
36+
#include "esp8266-compat.h"
3637
#include "soc/gpio_reg.h"
3738

3839
#include "stdlib_noniso.h"

cores/esp32/Esp.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ uint32_t EspClass::getFreeHeap(void)
119119

120120
uint8_t EspClass::getChipRevision(void)
121121
{
122-
return (REG_READ(EFUSE_BLK0_RDATA3_REG) >> EFUSE_RD_CHIP_VER_RESERVE_S) && EFUSE_RD_CHIP_VER_RESERVE_V;
122+
esp_chip_info_t chip_info;
123+
esp_chip_info(&chip_info);
124+
return chip_info.revision;
123125
}
124126

125127
const char * EspClass::getSdkVersion(void)

cores/esp32/HardwareSerial.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ HardwareSerial Serial(0);
99

1010
HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {}
1111

12-
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin)
12+
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)
1313
{
14+
if(0 > _uart_nr || _uart_nr > 2) {
15+
log_e("Serial number is invalid, please use 0, 1 or 2");
16+
return;
17+
}
1418
if(_uart) {
1519
end();
1620
}
@@ -26,7 +30,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
2630
rxPin = 16;
2731
txPin = 17;
2832
}
29-
_uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, false);
33+
_uart = uartBegin(_uart_nr, baud, config, rxPin, txPin, 256, invert);
3034
}
3135

3236
void HardwareSerial::end()
@@ -89,7 +93,11 @@ size_t HardwareSerial::write(const uint8_t *buffer, size_t size)
8993
uartWriteBuf(_uart, buffer, size);
9094
return size;
9195
}
96+
uint32_t HardwareSerial::baudRate()
9297

98+
{
99+
return uartGetBaudRate(_uart);
100+
}
93101
HardwareSerial::operator bool() const
94102
{
95103
return true;

cores/esp32/HardwareSerial.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class HardwareSerial: public Stream
3737
public:
3838
HardwareSerial(int uart_nr);
3939

40-
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1);
40+
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false);
4141
void end();
4242
int available(void);
4343
int peek(void);
@@ -66,6 +66,7 @@ class HardwareSerial: public Stream
6666
{
6767
return write((uint8_t) n);
6868
}
69+
uint32_t baudRate();
6970
operator bool() const;
7071

7172
void setDebugOutput(bool);

cores/esp32/WString.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "WString.h"
2525
#include "stdlib_noniso.h"
26+
#include "esp32-hal-log.h"
2627
//extern "C" {
2728
//#include "esp_common.h"
2829
//}
@@ -165,19 +166,23 @@ unsigned char String::reserve(unsigned int size)
165166

166167
unsigned char String::changeBuffer(unsigned int maxStrLen)
167168
{
168-
size_t newSize = (maxStrLen + 16) & (~0xf);
169-
char *newbuffer = (char *) malloc(newSize);
169+
size_t newSize = ((maxStrLen + 16) & (~0xf)) - 1;
170+
char *newbuffer = (char *) realloc(buffer, newSize+1);
170171
if(newbuffer) {
171-
memset(newbuffer, 0, newSize);
172-
memcpy(newbuffer, buffer, len);
173-
if (buffer) {
174-
free(buffer);
172+
if(newSize > len){
173+
if(newSize > capacity){
174+
memset(newbuffer+capacity, 0, newSize-capacity);
175+
}
176+
} else {
177+
//new buffer can not fit the old len
178+
newbuffer[newSize] = 0;
179+
len = newSize;
175180
}
176-
capacity = newSize - 1;
181+
capacity = newSize;
177182
buffer = newbuffer;
178183
return 1;
179184
}
180-
buffer = newbuffer;
185+
log_e("realloc failed! Buffer unchanged");
181186
return 0;
182187
}
183188

cores/esp32/esp32-hal-bt.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
#include "esp32-hal-bt.h"
1616

17-
#if CONFIG_BT_ENABLED
17+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
18+
1819

1920
#include "bt.h"
2021
#include "esp_bt_defs.h"
@@ -51,7 +52,7 @@ bool btStop(){
5152
return true;
5253
}
5354
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED){
54-
if (esp_bt_controller_disable(ESP_BT_MODE_BTDM)) {
55+
if (esp_bt_controller_disable()) {
5556
log_e("BT Disable failed");
5657
return false;
5758
}

cores/esp32/esp32-hal-gpio.c

+10-20
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
#include "soc/gpio_struct.h"
2525
#include "soc/rtc_io_reg.h"
2626

27-
#define ETS_GPIO_INUM 12
28-
29-
const int8_t esp32_adc2gpio[20] = {36, -1, -1, 39, 32, 33, 34, 35, -1, -1, 4, 0, 2, 15, 13, 12, 14, 27, 25, 26};
27+
const int8_t esp32_adc2gpio[20] = {36, 37, 38, 39, 32, 33, 34, 35, -1, -1, 4, 0, 2, 15, 13, 12, 14, 27, 25, 26};
3028

3129
const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={
3230
{0x44, 11, 11, 1},
@@ -66,8 +64,8 @@ const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={
6664
{0x14, 4, 6, -1},
6765
{0x18, 5, 7, -1},
6866
{0x04, 0, 0, -1},
69-
{0x08, 1, -1, -1},
70-
{0x0c, 2, -1, -1},
67+
{0x08, 1, 1, -1},
68+
{0x0c, 2, 2, -1},
7169
{0x10, 3, 3, -1}
7270
};
7371

@@ -193,6 +191,7 @@ extern int IRAM_ATTR __digitalRead(uint8_t pin)
193191
return 0;
194192
}
195193

194+
static intr_handle_t gpio_intr_handle = NULL;
196195

197196
static void IRAM_ATTR __onPinInterrupt(void *arg)
198197
{
@@ -229,38 +228,29 @@ static void IRAM_ATTR __onPinInterrupt(void *arg)
229228
extern void __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int intr_type)
230229
{
231230
static bool interrupt_initialized = false;
232-
static int core_id = 0;
233231

234232
if(!interrupt_initialized) {
235233
interrupt_initialized = true;
236-
core_id = xPortGetCoreID();
237-
ESP_INTR_DISABLE(ETS_GPIO_INUM);
238-
intr_matrix_set(core_id, ETS_GPIO_INTR_SOURCE, ETS_GPIO_INUM);
239-
xt_set_interrupt_handler(ETS_GPIO_INUM, &__onPinInterrupt, NULL);
240-
ESP_INTR_ENABLE(ETS_GPIO_INUM);
234+
esp_intr_alloc(ETS_GPIO_INTR_SOURCE, (int)ESP_INTR_FLAG_IRAM, __onPinInterrupt, NULL, &gpio_intr_handle);
241235
}
242236
__pinInterruptHandlers[pin] = userFunc;
243-
//lock gpio
244-
ESP_INTR_DISABLE(ETS_GPIO_INUM);
245-
if(core_id) { //APP_CPU
237+
esp_intr_disable(gpio_intr_handle);
238+
if(esp_intr_get_cpu(gpio_intr_handle)) { //APP_CPU
246239
GPIO.pin[pin].int_ena = 1;
247240
} else { //PRO_CPU
248241
GPIO.pin[pin].int_ena = 4;
249242
}
250243
GPIO.pin[pin].int_type = intr_type;
251-
ESP_INTR_ENABLE(ETS_GPIO_INUM);
252-
//unlock gpio
244+
esp_intr_enable(gpio_intr_handle);
253245
}
254246

255247
extern void __detachInterrupt(uint8_t pin)
256248
{
257-
//lock gpio
258-
ESP_INTR_DISABLE(ETS_GPIO_INUM);
249+
esp_intr_disable(gpio_intr_handle);
259250
__pinInterruptHandlers[pin] = NULL;
260251
GPIO.pin[pin].int_ena = 0;
261252
GPIO.pin[pin].int_type = 0;
262-
ESP_INTR_ENABLE(ETS_GPIO_INUM);
263-
//unlock gpio
253+
esp_intr_enable(gpio_intr_handle);
264254
}
265255

266256

0 commit comments

Comments
 (0)