Skip to content

Commit 084c9ec

Browse files
committed
Merge branch 'master' of https://github.com/espressif/arduino-esp32 into idf-update
2 parents 2fbe490 + 40d85ce commit 084c9ec

File tree

25 files changed

+461
-129
lines changed

25 files changed

+461
-129
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "libraries/BLE"]
22
path = libraries/BLE
33
url = https://github.com/nkolban/ESP32_BLE_Arduino.git
4+
[submodule "libraries/AzureIoT"]
5+
path = libraries/AzureIoT
6+
url = https://github.com/VSChina/ESP32_AzureIoT_Arduino

boards.txt

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ esp32.menu.PartitionScheme.minimal=Minimal (2MB FLASH)
3535
esp32.menu.PartitionScheme.minimal.build.partitions=minimal
3636
esp32.menu.PartitionScheme.no_ota=No OTA (Large APP)
3737
esp32.menu.PartitionScheme.no_ota.build.partitions=no_ota
38+
esp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
3839
esp32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
3940
esp32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
41+
esp32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
4042

4143
esp32.menu.FlashMode.qio=QIO
4244
esp32.menu.FlashMode.qio.build.flash_mode=dio
@@ -380,6 +382,15 @@ lolin32.menu.FlashFreq.80.build.flash_freq=80m
380382
lolin32.menu.FlashFreq.40=40MHz
381383
lolin32.menu.FlashFreq.40.build.flash_freq=40m
382384

385+
lolin32.menu.PartitionScheme.default=Default
386+
lolin32.menu.PartitionScheme.default.build.partitions=default
387+
lolin32.menu.PartitionScheme.no_ota=No OTA (Large APP)
388+
lolin32.menu.PartitionScheme.no_ota.build.partitions=no_ota
389+
lolin32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
390+
lolin32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
391+
lolin32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
392+
lolin32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
393+
383394
lolin32.menu.UploadSpeed.921600=921600
384395
lolin32.menu.UploadSpeed.921600.upload.speed=921600
385396
lolin32.menu.UploadSpeed.115200=115200
@@ -964,6 +975,15 @@ mhetesp32devkit.menu.FlashFreq.80.build.flash_freq=80m
964975
mhetesp32devkit.menu.FlashFreq.40=40MHz
965976
mhetesp32devkit.menu.FlashFreq.40.build.flash_freq=40m
966977

978+
mhetesp32devkit.menu.PartitionScheme.default=Default
979+
mhetesp32devkit.menu.PartitionScheme.default.build.partitions=default
980+
mhetesp32devkit.menu.PartitionScheme.no_ota=No OTA (Large APP)
981+
mhetesp32devkit.menu.PartitionScheme.no_ota.build.partitions=no_ota
982+
mhetesp32devkit.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
983+
mhetesp32devkit.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
984+
mhetesp32devkit.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
985+
mhetesp32devkit.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
986+
967987
mhetesp32devkit.menu.UploadSpeed.921600=921600
968988
mhetesp32devkit.menu.UploadSpeed.921600.upload.speed=921600
969989
mhetesp32devkit.menu.UploadSpeed.115200=115200
@@ -979,6 +999,19 @@ mhetesp32devkit.menu.UploadSpeed.460800.upload.speed=460800
979999
mhetesp32devkit.menu.UploadSpeed.512000.windows=512000
9801000
mhetesp32devkit.menu.UploadSpeed.512000.upload.speed=512000
9811001

1002+
mhetesp32devkit.menu.DebugLevel.none=None
1003+
mhetesp32devkit.menu.DebugLevel.none.build.code_debug=0
1004+
mhetesp32devkit.menu.DebugLevel.error=Error
1005+
mhetesp32devkit.menu.DebugLevel.error.build.code_debug=1
1006+
mhetesp32devkit.menu.DebugLevel.warn=Warn
1007+
mhetesp32devkit.menu.DebugLevel.warn.build.code_debug=2
1008+
mhetesp32devkit.menu.DebugLevel.info=Info
1009+
mhetesp32devkit.menu.DebugLevel.info.build.code_debug=3
1010+
mhetesp32devkit.menu.DebugLevel.debug=Debug
1011+
mhetesp32devkit.menu.DebugLevel.debug.build.code_debug=4
1012+
mhetesp32devkit.menu.DebugLevel.verbose=Verbose
1013+
mhetesp32devkit.menu.DebugLevel.verbose.build.code_debug=5
1014+
9821015
##############################################################
9831016

9841017
mhetesp32minikit.name=MH ET LIVE ESP32MiniKit
@@ -1007,6 +1040,15 @@ mhetesp32minikit.menu.FlashFreq.80.build.flash_freq=80m
10071040
mhetesp32minikit.menu.FlashFreq.40=40MHz
10081041
mhetesp32minikit.menu.FlashFreq.40.build.flash_freq=40m
10091042

