Skip to content

Commit 61cf742

Browse files
author
Chuck Todd
committed
Merge remote-tracking branch 'refs/remotes/espressif/master'
2 parents 90ff8bf + bac5609 commit 61cf742

File tree

171 files changed

+7460
-3839
lines changed

Some content is hidden

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

171 files changed

+7460
-3839
lines changed

cores/esp32/esp32-hal-bt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
1818

1919

20-
#include "bt.h"
20+
#include "esp_bt.h"
2121
#include "esp_bt_defs.h"
2222
#include "esp_bt_main.h"
2323

cores/esp32/esp32-hal-ledc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ static void _ledcSetupTimer(uint8_t chan, uint32_t div_num, uint8_t bit_num, boo
6868
#endif
6969
}
7070
LEDC_MUTEX_LOCK();
71-
LEDC_TIMER(group, timer).conf.div_num = div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
72-
LEDC_TIMER(group, timer).conf.bit_num = bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
71+
LEDC_TIMER(group, timer).conf.clock_divider = div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
72+
LEDC_TIMER(group, timer).conf.duty_resolution = bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
7373
LEDC_TIMER(group, timer).conf.tick_sel = apb_clk;//apb clock
7474
if(group) {
7575
LEDC_TIMER(group, timer).conf.low_speed_update = 1;//This bit is only useful for low speed timer channels, reserved for high speed timers
@@ -111,8 +111,8 @@ static double _ledcTimerRead(uint8_t chan)
111111
bool apb_clk;
112112
uint8_t group=(chan/8), timer=((chan/2)%4);
113113
LEDC_MUTEX_LOCK();
114-
div_num = LEDC_TIMER(group, timer).conf.div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
115-
bit_num = LEDC_TIMER(group, timer).conf.bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
114+
div_num = LEDC_TIMER(group, timer).conf.clock_divider;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
115+
bit_num = LEDC_TIMER(group, timer).conf.duty_resolution;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
116116
apb_clk = LEDC_TIMER(group, timer).conf.tick_sel;//apb clock
117117
LEDC_MUTEX_UNLOCK();
118118
uint64_t clk_freq = 1000000;

cores/esp32/pgmspace.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,33 @@ typedef unsigned long prog_uint32_t;
3737
#define _SFR_BYTE(n) (n)
3838

3939
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
40-
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
41-
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
42-
#define pgm_read_float(addr) (*(const float *)(addr))
40+
#define pgm_read_word(addr) ({ \
41+
typeof(addr) _addr = (addr); \
42+
*(const unsigned short *)(_addr); \
43+
})
44+
#define pgm_read_dword(addr) ({ \
45+
typeof(addr) _addr = (addr); \
46+
*(const unsigned long *)(_addr); \
47+
})
48+
#define pgm_read_float(addr) ({ \
49+
typeof(addr) _addr = (addr); \
50+
*(const float *)(_addr); \
51+
})
52+
#define pgm_read_ptr(addr) ({ \
53+
typeof(addr) _addr = (addr); \
54+
*(void * const *)(_addr); \
55+
})
4356

4457
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
4558
#define pgm_read_word_near(addr) pgm_read_word(addr)
4659
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
4760
#define pgm_read_float_near(addr) pgm_read_float(addr)
61+
#define pgm_read_ptr_near(addr) pgm_read_ptr(addr)
4862
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
4963
#define pgm_read_word_far(addr) pgm_read_word(addr)
5064
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
5165
#define pgm_read_float_far(addr) pgm_read_float(addr)
66+
#define pgm_read_ptr_far(addr) pgm_read_ptr(addr)
5267

5368
#define memcmp_P memcmp
5469
#define memccpy_P memccpy

