Compare commits

..

75 Commits

Author SHA1 Message Date
caef4006af Implement SigmaDelta based on ESP-IDF API (#6053)
Summary

This PR is refactoring of SigmaDelta HAL in order to use IDF instead of current Register manipulation approach.

Impact

Change in API:

uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq);
changed to -->
uint32_t sigmaDeltaSetup(uint8_t pin, uint8_t channel, uint32_t freq);

void sigmaDeltaAttachPin(uint8_t pin); removed, no longer needed. Pin is attached in sigmaDeltaSetup()
2021-12-22 16:41:52 +02:00
44fbde0189 Fixes Lib Builder compiling errors (#6052) 2021-12-22 14:37:40 +02:00
8c88ecbf77 add GPIO defines for C3 (#6005) 2021-12-22 14:36:54 +02:00
5724275cd8 fix tft feather pins for final version, qtpy spi pins, and add reversetft start (#6050)
SPI fix for QT Py, TFT fix for TFT Feather
2021-12-22 14:09:53 +02:00
1c94c38dbb IDF release/v4.4 a79dc75f0a (#6048) 2021-12-21 15:14:41 +02:00
7cf162346a RMT refactoring based on IDF (#6024)
Summary

RMT HAL refactoring based on IDF.

Impact

Improves RMT by adding IDF v4.4 support.
Receiving RMT can handle any size of data.
rmtInit() has a new parameter - RxBufferSize - to hold any number of data when receiving RMT.
rmtWrite() has a new parameter - wait_tx_done - to block writing until sending all data.

Related links

fix #5905
2021-12-21 15:02:40 +02:00
c66c7fe27e [Examples] README revision to include missing and remove old entries (#6049) 2021-12-21 15:00:37 +02:00
7ba11cc1ae [Docs] Added USB documentation (#6036)
Summary

Added USB documentation.

Closes: #5784
2021-12-21 12:51:38 +02:00
c3d41c9b54 Fixes baudrate with CPU Freq < 80MHz (#6037)
This PR fixes an issue with UART when CPUFreq is lower than 80MHz (APB Freq)
2021-12-21 10:10:31 +02:00
d6934a5289 Implement LEDC based on ESP-IDF API (#6045)
This PR is refactoring of LEDC HAL in order to use IDF instead of current Register manipulation approach.
Fixing duty -> if all bits in resolution are set -> FULL ON
2021-12-20 14:58:49 +02:00
6b90627b21 HID_BRAILLE_DISPLAY (#6043)
23 Braille Display Page (0x41)
Braille display allow visually impaired computer users to read out text using raised pins. The pins are electro-mechanically
activated. These devices also have support for controls that help navigate the computer screen. Typically, braille displays
interface with software known as a screen reader in order to perform this navigation.
2021-12-20 13:22:58 +02:00
063119ac87 fix variant wt32-eth01 (initializer not constant) (#6040)
fix not constant definitions in variant wt32-eth01 (error: initializer element is not constant)
2021-12-20 13:21:53 +02:00
7b96374ea6 [Fix] Added the Win32 not supported notice/warning (#6031)
Related to:
#6012
#5994
#5991
2021-12-20 13:11:22 +02:00
82ec74a072 Adds support to change LoopTask Stack size (#6025)
## Summary
Arduino ```setup()``` and ```loop()``` run under a Task with a fixed Stack size of 8KB.
Users may want to change this size.

This PR adds this possibility by just adding a line of code, as for example:
``` dart
ESP_LOOP_TASK_STACK_SIZE(16384);

void setup() { 
}

void loop() { 
}
```
## Impact
None. It adds a new functionality to ESP32 Arduino.
If ```ESP_LOOP_TASK_STACK_SIZE(newSize);``` is not declared/used, it will compile the sketch with the default stack size of 8KB.

## Related links
fix #6010 

https://github.com/espressif/arduino-esp32/issues/6010#issuecomment-992701658
Thanks @igrr for the suggestion!
2021-12-20 13:10:36 +02:00
5940d89e67 Fix wrongly applied patch to WiFi STA Init 2021-12-20 10:17:25 +02:00
bb09615391 Fix Arduino Core config for ESP32-S2
Fixes: https://github.com/espressif/arduino-esp32/issues/6019
2021-12-20 10:11:53 +02:00
c2c8d18992 Forces UART Flush() to wait until all bits are sent (#6026)
HardwareSerial flush() was returning before all data was sent out through serial port.
This is a problem to some RS485 libraries that depend on it to signaling.

This PR solves the issue by forcing it to block flush() until all data is sent.
2021-12-15 11:08:49 +02:00
39b9e1e533 Implement DAC based on ESP-IDF API (#5959)
This PR is refactoring of DAC HAL in order to use IDF instead of current Register manipulation approach.

Edited dacWrite() to use ESP-IDF api.
Added dacDisable() so there is an option to disable dac channel.

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2021-12-14 21:10:30 +02:00
40a5c1e461 Change default WiFi encryption to WIFI_AUTH_WPA2_PSK (#6022)
Fixes: https://github.com/espressif/arduino-esp32/issues/6020
2021-12-14 20:07:08 +02:00
2981bde88f Add some more adafruit boards and fix some board typos (#6014)
Co-authored-by: caternuson <caternuson@gmail.com>
Co-authored-by: Kattni Rembor <kattni@adafruit.com>
Co-authored-by: Jeff Epler <jeff@adafruit.com>
Co-authored-by: Jeff Epler <jepler@gmail.com>
Co-authored-by: Ha Thach <thach@tinyusb.org>
2021-12-14 18:17:04 +02:00
6d400df952 IDF release/v4.4 f23dcd3555 (#5996)
esp-dsp: master 6b25cbb
esp-face: master d141502
esp-rainmaker: f1b82c7
esp32-camera: master 61400bc
esp_littlefs: master 3c29afc
2021-12-14 16:38:06 +02:00
7bb30b3cf8 Refactoring TwoWire::requestFrom() headers in Wire.cpp (#5935)
* Refactoring function headers

Changing the header so the main TwoWire::requestFrom() definition uses a `size_t` instead of a `uint8_t`, removing the 255 bytes limit on I2C requests.

Co-authored-by: Flaviu Tamas <me@flaviutamas.com>
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2021-12-14 16:25:01 +02:00
4b638de19d using ksz8081 only from ESP-IDF 4.4 onwards (#5918)
* using ksz8081 only from ESP-IDF 4.4 onwards

The previous assertion only considerate the existance of ESP-IDF 4.3, but with the ESP-IDF 4.3.1 release this assertion would generate errors. Now only includes from ESP-IDF 4.4 onwards.

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2021-12-14 16:09:01 +02:00
2463f57246 Adding Issue and Feature template (#5999)
Summary

This PR contains adding:

Issue template using forms
Feature Template using forms
Update of Pull Request template
All yaml files have been checked by online validator.

Pages are rendered here (for easier review):
Feature Request template
Issue Template

Impact

These templates can help with more accurate issue/PR explanations which can improve handling these contribution and in overall have a positive influence on User experience.

Related links

This PR closed issue #5956
2021-12-14 16:05:36 +02:00
f29f4485b5 Fix memory leaks when SSL/TLS connection fails (#5945) 2021-12-14 15:59:26 +02:00
8a8f87d3a0 Fix for BluetoothSerial build when using nimBLE instead of Bluedroid (#5920) 2021-12-14 15:56:25 +02:00
082491d552 Add DPU ESP32 (#5884)
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2021-12-14 15:53:09 +02:00
794de50bf4 Migrate MD5Builder to use esp_rom functions directly rather than rely on wrappers that can be omitted from compilation based on sdkconfig. (#5941) 2021-12-14 15:49:43 +02:00
5e7db8dfac Timer based od ESP-IDF (#5931) 2021-12-14 15:46:39 +02:00
fb00b51f99 [DOCS] Writing a new Arduino documentation about GPIO (#5894)
* add new documation GPIO

Co-authored-by: pedro.minatel <pedro.minatel@espressif.com>
2021-12-14 15:39:54 +02:00
5dc8fb83c9 add board and variant for WT32-ETH01 (variant wt32-eth01) from Wireless-Tag (#5946)
- supports the WiFi/Ethernet board with WT32-S1 module and LAN8720A Ethernet PHY
- documentation available at http://www.wireless-tag.com/portfolio/wt32-eth01/
2021-12-14 15:37:59 +02:00
cb25fe8c7e Don't clear headers on redirect (#5973)
Current implementation clears _headers when request was sent. If the
user added custom request headers, they will be lost and the redirected
request will not contain them. This commit changes the scope of cleanup
so that the headers survive redirects but don't survive connection
reuse.
2021-12-14 15:37:31 +02:00
f5b04b9197 Use WIFI_FAST_SCAN if a specific channel was used (#5975)
1.0.6 changed scanning method to always scan all available channels during connect. This results in results in connect taking about ~3 seconds instead of ~1. This patch changes the behavior to use WIFI_FAST_SCAN if client used a specific channel.
2021-12-14 15:37:00 +02:00
8c5d18dd85 Merged all TTGO-LoRa32 Board profiles (see #5933) (#5961)
* Merged all TTGO-LoRa32 Board profiles (see #5933)

* Fix for LORA_RST (see #5966)
2021-12-14 14:55:55 +02:00
fa03966fcf [Feature] Added Sonoff DUALR3 support with RainMaker example (#5980)
* [Feature] Added Sonoff DUALR3 support with RainMaker example

* [Feature] Added skip files for C3 and S2
2021-12-14 14:35:10 +02:00
3750b14d74 Prevent self hosted jobs to run on forks. (#5983)
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-12-14 14:26:59 +02:00
cebac569de Update Boards.txt (#5984)
fix boad error : "--elf-gcc.path}/bin/--elf-g++": file does not exist
and fix follow esp32 dev module
2021-12-14 14:26:10 +02:00
d0e73bd269 .github/workflows: Update checkout and setup-python actions to their V2 (#5985)
(latest) version.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-12-14 14:25:11 +02:00
26dddc5f94 Fix the execute bit of some files. (#5986)
- Remove the execute bit from source and text files.
- on-pages.sh script needs the execute bit to be set.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-12-14 14:24:44 +02:00
c87ede88df Delete .travis.yml file. (#5987)
All the workflows are now migrated to Github Actions.
Update the on-push.sh script to remove references to TravisCI variables.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-12-14 14:24:01 +02:00
c90dffef44 Edit sd_diskio to check card status (#5988) 2021-12-14 14:22:30 +02:00
1945fae795 update boards.txt for adafruit feather esp32s2 (#6006)
also update tinyuf2 bootloader for adafruit boards to 0.6.2
2021-12-14 13:58:18 +02:00
6e0b57784f [Docs] Update on the Windows install procedures (#6018) 2021-12-14 13:56:26 +02:00
399f4ecbb3 [DOCS] Editing usage of Arduino as a component in ESP-IDF (#5896)
* Editing esp-idf_component docs

* Changed idt to ESP-IDF

Co-authored-by: Pedro Minatel <pminatel@gmail.com>
2021-11-22 13:37:06 +00:00
a5002c86a0 IDF release/v4.4 ddc44956bf (#5911)
esp-dsp: master 6b25cbb
esp-face: master 859f32a
esp-rainmaker: f1b82c7
esp32-camera: master 61400bc
esp_littlefs: master 3c29afc
2021-11-22 15:02:37 +02:00
c9916c463f Fix I2C clock stretching issue with ESP32 (#5910)
It was found that when I2C device is holding the clock LOW, ESP32 master is failing to wait for the clock to be released.

Fixes: #5875
Fixes: sparkfun/SparkFun_u-blox_GNSS_Arduino_Library#77
2021-11-19 18:43:59 +02:00
bd2be80b54 cbuf: allow inheritance (#5883)
changes "private" vars to "protected" so that descendants are allowed to access them.
2021-11-18 14:25:04 +02:00
6f1f394680 Update boards.txt (#5903) 2021-11-18 13:58:03 +02:00
5de09a9a49 [Docs] Add link to supported soc list on README and ESP32-S3 datasheet (#5891)
* [Docs] Added the supported SoC table link on the README file

* [Docs] Added the ESP32-S3 datasheet link to the getting started page
2021-11-15 15:19:28 +00:00
b94b38c9d1 Fix compiler.libraries.ldflags Option (#5866)
I misplaced the additions.
2021-11-09 17:01:21 +02:00
d218e58f96 Update package_esp32_index.template.json 2021-11-09 10:47:31 +02:00
14ece43654 Update README.md 2021-11-09 10:41:20 +02:00
ae7173d4d5 cmake: error out of IDF version is outside of supported range 2021-11-09 10:31:46 +02:00
c7080b0a83 ci: run CMake in script mode when finding source files 2021-11-09 10:31:11 +02:00
96c184d213 Add basic analogWrite support based on LEDC (#5861) 2021-11-09 10:26:41 +02:00
da72bc90b7 eliminates error messages when using Ethernet Static IP (#5836)
Summary

Only affects ETH (not WiFi)

This PR solves #5733 by allowing the DHCP IDF server to complete its tasks and only then it sets a static IP.
This also solves another related failure reported in this issue (#5733 (comment)).

fix #5733

Impact

Adds a delay in order to wait for DHCP to actually terminate before setting the static IP configuration in ETH.
2021-11-09 10:23:29 +02:00
16a9cf781f Add another Wire requestFrom function signature (#5768)
* Re-add with clean master

* Address @me-no-dev's comments

* static_cast<size_t> to static_cast<uint8_t>
2021-11-08 14:29:04 +02:00
b1497fb257 [Docs] Peripheral list updated to include all supported SoCs (#5851) 2021-11-08 12:36:06 +02:00
5e04eb48b6 Add precompiled (#5854)
Added an option for using precompiled libraries.

Empty if there is no precompilation.

```
compiler.libraries.ldflags=
```

Compiler Message when there is precompilation.

```
Compiling libraries...
Compiling library "aquestalk-esp32"
Library aquestalk-esp32 has been declared precompiled:
Using precompiled library in C:\Users\tanaka\Documents\Arduino\libraries\aquestalk-esp32\src\esp32
```

The precompiler cannot be used because it is not set up now.
2021-11-08 12:13:45 +02:00
674cf812e7 [FEATURE] add -D ARDUINO_PARTITION_xxx build flag to platform.txt (#5804)
* [FEATURE]  ARDUINO_PARTITION_xxx build flag

Proposition: adding `-DARDUINO_PARTITION_{build.partitions}` flag to make the build partition information available at compile time.

Use cas example:

```C
#if defined ARDUINO_PARTITION_default
  // prevent compilation
  #error "This sketch needs 'Minimal SPIFFS' partition scheme to compile" 
  // or disable sketch features that need flash space
  #define USE_HUGE_BITMAP_IMAGES false
#endif
```

* Adding -DARDUINO_PARTITION_{build.partitions} (see #5804)
2021-11-06 13:58:48 +02:00
83884a0cda Fix SparkFun MicroMod compilation issues
Fixes: https://github.com/espressif/arduino-esp32/issues/5818
2021-11-04 19:18:31 +02:00
80b8262595 Update esp-idf_component.rst 2021-11-04 17:21:44 +01:00
5747bfab67 Merge branch 'master' of https://github.com/espressif/arduino-esp32 2021-11-04 16:59:11 +01:00
4b9dc61447 Solving *"wifi:channel=0 is invalid"* when using FTM example code (#5809)
When using the FTM examples I got an error in the FTM_Initiator.ino:

*"wifi:channel=0 is invalid"*

I solved it for myself by simply passing the channel argument to be 1 in *WiFi.initiateFTM*. However, a better fix would be to directly change the default channel here.
2021-11-04 16:08:50 +02:00
a2d7c0dcf6 [Examples] WiFi and Ethernet examples organization (#5830)
* examples: WiFi and Ethernet examples organization

* examples: Change on CI scripts to include new folder

* Library name reverted to WiFi

* examples: WiFi and Ethernet examples organization in a new folder

* examples: Eth files moved from WiFi to Ethernet lib and CMakeLists updated
2021-11-04 16:08:08 +02:00
666cd3cde5 [Docs] Added I2C driver docs (#5770)
* Added I2C driver docs
docs: Changes on the images and added more details about the I2C slave

* docs: Added slaveWrite description and added docs build folder to the gitignore file
2021-11-04 14:32:05 +02:00
3e851b537a [Docs] Added useStaticBuffers function description (#5820)
* docs: Added useStaticBuffers function description

* docs: Default useStaticBuffers configuration in highlight
2021-11-04 14:30:16 +02:00
f410728444 docs: Added supported peripherals list on libraries section (#5829) 2021-11-04 14:29:42 +02:00
79e0889a16 Allow use of log_x() in if (#5844)
if (1) log_e("error") produces a warning ("missing braces") and probably wrong code if no log level is defined.
This fixes that.
2021-11-04 14:25:44 +02:00
4aff6dde39 Support additional authorization schemes (#5845)
The client always appends "Basic" to the authorization header, however there are other auth schemes that can be used: https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
For example "Bearer" when using OAuth.
This PR adds a `setAuthorizationType` method to the HTTPClient which allows this scheme to be configured by the caller. Authorization type is set to "Basic" by default so this will have no impact on existing usecases.
2021-11-04 14:25:12 +02:00
bb50046540 Fix double promotion in Stream::parseFloat() (#5846) 2021-11-04 14:24:28 +02:00
10258b4cc2 fix double promotions in rmtSetTick() (#5847) 2021-11-04 14:24:14 +02:00
418ac74be0 IDF release/v4.4 6a7d83af19
* Update toolchain to 2021r2 (#5828)
* Update C3 libs to support only ECO3 and newer
2021-11-04 14:22:34 +02:00
caa8d07aaf yay for esp32-s2 mini module with PSRAM :) (#5811) 2021-10-26 22:26:32 +03:00
0f174aae88 Update stale.yml 2021-09-30 17:12:45 +02:00
639 changed files with 16451 additions and 4071 deletions

View File

@ -0,0 +1,54 @@
name: Feature request
description: Suggest an idea for this project
labels: ["Type: Feature request"]
body:
- type: markdown
attributes:
value: |
* We welcome any ideas or feature requests! It is helpful if you can explain exactly why the feature would be useful.
* There are usually some outstanding feature requests in the [existing issues list](https://github.com/espressif/arduino-esp32/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature+request%22), feel free to add comments to them.
* If you would like to contribute, please read the [contributions guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html).
- type: input
id: Area
attributes:
label: Related area
description: Please briefly explain the area of your Feature Request.
placeholder: eg. Board support, specific Peripheral, BT, Wifi...
validations:
required: true
- type: input
id: HW
attributes:
label: Hardware specification
description: Please provide if your proposal depends on specific Hardware.
placeholder: eg. Support for ESP32 DevKitC, ESP32-C3 DevKitM...
validations:
required: true
- type: textarea
id: problem-related
attributes:
label: Is your feature request related to a problem?
description: Please provide a clear and concise description of what the problem is. Add relevant issue link.
placeholder: ex. I'm facing the issue/missing function...
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe the solution you'd like
description: Please provide a clear and concise description of what you want to happen.
placeholder: ex. When using this function...
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Describe alternatives you've considered
description: Please provide a clear and concise description of any alternative solutions or features you've considered.
placeholder: ex. Choosing other approach wouldn't work, because...
- type: textarea
id: context
attributes:
label: Additional context
description: Please add any other context or screenshots about the feature request here.
placeholder: ex. This would work only when ...

130
.github/ISSUE_TEMPLATE/Issue-report.yml vendored Normal file
View File

@ -0,0 +1,130 @@
name: Issue report
description: Report any problem here
labels: ["Status: Awaiting triage"]
body:
- type: markdown
attributes:
value: |
* Before reporting a new issue please check and search in [List of existing issues](https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue)
* Please check [Online Documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/index.html)
* Take a look on [Troubleshooting guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html)
* If still experiencing the issue, please provide as many details as possible below about your hardware, computer setup and code.
- type: input
id: Board
attributes:
label: Board
description: On which Board does this issue occur?
placeholder: eg. ESP32 Dev Module, ESP32-S2, LilyGo TTGO LoRa32...
validations:
required: true
- type: textarea
id: devboard
attributes:
label: Device Description
description: What development board or other hardware is the chip attached to?
placeholder: ex. DevKitC, plain module on breadboard, etc. If your hardware is custom or unusual, please attach a photo.
validations:
required: true
- type: textarea
id: other-hw
attributes:
label: Hardware Configuration
description: Is anything else attached to the development board?
placeholder: ex. GPIO 18 & 19 are connected to I2C devices.
validations:
required: true
- type: dropdown
id: version
attributes:
label: Version
description: What version of Arduino ESP32 are you running? If possible, consider updating to the latest version.
options:
- latest master
- v2.0.1
- v2.0.0
- v1.0.6
- other
validations:
required: true
- type: input
id: IDE
attributes:
label: IDE Name
description: What IDE are you using?
placeholder: eg. Arduino IDE, PlatformIO, IDF component...
validations:
required: true
- type: input
id: os
attributes:
label: Operating System
description: On which OS does this issue occur?
placeholder: ex. macOS 12.1, Windows 10...
validations:
required: true
- type: input
id: Flash
attributes:
label: Flash frequency
description: What flash frequency is used?
placeholder: eg. 40Mhz
validations:
required: true
- type: dropdown
id: PSRAM
attributes:
label: PSRAM enabled
description: Is PSRAM enabled?
options:
- 'yes'
- 'no'
validations:
required: true
- type: input
id: Upload
attributes:
label: Upload speed
description: What upload speed is used?
placeholder: eg. 115200
validations:
required: true
- type: textarea
id: Description
attributes:
label: Description
description: Please describe your problem here and expected behaviour
placeholder: ex. Can't connect/weird behaviour/wrong function/missing parameter..
validations:
required: true
- type: textarea
id: sketch
attributes:
label: Sketch
description: Please provide your sketch/code which was run
placeholder: ex. related part of the code
render: cpp
validations:
required: true
- type: textarea
id: Debug
attributes:
label: Debug Message
description: Please provide a debug message or error message. If you have a Guru Meditation Error or Backtrace, please decode it with [ExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder)
placeholder: Enable Core debug level - Debug on tools menu of Arduino IDE, then put the serial output here.
render: plain
validations:
required: true
- type: textarea
id: other-remarks
attributes:
label: Other Steps to Reproduce
description: Is there any other information you can think of which will help us reproduce this problem? Any additional info can be added as well.
placeholder: ex. I also tried on other OS, HW...it works correctly on that setup.
- type: checkboxes
id: confirmation
attributes:
label: I have checked existing issues, online documentation and the Troubleshooting Guide
description: You agree to check all the resources above before opening a new issue.
options:
- label: I confirm I have checked existing issues, online documentation and Troubleshooting guide.
required: true

View File

@ -1,54 +0,0 @@
---
name: Bug report
about: Please fill in the bug report carefully
title: ''
labels: ''
assignees: ''
---
Make your question, not a Statement, inclusive. Include all pertinent information:
What you are trying to do?
Describe your system( Hardware, computer, O/S, core version, environment).
Describe what is failing.
Show the shortest possible code that will duplicate the error.
Show the EXACT error message(it doesn't work is not enough).
All of this work on your part shows us that you have worked to solve YOUR problem. The more complete your issue posting is, the more likely someone will volunteer their time to help you.
If you have a Guru Meditation Error or Backtrace, ***please decode it***:
https://github.com/me-no-dev/EspExceptionDecoder
----------------------------- Remove above -----------------------------
### Hardware:
Board: ?ESP32 Dev Module? ?node32? ?ttgo_lora?
Core Installation version: ?1.0.0? ?1.0.1-rc4? ?1.0.1? ?1.0.1-git? ?1.0.2? ?1.0.3?
IDE name: ?Arduino IDE? ?Platform.io? ?IDF component?
Flash Frequency: ?40Mhz?
PSRAM enabled: ?no? ?yes?
Upload Speed: ?115200?
Computer OS: ?Windows 10? ?Mac OSX? ?Ubuntu?
### Description:
Describe your problem here
### Sketch: (leave the backquotes for [code formatting](https://help.github.com/articles/creating-and-highlighting-code-blocks/))
```cpp
//Change the code below by your sketch
#include <Arduino.h>
void setup() {
}
void loop() {
}
```
### Debug Messages:
```
Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here
```

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Arduino ESP32 Gitter Channel
url: https://gitter.im/espressif/arduino-esp32
about: Community channel for questions and help
- name: ESP32 Forum - Arduino
url: https://esp32.com/viewforum.php?f=19
about: Official Forum for questions

View File

@ -1,16 +1,18 @@
----------------------------------------------------------------------------------------------------------------------------------------------------
This entire section can be deleted if all items are checked.
*By completing this PR sufficiently, you help us to improve the quality of Release Notes*
### Checklist
1. [ ] Please provide specific title of the PR describing the change, including the component name (eg."Update of Documentation link on Readme.md")
1. [ ] Please provide specific title of the PR describing the change, including the component name (eg. *„Update of Documentation link on Readme.md“*)
2. [ ] Please provide related links (eg. Issue, other Project, submodule PR..)
----------------------------------------------------------------------------------------------------------------------------------------------------
3. [ ] Please check [Contributing guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html)
*This entire section above can be deleted if all items are checked.*
-----------
## Summary
Please describe your proposed PR and what it contains.
## Impact
Please describe impact of your PR and it's function.
## Related links
Please provide links to related issue, PRs etc.

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# This script is for Travis. It checks all non-examples source files in libraries/ and cores/ are listed in
# This script is used in the CI workflow. It checks all non-examples source files in libraries/ and cores/ are listed in
# CMakeLists.txt for the cmake-based IDF component
#
# If you see an error running this script, edit CMakeLists.txt and add any new source files into your PR
@ -15,7 +15,7 @@ git submodule update --init --recursive
REPO_SRCS=`find cores/esp32/ libraries/ -name 'examples' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort`
# find all source files named in CMakeLists.txt COMPONENT_SRCS
CMAKE_SRCS=`cmake --trace-expand -C CMakeLists.txt 2>&1 | grep set\(srcs | cut -d'(' -f3 | sed 's/ )//' | sed 's/srcs //' | tr ' ;' '\n' | sort`
CMAKE_SRCS=`cmake --trace-expand -P CMakeLists.txt 2>&1 | grep set\(srcs | cut -d'(' -f3 | sed 's/ )//' | sed 's/srcs //' | tr ' ;' '\n' | sort`
if ! diff -u0 --label "Repo Files" --label "srcs" <(echo "$REPO_SRCS") <(echo "$CMAKE_SRCS"); then
echo "Source files in repo (-) and source files in CMakeLists.txt (+) don't match"

0
.github/scripts/on-pages.sh vendored Normal file → Executable file
View File

View File

@ -2,18 +2,7 @@
set -e
if [ ! -z "$TRAVIS_TAG" ]; then
echo "Skipping Test: Tagged build"
exit 0
fi
if [ ! -z "$GITHUB_WORKSPACE" ]; then
export TRAVIS_BUILD_DIR="$GITHUB_WORKSPACE"
export TRAVIS_REPO_SLUG="$GITHUB_REPOSITORY"
elif [ ! -z "$TRAVIS_BUILD_DIR" ]; then
export GITHUB_WORKSPACE="$TRAVIS_BUILD_DIR"
export GITHUB_REPOSITORY="$TRAVIS_REPO_SLUG"
else
if [ -z "$GITHUB_WORKSPACE" ]; then
export GITHUB_WORKSPACE="$PWD"
export GITHUB_REPOSITORY="espressif/arduino-esp32"
fi

79
.github/stale.yml vendored
View File

@ -1,61 +1,26 @@
# Configuration for probot-stale - https://github.com/probot/stale
# This workflow firstly warns and then closes issues that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information can be found here: https://github.com/actions/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 60
name: Mark stale issues
on:
schedule:
- cron: '30 9 * * *'
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 14
jobs:
stale:
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []
runs-on: ubuntu-latest
permissions:
issues: write
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- "Type: For reference"
- "Type: To be implemented"
- "Type: Feature request"
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false
# Label to use when marking as stale
staleLabel: "Status: Stale"
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
[STALE_SET] This issue has been automatically marked as stale because it has not had
recent activity. It will be closed in 14 days if no further activity occurs. Thank you
for your contributions.
# Comment to post when removing the stale label.
unmarkComment: >
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
# Limit to only `issues` or `pulls`
only: issues
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.
# issues:
# exemptLabels:
# - confirmed
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.'
days-before-stale: 60
days-before-close: 14
exempt-issue-labels: 'Type: For reference,Type: To be implemented,Type: Feature request'
stale-issue-label: 'Status: Stale'

View File

@ -16,7 +16,7 @@ jobs:
name: Build GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Copy Files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -18,8 +18,8 @@ jobs:
chunk: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Build Sketches
@ -34,8 +34,8 @@ jobs:
os: [windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Build Sketches
@ -50,8 +50,8 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Build Sketches

View File

@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v1
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Build Release

View File

@ -10,6 +10,7 @@ jobs:
build:
name: Dummy test - self hosted GHR
runs-on: self-hosted
if: github.repository == 'espressif/arduino-esp32'
steps:
- name: Check out repo
uses: actions/checkout@v2

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ boards.sloeber.txt
# Ignore docs build (Sphinx)
docs/build
docs/source/_build

View File

@ -1,55 +0,0 @@
sudo: false
language: python
os:
- linux
git:
depth: false
before_install:
- git submodule update --init --recursive
stages:
- build
- deploy
jobs:
include:
- name: "Build Arduino 0"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 0 10
- name: "Build Arduino 1"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 1 10
- name: "Build Arduino 2"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 2 10
- name: "Build Arduino 3"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 3 10
- name: "Build PlatformIO"
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
stage: build
script: $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh 1 1
notifications:
email:
on_success: change
on_failure: change
webhooks:
urls:
- https://webhooks.gitter.im/e/cb057279c430d91a47a8
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always

View File

@ -1,3 +1,27 @@
# Check ESP-IDF version and error out if it is not in the supported range.
#
# Note for arduino-esp32 developers: to bypass the version check locally,
# set ARDUINO_SKIP_IDF_VERSION_CHECK environment variable to 1. For example:
# export ARDUINO_SKIP_IDF_VERSION_CHECK=1
# idf.py build
set(min_supported_idf_version "4.4.0")
set(max_supported_idf_version "4.4.99")
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
if (idf_version VERSION_LESS min_supported_idf_version)
message(FATAL_ERROR "Arduino-esp32 can be used with ESP-IDF versions "
"between ${min_supported_idf_version} and ${max_supported_idf_version}, "
"but an older version is detected: ${idf_version}.")
endif()
if (idf_version VERSION_GREATER max_supported_idf_version)
message(FATAL_ERROR "Arduino-esp32 can be used with ESP-IDF versions "
"between ${min_supported_idf_version} and ${max_supported_idf_version}, "
"but a newer version is detected: ${idf_version}.")
endif()
endif()
set(CORE_SRCS
cores/esp32/base64.cpp
cores/esp32/cbuf.cpp
@ -55,6 +79,7 @@ set(LIBRARY_SRCS
libraries/DNSServer/src/DNSServer.cpp
libraries/EEPROM/src/EEPROM.cpp
libraries/ESPmDNS/src/ESPmDNS.cpp
libraries/Ethernet/src/ETH.cpp
libraries/FFat/src/FFat.cpp
libraries/FS/src/FS.cpp
libraries/FS/src/vfs_api.cpp
@ -91,7 +116,6 @@ set(LIBRARY_SRCS
libraries/WebServer/src/detail/mimetable.cpp
libraries/WiFiClientSecure/src/ssl_client.cpp
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
libraries/WiFi/src/ETH.cpp
libraries/WiFi/src/WiFiAP.cpp
libraries/WiFi/src/WiFiClient.cpp
libraries/WiFi/src/WiFi.cpp

View File

@ -1,26 +1,15 @@
# Arduino core for the ESP32
# Arduino core for the ESP32, ESP32-S2 and ESP32-C3
[![Build Status](https://travis-ci.org/espressif/arduino-esp32.svg?branch=master)](https://travis-ci.org/espressif/arduino-esp32) ![](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![Documentation Status](https://readthedocs.com/projects/espressif-arduino-esp32/badge/?version=latest)](https://docs.espressif.com/projects/arduino-esp32/en/latest/?badge=latest)
![Build Status](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![Documentation Status](https://readthedocs.com/projects/espressif-arduino-esp32/badge/?version=latest)](https://docs.espressif.com/projects/arduino-esp32/en/latest/?badge=latest)
### Need help or have a question? Join the chat at [![https://gitter.im/espressif/arduino-esp32](https://badges.gitter.im/espressif/arduino-esp32.svg)](https://gitter.im/espressif/arduino-esp32?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Contents
- [ESP32-S2 and ESP32-C3 Support](#esp32-s2-and-esp32-c3-support)
- [Development Status](#development-status)
- [Decoding Exceptions](#decoding-exceptions)
- [Issue/Bug report template](#issuebug-report-template)
### ESP32-S2 and ESP32-C3 Support
If you want to test ESP32-S2 and/or ESP32-C3 through the board manager, please use the development release link:
```
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
```
Now you can install the latest 2.0.0 version from the boards manager.
### Development Status
Latest Stable Release [![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Release Date](https://img.shields.io/github/release-date/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/espressif/arduino-esp32/latest/total.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/)
@ -38,6 +27,10 @@ You can use [Arduino-ESP32 Online Documentation](https://docs.espressif.com/proj
* [FAQ](https://docs.espressif.com/projects/arduino-esp32/en/latest/faq.html)
* [Troubleshooting](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html)
### Supported Chips
Visit the [supported chips](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html#supported-soc-s) documentation to see the list of current supported ESP32 SoCs.
### Decoding exceptions
You can use [EspExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder) to get meaningful call trace.
@ -45,7 +38,7 @@ You can use [EspExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecod
### Issue/Bug report template
Before reporting an issue, make sure you've searched for similar one that was already created. Also make sure to go through all the issues labelled as [Type: For reference](https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue+label%3A%22Type%3A+For+reference%22+).
Finally, if you are sure no one else had the issue, follow the [issue template](docs/ISSUE_TEMPLATE.md) while reporting any issue.
Finally, if you are sure no one else had the issue, follow the **Issue template** or **Feature request template** while reporting any [new Issue](https://github.com/espressif/arduino-esp32/issues/new/choose).
### Contributing

1205
boards.txt

File diff suppressed because it is too large Load Diff

View File

@ -179,6 +179,9 @@ uint16_t makeWord(uint8_t h, uint8_t l);
#define word(...) makeWord(__VA_ARGS__)
size_t getArduinoLoopTaskStackSize(void);
#define SET_LOOP_TASK_STACK_SIZE(sz) size_t getArduinoLoopTaskStackSize() { return sz;}
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);

View File

@ -19,7 +19,7 @@
#include <Arduino.h>
#include <MD5Builder.h>
uint8_t hex_char_to_byte(uint8_t c)
static uint8_t hex_char_to_byte(uint8_t c)
{
return (c >= 'a' && c <= 'f') ? (c - ((uint8_t)'a' - 0xa)) :
(c >= 'A' && c <= 'F') ? (c - ((uint8_t)'A' - 0xA)) :
@ -28,13 +28,13 @@ uint8_t hex_char_to_byte(uint8_t c)
void MD5Builder::begin(void)
{
memset(_buf, 0x00, 16);
MD5Init(&_ctx);
memset(_buf, 0x00, ESP_ROM_MD5_DIGEST_LEN);
esp_rom_md5_init(&_ctx);
}
void MD5Builder::add(uint8_t * data, uint16_t len)
{
MD5Update(&_ctx, data, len);
esp_rom_md5_update(&_ctx, data, len);
}
void MD5Builder::addHexString(const char * data)
@ -82,7 +82,7 @@ bool MD5Builder::addStream(Stream & stream, const size_t maxLen)
}
// Update MD5 with buffer payload
MD5Update(&_ctx, buf, numBytesRead);
esp_rom_md5_update(&_ctx, buf, numBytesRead);
// update available number of bytes
maxLengthLeft -= numBytesRead;
@ -94,24 +94,24 @@ bool MD5Builder::addStream(Stream & stream, const size_t maxLen)
void MD5Builder::calculate(void)
{
MD5Final(_buf, &_ctx);
esp_rom_md5_final(_buf, &_ctx);
}
void MD5Builder::getBytes(uint8_t * output)
{
memcpy(output, _buf, 16);
memcpy(output, _buf, ESP_ROM_MD5_DIGEST_LEN);
}
void MD5Builder::getChars(char * output)
{
for(uint8_t i = 0; i < 16; i++) {
for(uint8_t i = 0; i < ESP_ROM_MD5_DIGEST_LEN; i++) {
sprintf(output + (i * 2), "%02x", _buf[i]);
}
}
String MD5Builder::toString(void)
{
char out[33];
char out[(ESP_ROM_MD5_DIGEST_LEN * 2) + 1];
getChars(out);
return String(out);
}

View File

@ -23,25 +23,13 @@
#include <Stream.h>
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/md5_hash.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/md5_hash.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/md5_hash.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/md5_hash.h"
#endif
#include "esp_rom_md5.h"
class MD5Builder
{
private:
struct MD5Context _ctx;
uint8_t _buf[16];
md5_context_t _ctx;
uint8_t _buf[ESP_ROM_MD5_DIGEST_LEN];
public:
void begin(void);
void add(uint8_t * data, uint16_t len);

View File

@ -256,7 +256,7 @@ float Stream::parseFloat(char skipChar)
} else if(c >= '0' && c <= '9') { // is c a digit?
value = value * 10 + c - '0';
if(isFraction) {
fraction *= 0.1;
fraction *= 0.1f;
}
}
read(); // consume the character we got with peek

View File

@ -62,7 +62,7 @@ public:
cbuf *next;
private:
protected:
inline char* wrap_if_bufend(char* ptr) const
{
return (ptr == _bufend) ? _buf : ptr;

View File

@ -13,51 +13,37 @@
// limitations under the License.
#include "esp32-hal.h"
#include "soc/soc_caps.h"
#if CONFIG_IDF_TARGET_ESP32
#include "soc/rtc_io_reg.h"
#define DAC1 25
#define DAC2 26
#elif CONFIG_IDF_TARGET_ESP32S2
#include "soc/rtc_io_reg.h"
#define DAC1 17
#define DAC2 18
#elif CONFIG_IDF_TARGET_ESP32C3
#ifndef SOC_DAC_SUPPORTED
#define NODAC
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#ifndef NODAC
#include "esp_attr.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/rtc_io_periph.h"
#include "soc/sens_reg.h"
#include "soc/sens_struct.h"
#include "driver/dac.h"
#include "soc/dac_channel.h"
#include "driver/dac_common.h"
void ARDUINO_ISR_ATTR __dacWrite(uint8_t pin, uint8_t value)
{
if(pin < DAC1 || pin > DAC2){
if(pin < DAC_CHANNEL_1_GPIO_NUM || pin > DAC_CHANNEL_2_GPIO_NUM){
return;//not dac pin
}
pinMode(pin, ANALOG);
uint8_t channel = pin - DAC1;
#if CONFIG_IDF_TARGET_ESP32
CLEAR_PERI_REG_MASK(SENS_SAR_DAC_CTRL1_REG, SENS_SW_TONE_EN);
#elif CONFIG_IDF_TARGET_ESP32S2
SENS.sar_dac_ctrl1.dac_clkgate_en = 1;
#endif
RTCIO.pad_dac[channel].dac_xpd_force = 1;
RTCIO.pad_dac[channel].xpd_dac = 1;
if (channel == 0) {
SENS.sar_dac_ctrl2.dac_cw_en1 = 0;
} else if (channel == 1) {
SENS.sar_dac_ctrl2.dac_cw_en2 = 0;
uint8_t channel = pin - DAC_CHANNEL_1_GPIO_NUM;
dac_output_enable(channel);
dac_output_voltage(channel, value);
}
void ARDUINO_ISR_ATTR __dacDisable(uint8_t pin)
{
if(pin < DAC_CHANNEL_1_GPIO_NUM || pin > DAC_CHANNEL_2_GPIO_NUM){
return;//not dac pin
}
RTCIO.pad_dac[channel].dac = value;
uint8_t channel = pin - DAC_CHANNEL_1_GPIO_NUM;
dac_output_disable(channel);
}
extern void dacWrite(uint8_t pin, uint8_t value) __attribute__ ((weak, alias("__dacWrite")));
extern void dacDisable(uint8_t pin) __attribute__ ((weak, alias("__dacDisable")));
#endif

View File

@ -28,6 +28,7 @@ extern "C" {
#include "driver/gpio.h"
void dacWrite(uint8_t pin, uint8_t value);
void dacDisable(uint8_t pin);
#ifdef __cplusplus
}

View File

@ -37,7 +37,13 @@
#include "soc/periph_defs.h"
#include "soc/rtc_io_reg.h"
#define GPIO_FUNC 1
#else
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/ets_sys.h"
#include "esp32c3/rom/gpio.h"
#include "esp_intr_alloc.h"
#include "soc/periph_defs.h"
#define USE_ESP_IDF_GPIO 1
#else
#define USE_ESP_IDF_GPIO 1
#endif
#else // ESP32 Before IDF 4.0
@ -143,6 +149,29 @@ const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[SOC_GPIO_PIN_COUNT]={
{0xb8, -1, -1, -1},//SCL?
{0xbc, -1, -1, -1},//INPUT ONLY
{0, -1, -1, -1}
#elif CONFIG_IDF_TARGET_ESP32C3
{0x04, -1, 0, -1}, // ADC1_CH0
{0x08, -1, 1, -1}, // ADC1_CH1
{0x0c, -1, 2, -1}, // ADC1_CH2 | FSPIQ
{0x10, -1, 3, -1}, // ADC1_CH3
{0x14, -1, 4, -1}, // MTMS | ADC1_CH4 | FSPIHD
{0x18, -1, 5, -1}, // MTDI | ADC2_CH0 | FSPIWP
{0x1c, -1, -1, -1}, // MTCK | FSPICLK
{0x20, -1, -1, -1}, // MTDO | FSPID
{0x24, -1, -1, -1}, //
{0x28, -1, -1, -1}, //
{0x2c, -1, -1, -1}, // FSPICSO
{0x30, -1, -1, -1}, //
{0x34, -1, -1, -1}, // SPIHD
{0x38, -1, -1, -1}, // SPIWP
{0x3c, -1, -1, -1}, // SPICSO
{0x40, -1, -1, -1}, // SPICLK
{0x44, -1, -1, -1}, // SPID
{0x48, -1, -1, -1}, // SPIQ
{0x4c, -1, -1, -1}, // USB-
{0x50, -1, -1, -1}, // USB+
{0x54, -1, -1, -1}, // U0RXD
{0x58, -1, -1, -1}, // U0TXD
#endif
};
@ -481,4 +510,3 @@ extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead")
extern void attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode) __attribute__ ((weak, alias("__attachInterrupt")));
extern void attachInterruptArg(uint8_t pin, voidFuncPtrArg handler, void * arg, int mode) __attribute__ ((weak, alias("__attachInterruptArg")));
extern void detachInterrupt(uint8_t pin) __attribute__ ((weak, alias("__detachInterrupt")));

2
cores/esp32/esp32-hal-i2c-slave.c Executable file → Normal file
View File

@ -302,7 +302,7 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
i2c_ll_slave_init(i2c->dev);
i2c_ll_set_fifo_mode(i2c->dev, true);
i2c_ll_set_slave_addr(i2c->dev, slaveID, false);
i2c_ll_set_tout(i2c->dev, 32000);
i2c_ll_set_tout(i2c->dev, I2C_LL_MAX_TIMEOUT);
i2c_slave_set_frequency(i2c, frequency);
if (!i2c_slave_check_line_state(sda, scl)) {

0
cores/esp32/esp32-hal-i2c-slave.h Executable file → Normal file
View File

View File

@ -24,6 +24,7 @@
#include "soc/soc_caps.h"
#include "soc/i2c_periph.h"
#include "hal/i2c_hal.h"
#include "hal/i2c_ll.h"
#include "driver/i2c.h"
typedef volatile struct {
@ -91,6 +92,8 @@ esp_err_t i2cInit(uint8_t i2c_num, int8_t sda, int8_t scl, uint32_t frequency){
} else {
bus[i2c_num].initialized = true;
bus[i2c_num].frequency = frequency;
//Clock Stretching Timeout: 20b:esp32, 5b:esp32-c3, 24b:esp32-s2
i2c_set_timeout((i2c_port_t)i2c_num, I2C_LL_MAX_TIMEOUT);
}
}
#if !CONFIG_DISABLE_HAL_LOCKS

View File

@ -13,45 +13,25 @@
// limitations under the License.
#include "esp32-hal.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp32-hal-matrix.h"
#include "soc/ledc_reg.h"
#include "soc/ledc_struct.h"
#include "driver/periph_ctrl.h"
#include "soc/soc_caps.h"
#include "driver/ledc.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "soc/dport_reg.h"
#include "esp32/rom/ets_sys.h"
#define LAST_CHAN (15)
#elif CONFIG_IDF_TARGET_ESP32S2
#include "soc/dport_reg.h"
#include "esp32s2/rom/ets_sys.h"
#define LAST_CHAN (7)
#define LEDC_DIV_NUM_HSTIMER0_V LEDC_CLK_DIV_LSTIMER0_V
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/ets_sys.h"
#define LAST_CHAN (7)
#define LEDC_DIV_NUM_HSTIMER0_V LEDC_CLK_DIV_LSTIMER0_V
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#endif
#if CONFIG_DISABLE_HAL_LOCKS
#define LEDC_MUTEX_LOCK()
#define LEDC_MUTEX_UNLOCK()
#ifdef SOC_LEDC_SUPPORT_HS_MODE
#define LEDC_CHANNELS (SOC_LEDC_CHANNEL_NUM<<1)
#else
#define LEDC_MUTEX_LOCK() do {} while (xSemaphoreTake(_ledc_sys_lock, portMAX_DELAY) != pdPASS)
#define LEDC_MUTEX_UNLOCK() xSemaphoreGive(_ledc_sys_lock)
xSemaphoreHandle _ledc_sys_lock = NULL;
#define LEDC_CHANNELS (SOC_LEDC_CHANNEL_NUM)
#endif
//Use XTAL clock if possible to avoid timer frequency error when setting APB clock < 80 Mhz
//Need to be fixed in ESP-IDF
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
#define LEDC_DEFAULT_CLK LEDC_USE_XTAL_CLK
#else
#define LEDC_DEFAULT_CLK LEDC_AUTO_CLK
#endif
#define LEDC_MAX_BIT_WIDTH SOC_LEDC_TIMER_BIT_WIDE_NUM
/*
* LEDC Chan to Group/Channel/Timer Mapping
** ledc: 0 => Group: 0, Channel: 0, Timer: 0
@ -71,203 +51,55 @@ xSemaphoreHandle _ledc_sys_lock = NULL;
** ledc: 14 => Group: 1, Channel: 6, Timer: 3
** ledc: 15 => Group: 1, Channel: 7, Timer: 3
*/
#define LEDC_CHAN(g,c) LEDC.channel_group[(g)].channel[(c)]
#define LEDC_TIMER(g,t) LEDC.timer_group[(g)].timer[(t)]
static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb){
if(ev_type == APB_AFTER_CHANGE && old_apb != new_apb){
uint16_t iarg = *(uint16_t*)arg;
uint8_t chan = 0;
old_apb /= 1000000;
new_apb /= 1000000;
while(iarg){ // run though all active channels, adjusting timing configurations
if(iarg & 1) {// this channel is active
uint8_t group=(chan/8), timer=((chan/2)%4);
if(LEDC_TIMER(group, timer).conf.tick_sel){
LEDC_MUTEX_LOCK();
uint32_t old_div = LEDC_TIMER(group, timer).conf.clock_divider;
uint32_t div_num = (new_apb * old_div) / old_apb;
if(div_num > LEDC_DIV_NUM_HSTIMER0_V){
div_num = ((REF_CLK_FREQ /1000000) * old_div) / old_apb;
if(div_num > LEDC_DIV_NUM_HSTIMER0_V) {
div_num = LEDC_DIV_NUM_HSTIMER0_V;//lowest clock possible
}
LEDC_TIMER(group, timer).conf.tick_sel = 0;
} else if(div_num < 256) {
div_num = 256;//highest clock possible
}
LEDC_TIMER(group, timer).conf.clock_divider = div_num;
LEDC_MUTEX_UNLOCK();
}
else {
log_d("using REF_CLK chan=%d",chan);
}
}
iarg = iarg >> 1;
chan++;
}
}
}
//uint32_t frequency = (80MHz or 1MHz)/((div_num / 256.0)*(1 << bit_num));
static void _ledcSetupTimer(uint8_t chan, uint32_t div_num, uint8_t bit_num, bool apb_clk)
{
uint8_t group=(chan/8), timer=((chan/2)%4);
static bool tHasStarted = false;
static uint16_t _activeChannels = 0;
#if CONFIG_IDF_TARGET_ESP32S2
// ESP32-S2 TRM v1.0 on Page 789 -> BIT LEDC_TICK_SEL_TIMERx is 0 for LEDC_PWM_CLK and 1 for REF_TICK
apb_clk = 0;
#endif
if(!tHasStarted) {
tHasStarted = true;
periph_module_enable(PERIPH_LEDC_MODULE);
LEDC.conf.apb_clk_sel = 1;//LS use apb clock
addApbChangeCallback((void*)&_activeChannels, _on_apb_change);
#if !CONFIG_DISABLE_HAL_LOCKS
_ledc_sys_lock = xSemaphoreCreateMutex();
#endif
}
LEDC_MUTEX_LOCK();
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.
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.
LEDC_TIMER(group, timer).conf.tick_sel = apb_clk;//apb clock
#if CONFIG_IDF_TARGET_ESP32
if(group) {
#endif
LEDC_TIMER(group, timer).conf.low_speed_update = 1;//This bit is only useful for low speed timer channels, reserved for high speed timers
#if CONFIG_IDF_TARGET_ESP32
}
#endif
LEDC_TIMER(group, timer).conf.pause = 0;
LEDC_TIMER(group, timer).conf.rst = 1;//This bit is used to reset timer the counter will be 0 after reset.
LEDC_TIMER(group, timer).conf.rst = 0;
LEDC_MUTEX_UNLOCK();
_activeChannels |= (1 << chan); // mark as active for APB callback
}
//max div_num 0x3FFFF (262143)
//max bit_num 0x1F (31)
static double _ledcSetupTimerFreq(uint8_t chan, double freq, uint8_t bit_num)
{
uint64_t clk_freq = getApbFrequency();
clk_freq <<= 8;//div_num is 8 bit decimal
uint32_t div_num = (clk_freq >> bit_num) / freq;
bool apb_clk = true;
if(div_num > LEDC_DIV_NUM_HSTIMER0_V) {
clk_freq /= 80;
div_num = (clk_freq >> bit_num) / freq;
if(div_num > LEDC_DIV_NUM_HSTIMER0_V) {
div_num = LEDC_DIV_NUM_HSTIMER0_V;//lowest clock possible
}
apb_clk = false;
} else if(div_num < 256) {
div_num = 256;//highest clock possible
}
_ledcSetupTimer(chan, div_num, bit_num, apb_clk);
//log_i("Fin: %f, Fclk: %uMhz, bits: %u, DIV: %u, Fout: %f",
// freq, apb_clk?80:1, bit_num, div_num, (clk_freq >> bit_num) / (double)div_num);
return (clk_freq >> bit_num) / (double)div_num;
}
static double _ledcTimerRead(uint8_t chan)
{
uint32_t div_num;
uint8_t bit_num;
bool apb_clk;
uint8_t group=(chan/8), timer=((chan/2)%4);
LEDC_MUTEX_LOCK();
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.
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.
apb_clk = LEDC_TIMER(group, timer).conf.tick_sel;//apb clock
LEDC_MUTEX_UNLOCK();
uint64_t clk_freq = 1000000;
if(apb_clk) {
clk_freq = getApbFrequency();
}
clk_freq <<= 8;//div_num is 8 bit decimal
return (clk_freq >> bit_num) / (double)div_num;
}
static void _ledcSetupChannel(uint8_t chan, uint8_t idle_level)
{
uint8_t group=(chan/8), channel=(chan%8), timer=((chan/2)%4);
LEDC_MUTEX_LOCK();
LEDC_CHAN(group, channel).conf0.timer_sel = timer;//2 bit Selects the timer to attach 0-3
LEDC_CHAN(group, channel).conf0.idle_lv = idle_level;//1 bit This bit is used to control the output value when channel is off.
LEDC_CHAN(group, channel).hpoint.hpoint = 0;//20 bit The output value changes to high when timer selected by channel has reached hpoint
LEDC_CHAN(group, channel).conf1.duty_inc = 1;//1 bit This register is used to increase the duty of output signal or decrease the duty of output signal for high speed channel
LEDC_CHAN(group, channel).conf1.duty_num = 1;//10 bit This register is used to control the number of increased or decreased times for channel
LEDC_CHAN(group, channel).conf1.duty_cycle = 1;//10 bit This register is used to increase or decrease the duty every duty_cycle cycles for channel
LEDC_CHAN(group, channel).conf1.duty_scale = 0;//10 bit This register controls the increase or decrease step scale for channel.
LEDC_CHAN(group, channel).duty.duty = 0;
LEDC_CHAN(group, channel).conf0.sig_out_en = 0;//This is the output enable control bit for channel
LEDC_CHAN(group, channel).conf1.duty_start = 0;//When duty_num duty_cycle and duty_scale has been configured. these register won't take effect until set duty_start. this bit is automatically cleared by hardware.
#if CONFIG_IDF_TARGET_ESP32
if(group) {
#endif
LEDC_CHAN(group, channel).conf0.low_speed_update = 1;
#if CONFIG_IDF_TARGET_ESP32
} else {
LEDC_CHAN(group, channel).conf0.clk_en = 0;
}
#endif
LEDC_MUTEX_UNLOCK();
}
uint8_t channels_resolution[LEDC_CHANNELS] = {0};
double ledcSetup(uint8_t chan, double freq, uint8_t bit_num)
{
if(chan > LAST_CHAN) {
if(chan >= LEDC_CHANNELS){
log_e("No more LEDC channels available! You can have maximum %u", LEDC_CHANNELS);
return 0;
}
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
_ledcSetupChannel(chan, LOW);
return res_freq;
uint8_t group=(chan/8), timer=((chan/2)%4);
ledc_timer_config_t ledc_timer = {
.speed_mode = group,
.timer_num = timer,
.duty_resolution = bit_num,
.freq_hz = freq,
.clk_cfg = LEDC_DEFAULT_CLK
};
ledc_timer_config(&ledc_timer);
channels_resolution[chan] = bit_num;
return ledc_get_freq(group,timer);
}
void ledcWrite(uint8_t chan, uint32_t duty)
{
if(chan > LAST_CHAN) {
if(chan >= LEDC_CHANNELS){
return;
}
uint8_t group=(chan/8), channel=(chan%8);
LEDC_MUTEX_LOCK();
LEDC_CHAN(group, channel).duty.duty = duty << 4;//25 bit (21.4)
if(duty) {
LEDC_CHAN(group, channel).conf0.sig_out_en = 1;//This is the output enable control bit for channel
LEDC_CHAN(group, channel).conf1.duty_start = 1;//When duty_num duty_cycle and duty_scale has been configured. these register won't take effect until set duty_start. this bit is automatically cleared by hardware.
#if CONFIG_IDF_TARGET_ESP32
if(group) {
#endif
LEDC_CHAN(group, channel).conf0.low_speed_update = 1;
#if CONFIG_IDF_TARGET_ESP32
} else {
LEDC_CHAN(group, channel).conf0.clk_en = 1;
}
#endif
} else {
LEDC_CHAN(group, channel).conf0.sig_out_en = 0;//This is the output enable control bit for channel
LEDC_CHAN(group, channel).conf1.duty_start = 0;//When duty_num duty_cycle and duty_scale has been configured. these register won't take effect until set duty_start. this bit is automatically cleared by hardware.
#if CONFIG_IDF_TARGET_ESP32
if(group) {
#endif
LEDC_CHAN(group, channel).conf0.low_speed_update = 1;
#if CONFIG_IDF_TARGET_ESP32
} else {
LEDC_CHAN(group, channel).conf0.clk_en = 0;
}
#endif
//Fixing if all bits in resolution is set = LEDC FULL ON
uint32_t max_duty = (1 << channels_resolution[chan]) - 1;
if(duty == max_duty){
duty = max_duty + 1;
}
LEDC_MUTEX_UNLOCK();
ledc_set_duty(group, channel, duty);
ledc_update_duty(group, channel);
}
uint32_t ledcRead(uint8_t chan)
{
if(chan > LAST_CHAN) {
if(chan >= LEDC_CHANNELS){
return 0;
}
return LEDC.channel_group[chan/8].channel[chan%8].duty.duty >> 4;
uint8_t group=(chan/8), channel=(chan%8);
return ledc_get_duty(group,channel);
}
double ledcReadFreq(uint8_t chan)
@ -275,19 +107,33 @@ double ledcReadFreq(uint8_t chan)
if(!ledcRead(chan)){
return 0;
}
return _ledcTimerRead(chan);
uint8_t group=(chan/8), timer=((chan/2)%4);
return ledc_get_freq(group,timer);
}
double ledcWriteTone(uint8_t chan, double freq)
{
if(chan > LAST_CHAN) {
if(chan >= LEDC_CHANNELS){
return 0;
}
if(!freq) {
if(!freq){
ledcWrite(chan, 0);
return 0;
}
double res_freq = _ledcSetupTimerFreq(chan, freq, 10);
uint8_t group=(chan/8), timer=((chan/2)%4);
ledc_timer_config_t ledc_timer = {
.speed_mode = group,
.timer_num = timer,
.duty_resolution = 10,
.freq_hz = freq,
.clk_cfg = LEDC_DEFAULT_CLK
};
ledc_timer_config(&ledc_timer);
channels_resolution[chan] = 10;
double res_freq = ledc_get_freq(group,timer);
ledcWrite(chan, 0x1FF);
return res_freq;
}
@ -307,15 +153,21 @@ double ledcWriteNote(uint8_t chan, note_t note, uint8_t octave){
void ledcAttachPin(uint8_t pin, uint8_t chan)
{
if(chan > LAST_CHAN) {
if(chan >= LEDC_CHANNELS){
return;
}
pinMode(pin, OUTPUT);
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
pinMatrixOutAttach(pin, LEDC_LS_SIG_OUT0_IDX + chan, false, false);
#else
pinMatrixOutAttach(pin, ((chan/8)?LEDC_LS_SIG_OUT0_IDX:LEDC_HS_SIG_OUT0_IDX) + (chan%8), false, false);
#endif
uint8_t group=(chan/8), channel=(chan%8), timer=((chan/2)%4);
ledc_channel_config_t ledc_channel = {
.speed_mode = group,
.channel = channel,
.timer_sel = timer,
.intr_type = LEDC_INTR_DISABLE,
.gpio_num = pin,
.duty = 0,
.hpoint = 0
};
ledc_channel_config(&ledc_channel);
}
void ledcDetachPin(uint8_t pin)
@ -325,9 +177,38 @@ void ledcDetachPin(uint8_t pin)
double ledcChangeFrequency(uint8_t chan, double freq, uint8_t bit_num)
{
if (chan > 15) {
if(chan >= LEDC_CHANNELS){
return 0;
}
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
return res_freq;
uint8_t group=(chan/8), timer=((chan/2)%4);
ledc_timer_config_t ledc_timer = {
.speed_mode = group,
.timer_num = timer,
.duty_resolution = bit_num,
.freq_hz = freq,
.clk_cfg = LEDC_DEFAULT_CLK
};
ledc_timer_config(&ledc_timer);
channels_resolution[chan] = bit_num;
return ledc_get_freq(group,timer);
}
static int8_t pin_to_channel[SOC_GPIO_PIN_COUNT] = { 0 };
static int cnt_channel = LEDC_CHANNELS;
void analogWrite(uint8_t pin, int value) {
// Use ledc hardware for internal pins
if (pin < SOC_GPIO_PIN_COUNT) {
if (pin_to_channel[pin] == 0) {
if (!cnt_channel) {
log_e("No more analogWrite channels available! You can have maximum %u", LEDC_CHANNELS);
return;
}
pin_to_channel[pin] = cnt_channel--;
ledcAttachPin(pin, cnt_channel);
ledcSetup(cnt_channel, 1000, 8);
}
ledcWrite(pin_to_channel[pin] - 1, value);
}
}

View File

@ -99,9 +99,9 @@ void log_print_buf(const uint8_t *b, size_t len);
#define log_buf_v(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_VERBOSE);}while(0)
#endif
#else
#define log_v(format, ...)
#define isr_log_v(format, ...)
#define log_buf_v(b,l)
#define log_v(format, ...) do {} while(0)
#define isr_log_v(format, ...) do {} while(0)
#define log_buf_v(b,l) do {} while(0)
#endif
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
@ -115,9 +115,9 @@ void log_print_buf(const uint8_t *b, size_t len);
#define log_buf_d(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_DEBUG);}while(0)
#endif
#else
#define log_d(format, ...)
#define isr_log_d(format, ...)
#define log_buf_d(b,l)
#define log_d(format, ...) do {} while(0)
#define isr_log_d(format, ...) do {} while(0)
#define log_buf_d(b,l) do {} while(0)
#endif
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
@ -131,9 +131,9 @@ void log_print_buf(const uint8_t *b, size_t len);
#define log_buf_i(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_INFO);}while(0)
#endif
#else
#define log_i(format, ...)
#define isr_log_i(format, ...)
#define log_buf_i(b,l)
#define log_i(format, ...) do {} while(0)
#define isr_log_i(format, ...) do {} while(0)
#define log_buf_i(b,l) do {} while(0)
#endif
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
@ -147,9 +147,9 @@ void log_print_buf(const uint8_t *b, size_t len);
#define log_buf_w(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_WARN);}while(0)
#endif
#else
#define log_w(format, ...)
#define isr_log_w(format, ...)
#define log_buf_w(b,l)
#define log_w(format, ...) do {} while(0)
#define isr_log_w(format, ...) do {} while(0)
#define log_buf_w(b,l) do {} while(0)
#endif
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
@ -163,9 +163,9 @@ void log_print_buf(const uint8_t *b, size_t len);
#define log_buf_e(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR);}while(0)
#endif
#else
#define log_e(format, ...)
#define isr_log_e(format, ...)
#define log_buf_e(b,l)
#define log_e(format, ...) do {} while(0)
#define isr_log_e(format, ...) do {} while(0)
#define log_buf_e(b,l) do {} while(0)
#endif
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_NONE
@ -179,9 +179,9 @@ void log_print_buf(const uint8_t *b, size_t len);
#define log_buf_n(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR);}while(0)
#endif
#else
#define log_n(format, ...)
#define isr_log_n(format, ...)
#define log_buf_n(b,l)
#define log_n(format, ...) do {} while(0)
#define isr_log_n(format, ...) do {} while(0)
#define log_buf_n(b,l) do {} while(0)
#endif
#include "esp_log.h"

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,9 @@ extern "C" {
#define RMT_FLAG_ERROR (4)
#define RMT_FLAGS_ALL (RMT_FLAG_TX_DONE | RMT_FLAG_RX_DONE | RMT_FLAG_ERROR)
#define RMT_TX_MODE true
#define RMT_RX_MODE false
struct rmt_obj_s;
typedef enum {
@ -54,6 +57,13 @@ typedef struct {
};
} rmt_data_t;
/**
* Prints object information
*
*/
void _rmtDumpStatus(rmt_obj_t* rmt);
/**
* Initialize the object
*
@ -69,10 +79,17 @@ float rmtSetTick(rmt_obj_t* rmt, float tick);
/**
* Sending data in one-go mode or continual mode
* (more data being send while updating buffers in interrupts)
*
* Non-Blocking mode - returns right after executing
*/
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
/**
* Sending data in one-go mode or continual mode
* (more data being send while updating buffers in interrupts)
* Blocking mode - only returns when data has been sent
*/
bool rmtWriteBlocking(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
/**
* Loop data up to the reserved memsize continuously
*

View File

@ -12,38 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "esp32-hal.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp32-hal-matrix.h"
#include "soc/gpio_sd_reg.h"
#include "soc/gpio_sd_struct.h"
#include "soc/soc_caps.h"
#include "driver/sigmadelta.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/ets_sys.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/ets_sys.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#endif
#if CONFIG_DISABLE_HAL_LOCKS
#define SD_MUTEX_LOCK()
#define SD_MUTEX_UNLOCK()
#else
#define SD_MUTEX_LOCK() do {} while (xSemaphoreTake(_sd_sys_lock, portMAX_DELAY) != pdPASS)
#define SD_MUTEX_UNLOCK() xSemaphoreGive(_sd_sys_lock)
xSemaphoreHandle _sd_sys_lock;
#endif
static uint8_t duty_set[SOC_SIGMADELTA_CHANNEL_NUM] = {0};
static uint32_t prescaler_set[SOC_SIGMADELTA_CHANNEL_NUM] = {0};
static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb){
if(old_apb == new_apb){
@ -51,82 +27,63 @@ static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb
}
uint32_t iarg = (uint32_t)arg;
uint8_t channel = iarg;
if(ev_type == APB_BEFORE_CHANGE){
SIGMADELTA.cg.clk_en = 0;
} else {
if(ev_type == APB_AFTER_CHANGE){
old_apb /= 1000000;
new_apb /= 1000000;
SD_MUTEX_LOCK();
uint32_t old_prescale = SIGMADELTA.channel[channel].prescale + 1;
SIGMADELTA.channel[channel].prescale = ((new_apb * old_prescale) / old_apb) - 1;
SIGMADELTA.cg.clk_en = 0;
SIGMADELTA.cg.clk_en = 1;
SD_MUTEX_UNLOCK();
uint32_t old_prescale = prescaler_set[channel] + 1;
uint32_t new_prescale = ((new_apb * old_prescale) / old_apb) - 1;
sigmadelta_set_prescale(channel,new_prescale);
prescaler_set[channel] = new_prescale;
}
}
uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq) //chan 0-7 freq 1220-312500
uint32_t sigmaDeltaSetup(uint8_t pin, uint8_t channel, uint32_t freq) //chan 0-x according to SOC, freq 1220-312500
{
if(channel > 7) {
if(channel >= SOC_SIGMADELTA_CHANNEL_NUM){
return 0;
}
#if !CONFIG_DISABLE_HAL_LOCKS
static bool tHasStarted = false;
if(!tHasStarted) {
tHasStarted = true;
_sd_sys_lock = xSemaphoreCreateMutex();
}
#endif
uint32_t apb_freq = getApbFrequency();
uint32_t prescale = (apb_freq/(freq*256)) - 1;
if(prescale > 0xFF) {
prescale = 0xFF;
}
SD_MUTEX_LOCK();
#ifndef CONFIG_IDF_TARGET_ESP32
SIGMADELTA.misc.function_clk_en = 1;
#endif
SIGMADELTA.channel[channel].prescale = prescale;
SIGMADELTA.cg.clk_en = 0;
SIGMADELTA.cg.clk_en = 1;
SD_MUTEX_UNLOCK();
sigmadelta_config_t sigmadelta_cfg = {
.channel = channel,
.sigmadelta_prescale = prescale,
.sigmadelta_duty = 0,
.sigmadelta_gpio = pin,
};
sigmadelta_config(&sigmadelta_cfg);
prescaler_set[channel] = prescale;
uint32_t iarg = channel;
addApbChangeCallback((void*)iarg, _on_apb_change);
return apb_freq/((prescale + 1) * 256);
}
void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-x according to SOC duty 8 bit
{
if(channel > 7) {
if(channel >= SOC_SIGMADELTA_CHANNEL_NUM){
return;
}
duty -= 128;
SD_MUTEX_LOCK();
SIGMADELTA.channel[channel].duty = duty;
SD_MUTEX_UNLOCK();
duty -= 128;
sigmadelta_set_duty(channel,duty);
duty_set[channel] = duty;
}
uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-x according to SOC
{
if(channel > 7) {
if(channel >= SOC_SIGMADELTA_CHANNEL_NUM){
return 0;
}
SD_MUTEX_LOCK();
uint8_t duty = SIGMADELTA.channel[channel].duty + 128;
SD_MUTEX_UNLOCK();
return duty;
}
void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel) //channel 0-7
{
if(channel > 7) {
return;
}
pinMode(pin, OUTPUT);
pinMatrixOutAttach(pin, GPIO_SD0_OUT_IDX + channel, false, false);
return duty_set[channel]+128;
}
void sigmaDeltaDetachPin(uint8_t pin)
{
pinMatrixOutDetach(pin, false, false);
}
}

View File

@ -23,10 +23,9 @@ extern "C" {
#include <stdbool.h>
//channel 0-7 freq 1220-312500 duty 0-255
uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq);
uint32_t sigmaDeltaSetup(uint8_t pin, uint8_t channel, uint32_t freq);
void sigmaDeltaWrite(uint8_t channel, uint8_t duty);
uint8_t sigmaDeltaRead(uint8_t channel);
void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel);
void sigmaDeltaDetachPin(uint8_t pin);

View File

@ -13,335 +13,227 @@
// limitations under the License.
#include "esp32-hal-timer.h"
#include "freertos/FreeRTOS.h"
#ifndef CONFIG_IDF_TARGET_ESP32C3
#include "freertos/xtensa_api.h"
#include "soc/dport_reg.h"
#endif
#include "freertos/task.h"
#include "soc/timer_group_struct.h"
#include "esp_attr.h"
#include "driver/periph_ctrl.h"
#include "driver/timer.h"
#include "soc/soc_caps.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#include "soc/periph_defs.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#include "soc/periph_defs.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "esp_intr.h"
#endif
typedef union {
struct {
uint32_t reserved0: 10;
uint32_t alarm_en: 1; /*When set alarm is enabled*/
uint32_t level_int_en: 1; /*When set level type interrupt will be generated during alarm*/
uint32_t edge_int_en: 1; /*When set edge type interrupt will be generated during alarm*/
uint32_t divider: 16; /*Timer clock (T0/1_clk) pre-scale value.*/
uint32_t autoreload: 1; /*When set timer 0/1 auto-reload at alarming is enabled*/
uint32_t increase: 1; /*When set timer 0/1 time-base counter increment. When cleared timer 0 time-base counter decrement.*/
uint32_t enable: 1; /*When set timer 0/1 time-base counter is enabled*/
};
uint32_t val;
} timer_cfg_t;
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)
#define NUM_OF_TIMERS SOC_TIMER_GROUP_TOTAL_TIMERS
typedef volatile struct {
union {
struct {
uint32_t reserved0: 10;
uint32_t alarm_en: 1; /*When set alarm is enabled*/
uint32_t level_int_en: 1; /*When set level type interrupt will be generated during alarm*/
uint32_t edge_int_en: 1; /*When set edge type interrupt will be generated during alarm*/
uint32_t divider: 16; /*Timer clock (T0/1_clk) pre-scale value.*/
uint32_t autoreload: 1; /*When set timer 0/1 auto-reload at alarming is enabled*/
uint32_t increase: 1; /*When set timer 0/1 time-base counter increment. When cleared timer 0 time-base counter decrement.*/
uint32_t enable: 1; /*When set timer 0/1 time-base counter is enabled*/
};
uint32_t val;
} config;
uint32_t cnt_low; /*Register to store timer 0/1 time-base counter current value lower 32 bits.*/
uint32_t cnt_high; /*Register to store timer 0 time-base counter current value higher 32 bits.*/
uint32_t update; /*Write any value will trigger a timer 0 time-base counter value update (timer 0 current value will be stored in registers above)*/
uint32_t alarm_low; /*Timer 0 time-base counter value lower 32 bits that will trigger the alarm*/
uint32_t alarm_high; /*Timer 0 time-base counter value higher 32 bits that will trigger the alarm*/
uint32_t load_low; /*Lower 32 bits of the value that will load into timer 0 time-base counter*/
uint32_t load_high; /*higher 32 bits of the value that will load into timer 0 time-base counter*/
uint32_t reload; /*Write any value will trigger timer 0 time-base counter reload*/
} hw_timer_reg_t;
typedef struct {
int timer_group;
int timer_idx;
int alarm_interval;
bool auto_reload;
} timer_info_t;
typedef struct hw_timer_s {
hw_timer_reg_t * dev;
uint8_t num;
uint8_t group;
uint8_t timer;
portMUX_TYPE lock;
typedef struct hw_timer_s
{
uint8_t group;
uint8_t num;
} hw_timer_t;
static hw_timer_t hw_timer[4] = {
{(hw_timer_reg_t *)(DR_REG_TIMERGROUP0_BASE),0,0,0,portMUX_INITIALIZER_UNLOCKED},
{(hw_timer_reg_t *)(DR_REG_TIMERGROUP0_BASE + 0x0024),1,0,1,portMUX_INITIALIZER_UNLOCKED},
{(hw_timer_reg_t *)(DR_REG_TIMERGROUP0_BASE + 0x1000),2,1,0,portMUX_INITIALIZER_UNLOCKED},
{(hw_timer_reg_t *)(DR_REG_TIMERGROUP0_BASE + 0x1024),3,1,1,portMUX_INITIALIZER_UNLOCKED}
// Works for all chips
static hw_timer_t timer_dev[4] = {
{0,0}, {1,0}, {1,0}, {1,1}
};
typedef void (*voidFuncPtr)(void);
static voidFuncPtr __timerInterruptHandlers[4] = {0,0,0,0};
// NOTE: (in IDF 5.0 there wont be need to know groups/numbers
// timer_init() will list thru all timers and return free timer handle)
void ARDUINO_ISR_ATTR __timerISR(void * arg){
uint32_t s0 = TIMERG0.int_st_timers.val;
uint32_t s1 = TIMERG1.int_st_timers.val;
TIMERG0.int_clr_timers.val = s0;
TIMERG1.int_clr_timers.val = s1;
uint8_t status = (s1 & 3) << 2 | (s0 & 3);
uint8_t i = 4;
//restart the timers that should autoreload
while(i--){
hw_timer_reg_t * dev = hw_timer[i].dev;
if((status & (1 << i)) && dev->config.autoreload){
dev->config.alarm_en = 1;
}
}
i = 4;
//call callbacks
while(i--){
if(__timerInterruptHandlers[i] && (status & (1 << i))){
__timerInterruptHandlers[i]();
}
}
}
uint64_t inline timerRead(hw_timer_t *timer){
timer->dev->update = 1;
while (timer->dev->update) {};
uint64_t h = timer->dev->cnt_high;
uint64_t l = timer->dev->cnt_low;
return (h << 32) | l;
uint64_t value;
timer_get_counter_value(timer->group, timer->num,&value);
return value;
}
uint64_t timerAlarmRead(hw_timer_t *timer){
uint64_t h = timer->dev->alarm_high;
uint64_t l = timer->dev->alarm_low;
return (h << 32) | l;
uint64_t value;
timer_get_alarm_value(timer->group, timer->num, &value);
return value;
}
void timerWrite(hw_timer_t *timer, uint64_t val){
timer->dev->load_high = (uint32_t) (val >> 32);
timer->dev->load_low = (uint32_t) (val);
timer->dev->reload = 1;
timer_set_counter_value(timer->group, timer->num, val);
}
void timerAlarmWrite(hw_timer_t *timer, uint64_t alarm_value, bool autoreload){
timer->dev->alarm_high = (uint32_t) (alarm_value >> 32);
timer->dev->alarm_low = (uint32_t) alarm_value;
timer->dev->config.autoreload = autoreload;
timer_set_alarm_value(timer->group, timer->num, alarm_value);
timerSetAutoReload(timer,autoreload);
}
void timerSetConfig(hw_timer_t *timer, uint32_t config){
timer->dev->config.val = config;
timer_cfg_t cfg;
cfg.val = config;
timer_set_alarm(timer->group, timer->num, cfg.alarm_en);
timerSetDivider(timer,cfg.divider);
timerSetAutoReload(timer,cfg.autoreload);
timerSetCountUp(timer, cfg.increase);
if (cfg.enable) {
timerStart(timer);
}
else{
timerStop(timer);
}
return;
}
uint32_t timerGetConfig(hw_timer_t *timer){
return timer->dev->config.val;
timer_config_t timer_cfg;
timer_get_config(timer->group, timer->num,&timer_cfg);
//Translate to default uint32_t
timer_cfg_t cfg;
cfg.alarm_en = timer_cfg.alarm_en;
cfg.autoreload = timer_cfg.auto_reload;
cfg.divider = timer_cfg.divider;
cfg.edge_int_en = timer_cfg.intr_type;
cfg.level_int_en = !timer_cfg.intr_type;
cfg.enable = timer_cfg.counter_en;
cfg.increase = timer_cfg.counter_dir;
return cfg.val;
}
void timerSetCountUp(hw_timer_t *timer, bool countUp){
timer->dev->config.increase = countUp;
timer_set_counter_mode(timer->group, timer->num,countUp);
}
bool timerGetCountUp(hw_timer_t *timer){
return timer->dev->config.increase;
timer_cfg_t config;
config.val = timerGetConfig(timer);
return config.increase;
}
void timerSetAutoReload(hw_timer_t *timer, bool autoreload){
timer->dev->config.autoreload = autoreload;
timer_set_auto_reload(timer->group, timer->num,autoreload);
}
bool timerGetAutoReload(hw_timer_t *timer){
return timer->dev->config.autoreload;
timer_cfg_t config;
config.val= timerGetConfig(timer);
return config.autoreload;
}
void timerSetDivider(hw_timer_t *timer, uint16_t divider){//2 to 65536
if(!divider){
divider = 0xFFFF;
} else if(divider == 1){
divider = 2;
// Set divider from 2 to 65535
void timerSetDivider(hw_timer_t *timer, uint16_t divider){
if(divider < 2)
{
log_e("Timer divider must be set in range of 2 to 65535");
return;
}
int timer_en = timer->dev->config.enable;
timer->dev->config.enable = 0;
timer->dev->config.divider = divider;
timer->dev->config.enable = timer_en;
timer_set_divider(timer->group, timer->num,divider);
}
uint16_t timerGetDivider(hw_timer_t *timer){
return timer->dev->config.divider;
timer_cfg_t config;
config.val = timerGetConfig(timer);
return config.divider;
}
void timerStart(hw_timer_t *timer){
timer->dev->config.enable = 1;
timer_start(timer->group, timer->num);
}
void timerStop(hw_timer_t *timer){
timer->dev->config.enable = 0;
timer_pause(timer->group, timer->num);
}
void timerRestart(hw_timer_t *timer){
timer->dev->config.enable = 0;
timer->dev->reload = 1;
timer->dev->config.enable = 1;
timerWrite(timer,0);
}
bool timerStarted(hw_timer_t *timer){
return timer->dev->config.enable;
timer_cfg_t config;
config.val = timerGetConfig(timer);
return config.enable;
}
void timerAlarmEnable(hw_timer_t *timer){
timer->dev->config.alarm_en = 1;
timer_set_alarm(timer->group, timer->num,true);
}
void timerAlarmDisable(hw_timer_t *timer){
timer->dev->config.alarm_en = 0;
timer_set_alarm(timer->group, timer->num,false);
}
bool timerAlarmEnabled(hw_timer_t *timer){
return timer->dev->config.alarm_en;
timer_cfg_t config;
config.val = timerGetConfig(timer);
return config.alarm_en;
}
static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb){
hw_timer_t * timer = (hw_timer_t *)arg;
if(ev_type == APB_BEFORE_CHANGE){
timer->dev->config.enable = 0;
timerStop(timer);
} else {
old_apb /= 1000000;
new_apb /= 1000000;
timer->dev->config.divider = (new_apb * timer->dev->config.divider) / old_apb;
timer->dev->config.enable = 1;
uint16_t divider = (new_apb * timerGetDivider(timer)) / old_apb;
timerSetDivider(timer,divider);
timerStart(timer);
}
}
hw_timer_t * timerBegin(uint8_t num, uint16_t divider, bool countUp){
if(num > 3){
if(num >= NUM_OF_TIMERS)
{
log_e("Timer dont have that timer number.");
return NULL;
}
hw_timer_t * timer = &hw_timer[num];
if(timer->group) {
periph_module_enable(PERIPH_TIMG1_MODULE);
} else {
periph_module_enable(PERIPH_TIMG0_MODULE);
}
timer->dev->config.enable = 0;
if(timer->group) {
#if CONFIG_IDF_TARGET_ESP32
TIMERG1.int_ena.val &= ~BIT(timer->timer);
#else
TIMERG1.int_ena_timers.val &= ~BIT(timer->timer);
#endif
TIMERG1.int_clr_timers.val |= BIT(timer->timer);
} else {
#if CONFIG_IDF_TARGET_ESP32
TIMERG0.int_ena.val &= ~BIT(timer->timer);
#else
TIMERG0.int_ena_timers.val &= ~BIT(timer->timer);
#endif
TIMERG0.int_clr_timers.val |= BIT(timer->timer);
}
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
timer->dev->config.use_xtal = 0;
#endif
timerSetDivider(timer, divider);
timerSetCountUp(timer, countUp);
timerSetAutoReload(timer, false);
timerAttachInterrupt(timer, NULL, false);
timerWrite(timer, 0);
timer->dev->config.enable = 1;
hw_timer_t * timer = &timer_dev[num]; //Get Timer group/num from 0-3 number
timer_config_t config = {
.divider = divider,
.counter_dir = countUp,
.counter_en = TIMER_PAUSE,
.alarm_en = TIMER_ALARM_DIS,
.auto_reload = false,
};
timer_init(timer->group, timer->num, &config);
timer_set_counter_value(timer->group, timer->num, 0);
timerStart(timer);
addApbChangeCallback(timer, _on_apb_change);
return timer;
}
void timerEnd(hw_timer_t *timer){
timer->dev->config.enable = 0;
timerAttachInterrupt(timer, NULL, false);
removeApbChangeCallback(timer, _on_apb_change);
timer_deinit(timer->group, timer->num);
}
void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
#if CONFIG_IDF_TARGET_ESP32
if(edge){
log_w("EDGE timer interrupt does not work properly on ESP32! Setting to LEVEL...");
log_w("EDGE timer interrupt is not supported! Setting to LEVEL...");
edge = false;
}
#endif
static bool initialized = false;
static intr_handle_t intr_handle = NULL;
if(intr_handle){
esp_intr_disable(intr_handle);
}
if(fn == NULL){
timer->dev->config.level_int_en = 0;
timer->dev->config.edge_int_en = 0;
timer->dev->config.alarm_en = 0;
if(timer->num & 2){
#if CONFIG_IDF_TARGET_ESP32
TIMERG1.int_ena.val &= ~BIT(timer->timer);
#else
TIMERG1.int_ena_timers.val &= ~BIT(timer->timer);
#endif
TIMERG1.int_clr_timers.val |= BIT(timer->timer);
} else {
#if CONFIG_IDF_TARGET_ESP32
TIMERG0.int_ena.val &= ~BIT(timer->timer);
#else
TIMERG0.int_ena_timers.val &= ~BIT(timer->timer);
#endif
TIMERG0.int_clr_timers.val |= BIT(timer->timer);
}
__timerInterruptHandlers[timer->num] = NULL;
} else {
__timerInterruptHandlers[timer->num] = fn;
timer->dev->config.level_int_en = edge?0:1;//When set, an alarm will generate a level type interrupt.
timer->dev->config.edge_int_en = edge?1:0;//When set, an alarm will generate an edge type interrupt.
int intr_source = 0;
#ifndef CONFIG_IDF_TARGET_ESP32C3
if(!edge){
#endif
if(timer->group){
intr_source = ETS_TG1_T0_LEVEL_INTR_SOURCE + timer->timer;
} else {
intr_source = ETS_TG0_T0_LEVEL_INTR_SOURCE + timer->timer;
}
#ifndef CONFIG_IDF_TARGET_ESP32C3
} else {
if(timer->group){
intr_source = ETS_TG1_T0_EDGE_INTR_SOURCE + timer->timer;
} else {
intr_source = ETS_TG0_T0_EDGE_INTR_SOURCE + timer->timer;
}
}
#endif
if(!initialized){
initialized = true;
esp_intr_alloc(intr_source, (int)(ARDUINO_ISR_FLAG|ESP_INTR_FLAG_LOWMED), __timerISR, NULL, &intr_handle);
} else {
intr_matrix_set(esp_intr_get_cpu(intr_handle), intr_source, esp_intr_get_intno(intr_handle));
}
if(timer->group){
#if CONFIG_IDF_TARGET_ESP32
TIMERG1.int_ena.val |= BIT(timer->timer);
#else
TIMERG1.int_ena_timers.val |= BIT(timer->timer);
#endif
} else {
#if CONFIG_IDF_TARGET_ESP32
TIMERG0.int_ena.val |= BIT(timer->timer);
#else
TIMERG0.int_ena_timers.val |= BIT(timer->timer);
#endif
}
}
if(intr_handle){
esp_intr_enable(intr_handle);
}
timer_enable_intr(timer->group, timer->num);
timer_info_t *timer_info = calloc(1, sizeof(timer_info_t));
timer_info->timer_group = timer->group;
timer_info->timer_idx = timer->num;
timer_info->auto_reload = timerGetAutoReload(timer);
timer_info->alarm_interval = timerAlarmRead(timer);
timer_isr_callback_add(timer->group, timer->num, (timer_isr_t)fn, timer_info, 0);
}
void timerDetachInterrupt(hw_timer_t *timer){
@ -354,6 +246,12 @@ uint64_t timerReadMicros(hw_timer_t *timer){
return timer_val * div / (getApbFrequency() / 1000000);
}
uint64_t timerReadMilis(hw_timer_t *timer){
uint64_t timer_val = timerRead(timer);
uint16_t div = timerGetDivider(timer);
return timer_val * div / (getApbFrequency() / 1000);
}
double timerReadSeconds(hw_timer_t *timer){
uint64_t timer_val = timerRead(timer);
uint16_t div = timerGetDivider(timer);
@ -366,6 +264,12 @@ uint64_t timerAlarmReadMicros(hw_timer_t *timer){
return timer_val * div / (getApbFrequency() / 1000000);
}
uint64_t timerAlarmReadMilis(hw_timer_t *timer){
uint64_t timer_val = timerAlarmRead(timer);
uint16_t div = timerGetDivider(timer);
return timer_val * div / (getApbFrequency() / 1000);
}
double timerAlarmReadSeconds(hw_timer_t *timer){
uint64_t timer_val = timerAlarmRead(timer);
uint16_t div = timerGetDivider(timer);

View File

@ -20,13 +20,13 @@
#ifndef MAIN_ESP32_HAL_TIMER_H_
#define MAIN_ESP32_HAL_TIMER_H_
#include "esp32-hal.h"
#include "freertos/FreeRTOS.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "esp32-hal.h"
#include "freertos/FreeRTOS.h"
struct hw_timer_s;
typedef struct hw_timer_s hw_timer_t;
@ -50,6 +50,7 @@ void timerSetAutoReload(hw_timer_t *timer, bool autoreload);
bool timerStarted(hw_timer_t *timer);
uint64_t timerRead(hw_timer_t *timer);
uint64_t timerReadMicros(hw_timer_t *timer);
uint64_t timerReadMilis(hw_timer_t *timer);
double timerReadSeconds(hw_timer_t *timer);
uint16_t timerGetDivider(hw_timer_t *timer);
bool timerGetCountUp(hw_timer_t *timer);

View File

@ -69,6 +69,19 @@ static uart_t _uart_bus_array[] = {
#endif
// solves issue https://github.com/espressif/arduino-esp32/issues/6032
// baudrate must be multiplied when CPU Frequency is lower than APB 80MHz
uint32_t _get_effective_baudrate(uint32_t baudrate)
{
uint32_t Freq = getApbFrequency()/1000000;
if (Freq < 80) {
return 80 / Freq * baudrate;
}
else {
return baudrate;
}
}
bool uartIsDriverInstalled(uart_t* uart)
{
if(uart == NULL) {
@ -121,7 +134,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
UART_MUTEX_LOCK();
uart_config_t uart_config;
uart_config.baud_rate = baudrate;
uart_config.baud_rate = _get_effective_baudrate(baudrate);
uart_config.data_bits = (config & 0xc) >> 2;
uart_config.parity = (config & 0x3);
uart_config.stop_bits = (config & 0x30) >> 4;
@ -140,6 +153,9 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
ESP_ERROR_CHECK(uart_set_line_inverse(uart_nr, UART_SIGNAL_TXD_INV | UART_SIGNAL_RXD_INV));
}
// Set RS485 half duplex mode on UART. This shall force flush to wait up to sending all bits out
ESP_ERROR_CHECK(uart_set_mode(uart_nr, UART_MODE_RS485_HALF_DUPLEX));
UART_MUTEX_UNLOCK();
uartFlush(uart);
@ -304,7 +320,7 @@ void uartSetBaudRate(uart_t* uart, uint32_t baud_rate)
return;
}
UART_MUTEX_LOCK();
uart_ll_set_baudrate(UART_LL_GET_HW(uart->num), baud_rate);
uart_ll_set_baudrate(UART_LL_GET_HW(uart->num), _get_effective_baudrate(baud_rate));
UART_MUTEX_UNLOCK();
}

View File

@ -90,6 +90,8 @@ void yield(void);
#include "esp32-hal-psram.h"
#include "esp32-hal-cpu.h"
void analogWrite(uint8_t pin, int value);
//returns chip temperature in Celsius
float temperatureRead();

0
cores/esp32/libb64/AUTHORS Executable file → Normal file
View File

0
cores/esp32/libb64/LICENSE Executable file → Normal file
View File

0
cores/esp32/libb64/cdecode.c Executable file → Normal file
View File

0
cores/esp32/libb64/cdecode.h Executable file → Normal file
View File

0
cores/esp32/libb64/cencode.c Executable file → Normal file
View File

0
cores/esp32/libb64/cencode.h Executable file → Normal file
View File

View File

@ -33,6 +33,10 @@ void yieldIfNecessary(void){
bool loopTaskWDTEnabled;
__attribute__((weak)) size_t getArduinoLoopTaskStackSize(void) {
return ARDUINO_LOOP_STACK_SIZE;
}
void loopTask(void *pvParameters)
{
setup();
@ -64,7 +68,7 @@ extern "C" void app_main()
#endif
loopTaskWDTEnabled = false;
initArduino();
xTaskCreateUniversal(loopTask, "loopTask", ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
}
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,3 +1,170 @@
####
GPIO
####
About
-----
One of the most used and versatile peripheral in a microcontroller is the GPIO. The GPIO is commonly used to write and read the pin state.
GPIO stands to General Purpose Input Output, and is responsible to control or read the state of a specific pin in the digital world. For example, this peripheral is widely used to create the LED blinking or to read a simple button.
.. note:: There are some GPIOs with special restrictions, and not all GPIOs are accessible through the developemnt board. For more information about it, see the corresponding board pin layout information.
GPIOs Modes
***********
There are two different modes in the GPIO configuration:
- **Input Mode**
In this mode, the GPIO will receive the digital state from a specific device. This device could be a button or a switch.
- **Output Mode**
For the output mode, the GPIO will change the GPIO digital state to a specific device. You can drive an LED for example.
GPIO API
--------
Here is the common functions used for the GPIO peripheral.
pinMode
*******
The ``pinMode`` function is used to define the GPIO operation mode for a specific pin.
.. code-block:: arduino
void pinMode(uint8_t pin, uint8_t mode);
* ``pin`` defines the GPIO pin number.
* ``mode`` sets operation mode.
The following modes are supported for the basic `input` and `output`:
* **INPUT** sets the GPIO as input without pullup or pulldown (high impedance).
* **OUTPUT** sets the GPIO as output/read mode.
* **INPUT_PULLDOWN** sets the GPIO as input with the internal pulldown.
* **INPUT_PULLUP** sets the GPIO as input with the internal pullup.
Internal Pullup and Pulldown
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ESP32 SoC families supports the internal pullup and pulldown throught a 45kR resistor, that can be enabled when configuring the GPIO mode as ``INPUT`` mode.
If the pullup or pulldown mode is not defined, the pin will stay in the high impedance mode.
digitalWrite
*************
The function ``digitalWrite`` sets the state of the selected GPIO to ``HIGH`` or ``LOW``. This function is only used if the ``pinMode`` was configured as ``OUTPUT``.
.. code-block:: arduino
void digitalWrite(uint8_t pin, uint8_t val);
* ``pin`` defines the GPIO pin number.
* ``val`` set the output digital state to ``HIGH`` or ``LOW``.
digitalRead
***********
To read the state of a given pin configured as ``INPUT``, the function ``digitalRead`` is used.
.. code-block:: arduino
int digitalRead(uint8_t pin);
* ``pin`` select GPIO
This function will return the logical state of the selected pin as ``HIGH`` or ``LOW``.
Interrupts
----------
The GPIO peripheral on the ESP32 supports interruptions.
attachInterrupt
***************
The function ``attachInterruptArg`` is used to attach the interrupt to the defined pin.
.. code-block:: arduino
attachInterrupt(uint8_t pin, voidFuncPtr handler, int mode);
* ``pin`` defines the GPIO pin number.
* ``handler`` set the handler function.
* ``mode`` set the interrupt mode.
Here are the supported interrupt modes:
* **DISABLED**
* **RISING**
* **FALLING**
* **CHANGE**
* **ONLOW**
* **ONHIGH**
* **ONLOW_WE**
* **ONHIGH_WE**
attachInterruptArg
******************
The function ``attachInterruptArg`` is used to attach the interrupt to the defined pin using arguments.
.. code-block:: arduino
attachInterruptArg(uint8_t pin, voidFuncPtrArg handler, void * arg, int mode);
* ``pin`` defines the GPIO pin number.
* ``handler`` set the handler function.
* ``arg`` pointer to the interrupt arguments.
* ``mode`` set the interrupt mode.
detachInterrupt
***************
To detach the interruption from a specific pin, use the ``detachInterrupt`` function giving the GPIO to be detached.
.. code-block:: arduino
detachInterrupt(uint8_t pin);
* ``pin`` defines the GPIO pin number.
.. _gpio_example_code:
Example Code
------------
GPIO Input and Output Modes
***************************
.. code-block:: arduino
#define LED 12
#define BUTTON 2
uint8_t stateLED = 0;
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON,INPUT_PULLUP);
}
void loop() {
if(!digitalRead(BUTTON)){
stateLED = stateLED^1;
digitalWrite(LED,stateLED);
}
}
GPIO Interrupt
**************
.. literalinclude:: ../../../libraries/ESP32/examples/GPIO/GPIOInterrupt/GPIOInterrupt.ino
:language: arduino
.. _datasheet: https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf

384
docs/source/api/i2c.rst Normal file
View File

@ -0,0 +1,384 @@
###
I2C
###
About
-----
I2C (Inter-Integrated Circuit) / TWI (Two-wire Interface) is a widely used serial communication to connect devices in a short distance. This is one of the most common peripherals used to connect sensors, EEPROMs, RTC, ADC, DAC, displays, OLED, and many other devices and microcontrollers.
This serial communication is considered as a low-speed bus, and multiple devices can be connected on the same two-wires bus, each with a unique 7-bits address (up to 128 devices). These two wires are called SDA (serial data line) and SCL (serial clock line).
.. note:: The SDA and SCL lines require pull-up resistors. See the device datasheet for more details about the resistors' values and the operating voltage.
I2C Modes
*********
The I2C can be used in two different modes:
* **I2C Master Mode**
* In this mode, the ESP32 generates the clock signal and initiates the communication with the slave device.
.. figure:: ../_static/arduino_i2c_master.png
:align: center
:width: 720
:figclass: align-center
* **I2C Slave Mode**
* The slave mode, the clock is generated by the master device and responds to the master if the destination address is the same as the destination.
.. figure:: ../_static/arduino_i2c_slave.png
:align: center
:width: 520
:figclass: align-center
Arduino-ESP32 I2C API
---------------------
The ESP32 I2C library is based on the `Arduino Wire Library`_ and implements a few more APIs, described in this documentation.
I2C Common API
**************
Here are the common functions used for master and slave modes.
begin
^^^^^
This function is used to start the peripheral using the default configuration.
.. code-block:: arduino
bool begin();
This function will return ``true`` if the peripheral was initialized correctly.
setPins
^^^^^^^
This function is used to define the ``SDA`` and ``SCL`` pins.
.. note:: Call this function before ``begin`` to change the pins from the default ones.
.. code-block:: arduino
bool setPins(int sdaPin, int sclPin);
* ``sdaPin`` sets the GPIO to be used as the I2C peripheral data line.
* ``sclPin`` sets the GPIO to be used as the I2C peripheral clock line.
The default pins may vary from board to board. On the *Generic ESP32* the default I2C pins are:
* ``sdaPin`` **GPIO21**
* ``sclPin`` **GPIO22**
This function will return ``true`` if the peripheral was configured correctly.
setClock
^^^^^^^^
Use this function to set the bus clock. The default value will be used if this function is not used.
.. code-block:: arduino
bool setClock(uint32_t frequency);
* ``frequency`` sets the bus frequency clock.
This function will return ``true`` if the clock was configured correctly.
getClock
^^^^^^^^
Use this function to get the bus clock.
.. code-block:: arduino
uint32_t getClock();
This function will return the current frequency configuration.
setTimeOut
^^^^^^^^^^
Set the bus timeout given in milliseconds. The default value is 50ms.
.. code-block:: arduino
void setTimeOut(uint16_t timeOutMillis);
* ``timeOutMillis`` sets the timeout in ms.
getTimeOut
^^^^^^^^^^
Get the bus timeout in milliseconds.
.. code-block:: arduino
uint16_t getTimeOut();
This function will return the current timeout configuration.
.. _i2c write:
write
^^^^^
This function writes data to the buffer.
.. code-block:: arduino
size_t write(uint8_t);
or
.. code-block:: arduino
size_t write(const uint8_t *, size_t);
The return will be the size of the data added to the buffer.
.. _i2c end:
end
^^^
This function will finish the communication and release all the allocated resources. After calling ``end`` you need to use ``begin`` again in order to initialize the I2C driver again.
.. code-block:: arduino
bool end();
I2C Master Mode
***************
This mode is used to initiate communication to the slave.
Basic Usage
^^^^^^^^^^^
To start using I2C master mode on the Arduino, the first step is to include the ``Wire.h`` header to the sketch.
.. code-block:: arduino
#include "Wire.h"
Now, we can start the peripheral configuration by calling ``begin`` function.
.. code-block:: arduino
Wire.begin();
By using ``begin`` without any arguments, all the settings will be done by using the default values. To set the values by your own, see the function description. This function is described here: `i2c begin`_
After calling ``begin``, we can start the transmission by calling ``beginTransmission`` and passing the I2C slave address:
.. code-block:: arduino
Wire.beginTransmission(I2C_DEV_ADDR);
To write some bytes to the slave, use the ``write`` function.
.. code-block:: arduino
Wire.write(x);
You can pass different data types using ``write`` function. This function is described here: `i2c write`_
.. note:: The ``write`` function does not write directly to the slave device but adds to the I2C buffer. To do so, you need to use the ``endTransmission`` function to send the buffered bytes to the slave device.
.. code-block:: arduino
Wire.endTransmission(true);
After calling ``endTransmission``, the data stored in the I2C buffer will be transmitted to the slave device.
Now you can request a reading from the slave device. The ``requestFrom`` will ask for a readout to the selected device by giving the address and the size.
.. code-block:: arduino
Wire.requestFrom(I2C_DEV_ADDR, SIZE);
and the ``readBytes`` will read it.
.. code-block:: arduino
Wire.readBytes(temp, error);
.. _i2c begin:
I2C Master APIs
***************
Here are the I2C master APIs. These function are intended to be used only for master mode.
begin
^^^^^
In master mode, the ``begin`` function can be used by passing the **pins** and **bus frequency**. Use this function only for the master mode.
.. code-block:: arduino
bool begin(int sdaPin, int sclPin, uint32_t frequency)
Alternatively, you can use the ``begin`` function without any argument to use all default values.
This function will return ``true`` if the peripheral was initialized correctly.
beginTransmission
^^^^^^^^^^^^^^^^^
This function is used to star a communication process with the slave device. Call this function by passing the slave ``address`` before writing the message to the buffer.
.. code-block:: arduino
void beginTransmission(uint16_t address)
endTransmission
^^^^^^^^^^^^^^^
After writing to the buffer using `i2c write`_, use the function ``endTransmission`` to send the message to the slave device address defined on the ``beginTransmission`` function.
.. code-block:: arduino
uint8_t endTransmission(bool sendStop);
* ``sendStop`` enables **(true)** or disables **(false)** the stop signal *(only used in master mode)*.
Calling the this function without ``sendStop`` is equivalent to ``sendStop = true``.
.. code-block:: arduino
uint8_t endTransmission(void);
This function will return the error code.
requestFrom
^^^^^^^^^^^
To read from the slave device, use the ``requestFrom`` function.
.. code-block:: arduino
uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop)
* ``address`` set the device address.
* ``size`` define the size to be requested.
* ``sendStop`` enables (true) or disables (false) the stop signal.
This function will return the number of bytes read from the device.
Example Application - WireMaster.ino
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here is an example of how to use the I2C in Master Mode.
.. literalinclude:: ../../../libraries/Wire/examples/WireMaster/WireMaster.ino
:language: arduino
I2C Slave Mode
**************
This mode is used to accept communication from the master.
Basic Usage
^^^^^^^^^^^
To start using I2C as slave mode on the Arduino, the first step is to include the ``Wire.h`` header to the scketch.
.. code-block:: arduino
#include "Wire.h"
Before calling ``begin`` we must create two callback functions to handle the communication with the master device.
.. code-block:: arduino
Wire.onReceive(onReceive);
and
.. code-block:: arduino
Wire.onRequest(onRequest);
The ``onReceive`` will handle the request from the master device uppon a slave read request and the ``onRequest`` will handle the answer to the master.
Now, we can start the peripheral configuration by calling ``begin`` function with the device address.
.. code-block:: arduino
Wire.begin((uint8_t)I2C_DEV_ADDR);
By using ``begin`` without any arguments, all the settings will be done by using the default values. To set the values by your own, see the function description. This function is described here: `i2c begin`_
**For ESP32 only!**
Use the function ``slaveWrite`` in order to pre-write to the slave response buffer. This is used only for the ESP32 in order to add the slave capability on the chip and keep compatability with Arduino.
.. code-block:: arduino
Wire.slaveWrite((uint8_t *)message, strlen(message));
I2C Slave APIs
**************
Here are the I2C slave APIs. These function are intended to be used only for slave mode.
begin
^^^^^
In slave mode, the ``begin`` function must be used by passing the **slave address**. You can also define the **pins** and the **bus frequency**.
.. code-block:: arduino
bool Wire.begin(uint8_t addr, int sdaPin, int sclPin, uint32_t frequency)
This function will return ``true`` if the peripheral was initialized correctly.
onReceive
^^^^^^^^^
The ``onReceive`` function is used to define the callback for the data received from the master.
.. code-block:: arduino
void onReceive( void (*)(int) );
onRequest
^^^^^^^^^
The ``onRequest`` function is used to define the callback for the data to be send to the master.
.. code-block:: arduino
void onRequest( void (*)(void) );
slaveWrite
^^^^^^^^^^
The ``slaveWrite`` function writes on the slave response buffer before receiving the response message. This function is only used for adding the slave compatability for the ESP32.
.. warning:: This function is only required for the ESP32. You **don't** need to use for ESP32-S2 and ESP32-C3.
.. code-block:: arduino
size_t slaveWrite(const uint8_t *, size_t);
Example Application - WireSlave.ino
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here is an example of how to use the I2C in Slave Mode.
.. literalinclude:: ../../../libraries/Wire/examples/WireSlave/WireSlave.ino
:language: arduino
.. _Arduino Wire Library: https://www.arduino.cc/en/reference/wire

331
docs/source/api/usb.rst Normal file
View File

@ -0,0 +1,331 @@
#######
USB API
#######
.. note:: This feature is only supported on ESP chips that have USB peripheral, like the ESP32-S2 and ESP32-S3. Some chips, like the ESP32-C3 include native CDC+JTAG peripheral that is not covered here.
About
-----
The **Universal Serial Bus** is a widely used peripheral to exchange data between devices. USB was introduced on the ESP32, supporting both device and host mode.
To learn about the USB, see the `USB.org`_ for developers.
USB as Device
*************
In the device mode, the ESP32 acts as an USB device, like a mouse or keyboard to be connected to a host device, like your computer or smartphone.
USB as Host
***********
The USB host mode, you can connect devices on the ESP32, like external modems, mouse and keyboards.
.. note:: This mode is still under development for the ESP32.
API Description
---------------
This is the common USB API description.
For more supported USB classes implementation, see the following sections:
.. toctree::
:maxdepth: 1
:caption: Classes:
USB CDC <usb_cdc>
USB MSC <usb_msc>
USB Common
**********
These are the common APIs for the USB driver.
onEvent
^^^^^^^
Event handling function to set the callback.
.. code-block:: arduino
void onEvent(esp_event_handler_t callback);
Event handling function for the specific event.
.. code-block:: arduino
void onEvent(arduino_usb_event_t event, esp_event_handler_t callback);
Where ``event`` can be:
* ARDUINO_USB_ANY_EVENT
* ARDUINO_USB_STARTED_EVENT
* ARDUINO_USB_STOPPED_EVENT
* ARDUINO_USB_SUSPEND_EVENT
* ARDUINO_USB_RESUME_EVENT
* ARDUINO_USB_MAX_EVENT
VID
^^^
Set the Vendor ID. This 16 bits identification is used to identify the company that develops the product.
.. note:: You can't define your own VID. If you need your own VID, you need to buy one. See https://www.usb.org/getting-vendor-id for more details.
.. code-block:: arduino
bool VID(uint16_t v);
Get the Vendor ID.
.. code-block:: arduino
uint16_t VID(void);
Returns the Vendor ID. The default value for the VID is: ``0x303A``.
PID
^^^
Set the Product ID. This 16 bits identification is used to identify the product.
.. code-block:: arduino
bool PID(uint16_t p);
Get the Product ID.
.. code-block:: arduino
uint16_t PID(void);
Returns the Product ID. The default PID is: ``0x0002``.
firmwareVersion
^^^^^^^^^^^^^^^
Set the firmware version. This is a 16 bits unsigned value.
.. code-block:: arduino
bool firmwareVersion(uint16_t version);
Get the firmware version.
.. code-block:: arduino
uint16_t firmwareVersion(void);
Return the 16 bits unsigned value. The default value is: ``0x100``.
usbVersion
^^^^^^^^^^
Set the USB version.
.. code-block:: arduino
bool usbVersion(uint16_t version);
Get the USB version.
.. code-block:: arduino
uint16_t usbVersion(void);
Return the USB version. The default value is: ``0x200`` (USB 2.0).
usbPower
^^^^^^^^
Set the USB power as mA (current).
.. note:: This configuration does not change the physical power output. This is only used for the USB device information.
.. code-block:: arduino
bool usbPower(uint16_t mA);
Get the USB power configuration.
.. code-block:: arduino
uint16_t usbPower(void);
Return the current in mA. The default value is: ``0x500`` (500mA).
usbClass
^^^^^^^^
Set the USB class.
.. code-block:: arduino
bool usbClass(uint8_t _class);
Get the USB class.
.. code-block:: arduino
uint8_t usbClass(void);
Return the USB class. The default value is: ``TUSB_CLASS_MISC``.
usbSubClass
^^^^^^^^^^^
Set the USB sub-class.
.. code-block:: arduino
bool usbSubClass(uint8_t subClass);
Get the USB sub-class.
.. code-block:: arduino
uint8_t usbSubClass(void);
Return the USB sub-class. The default value is: ``MISC_SUBCLASS_COMMON``.
usbProtocol
^^^^^^^^^^^
Define the USB protocol.
.. code-block:: arduino
bool usbProtocol(uint8_t protocol);
Get the USB protocol.
.. code-block:: arduino
uint8_t usbProtocol(void);
Return the USB protocol. The default value is: ``MISC_PROTOCOL_IAD``
usbAttributes
^^^^^^^^^^^^^
Set the USB attributes.
.. code-block:: arduino
bool usbAttributes(uint8_t attr);
Get the USB attributes.
.. code-block:: arduino
uint8_t usbAttributes(void);
Return the USB attributes. The default value is: ``TUSB_DESC_CONFIG_ATT_SELF_POWERED``
webUSB
^^^^^^
This function is used to enable the ``webUSB`` functionality.
.. code-block:: arduino
bool webUSB(bool enabled);
This function is used to get the ``webUSB`` setting.
.. code-block:: arduino
bool webUSB(void);
Return the ``webUSB`` setting (`Enabled` or `Disabled`)
productName
^^^^^^^^^^^
This function is used to define the product name.
.. code-block:: arduino
bool productName(const char * name);
This function is used to get the product's name.
.. code-block:: arduino
const char * productName(void);
manufacturerName
^^^^^^^^^^^^^^^^
This function is used to define the manufacturer name.
.. code-block:: arduino
bool manufacturerName(const char * name);
This function is used to get the manufacturer's name.
.. code-block:: arduino
const char * manufacturerName(void);
serialNumber
^^^^^^^^^^^^
This function is used to define the serial number.
.. code-block:: arduino
bool serialNumber(const char * name);
This function is used to get the serial number.
.. code-block:: arduino
const char * serialNumber(void);
The default serial number is: ``0``.
webUSBURL
^^^^^^^^^
This function is used to define the ``webUSBURL``.
.. code-block:: arduino
bool webUSBURL(const char * name);
This function is used to get the ``webUSBURL``.
.. code-block:: arduino
const char * webUSBURL(void);
The default ``webUSBURL`` is: https://espressif.github.io/arduino-esp32/webusb.html
enableDFU
^^^^^^^^^
This function is used to enable the DFU capability.
.. code-block:: arduino
bool enableDFU();
begin
^^^^^
This function is used to start the peripheral using the default configuration.
.. code-block:: arduino
bool begin();
Example Code
------------
There are a collection of USB device examples on the project GitHub, including Firmware MSC update, USB CDC, HID and composite device.
.. _USB.org: https://www.usb.org/developers

192
docs/source/api/usb_cdc.rst Normal file
View File

@ -0,0 +1,192 @@
#######
USB CDC
#######
About
-----
USB Communications Device Class API. This class is used to enable communication between the host and the device.
This class is often used to enable serial communication and can be used to flash the firmware on the ESP32 without the external USB to Serial chip.
APIs
****
onEvent
^^^^^^^
Event handling functions.
.. code-block:: arduino
void onEvent(esp_event_handler_t callback);
.. code-block:: arduino
void onEvent(arduino_usb_cdc_event_t event, esp_event_handler_t callback);
Where ``event`` can be:
* ARDUINO_USB_CDC_ANY_EVENT
* ARDUINO_USB_CDC_CONNECTED_EVENT
* ARDUINO_USB_CDC_DISCONNECTED_EVENT
* ARDUINO_USB_CDC_LINE_STATE_EVENT
* ARDUINO_USB_CDC_LINE_CODING_EVENT
* ARDUINO_USB_CDC_RX_EVENT
* ARDUINO_USB_CDC_TX_EVENT
* ARDUINO_USB_CDC_MAX_EVENT
setRxBufferSize
^^^^^^^^^^^^^^^
The ``setRxBufferSize`` function is used to set the size of the RX buffer.
.. code-block:: arduino
size_t setRxBufferSize(size_t size);
setTxTimeoutMs
^^^^^^^^^^^^^^
This function is used to define the time to reach the timeout for the TX.
.. code-block:: arduino
void setTxTimeoutMs(uint32_t timeout);
begin
^^^^^
This function is used to start the peripheral using the default CDC configuration.
.. code-block:: arduino
void begin(unsigned long baud);
Where:
* ``baud`` is the baud rate.
end
^^^
This function will finish the peripheral as CDC and release all the allocated resources. After calling ``end`` you need to use ``begin`` again in order to initialize the USB CDC driver again.
.. code-block:: arduino
void end();
available
^^^^^^^^^
This function will return if there are messages in the queue.
.. code-block:: arduino
int available(void);
The return is the number of bytes available to read.
availableForWrite
^^^^^^^^^^^^^^^^^
This function will return if the hardware is available to write data.
.. code-block:: arduino
int availableForWrite(void);
peek
^^^^
This function is used to ``peek`` messages from the queue.
.. code-block:: arduino
int peek(void);
read
^^^^
This function is used to read the bytes available.
.. code-block:: arduino
size_t read(uint8_t *buffer, size_t size);
Where:
* ``buffer`` is the pointer to the buffer to be read.
* ``size`` is the number of bytes to be read.
write
^^^^^
This function is used to write the message.
.. code-block:: arduino
size_t write(const uint8_t *buffer, size_t size);
Where:
* ``buffer`` is the pointer to the buffer to be written.
* ``size`` is the number of bytes to be written.
flush
^^^^^
This function is used to flush the data.
.. code-block:: arduino
void flush(void);
baudRate
^^^^^^^^
This function is used to get the ``baudRate``.
.. code-block:: arduino
uint32_t baudRate();
setDebugOutput
^^^^^^^^^^^^^^
This function will enable the debug output, usually from the `UART0`, to the USB CDC.
.. code-block:: arduino
void setDebugOutput(bool);
enableReboot
^^^^^^^^^^^^
This function enables the device to reboot by the DTR as RTS signals.
.. code-block:: arduino
void enableReboot(bool enable);
rebootEnabled
^^^^^^^^^^^^^
This function will return if the reboot is enabled.
.. code-block:: arduino
bool rebootEnabled(void);
Example Code
------------
Here is an example of how to use the USB CDC.
USBSerial
*********
.. literalinclude:: ../../../libraries/USB/examples/USBSerial/USBSerial.ino
:language: arduino
.. _USB.org: https://www.usb.org/developers

114
docs/source/api/usb_msc.rst Normal file
View File

@ -0,0 +1,114 @@
#######
USB MSC
#######
About
-----
USB Mass Storage Class API. This class makes the device accessible as a mass storage device and allows you to transfer data between the host and the device.
One of the examples for this mode is to flash the device by dropping the firmware binary like a flash memory device when connecting the ESP32 to the host computer.
APIs
****
begin
^^^^^
This function is used to start the peripheral using the default MSC configuration.
.. code-block:: arduino
bool begin(uint32_t block_count, uint16_t block_size);
Where:
* ``block_count`` set the disk sector count.
* ``block_size`` set the disk sector size.
This function will return ``true`` if the configuration was successful.
end
^^^
This function will finish the peripheral as MSC and release all the allocated resources. After calling ``end`` you need to use ``begin`` again in order to initialize the USB MSC driver again.
.. code-block:: arduino
void end();
vendorID
^^^^^^^^
This function is used to define the vendor ID.
.. code-block:: arduino
void vendorID(const char * vid);//max 8 chars
productID
^^^^^^^^^
This function is used to define the product ID.
.. code-block:: arduino
void productID(const char * pid);//max 16 chars
productRevision
^^^^^^^^^^^^^^^
This function is used to define the product revision.
.. code-block:: arduino
void productRevision(const char * ver);//max 4 chars
mediaPresent
^^^^^^^^^^^^
Set the ``mediaPresent`` configuration.
.. code-block:: arduino
void mediaPresent(bool media_present);
onStartStop
^^^^^^^^^^^
Set the ``onStartStop`` callback function.
.. code-block:: arduino
void onStartStop(msc_start_stop_cb cb);
onRead
^^^^^^
Set the ``onRead`` callback function.
.. code-block:: arduino
void onRead(msc_read_cb cb);
onWrite
^^^^^^^
Set the ``onWrite`` callback function.
.. code-block:: arduino
void onWrite(msc_write_cb cb);
Example Code
------------
Here is an example of how to use the USB MSC.
FirmwareMSC
***********
.. literalinclude:: ../../../libraries/USB/examples/FirmwareMSC/FirmwareMSC.ino
:language: arduino
.. _USB.org: https://www.usb.org/developers

View File

@ -26,7 +26,7 @@ a Wi-Fi network.
:width: 520
:figclass: align-center
This mode can be used for serving a HTTP or HTTPS server inside the ESP32, for example.
This mode can be used for serving an HTTP or HTTPS server inside the ESP32, for example.
Working as STA
**************
@ -38,12 +38,34 @@ The STA mode is used to connect the ESP32 to a Wi-Fi network, provided by an Acc
:width: 520
:figclass: align-center
If you need to connect your project to the Internet, this is the mode you are looking for.
This is the mode to be used if you want to connect your project to the Internet.
API Description
---------------
Here is the description about the WiFi API.
Here is the description of the WiFi API.
Common API
----------
Here are the common APIs that are used for both modes, AP and STA.
useStaticBuffers
****************
This function is used to set the memory allocation mode for the Wi-Fi buffers.
.. code-block:: arduino
static void useStaticBuffers(bool bufferMode);
* Set ``true`` to use the Wi-Fi buffers memory allocation as **static**.
* Set ``false`` to set the buffers memory allocation to **dynamic**.
The use of dynamic allocation is recommended to save memory and reduce resources usage. However, the dynamic performs slightly slower than the static allocation.
Use static allocation if you want to have more performance and if your application is multi-tasking.
By default, the memory allocation will be set to **dynamic** if this function is not being used.
WiFiAP
------

View File

@ -5,13 +5,15 @@ Arduino as a ESP-IDF component
ESP32 Arduino lib-builder
-------------------------
For a simplified method, see `lib-builder <lib_builder>`_.
For a simplified method, see `lib-builder <https://github.com/espressif/esp32-arduino-lib-builder>`_.
Installation
------------
.. note:: Latest Arduino Core ESP32 version is now compatible with `ESP-IDF v4.4 <https://github.com/espressif/esp-idf/tree/release/v4.4>`_. Please consider this compability when using Arduino as component in ESP-IDF.
- Download and install `ESP-IDF <https://github.com/espressif/esp-idf>`_.
- Create blank idf project (from one of the examples).
- Create blank ESP-IDF project (use sample_project from /examples/get-started) or choose one of the examples.
- In the project folder, create a new folder called `components` and clone this repository inside the new created folder.
.. code-block:: bash
@ -24,10 +26,19 @@ Installation
cd ../.. && \
idf.py menuconfig
Option 1. Using Arduino setup() and loop()
******************************************
- The `idf.py menuconfig` has some Arduino options.
- On `Autostart Arduino setup and loop on boot`.
- If you enable these options, your main.cpp should be formated like any other sketch.
- Turn on `Autostart Arduino setup and loop on boot`.
- In main folder rename file `main.c` to `main.cpp`.
- In main folder open file `CMakeList.txt` and change `main.c` to `main.cpp` as described below.
.. code-block:: bash
idf_component_register(SRCS "main.cpp" INCLUDE_DIRS ".")
- Your main.cpp should be formated like any other sketch.
.. code-block:: c
@ -43,14 +54,17 @@ Installation
delay(1000);
}
- Otherwise, you need to implement ```app_main()``` and call ```initArduino();``` in it.
Option 2. Using ESP-IDF appmain()
*********************************
- You need to implement ``app_main()`` and call ``initArduino();`` in it.
Keep in mind that setup() and loop() will not be called in this case.
If you plan to base your code on examples provided in `examples <https://github.com/espressif/esp-idf/tree/master/examples>`_, please make sure to move the app_main() function in main.cpp from the files in the example.
.. code-block:: cpp
//file: main.cpp
//file: main.c or main.cpp
#include "Arduino.h"
extern "C" void app_main()
@ -67,7 +81,11 @@ If you plan to base your code on examples provided in `examples <https://github.
- If enabled, WiFi will start with the last known configuration
- Otherwise it will wait for WiFi.begin
- ```idf.py -p <your-board-serial-port> flash monitor``` will build, upload and open serial monitor to your board
Build, flash and monitor
************************
- For both options use command ``idf.py -p <your-board-serial-port> flash monitor``
- It will build, upload and open serial monitor to your board.
Logging To Serial
-----------------

View File

@ -37,7 +37,7 @@ SoC Stable Development Datasheet
ESP32 Yes Yes `ESP32 Datasheet`_
ESP32-S2 Yes Yes `ESP32-S2 Datasheet`_
ESP32-C3 Yes Yes `ESP32-C3 Datasheet`_
ESP32-S3 No No Not Available Yet
ESP32-S3 No No `ESP32-S3 Datasheet`_
======== ====== =========== ===================================
See `Boards <boards/boards.html>`_ for more details about ESP32 development boards.
@ -122,6 +122,7 @@ Resources
.. _ESP32 Datasheet: https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
.. _ESP32-S2 Datasheet: https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf
.. _ESP32-C3 Datasheet: https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf
.. _ESP32-S3 Datasheet: https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf
.. _Arduino.cc: https://www.arduino.cc/en/Main/Software
.. _Arduino Reference: https://www.arduino.cc/reference/en/
.. _ESP32 Forum: https://esp32.com

View File

@ -29,7 +29,7 @@ This is the preferred and easiest way to install Arduino-ESP32.
.. note::
Starting with the Arduino IDE version 1.6.4, Arduino allows installation of third-party platform
packages using Boards Manager. We have packages available for Windows, macOS, and Linux (x86, amd64, armhf and arm64).
packages using Boards Manager. We have packages available for Windows, macOS, and Linux.
To start the installation process using the Boards Managaer, follow these steps:
@ -61,10 +61,11 @@ To start the installation process using the Boards Managaer, follow these steps:
Windows
-------
Steps to install Arduino ESP32 support on Windows:
.. warning:: Arduino ESP32 core v2.x.x cannot be used on Windows 8.x x86 (32 bits), Windows 7 or earlier. The Windows 32 bits OS is no longer supported by this toolchain.
.. note::
Tested on Windows 10 32 and 64 bit machines.
The Arduino ESP32 v1.0.6 still works on WIN32. You might want to install python 3.8.x because it is the latest release supported by Windows 7.
Steps to install Arduino ESP32 support on Windows:
**Step 1**

View File

@ -2,16 +2,89 @@
Libraries
#########
Here is where the Libraries API's descriptions are located.
Here is where the Libraries API's descriptions are located:
Supported Peripherals
---------------------
Currently, the Arduino ESP32 supports the following peripherals with Arduino APIs.
+---------------+---------------+---------------+---------------+-------------------------------+
| Peripheral | ESP32 | ESP32-S2 | ESP32-C3 | Comments |
+===============+===============+===============+===============+===============================+
| ADC | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Bluetooth | Yes | Not Supported | Not Supported | Bluetooth Classic |
+---------------+---------------+---------------+---------------+-------------------------------+
| BLE | Yes | Not Supported | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| DAC | Yes | Yes | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Ethernet | Yes | Not Supported | Not Supported | (*) |
+---------------+---------------+---------------+---------------+-------------------------------+
| GPIO | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Hall Sensor | Yes | Not Supported | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| I2C | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| I2S | No | No | No | WIP |
+---------------+---------------+---------------+---------------+-------------------------------+
| LEDC | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Motor PWM | No | Not Supported | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Pulse Counter | No | No | No | |
+---------------+---------------+---------------+---------------+-------------------------------+
| RMT | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| SDIO | No | No | No | |
+---------------+---------------+---------------+---------------+-------------------------------+
| SPI | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Timer | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Temp. Sensor | Not Supported | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Touch | Yes | Yes | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| TWAI | No | No | No | |
+---------------+---------------+---------------+---------------+-------------------------------+
| UART | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| USB | Not Supported | Yes | Yes | ESP32-C3 only CDC/JTAG |
+---------------+---------------+---------------+---------------+-------------------------------+
| Wi-Fi | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
Notes
^^^^^
(*) SPI Ethernet is supported by all ESP32 families and RMII only for ESP32.
.. note:: Some peripherals are not available for all ESP32 families. To see more details about it, see the corresponding SoC at `Product Selector <https://products.espressif.com>`_ page.
Datasheet
^^^^^^^^^
* `ESP32 <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_
* `ESP32-S2 <https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf>`_
* `ESP32-C3 <https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf>`_
APIs
----
The Arduino ESP32 offers some unique APIs, described in this section:
.. toctree::
:maxdepth: 1
:caption: API's:
Bluetooth <api/bluetooth>
Deep Sleep <api/deepsleep>
ESPNOW <api/espnow>
GPIO <api/gpio>
I2C <api/i2c>
RainMaker <api/rainmaker>
Reset Reason <api/reset_reason>
USB <api/usb.rst>
Wi-Fi <api/wifi>

View File

@ -26,6 +26,7 @@
#define HID_CARD_READER 0x03C6
#define HID_DIGITAL_PEN 0x03C7
#define HID_BARCODE 0x03C8
#define HID_BRAILLE_DISPLAY 0x03C9
class BLEHIDDevice {
public:

View File

@ -7,7 +7,7 @@
* Author: Thomas M. (ArcticSnowSky)
*/
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
#include "BTAddress.h"
#include <string>

View File

@ -10,7 +10,7 @@
#ifndef COMPONENTS_CPP_UTILS_BTADDRESS_H_
#define COMPONENTS_CPP_UTILS_BTADDRESS_H_
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
#include <esp_gap_bt_api.h> // ESP32 BT
#include <string>

View File

@ -6,7 +6,7 @@
*/
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
//#include <map>

View File

@ -6,7 +6,7 @@
*/
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
#include <esp_err.h>

View File

@ -1,9 +1,7 @@
void setup()
{
//setup channel 0 with frequency 312500 Hz
sigmaDeltaSetup(0, 312500);
//attach pin 18 to channel 0
sigmaDeltaAttachPin(18,0);
//setup on pin 18, channel 0 with frequency 312500 Hz
sigmaDeltaSetup(18,0, 312500);
//initialize channel 0 to off
sigmaDeltaWrite(0, 0);
}

View File

@ -0,0 +1,36 @@
/*
ESP32 Arduino creates a task to run setup() and then to execute loop() continuously
This task can be found at https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp
By default "loopTask" will be created with a stack size of 8KB.
This should be plenty for most general sketches.
There is a way to change the stack size of this task by using
SET_LOOP_TASK_STACK_SIZE(size);
It will bypass the default stack size of 8KB and allow the user to define a new size.
It is recommend this value to be higher than 8KB, for instance 16KB.
This increasing may be necessary for the sketches that use deep recursion for instance.
In this example, you can verify it by changing or just commenting out SET_LOOP_TASK_STACK_SIZE();
*/
// This sets Arduino Stack Size - comment this line to use default 8K stack size
SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
void setup() {
Serial.begin(115200);
Serial.printf("Arduino Stack was set to %d bytes", getArduinoLoopTaskStackSize());
// Print unused stack for the task that is running setup()
Serial.printf("\nSetup() - Free Stack Space: %d", uxTaskGetStackHighWaterMark(NULL));
}
void loop() {
delay(1000);
// Print unused stack for the task that is running loop() - the same as for setup()
Serial.printf("\nLoop() - Free Stack Space: %d", uxTaskGetStackHighWaterMark(NULL));
}

View File

@ -12,7 +12,7 @@ class MyProcessor {
public:
MyProcessor(uint8_t pin, float nanoTicks) {
assert((rmt_recv = rmtInit(21, false, RMT_MEM_192)));
assert((rmt_recv = rmtInit(21, RMT_RX_MODE, RMT_MEM_192)));
realNanoTick = rmtSetTick(rmt_recv, nanoTicks);
};
@ -61,4 +61,4 @@ void loop()
{
Serial.printf("GPIO 4: %08x 5: %08x 6: %08x\n", mp1.val(), mp2.val(), mp3.val());
delay(500);
}
}

View File

@ -5,6 +5,17 @@
#include "esp32-hal.h"
#if CONFIG_IDF_TARGET_ESP32C3
// ESP32 C3 has only 2 channels for RX and 2 for TX, thus MAX RMT_MEM is 128
#define RMT_TX_PIN 4
#define RMT_RX_PIN 5
#define RMT_MEM_RX RMT_MEM_128
#else
#define RMT_TX_PIN 18
#define RMT_RX_PIN 21
#define RMT_MEM_RX RMT_MEM_192
#endif
rmt_data_t my_data[256];
rmt_data_t data[256];
@ -18,18 +29,19 @@ void setup()
Serial.begin(115200);
events = xEventGroupCreate();
if ((rmt_send = rmtInit(18, true, RMT_MEM_64)) == NULL)
if ((rmt_send = rmtInit(RMT_TX_PIN, RMT_TX_MODE, RMT_MEM_64)) == NULL)
{
Serial.println("init sender failed\n");
}
if ((rmt_recv = rmtInit(21, false, RMT_MEM_192)) == NULL)
if ((rmt_recv = rmtInit(RMT_RX_PIN, RMT_RX_MODE, RMT_MEM_RX)) == NULL)
{
Serial.println("init receiver failed\n");
}
float realTick = rmtSetTick(rmt_send, 100);
printf("real tick set to: %fns\n", realTick);
// both will keep same tick
realTick = rmtSetTick(rmt_recv, 100);
}
void loop()

View File

@ -182,7 +182,7 @@ void setup()
Serial.begin(115200);
// Initialize the channel to capture up to 192 items
if ((rmt_recv = rmtInit(21, false, RMT_MEM_192)) == NULL)
if ((rmt_recv = rmtInit(21, RMT_RX_MODE, RMT_MEM_192)) == NULL)
{
Serial.println("init receiver failed\n");
}

View File

@ -41,7 +41,7 @@ void setup()
{
Serial.begin(115200);
if ((rmt_send = rmtInit(18, true, RMT_MEM_64)) == NULL)
if ((rmt_send = rmtInit(18, RMT_TX_MODE, RMT_MEM_64)) == NULL)
{
Serial.println("init sender failed\n");
}

View File

@ -0,0 +1,9 @@
name=Ethernet
version=2.0.0
author=Hristo Gochkov
maintainer=Hristo Gochkov <hristo@espressif.com>
sentence=Enables network connection (local and Internet) using the ESP32 Ethernet.
paragraph=With this library you can instantiate Servers, Clients and send/receive UDP packets through Ethernet. The IP address can be assigned statically or through a DHCP. The library can also manage DNS.
category=Communication
url=
architectures=esp32

View File

@ -282,7 +282,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
break;
#endif
case ETH_PHY_KSZ8081:
#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(4,3,0)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4,4,0)
eth_phy = esp_eth_phy_new_ksz8081(&phy_config);
#else
log_e("unsupported ethernet type 'ETH_PHY_KSZ8081'");
@ -368,6 +368,10 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
log_e("esp_eth_init error: %d", err);
}
#endif
// holds a few microseconds to let DHCP start and enter into a good state
// FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733
delay(50);
return true;
}
@ -396,7 +400,8 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
if(err != ERR_OK){
log_e("STA IP could not be configured! Error: %d", err);
return false;
}
}
if(info.ip.addr){
staticIP = true;
} else {

View File

@ -200,6 +200,7 @@ bool HTTPClient::begin(String url, const char* CAcert)
end();
}
clear();
_port = 443;
if (!beginInternal(url, "https")) {
return false;
@ -226,6 +227,7 @@ bool HTTPClient::begin(String url)
end();
}
clear();
_port = 80;
if (!beginInternal(url, "http")) {
return begin(url, (const char*)NULL);
@ -243,7 +245,6 @@ bool HTTPClient::begin(String url)
bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
{
log_v("url: %s", url.c_str());
clear();
// check for : (http: or https:
int index = url.indexOf(':');
@ -463,6 +464,17 @@ void HTTPClient::setAuthorization(const char * auth)
}
}
/**
* set the Authorization type for the http request
* @param authType const char *
*/
void HTTPClient::setAuthorizationType(const char * authType)
{
if(authType) {
_authorizationType = authType;
}
}
/**
* set the timeout (ms) for establishing a connection to the server
* @param connectTimeout int32_t
@ -1178,7 +1190,9 @@ bool HTTPClient::sendHeader(const char * type)
if(_base64Authorization.length()) {
_base64Authorization.replace("\n", "");
header += F("Authorization: Basic ");
header += F("Authorization: ");
header += _authorizationType;
header += " ";
header += _base64Authorization;
header += "\r\n";
}
@ -1199,8 +1213,8 @@ int HTTPClient::handleHeaderResponse()
return HTTPC_ERROR_NOT_CONNECTED;
}
clear();
_returnCode = 0;
_size = -1;
_canReuse = _reuse;
String transferEncoding;

View File

@ -171,6 +171,7 @@ public:
void setUserAgent(const String& userAgent);
void setAuthorization(const char * user, const char * password);
void setAuthorization(const char * auth);
void setAuthorizationType(const char * authType);
void setConnectTimeout(int32_t connectTimeout);
void setTimeout(uint16_t timeout);
@ -251,6 +252,7 @@ protected:
String _headers;
String _userAgent = "ESP32HTTPClient";
String _base64Authorization;
String _authorizationType = "Basic";
/// Response handling
RequestArgument* _currentHeaders = nullptr;

View File

@ -8,9 +8,6 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### AsyncUDP
Asynchronous task driven UDP datagram client/server
### AzureIoT
Library to interact with Microsoft Azure IoT services
### BLE
Bluetooth Low Energy v4.2 client/server framework
@ -43,6 +40,9 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### ESPmDNS
mDNS service advertising
### Ethernet
Ethernet networking
### FFat
FAT indexed filesystem on SPI flash
@ -55,6 +55,12 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### HTTPUpdate
Download a firmware update from HTTPd and apply it using Update
### HTTPUpdateServer
Upload a firmware for the update from HTTPd
### LittleFS
LittleFS (File System)
### NetBIOS
NetBIOS name advertiser
@ -85,6 +91,9 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
### Update
Sketch Update using ESP32 OTA functionality
### USB
Universal Serial Bus driver (device only)
### WebServer
A simple HTTP daemon
@ -95,4 +104,4 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec
Arduino compatible WiFi client object using embedded encryption
### Wire
Arduino compatible I2C driver (master only)
Arduino compatible I2C driver

View File

@ -0,0 +1,193 @@
//This example demonstrates the ESP RainMaker with a standard Switch device.
#include "RMaker.h"
#include "WiFi.h"
#include "WiFiProv.h"
#define DEFAULT_POWER_MODE false
const char *service_name = "PROV_SONOFF_DUALR3";
const char *pop = "123456";
// GPIO for push button
static uint8_t gpio_reset = 0;
// GPIO for switch
static uint8_t gpio_switch1 = 32;
static uint8_t gpio_switch2 = 33;
// GPIO for virtual device
static uint8_t gpio_relay1 = 27;
static uint8_t gpio_relay2 = 14;
/* Variable for reading pin status*/
bool switch_state_ch1 = true;
bool switch_state_ch2 = true;
// GPIO for link status LED
static uint8_t gpio_led = 13;
struct LightSwitch {
const uint8_t pin;
bool pressed;
};
// Define the light switches for channel 1 and 2
LightSwitch switch_ch1 = {gpio_switch1, false};
LightSwitch switch_ch2 = {gpio_switch2, false};
//The framework provides some standard device types like switch, lightbulb, fan, temperature sensor.
static Switch my_switch1("Switch_ch1", &gpio_relay1);
static Switch my_switch2("Switch_ch2", &gpio_relay2);
void sysProvEvent(arduino_event_t *sys_event)
{
switch (sys_event->event_id) {
case ARDUINO_EVENT_PROV_START:
#if CONFIG_IDF_TARGET_ESP32
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");
#else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
printQR(service_name, pop, "softap");
#endif
break;
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
Serial.printf("\nConnected to Wi-Fi!\n");
digitalWrite(gpio_led, true);
break;
}
}
void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
const char *device_name = device->getDeviceName();
const char *param_name = param->getParamName();
if(strcmp(device_name, "Switch_ch1") == 0) {
Serial.printf("Lightbulb = %s\n", val.val.b? "true" : "false");
if(strcmp(param_name, "Power") == 0) {
Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
switch_state_ch1 = val.val.b;
(switch_state_ch1 == false) ? digitalWrite(gpio_relay1, LOW) : digitalWrite(gpio_relay1, HIGH);
param->updateAndReport(val);
}
} else if(strcmp(device_name, "Switch_ch2") == 0) {
Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");
if(strcmp(param_name, "Power") == 0) {
Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
switch_state_ch2 = val.val.b;
(switch_state_ch2 == false) ? digitalWrite(gpio_relay2, LOW) : digitalWrite(gpio_relay2, HIGH);
param->updateAndReport(val);
}
}
}
void ARDUINO_ISR_ATTR isr(void* arg) {
LightSwitch* s = static_cast<LightSwitch*>(arg);
s->pressed = true;
}
void setup()
{
uint32_t chipId = 0;
Serial.begin(115200);
// Configure the input GPIOs
pinMode(gpio_reset, INPUT);
pinMode(switch_ch1.pin, INPUT_PULLUP);
attachInterruptArg(switch_ch1.pin, isr, &switch_ch1, CHANGE);
pinMode(switch_ch2.pin, INPUT_PULLUP);
attachInterruptArg(switch_ch2.pin, isr, &switch_ch2, CHANGE);
// Set the Relays GPIOs as output mode
pinMode(gpio_relay1, OUTPUT);
pinMode(gpio_relay2, OUTPUT);
pinMode(gpio_led, OUTPUT);
// Write to the GPIOs the default state on booting
digitalWrite(gpio_relay1, DEFAULT_POWER_MODE);
digitalWrite(gpio_relay2, DEFAULT_POWER_MODE);
digitalWrite(gpio_led, false);
Node my_node;
my_node = RMaker.initNode("Sonoff Dual R3");
//Standard switch device
my_switch1.addCb(write_callback);
my_switch2.addCb(write_callback);
//Add switch device to the node
my_node.addDevice(my_switch1);
my_node.addDevice(my_switch2);
//This is optional
RMaker.enableOTA(OTA_USING_PARAMS);
//If you want to enable scheduling, set time zone for your region using setTimeZone().
//The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
// RMaker.setTimeZone("Asia/Shanghai");
// Alternatively, enable the Timezone service and let the phone apps set the appropriate timezone
RMaker.enableTZService();
RMaker.enableSchedule();
//Service Name
for(int i=0; i<17; i=i+8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
Serial.printf("\nChip ID: %d Service Name: %s\n", chipId, service_name);
Serial.printf("\nStarting ESP-RainMaker\n");
RMaker.start();
WiFi.onEvent(sysProvEvent);
#if CONFIG_IDF_TARGET_ESP32
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
#endif
}
void loop()
{
if (switch_ch1.pressed) {
Serial.printf("Switch 1 has been changed\n");
switch_ch1.pressed = false;
// Toggle switch 1 device state
switch_state_ch1 = !switch_state_ch1;
Serial.printf("Toggle State to %s.\n", switch_state_ch1 ? "true" : "false");
my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, switch_state_ch1);
(switch_state_ch1 == false) ? digitalWrite(gpio_relay1, LOW) : digitalWrite(gpio_relay1, HIGH);
} else if (switch_ch2.pressed) {
Serial.printf("Switch 2 has been changed\n");
switch_ch2.pressed = false;
// Toggle switch 2 device state
switch_state_ch2 = !switch_state_ch2;
Serial.printf("Toggle State to %s.\n", switch_state_ch2 ? "true" : "false");
my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, switch_state_ch2);
(switch_state_ch2 == false) ? digitalWrite(gpio_relay2, LOW) : digitalWrite(gpio_relay2, HIGH);
}
// Read GPIO0 (external button to reset device
if(digitalRead(gpio_reset) == LOW) { //Push button pressed
Serial.printf("Reset Button Pressed!\n");
// Key debounce handling
delay(100);
int startTime = millis();
while(digitalRead(gpio_reset) == LOW) delay(50);
int endTime = millis();
if ((endTime - startTime) > 10000) {
// If key pressed for more than 10secs, reset all
Serial.printf("Reset to factory.\n");
RMakerFactoryReset(2);
} else if ((endTime - startTime) > 3000) {
Serial.printf("Reset Wi-Fi.\n");
// If key pressed for more than 3secs, but less than 10, reset Wi-Fi
RMakerWiFiReset(2);
}
}
delay(100);
}

View File

@ -609,6 +609,11 @@ unknown_card:
DSTATUS ff_sd_status(uint8_t pdrv)
{
if(sdCommand(pdrv, SEND_STATUS, 0, NULL) == 0xFF)
{
log_e("Check status failed");
return STA_NOINIT;
}
return s_cards[pdrv]->status;
}

View File

@ -172,7 +172,7 @@ class WiFiGenericClass
bool setTxPower(wifi_power_t power);
wifi_power_t getTxPower();
bool initiateFTM(uint8_t frm_count=16, uint16_t burst_period=2, uint8_t channel=0, const uint8_t * mac=NULL);
bool initiateFTM(uint8_t frm_count=16, uint16_t burst_period=2, uint8_t channel=1, const uint8_t * mac=NULL);
static const char * getHostname();
static bool setHostname(const char * hostname);

View File

@ -98,7 +98,7 @@ static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL,
if(ssid != NULL && ssid[0] != 0){
_wifi_strncpy((char*)wifi_config->sta.ssid, ssid, 32);
if(password != NULL && password[0] != 0){
wifi_config->sta.threshold.authmode = WIFI_AUTH_WEP;
wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
_wifi_strncpy((char*)wifi_config->sta.password, password, 64);
}
if(bssid != NULL){
@ -176,15 +176,19 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
wifi_config_t conf;
memset(&conf, 0, sizeof(wifi_config_t));
_wifi_strncpy(reinterpret_cast<char*>(conf.sta.ssid), ssid, 32);
conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; //force full scan to be able to choose the nearest / strongest AP
if(passphrase) {
_wifi_strncpy(reinterpret_cast<char*>(conf.sta.password), passphrase, 64);
}
wifi_config_t current_conf;
wifi_sta_config(&conf, ssid, passphrase, bssid, channel);
if(channel == 0) {
// If no specific channel specified, then do an slower WIFI_ALL_CHANNEL_SCAN
wifi_sta_config(&conf, ssid, passphrase, bssid, channel, WIFI_ALL_CHANNEL_SCAN);
}
else
wifi_sta_config(&conf, ssid, passphrase, bssid, channel, WIFI_FAST_SCAN);
wifi_config_t current_conf;
if(esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, &current_conf) != ESP_OK){
log_e("get current config failed!");
return WL_CONNECT_FAILED;

View File

@ -45,6 +45,8 @@ static int _handle_error(int err, const char * function, int line)
void ssl_init(sslclient_context *ssl_client)
{
// reset embedded pointers to zero
memset(ssl_client, 0, sizeof(sslclient_context));
mbedtls_ssl_init(&ssl_client->ssl_ctx);
mbedtls_ssl_config_init(&ssl_client->ssl_conf);
mbedtls_ctr_drbg_init(&ssl_client->drbg_ctx);
@ -232,6 +234,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
ret = mbedtls_pk_parse_key(&ssl_client->client_key, (const unsigned char *)cli_key, strlen(cli_key) + 1, NULL, 0);
if (ret != 0) {
mbedtls_x509_crt_free(&ssl_client->client_cert); // cert+key are free'd in pair
return handle_error(ret);
}
@ -243,7 +246,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
// Hostname set here should match CN in server certificate
if((ret = mbedtls_ssl_set_hostname(&ssl_client->ssl_ctx, host)) != 0){
return handle_error(ret);
}
}
mbedtls_ssl_conf_rng(&ssl_client->ssl_conf, mbedtls_ctr_drbg_random, &ssl_client->drbg_ctx);
@ -260,8 +263,8 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
return handle_error(ret);
}
if((millis()-handshake_start_time)>ssl_client->handshake_timeout)
return -1;
vTaskDelay(2);//2 ticks
return -1;
vTaskDelay(2);//2 ticks
}
@ -280,7 +283,6 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
memset(buf, 0, sizeof(buf));
mbedtls_x509_crt_verify_info(buf, sizeof(buf), " ! ", flags);
log_e("Failed to verify peer certificate! verification info: %s", buf);
stop_ssl_socket(ssl_client, rootCABuff, cli_cert, cli_key); //It's not safe continue.
return handle_error(ret);
} else {
log_v("Certificate verified.");
@ -313,10 +315,20 @@ void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, cons
ssl_client->socket = -1;
}
// avoid memory leak if ssl connection attempt failed
if (ssl_client->ssl_conf.ca_chain != NULL) {
mbedtls_x509_crt_free(&ssl_client->ca_cert);
}
if (ssl_client->ssl_conf.key_cert != NULL) {
mbedtls_x509_crt_free(&ssl_client->client_cert);
mbedtls_pk_free(&ssl_client->client_key);
}
mbedtls_ssl_free(&ssl_client->ssl_ctx);
mbedtls_ssl_config_free(&ssl_client->ssl_conf);
mbedtls_ctr_drbg_free(&ssl_client->drbg_ctx);
mbedtls_entropy_free(&ssl_client->entropy_ctx);
// reset embedded pointers to zero
memset(ssl_client, 0, sizeof(sslclient_context));
}

View File

@ -354,7 +354,7 @@ uint8_t TwoWire::endTransmission(bool sendStop)
return 4;
}
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t size, bool sendStop)
size_t TwoWire::requestFrom(uint16_t address, size_t size, bool sendStop)
{
if(is_slave){
log_e("Bus is in Slave Mode");
@ -445,34 +445,47 @@ void TwoWire::flush(void)
//i2cFlush(num); // cleanup
}
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop)
size_t TwoWire::requestFrom(uint8_t address, size_t len, bool sendStop)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop));
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(len), static_cast<bool>(sendStop));
}
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t len, uint8_t sendStop)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(len), static_cast<bool>(sendStop));
}
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity, uint8_t sendStop)
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t len, uint8_t sendStop)
{
return requestFrom(address, static_cast<size_t>(quantity), static_cast<bool>(sendStop));
return requestFrom(address, static_cast<size_t>(len), static_cast<bool>(sendStop));
}
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
/* Added to match the Arduino function definition: https://github.com/arduino/ArduinoCore-API/blob/173e8eadced2ad32eeb93bcbd5c49f8d6a055ea6/api/HardwareI2C.h#L39
* See: https://github.com/arduino-libraries/ArduinoECCX08/issues/25
*/
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t len, bool stopBit)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
return requestFrom((uint16_t)address, (size_t)len, stopBit);
}
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity)
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t len)
{
return requestFrom(address, static_cast<size_t>(quantity), true);
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(len), true);
}
uint8_t TwoWire::requestFrom(int address, int quantity)
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t len)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
return requestFrom(address, static_cast<size_t>(len), true);
}
uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
uint8_t TwoWire::requestFrom(int address, int len)
{
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop)));
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(len), true);
}
uint8_t TwoWire::requestFrom(int address, int len, int sendStop)
{
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(len), static_cast<bool>(sendStop)));
}
void TwoWire::beginTransmission(int address)

View File

@ -93,8 +93,10 @@ public:
uint8_t endTransmission(bool sendStop);
uint8_t endTransmission(void);
size_t requestFrom(uint16_t address, size_t size, bool sendStop);
uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
uint8_t requestFrom(uint16_t address, uint8_t size, uint8_t sendStop);
size_t requestFrom(uint8_t address, size_t len, bool stopBit);
uint8_t requestFrom(uint16_t address, uint8_t size);
uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);
uint8_t requestFrom(uint8_t address, uint8_t size);

0
package.json Executable file → Normal file
View File

View File

@ -23,30 +23,30 @@
},
"boards": [
{
"name": "ESP32 Dev Module"
"name": "ESP32 Dev Board"
},
{
"name": "WEMOS LoLin32"
"name": "ESP32-S2 Dev Board"
},
{
"name": "WEMOS D1 MINI ESP32"
"name": "ESP32-C3 Dev Board"
}
],
"toolsDependencies": [
{
"packager": "esp32",
"name": "riscv32-esp-elf-gcc",
"version": "gcc8_4_0-esp-2021r1"
"version": "gcc8_4_0-esp-2021r2"
},
{
"packager": "esp32",
"name": "xtensa-esp32-elf-gcc",
"version": "gcc8_4_0-esp-2021r1"
"version": "gcc8_4_0-esp-2021r2"
},
{
"packager": "esp32",
"name": "xtensa-esp32s2-elf-gcc",
"version": "gcc8_4_0-esp-2021r1"
"version": "gcc8_4_0-esp-2021r2"
},
{
"packager": "esp32",
@ -69,124 +69,166 @@
"tools": [
{
"name": "riscv32-esp-elf-gcc",
"version": "gcc8_4_0-esp-2021r1",
"version": "gcc8_4_0-esp-2021r2",
"systems": [
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/riscv32-esp-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz",
"checksum": "SHA-256:3459618f33bbd5f54d7d7783e807cb6eef6472a220f2f1eb3faced735b9d13bb",
"size": "152812483"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-amd64.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-amd64.tar.gz",
"checksum": "SHA-256:812d735063da9d063b374b59f55832a96c41fbd27ddaef19000a75de8607ba21",
"size": "106837189"
},
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-arm64.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-arm64.tar.gz",
"checksum": "SHA-256:712f1fbc3e08304a6f32aa18b346b16bbcb413b507b3d4c7c3211bf0d7dc4813",
"size": "103273444"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/riscv32-esp-elf-gcc8_4_0-esp-2021r1-linux-armel.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r1-linux-armel.tar.gz",
"checksum": "SHA-256:24b9e54b348bbd5fb816fc4c52abb47337c702beecdbba840750b7cfb9d38069",
"size": "151726623"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-armel.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-armel.tar.gz",
"checksum": "SHA-256:80a3342cda2cd4b6b75ebb2b36d5d12fce7d375cfadadcff01ec3a907f0a16a2",
"size": "103058744"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/riscv32-esp-elf-gcc8_4_0-esp-2021r1-linux-i686.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r1-linux-i686.tar.gz",
"checksum": "SHA-256:954d340ebffef12a2ce9be1ea004e6f45a8863f1e6f41f46fd3f04f58499627c",
"size": "155430963"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-i686.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-linux-i686.tar.gz",
"checksum": "SHA-256:7f0162a81558ab0ed09d6c5d356def25b5cb3d5c2d61358f20152fa260ccc8ae",
"size": "109447789"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/riscv32-esp-elf-gcc8_4_0-esp-2021r1-macos.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r1-macos.tar.gz",
"checksum": "SHA-256:612fb3a3f84f703222327bd16581df8f80fda8cdf137637fe5d611587d1b664e",
"size": "159836199"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-macos.tar.gz",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-macos.tar.gz",
"checksum": "SHA-256:3ff7e5427907cf8e271c1f959b70fb01e39625c3caf61a6567e7b38aa0c11578",
"size": "113672945"
},
{
"host": "i686-mingw32",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/riscv32-esp-elf-gcc8_4_0-esp-2021r1-win32.zip",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r1-win32.zip",
"checksum": "SHA-256:5711eb407ffe44adddbd1281b6b575a5645e7193ca78faefa27dc5bc5b662bec",
"size": "191266312"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-win32.zip",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-win32.zip",
"checksum": "SHA-256:c8ff08883c1456c278fad85e1c43b7c6e251d525683214168655550e85c5b82e",
"size": "140809778"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/riscv32-esp-elf-gcc8_4_0-esp-2021r2-win64.zip",
"archiveFileName": "riscv32-esp-elf-gcc8_4_0-esp-2021r2-win64.zip",
"checksum": "SHA-256:6c04cb4728db928ec6473e63146b695b6dec686a0d40dd73dd3353f05247b19e",
"size": "142365782"
}
]
},
{
"name": "xtensa-esp32-elf-gcc",
"version": "gcc8_4_0-esp-2021r1",
"version": "gcc8_4_0-esp-2021r2",
"systems": [
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz",
"checksum": "SHA-256:44a0b467b9d2b759ab48b2f27aed684581f33c96e2842992781c4e045992c5b0",
"size": "86361217"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-amd64.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-amd64.tar.gz",
"checksum": "SHA-256:3eb3d68b27fa6ba5af6f88da21cb8face9be0094daaa8960793cfe570ab785ff",
"size": "90565318"
},
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-arm64.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-arm64.tar.gz",
"checksum": "SHA-256:aa534be24e45e06b7080a6a3bb8cd9e3cfb818f5f8bce2244d7cfb5e91336541",
"size": "86860292"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-armel.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-armel.tar.gz",
"checksum": "SHA-256:fdacdb2a7bbf6293bcafda9b52463a4da8a2f3b7e1df9f83d35ff9d1efa22012",
"size": "84520407"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-armel.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-armel.tar.gz",
"checksum": "SHA-256:f0e49ce06fe7833ff5d76961dc2dac5449d320f823bb8c05a302cf85a3a6eb04",
"size": "86183421"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-i686.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-i686.tar.gz",
"checksum": "SHA-256:e2024096492dfaa50fc6ac336cd8faa2e395e8cebb617753eab0b5f16d3dd0dc",
"size": "88375391"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-i686.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-linux-i686.tar.gz",
"checksum": "SHA-256:06de09b74652de43e5b22db3b7fc992623044baa75e9faaab68317a986715ba3",
"size": "92582250"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-macos.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r1-macos.tar.gz",
"checksum": "SHA-256:7bbc6a2b94f009cd8a3351b9c7acf7a5caa1c4d3700500ead60f84965386a61b",
"size": "93357296"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-macos.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-macos.tar.gz",
"checksum": "SHA-256:96443f69c8569417c780ee749d91ef33cffe22153fffa30a0fbf12107d87381b",
"size": "97808961"
},
{
"host": "i686-mingw32",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-win32.zip",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r1-win32.zip",
"checksum": "SHA-256:e4f9fdda192abfc9807e3e7fcd6e9fea30c1a0cf3f3c5a5c961b5114fc8c9b7e",
"size": "105603626"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-win32.zip",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-win32.zip",
"checksum": "SHA-256:076a4171bdc33e5ced3952efffb233d70263dfa760e636704050597a9edf61db",
"size": "112578260"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-win64.zip",
"archiveFileName": "xtensa-esp32-elf-gcc8_4_0-esp-2021r2-win64.zip",
"checksum": "SHA-256:c35b7998f7f503e0cb22055d1e279ae14b6b0e09bb3ff3846b17d552ece9c247",
"size": "115278695"
}
]
},
{
"name": "xtensa-esp32s2-elf-gcc",
"version": "gcc8_4_0-esp-2021r1",
"version": "gcc8_4_0-esp-2021r2",
"systems": [
{
"host": "x86_64-pc-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz",
"checksum": "SHA-256:b127baccfe6949ee7eaf3d0782ea772750a9b8e2732b16ce6bcc9dcd91f7209a",
"size": "86687290"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-amd64.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-amd64.tar.gz",
"checksum": "SHA-256:a6e0947c92b823ca04f062522249f0a428357e0b056f1ff4c6bcabef83cf63a7",
"size": "90901736"
},
{
"host": "aarch64-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-arm64.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-arm64.tar.gz",
"checksum": "SHA-256:d2e5600fc194b508bd393b236a09fd62ed70afb6c36619d4b106b696a56ca66d",
"size": "87176557"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-armel.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-armel.tar.gz",
"checksum": "SHA-256:7ca0d240f11e1c53c01a56257b0c968f876ab405142d1068d8c9b456d939554c",
"size": "84916701"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-armel.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-armel.tar.gz",
"checksum": "SHA-256:3fff4199e986dd74660f17ca27d9414cb98f1b911a7f13bb3b22e784cb1156cf",
"size": "86581102"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-i686.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-i686.tar.gz",
"checksum": "SHA-256:9941f993ff84d1c606b45ffbeeb7bcdc5a72cf24e787bb9230390510fe3511c6",
"size": "88699953"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-i686.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-linux-i686.tar.gz",
"checksum": "SHA-256:7732f9fb371d36b6b324820e300beecc33c2719921a61cf1cdb5bc625016b346",
"size": "92875986"
},
{
"host": "x86_64-apple-darwin",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-macos.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-macos.tar.gz",
"checksum": "SHA-256:4b55b1a9ca7fc945be6fc3513802b6cece9264bee4cbca76013569cec2695973",
"size": "93757895"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-macos.tar.gz",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-macos.tar.gz",
"checksum": "SHA-256:e6dd32782fcff8f633299b97d1c671d6b6513390aca2ddbd7543c2cc62e72d7e",
"size": "98212907"
},
{
"host": "i686-mingw32",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-win32.zip",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-win32.zip",
"checksum": "SHA-256:c94ec1e45c81b7e4944d216bab4aa41d46849768d7761fd691661dab1a3df828",
"size": "106013515"
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-win32.zip",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-win32.zip",
"checksum": "SHA-256:41b917b35f6fbe7d30b7de91c32cf348c406acfa729a1eabc450d040dc46fbe2",
"size": "113022469"
},
{
"host": "x86_64-mingw32",
"url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r2/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-win64.zip",
"archiveFileName": "xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-win64.zip",
"checksum": "SHA-256:a764c1a0ee743d69f8cbfadbe4426a2c15c0e233b0894244c7cadf3b4d7dd32a",
"size": "115696999"
}
]
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More