1043+
mhetesp32minikit.menu.PartitionScheme.default=Default
1044+
mhetesp32minikit.menu.PartitionScheme.default.build.partitions=default
1045+
mhetesp32minikit.menu.PartitionScheme.no_ota=No OTA (Large APP)
1046+
mhetesp32minikit.menu.PartitionScheme.no_ota.build.partitions=no_ota
1047+
mhetesp32minikit.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
1048+
mhetesp32minikit.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
1049+
mhetesp32minikit.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
1050+
mhetesp32minikit.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
1051+
10101052
mhetesp32minikit.menu.UploadSpeed.921600=921600
10111053
mhetesp32minikit.menu.UploadSpeed.921600.upload.speed=921600
10121054
mhetesp32minikit.menu.UploadSpeed.115200=115200
@@ -1022,6 +1064,19 @@ mhetesp32minikit.menu.UploadSpeed.460800.upload.speed=460800
10221064
mhetesp32minikit.menu.UploadSpeed.512000.windows=512000
10231065
mhetesp32minikit.menu.UploadSpeed.512000.upload.speed=512000
10241066

1067+
mhetesp32minikit.menu.DebugLevel.none=None
1068+
mhetesp32minikit.menu.DebugLevel.none.build.code_debug=0
1069+
mhetesp32minikit.menu.DebugLevel.error=Error
1070+
mhetesp32minikit.menu.DebugLevel.error.build.code_debug=1
1071+
mhetesp32minikit.menu.DebugLevel.warn=Warn
1072+
mhetesp32minikit.menu.DebugLevel.warn.build.code_debug=2
1073+
mhetesp32minikit.menu.DebugLevel.info=Info
1074+
mhetesp32minikit.menu.DebugLevel.info.build.code_debug=3
1075+
mhetesp32minikit.menu.DebugLevel.debug=Debug
1076+
mhetesp32minikit.menu.DebugLevel.debug.build.code_debug=4
1077+
mhetesp32minikit.menu.DebugLevel.verbose=Verbose
1078+
mhetesp32minikit.menu.DebugLevel.verbose.build.code_debug=5
1079+
10251080
#################################################################
10261081

10271082
esp32vn-iot-uno.name=ESP32vn IoT Uno
@@ -1037,7 +1092,7 @@ esp32vn-iot-uno.serial.disableRTS=true
10371092
esp32vn-iot-uno.build.mcu=esp32
10381093
esp32vn-iot-uno.build.core=esp32
10391094
esp32vn-iot-uno.build.variant=esp32vn-iot-uno
1040-
esp32vn-iot-uno.build.board=esp32vn-iot-uno
1095+
esp32vn-iot-uno.build.board=esp32vn_iot_uno
10411096

10421097
esp32vn-iot-uno.build.f_cpu=240000000L
10431098
esp32vn-iot-uno.build.flash_mode=dio
@@ -1134,7 +1189,7 @@ esp32-evb.serial.disableRTS=true
11341189
esp32-evb.build.mcu=esp32
11351190
esp32-evb.build.core=esp32
11361191
esp32-evb.build.variant=esp32-evb
1137-
esp32-evb.build.board=ESP32-EVB
1192+
esp32-evb.build.board=ESP32_EVB
11381193

11391194
esp32-evb.build.f_cpu=240000000L
11401195
esp32-evb.build.flash_mode=dio
@@ -1166,7 +1221,7 @@ esp32-gateway.serial.disableRTS=true
11661221
esp32-gateway.build.mcu=esp32
11671222
esp32-gateway.build.core=esp32
11681223
esp32-gateway.build.variant=esp32-gateway
1169-
esp32-gateway.build.board=ESP32-GATEWAY
1224+
esp32-gateway.build.board=ESP32_GATEWAY
11701225

11711226
esp32-gateway.build.f_cpu=240000000L
11721227
esp32-gateway.build.flash_mode=dio
@@ -1267,6 +1322,15 @@ m5stack-core-esp32.menu.FlashFreq.80.build.flash_freq=80m
12671322
m5stack-core-esp32.menu.FlashFreq.40=40MHz
12681323
m5stack-core-esp32.menu.FlashFreq.40.build.flash_freq=40m
12691324

1325+
m5stack-core-esp32.menu.PartitionScheme.default=Default
1326+
m5stack-core-esp32.menu.PartitionScheme.default.build.partitions=default
1327+
m5stack-core-esp32.menu.PartitionScheme.no_ota=No OTA (Large APP)
1328+
m5stack-core-esp32.menu.PartitionScheme.no_ota.build.partitions=no_ota
1329+
m5stack-core-esp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
1330+
m5stack-core-esp32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
1331+
m5stack-core-esp32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
1332+
m5stack-core-esp32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
1333+
12701334
m5stack-core-esp32.menu.UploadSpeed.921600=921600
12711335
m5stack-core-esp32.menu.UploadSpeed.921600.upload.speed=921600
12721336
m5stack-core-esp32.menu.UploadSpeed.115200=115200