docs/arduino-ide/windows.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
## Steps to install Arduino ESP32 support on Windows
2-
### Tested on 32 and 64 bit Windows 10 machines
3-
4-
1. Download and install the latest Arduino IDE ```Windows Installer``` from [arduino.cc](https://www.arduino.cc/en/Main/Software)
5-
2. Download and install Git from [git-scm.com](https://git-scm.com/download/win)
6-
3. Start ```Git GUI``` and run through the following steps:
7-
- Select ```Clone Existing Repository```
8-
9-
![Step 1](win-screenshots/win-gui-1.png)
10-
11-
- Select source and destination
12-
- Source Location: ```https://github.com/espressif/arduino-esp32.git```
13-
- Target Directory: ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32```
14-
- Change this to your Sketchbook Location if you have a different directory listed underneath the "Sketchbook location" in Arduino preferences.
15-
- Click ```Clone``` to start cloning the repository
16-
17-
![Step 2](win-screenshots/win-gui-2.png)
18-
![Step 3](win-screenshots/win-gui-3.png)
19-
20-
- Open ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools``` and double-click ```get.exe```
21-
22-
![Step 4](win-screenshots/win-gui-4.png)
23-
24-
- When ```get.exe``` finishes, you should see the following files in the directory
25-
26-
![Step 5](win-screenshots/win-gui-5.png)
27-
28-
4. Plug your ESP32 board and wait for the drivers to install (or install manually any that might be required)
29-
5. Start Arduino IDE
30-
6. Select your board in ```Tools > Board``` menu
31-
7. Select the COM port that the board is attached to
32-
8. Compile and upload (You might need to hold the boot button while uploading)
33-
34-
![Arduino IDE Example](win-screenshots/arduino-ide.png)
35-
36-
### How to update to the latest code
37-
38-
1. Start ```Git GUI``` and you should see the repository under ```Open Recent Repository```. Click on it!
39-
40-
![Update Step 1](win-screenshots/win-gui-update-1.png)
41-
42-
2. From menu ```Remote``` select ```Fetch from``` > ```origin```
43-
44-
![Update Step 2](win-screenshots/win-gui-update-2.png)
45-
46-
3. Wait for git to pull any changes and close ```Git GUI```
47-
4. Open ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools``` and double-click ```get.exe```
48-
49-
![Step 4](win-screenshots/win-gui-4.png)
1+
## Steps to install Arduino ESP32 support on Windows
2+
### Tested on 32 and 64 bit Windows 10 machines
3+
4+
1. Download and install the latest Arduino IDE ```Windows Installer``` from [arduino.cc](https://www.arduino.cc/en/Main/Software)
5+
2. Download and install Git from [git-scm.com](https://git-scm.com/download/win)
6+
3. Start ```Git GUI``` and run through the following steps:
7+
- Select ```Clone Existing Repository```
8+
9+
![Step 1](win-screenshots/win-gui-1.png)
10+
11+
- Select source and destination
12+
- Sketchbook Directory: Usually ```C:/Users/[YOUR_USER_NAME]/Documents/Arduino``` and is listed underneath the "Sketchbook location" in Arduino preferences.
13+
- Source Location: ```https://github.com/espressif/arduino-esp32.git```
14+
- Target Directory: ```[ARDUINO_SKETCHBOOK_DIR]/hardware/espressif/esp32```
15+
- Click ```Clone``` to start cloning the repository
16+
17+
![Step 2](win-screenshots/win-gui-2.png)
18+
![Step 3](win-screenshots/win-gui-3.png)
19+
- open a `Git Bash` session pointing to ```ARDUINO_SKETCHBOOK_DIR``` and execute ```git submodule update --init --recursive```
20+
- Open ```[ARDUINO_SKETCHBOOK_DIR]/hardware/espressif/esp32/tools``` and double-click ```get.exe```
21+
22+
![Step 4](win-screenshots/win-gui-4.png)
23+
24+
- When ```get.exe``` finishes, you should see the following files in the directory
25+
26+
![Step 5](win-screenshots/win-gui-5.png)
27+
28+
4. Plug your ESP32 board and wait for the drivers to install (or install manually any that might be required)
29+
5. Start Arduino IDE
30+
6. Select your board in ```Tools > Board``` menu
31+
7. Select the COM port that the board is attached to
32+
8. Compile and upload (You might need to hold the boot button while uploading)
33+
34+
![Arduino IDE Example](win-screenshots/arduino-ide.png)
35+
36+
### How to update to the latest code
37+
38+
1. Start ```Git GUI``` and you should see the repository under ```Open Recent Repository```. Click on it!
39+
40+
![Update Step 1](win-screenshots/win-gui-update-1.png)
41+
42+
2. From menu ```Remote``` select ```Fetch from``` > ```origin```
43+
44+
![Update Step 2](win-screenshots/win-gui-update-2.png)
45+
46+
3. Wait for git to pull any changes and close ```Git GUI```
47+
4. Open ```[ARDUINO_SKETCHBOOK_DIR]/hardware/espressif/esp32/tools``` and double-click ```get.exe```
48+
49+
![Step 4](win-screenshots/win-gui-4.png)

docs/platformio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Installation instructions for using PlatformIO
55

66
- [What is PlatformIO?](http://docs.platformio.org/page/what-is-platformio.html)
77
- [PlatformIO IDE](http://platformio.org/platformio-ide)
8-
- Quick Start with [PlatformIO IDE](http://docs.platformio.org/page/ide/atom.html#quick-start) or [PlatformIO Core](http://docs.platformio.org/page/core.html)
8+
- [PlatformIO Core (CLI)](http://docs.platformio.org/page/core.html)
99
- [Integration with Cloud and Standalone IDEs](http://docs.platformio.org/page/ide.html) -
1010
Cloud9, Codeanywehre, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM and Visual Studio
1111
- [Project Examples](https://github.com/platformio/platform-espressif32/tree/develop/examples)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <WiFi.h>
2+
#include "time.h"
3+
4+
const char* ssid = "YOUR_SSID";
5+
const char* password = "YOUR_PASS";
6+
7+
const char* ntpServer = "pool.ntp.org";
8+
const long gmtOffset_sec = 3600;
9+
const int daylightOffset_sec = 3600;
10+
11+
void printLocalTime()
12+
{
13+
struct tm timeinfo;
14+
if(!getLocalTime(&timeinfo)){
15+
Serial.println("Failed to obtain time");
16+
return;
17+
}
18+
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
19+
}
20+
21+
void setup()
22+
{
23+
Serial.begin(115200);
24+
25+
//connect to WiFi
26+
Serial.printf("Connecting to %s ", ssid);
27+
WiFi.begin(ssid, password);
28+
while (WiFi.status() != WL_CONNECTED) {
29+
delay(500);
30+
Serial.print(".");
31+
}
32+
Serial.println(" CONNECTED");
33+
34+
//init and get the time
35+
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
36+
printLocalTime();
37+
38+
//disconnect WiFi as it's no longer needed
39+
WiFi.disconnect(true);
40+
WiFi.mode(WIFI_OFF);
41+
}
42+
43+
void loop()
44+
{
45+
delay(1000);
46+
printLocalTime();
47+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "esp_system.h"
2+
3+
const int button = 0; //gpio to use to trigger delay
4+
const int wdtTimeout = 3000; //time in ms to trigger the watchdog
5+
hw_timer_t *timer = NULL;
6+
7+
void IRAM_ATTR resetModule() {
8+
ets_printf("reboot\n");
9+
esp_restart_noos();
10+
}
11+
12+
void setup() {
13+
Serial.begin(115200);
14+
Serial.println();
15+
Serial.println("running setup");
16+
17+
pinMode(button, INPUT_PULLUP); //init control pin
18+
timer = timerBegin(0, 80, true); //timer 0, div 80
19+
timerAttachInterrupt(timer, &resetModule, true); //attach callback
20+
timerAlarmWrite(timer, wdtTimeout * 1000, false); //set time in us
21+
timerAlarmEnable(timer); //enable interrupt
22+
}
23+
24+
void loop() {
25+
Serial.println("running main loop");
26+
27+
timerWrite(timer, 0); //reset timer (feed watchdog)
28+
long loopTime = millis();
29+
//while button is pressed, delay up to 3 seconds to trigger the timer
30+
while (!digitalRead(button)) {
31+
Serial.println("button pressed");
32+
delay(500);
33+
}
34+
delay(1000); //simulate work
35+
loopTime = millis() - loopTime;
36+
37+
Serial.print("loop time is = ");
38+
Serial.println(loopTime); //should be under 3000
39+
}

0 commit comments

Comments
 (0)