cores/esp32/esp32-hal-misc.c

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "nvs.h"
2222
#include "esp_partition.h"
2323
#include "esp_log.h"
24-
#include "pthread.h"
24+
#include "esp_timer.h"
2525
#include <sys/time.h>
2626

2727
//Undocumented!!! Get chip temperature in Farenheit
@@ -38,51 +38,14 @@ void yield()
3838
vPortYield();
3939
}
4040

41-
portMUX_TYPE microsMux = portMUX_INITIALIZER_UNLOCKED;
42-
static pthread_key_t microsStore=NULL; // Thread Local Storage Handle
43-
44-
void microsStoreDelete(void * storage) { // release thread local data when task is delete.
45-
if(storage) free(storage);
46-
}
47-
4841
unsigned long IRAM_ATTR micros()
4942
{
50-
if (!microsStore) { // first Time Ever thread local not init'd
51-
portENTER_CRITICAL_ISR(&microsMux);
52-
pthread_key_create(&microsStore,microsStoreDelete); // create initial holder
53-
portEXIT_CRITICAL_ISR(&microsMux);
54-
}
55-
56-
uint32_t *ptr;// [0] is lastCount, [1] is overFlow
57-
58-
ptr = pthread_getspecific(microsStore); // get address of storage
59-
60-
if(ptr == NULL) { // first time in this thread, allocate mem, init it.
61-
portENTER_CRITICAL_ISR(&microsMux);
62-
ptr = (uint32_t*)malloc(sizeof(uint32_t)*2);
63-
pthread_setspecific(microsStore,ptr); // store the pointer to this thread's values
64-
ptr[0] = 0; // lastCount value
65-
ptr[1] = 0; // overFlow
66-
portEXIT_CRITICAL_ISR(&microsMux);
67-
}
68-
69-
unsigned long ccount;
70-
71-
portENTER_CRITICAL_ISR(&microsMux);
72-
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) ); //get cycle count
73-
if(ccount < ptr[0]) { // overflow occurred
74-
ptr[1] += UINT32_MAX / CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ;
75-
}
76-
77-
ptr[0] = ccount;
78-
portEXIT_CRITICAL_ISR(&microsMux);
79-
80-
return ptr[1] + (ccount / CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ);
43+
return (unsigned long) esp_timer_get_time();
8144
}
8245

8346
unsigned long IRAM_ATTR millis()
8447
{
85-
return xTaskGetTickCount() * portTICK_PERIOD_MS;
48+
return (unsigned long) (esp_timer_get_time() / 1000);
8649
}
8750

8851
void delay(uint32_t ms)

cores/esp32/esp32-hal-sigmadelta.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
6060
if(channel > 7) {
6161
return;
6262
}
63-
duty += 128;
63+
duty -= 128;
6464
SD_MUTEX_LOCK();
6565
SIGMADELTA.channel[channel].duty = duty;
6666
SD_MUTEX_UNLOCK();
@@ -72,7 +72,7 @@ uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
7272
return 0;
7373
}
7474
SD_MUTEX_LOCK();
75-
uint8_t duty = SIGMADELTA.channel[channel].duty - 128;
75+
uint8_t duty = SIGMADELTA.channel[channel].duty + 128;
7676
SD_MUTEX_UNLOCK();
7777
return duty;
7878
}

cores/esp32/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ void loopTask(void *pvParameters)
1414
{
1515
setup();
1616
for(;;) {
17-
micros(); //update overflow
1817
loop();
1918
}
2019
}

cores/esp32/pgmspace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ typedef unsigned long prog_uint32_t;
7171
#define memcpy_P memcpy
7272
#define strcpy_P strcpy
7373
#define strncpy_P strncpy
74-
#define strcat_p strcat
74+
#define strcat_P strcat
7575
#define strncat_P strncat
7676
#define strcmp_P strcmp
7777
#define strncmp_P strncmp

docs/arduino-ide/mac.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ Installation instructions for Mac OS
1313
cd tools && \
1414
python get.py
1515
```
16+
Where `~/Documents/Arduino` represents your sketch book location as per "Arduino" > "Preferences" > "Sketchbook location" (in the IDE once started). Adjust the command above accordingly if necessary!
17+
 
1618
- If you get the error below. Install the command line dev tools with xcode-select --install and try the command above again:
1719

18-
```xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun```
19-
20-
```xcode-select --install```
20+
```xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun```
21+
22+
```xcode-select --install```
2123

2224
- Restart Arduino IDE
2325

docs/esp-idf_component.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ If you are writing code that does not require Arduino to compile and you want yo
6868
#endif
6969
```
7070

71+
## Compilation Errors
72+
73+
As commits are made to esp-idf and submodules, the codebases can develop incompatibilities which cause compilation errors. If you have problems compiling, follow the instructions in [Issue #1142](https://github.com/espressif/arduino-esp32/issues/1142) to roll esp-idf back to a known good version.

libraries/AzureIoT

Submodule AzureIoT added at 67dfa4f

libraries/ESP32/examples/DeepSleep/ExternalWakeUp/ExternalWakeUp.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void setup(){
6969
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
7070

7171
//If you were to use ext1, you would use it like
72-
//esp_deep_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
72+
//esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
7373

7474
//Go to sleep now
7575
Serial.println("Going to sleep now");
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
3+
/* The ESP32 has four SPi buses, however as of right now only two of
4+
* them are available to use, HSPI and VSPI. Simply using the SPI API
5+
* as illustrated in Arduino examples will use HSPI, leaving VSPI unused.
6+
*
7+
* However if we simply intialise two instance of the SPI class for both
8+
* of these buses both can be used. However when just using these the Arduino
9+
* way only will actually be outputting at a time.
10+
*
11+
* Logic analyser capture is in the same folder as this example as
12+
* "multiple_bus_output.png"
13+
*
14+
* created 30/04/2018 by Alistair Symonds
15+
*/
16+
#include <SPI.h>
17+
18+
static const int spiClk = 1000000; // 1 MHz
19+
20+
//uninitalised pointers to SPI objects
21+
SPIClass * vspi = NULL;
22+
SPIClass * hspi = NULL;
23+
24+
void setup() {
25+
//initialise two instances of the SPIClass attached to VSPI and HSPI respectively
26+
vspi = new SPIClass(VSPI);
27+
hspi = new SPIClass(HSPI);
28+
29+
//clock miso mosi ss
30+
31+
//initialise vspi with default pins
32+
//SCLK = 18, MISO = 19, MOSI = 23, SS = 5
33+
vspi->begin();
34+
//alternatively route through GPIO pins of your choice
35+
//hspi->begin(0, 2, 4, 33); //SCLK, MISO, MOSI, SS
36+
37+
//initialise hspi with default pins
38+
//SCLK = 14, MISO = 12, MOSI = 13, SS = 15
39+
hspi->begin();
40+
//alternatively route through GPIO pins
41+
//hspi->begin(25, 26, 27, 32); //SCLK, MISO, MOSI, SS
42+
43+
//set up slave select pins as outputs as the Arduino API
44+
//doesn't handle automatically pulling SS low
45+
pinMode(5, OUTPUT); //VSPI SS
46+
pinMode(15, OUTPUT); //HSPI SS
47+
48+
}
49+
50+
// the loop function runs over and over again until power down or reset
51+
void loop() {
52+
//use the SPI buses
53+
vspiCommand();
54+
hspiCommand();
55+
delay(100);
56+
}
57+
58+
void vspiCommand() {
59+
byte data = 0b01010101; // junk data to illustrate usage
60+
61+
//use it as you would the regular arduino SPI API
62+
vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
63+
digitalWrite(5, LOW); //pull SS slow to prep other end for transfer
64+
vspi->transfer(data);
65+
digitalWrite(5, HIGH); //pull ss high to signify end of data transfer
66+
vspi->endTransaction();
67+
}
68+
69+
void hspiCommand() {
70+
byte stuff = 0b11001100;
71+
72+
hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
73+
digitalWrite(15, LOW);
74+
hspi->transfer(stuff);
75+
digitalWrite(15, HIGH);
76+
hspi->endTransaction();
77+
}
Loading

libraries/SPI/src/SPI.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SPIClass::SPIClass(uint8_t spi_bus)
3131
,_ss(-1)
3232
,_div(0)
3333
,_freq(1000000)
34-
, _inTransaction(false)
34+
,_inTransaction(false)
3535
{}
3636

3737
void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
@@ -109,6 +109,11 @@ void SPIClass::setClockDivider(uint32_t clockDiv)
109109
spiSetClockDiv(_spi, _div);
110110
}
111111

112+
uint32_t SPIClass::getClockDivider()
113+
{
114+
return spiGetClockDiv(_spi);
115+
}
116+
112117
void SPIClass::setDataMode(uint8_t dataMode)
113118
{
114119
spiSetDataMode(_spi, dataMode);

libraries/SPI/src/SPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class SPIClass
6060
void setDataMode(uint8_t dataMode);
6161
void setFrequency(uint32_t freq);
6262
void setClockDivider(uint32_t clockDiv);
63+
64+
uint32_t getClockDivider();
6365

6466
void beginTransaction(SPISettings settings);
6567
void endTransaction(void);

0 commit comments

Comments
 (0)