mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-25 09:51:33 +02:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
d218e58f96 | |||
14ece43654 | |||
ae7173d4d5 | |||
c7080b0a83 | |||
96c184d213 | |||
da72bc90b7 | |||
16a9cf781f | |||
b1497fb257 | |||
5e04eb48b6 | |||
674cf812e7 | |||
83884a0cda | |||
80b8262595 | |||
5747bfab67 | |||
4b9dc61447 | |||
a2d7c0dcf6 | |||
666cd3cde5 | |||
3e851b537a | |||
f410728444 | |||
79e0889a16 | |||
4aff6dde39 | |||
bb50046540 | |||
10258b4cc2 | |||
418ac74be0 | |||
caa8d07aaf | |||
0f174aae88 |
2
.github/scripts/check-cmakelists.sh
vendored
2
.github/scripts/check-cmakelists.sh
vendored
@ -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"
|
||||
|
79
.github/stale.yml
vendored
79
.github/stale.yml
vendored
@ -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'
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ boards.sloeber.txt
|
||||
|
||||
# Ignore docs build (Sphinx)
|
||||
docs/build
|
||||
docs/source/_build
|
||||
|
@ -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
|
||||
|
15
README.md
15
README.md
@ -1,26 +1,15 @@
|
||||
# Arduino core for the ESP32
|
||||
# Arduino core for the ESP32, ESP32-S2 and ESP32-C3
|
||||
|
||||
[](https://travis-ci.org/espressif/arduino-esp32)  [](https://docs.espressif.com/projects/arduino-esp32/en/latest/?badge=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?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 [](https://github.com/espressif/arduino-esp32/releases/latest/) [](https://github.com/espressif/arduino-esp32/releases/latest/) [](https://github.com/espressif/arduino-esp32/releases/latest/)
|
||||
|
11
boards.txt
11
boards.txt
@ -2571,6 +2571,9 @@ esp32micromod.upload.extra_flags=
|
||||
esp32micromod.serial.disableDTR=true
|
||||
esp32micromod.serial.disableRTS=true
|
||||
|
||||
esp32micromod.build.tarch=xtensa
|
||||
esp32micromod.build.bootloader_addr=0x1000
|
||||
esp32micromod.build.target=esp32
|
||||
esp32micromod.build.mcu=esp32
|
||||
esp32micromod.build.core=esp32
|
||||
esp32micromod.build.variant=esp32micromod
|
||||
@ -4373,7 +4376,7 @@ adafruit_funhouse_esp32s2.menu.DebugLevel.verbose.build.code_debug=5
|
||||
|
||||
##############################################################
|
||||
|
||||
adafruit_feather_esp32s2_nopsram.name=Adafruit Feather ESP32-S2 (no PSRAM)
|
||||
adafruit_feather_esp32s2_nopsram.name=Adafruit Feather ESP32-S2
|
||||
adafruit_feather_esp32s2_nopsram.vid.0=0x239A
|
||||
adafruit_feather_esp32s2_nopsram.pid.0=0x80EB
|
||||
adafruit_feather_esp32s2_nopsram.vid.1=0x239A
|
||||
@ -4398,7 +4401,7 @@ adafruit_feather_esp32s2_nopsram.build.target=esp32s2
|
||||
adafruit_feather_esp32s2_nopsram.build.mcu=esp32s2
|
||||
adafruit_feather_esp32s2_nopsram.build.core=esp32
|
||||
adafruit_feather_esp32s2_nopsram.build.variant=adafruit_feather_esp32s2
|
||||
adafruit_feather_esp32s2_nopsram.build.board=ADAFRUIT_FEATHER_ESP32S2_NOPSRAM
|
||||
adafruit_feather_esp32s2_nopsram.build.board=ADAFRUIT_FEATHER_ESP32S2
|
||||
|
||||
adafruit_feather_esp32s2_nopsram.build.cdc_on_boot=0
|
||||
adafruit_feather_esp32s2_nopsram.build.msc_on_boot=0
|
||||
@ -4426,10 +4429,10 @@ adafruit_feather_esp32s2_nopsram.menu.DFUOnBoot.default.build.dfu_on_boot=0
|
||||
adafruit_feather_esp32s2_nopsram.menu.DFUOnBoot.dfu=Enabled
|
||||
adafruit_feather_esp32s2_nopsram.menu.DFUOnBoot.dfu.build.dfu_on_boot=1
|
||||
|
||||
adafruit_feather_esp32s2_nopsram.menu.PSRAM.disabled=Disabled
|
||||
adafruit_feather_esp32s2_nopsram.menu.PSRAM.disabled.build.defines=
|
||||
adafruit_feather_esp32s2_nopsram.menu.PSRAM.enabled=Enabled
|
||||
adafruit_feather_esp32s2_nopsram.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM
|
||||
adafruit_feather_esp32s2_nopsram.menu.PSRAM.disabled=Disabled
|
||||
adafruit_feather_esp32s2_nopsram.menu.PSRAM.disabled.build.defines=
|
||||
|
||||
adafruit_feather_esp32s2_nopsram.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
|
||||
adafruit_feather_esp32s2_nopsram.menu.PartitionScheme.default.build.partitions=default
|
||||
|
@ -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
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp32-hal-matrix.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
@ -331,3 +332,21 @@ double ledcChangeFrequency(uint8_t chan, double freq, uint8_t bit_num)
|
||||
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
|
||||
return res_freq;
|
||||
}
|
||||
|
||||
static int8_t pin_to_channel[SOC_GPIO_PIN_COUNT] = { 0 };
|
||||
static int cnt_channel = SOC_LEDC_CHANNEL_NUM;
|
||||
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", SOC_LEDC_CHANNEL_NUM);
|
||||
return;
|
||||
}
|
||||
pin_to_channel[pin] = cnt_channel--;
|
||||
ledcAttachPin(pin, cnt_channel);
|
||||
ledcSetup(cnt_channel, 1000, 8);
|
||||
}
|
||||
ledcWrite(pin_to_channel[pin] - 1, value);
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -546,16 +546,16 @@ float rmtSetTick(rmt_obj_t* rmt, float tick)
|
||||
size_t channel = rmt->channel;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
int apb_div = _LIMIT(tick/25.0, 256);
|
||||
float apb_tick = 25.0 * apb_div;
|
||||
int apb_div = _LIMIT(tick/25.0f, 256);
|
||||
float apb_tick = 25.0f * apb_div;
|
||||
RMT.tx_conf[channel].div_cnt = apb_div & 0xFF;
|
||||
RMT.tx_conf[channel].conf_update = 1;
|
||||
return apb_tick;
|
||||
#else
|
||||
int apb_div = _LIMIT(tick/12.5, 256);
|
||||
int apb_div = _LIMIT(tick/12.5f, 256);
|
||||
int ref_div = _LIMIT(tick/1000, 256);
|
||||
float apb_tick = 12.5 * apb_div;
|
||||
float ref_tick = 1000.0 * ref_div;
|
||||
float apb_tick = 12.5f * apb_div;
|
||||
float ref_tick = 1000.0f * ref_div;
|
||||
if (_ABS(apb_tick - tick) < _ABS(ref_tick - tick)) {
|
||||
RMT.conf_ch[channel].conf0.div_cnt = apb_div & 0xFF;
|
||||
RMT.conf_ch[channel].conf1.ref_always_on = 1;
|
||||
|
@ -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();
|
||||
|
||||
|
BIN
docs/source/_static/arduino_i2c_master.png
Normal file
BIN
docs/source/_static/arduino_i2c_master.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
BIN
docs/source/_static/arduino_i2c_slave.png
Normal file
BIN
docs/source/_static/arduino_i2c_slave.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 114 KiB |
384
docs/source/api/i2c.rst
Normal file
384
docs/source/api/i2c.rst
Normal 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
|
@ -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
|
||||
------
|
||||
|
@ -10,6 +10,8 @@ For a simplified method, see `lib-builder <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).
|
||||
- In the project folder, create a new folder called `components` and clone this repository inside the new created folder.
|
||||
|
@ -2,16 +2,88 @@
|
||||
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>
|
||||
Wi-Fi <api/wifi>
|
||||
|
9
libraries/Ethernet/library.properties
Normal file
9
libraries/Ethernet/library.properties
Normal 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
|
@ -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 {
|
@ -463,6 +463,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 +1189,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";
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -447,32 +447,40 @@ void TwoWire::flush(void)
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t 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<uint8_t>(quantity), static_cast<bool>(sendStop));
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity, uint8_t sendStop)
|
||||
{
|
||||
return requestFrom(address, static_cast<size_t>(quantity), static_cast<bool>(sendStop));
|
||||
return requestFrom(address, static_cast<uint8_t>(quantity), static_cast<bool>(sendStop));
|
||||
}
|
||||
|
||||
/* 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
|
||||
*/
|
||||
size_t TwoWire::requestFrom(uint8_t address, size_t len, bool stopBit)
|
||||
{
|
||||
return requestFrom((uint16_t)address, (uint8_t)len, stopBit);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
|
||||
{
|
||||
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
|
||||
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), true);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity)
|
||||
{
|
||||
return requestFrom(address, static_cast<size_t>(quantity), true);
|
||||
return requestFrom(address, static_cast<uint8_t>(quantity), true);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(int address, int quantity)
|
||||
{
|
||||
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
|
||||
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), true);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
|
||||
{
|
||||
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop)));
|
||||
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), static_cast<bool>(sendStop)));
|
||||
}
|
||||
|
||||
void TwoWire::beginTransmission(int address)
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
|
||||
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);
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
22
platform.txt
22
platform.txt
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
@ -673,5 +673,5 @@
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
|
||||
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
|
||||
#define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "2720d45e71"
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "6a7d83af19"
|
||||
#define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4"
|
||||
|
208
tools/sdk/esp32/include/esp-dsp/modules/kalman/ekf/include/ekf.h
Normal file
208
tools/sdk/esp32/include/esp-dsp/modules/kalman/ekf/include/ekf.h
Normal file
@ -0,0 +1,208 @@
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef _ekf_h_
|
||||
#define _ekf_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <mat.h>
|
||||
|
||||
class ekf {
|
||||
public:
|
||||
// x - amount of states in EKF. x[n] = F*x[n-1] + G*u + W. Size of matrix F
|
||||
// w - amount of control measurements and noise inputs. Size of matrix G
|
||||
|
||||
ekf(int x, int w);
|
||||
|
||||
virtual ~ekf();
|
||||
virtual void Process(float *u, float dt);
|
||||
|
||||
virtual void Init() = 0;
|
||||
// x[n] = F*x[n-1] + G*u + W
|
||||
int NUMX; // number of states, X is the state vector (size of F matrix)
|
||||
int NUMW; // size of G matrix
|
||||
|
||||
// System state vector
|
||||
dspm::Mat &X;
|
||||
|
||||
// linearized system matrices
|
||||
dspm::Mat &F;
|
||||
dspm::Mat &G;
|
||||
|
||||
// covariance matrix and state vector
|
||||
dspm::Mat &P;
|
||||
|
||||
// input noise and measurement noise variances
|
||||
dspm::Mat &Q;
|
||||
|
||||
/**
|
||||
* Runge-Kutta state update method.
|
||||
* The method calculates derivatives of input vector x and control measurements u
|
||||
* Re
|
||||
* @param[in] x: state vector
|
||||
* @param[in] u: control measurement
|
||||
* @param[in] dt: time interval from last update in seconds
|
||||
*/
|
||||
void RungeKutta(dspm::Mat &x, float *u, float dt);
|
||||
|
||||
// System Dependent methods:
|
||||
|
||||
/**
|
||||
* Derivative of state vector X
|
||||
* Re
|
||||
* @param[in] x: state vector
|
||||
* @param[in] u: control measurement
|
||||
* @return
|
||||
* - derivative of input vector x and u
|
||||
*/
|
||||
virtual dspm::Mat StateXdot(dspm::Mat &x, float *u) = 0;
|
||||
/**
|
||||
* Calculation of system state matrices F and G
|
||||
* @param[in] x: state vector
|
||||
* @param[in] u: control measurement
|
||||
*/
|
||||
virtual void LinearizeFG(dspm::Mat &x, float *u) = 0;
|
||||
//
|
||||
|
||||
// System independent methods
|
||||
|
||||
/**
|
||||
* Calculates covariance prediction matrux P.
|
||||
* Update matrix P
|
||||
* @param[in] dt: time interval from last update
|
||||
*/
|
||||
virtual void CovariancePrediction(float dt);
|
||||
|
||||
/**
|
||||
* Update of current state by measured values.
|
||||
* Optimized method for non correlated values
|
||||
* Calculate Kalman gain and update matrix P and vector X.
|
||||
* @param[in] H: derivative matrix
|
||||
* @param[in] measured: array of measured values
|
||||
* @param[in] expected: array of expected values
|
||||
* @param[in] R: measurement noise covariance values
|
||||
*/
|
||||
virtual void Update(dspm::Mat &H, float *measured, float *expected, float *R);
|
||||
/**
|
||||
* Update of current state by measured values.
|
||||
* This method just as a reference for research purpose.
|
||||
* Not used in real calculations.
|
||||
* @param[in] H: derivative matrix
|
||||
* @param[in] measured: array of measured values
|
||||
* @param[in] expected: array of expected values
|
||||
* @param[in] R: measurement noise covariance values
|
||||
*/
|
||||
virtual void UpdateRef(dspm::Mat &H, float *measured, float *expected, float *R);
|
||||
|
||||
|
||||
float *HP;
|
||||
float *Km;
|
||||
|
||||
public:
|
||||
// Additional universal helper methods
|
||||
/**
|
||||
* Convert quaternion to rotation matrix.
|
||||
* @param[in] q: quaternion
|
||||
*
|
||||
* @return
|
||||
* - rotation matrix 3x3
|
||||
*/
|
||||
static dspm::Mat quat2rotm(float q[4]);
|
||||
|
||||
/**
|
||||
* Convert rotation matrix to quaternion.
|
||||
* @param[in] R: rotation matrix
|
||||
*
|
||||
* @return
|
||||
* - quaternion 4x1
|
||||
*/
|
||||
static dspm::Mat rotm2quat(dspm::Mat &R);
|
||||
|
||||
/**
|
||||
* Convert quaternion to Euler angels.
|
||||
* @param[in] R: quaternion
|
||||
*
|
||||
* @return
|
||||
* - Euler angels 3x1
|
||||
*/
|
||||
static dspm::Mat quat2eul(const float q[4]);
|
||||
/**
|
||||
* Convert Euler angels to rotation matrix.
|
||||
* @param[in] xyz: Euler angels
|
||||
*
|
||||
* @return
|
||||
* - rotation matrix 3x3
|
||||
*/
|
||||
static dspm::Mat eul2rotm(float xyz[3]);
|
||||
|
||||
/**
|
||||
* Convert rotation matrix to Euler angels.
|
||||
* @param[in] rotm: rotation matrix
|
||||
*
|
||||
* @return
|
||||
* - Euler angels 3x1
|
||||
*/
|
||||
static dspm::Mat rotm2eul(dspm::Mat &rotm);
|
||||
|
||||
/**
|
||||
* Df/dq: Derivative of vector by quaternion.
|
||||
* @param[in] vector: input vector
|
||||
* @param[in] quat: quaternion
|
||||
*
|
||||
* @return
|
||||
* - Derivative matrix 3x4
|
||||
*/
|
||||
static dspm::Mat dFdq(dspm::Mat &vector, dspm::Mat &quat);
|
||||
|
||||
/**
|
||||
* Df/dq: Derivative of vector by inverted quaternion.
|
||||
* @param[in] vector: input vector
|
||||
* @param[in] quat: quaternion
|
||||
*
|
||||
* @return
|
||||
* - Derivative matrix 3x4
|
||||
*/
|
||||
static dspm::Mat dFdq_inv(dspm::Mat &vector, dspm::Mat &quat);
|
||||
|
||||
/**
|
||||
* Make skew-symmetric matrix of vector.
|
||||
* @param[in] w: source vector
|
||||
*
|
||||
* @return
|
||||
* - skew-symmetric matrix 4x4
|
||||
*/
|
||||
static dspm::Mat SkewSym4x4(float *w);
|
||||
|
||||
// q product
|
||||
// Rl = [q(1) - q(2) - q(3) - q(4); ...
|
||||
// q(2) q(1) - q(4) q(3); ...
|
||||
// q(3) q(4) q(1) - q(2); ...
|
||||
// q(4) - q(3) q(2) q(1); ...
|
||||
|
||||
/**
|
||||
* Make right quaternion-product matrices.
|
||||
* @param[in] q: source quaternion
|
||||
*
|
||||
* @return
|
||||
* - right quaternion-product matrix 4x4
|
||||
*/
|
||||
static dspm::Mat qProduct(float *q);
|
||||
|
||||
};
|
||||
|
||||
#endif // _ekf_h_
|
@ -0,0 +1,83 @@
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _ekf_imu13states_H_
|
||||
#define _ekf_imu13states_H_
|
||||
|
||||
#include "ekf.h"
|
||||
|
||||
/**
|
||||
* @brief This class is used to process and calculate attitude from imu sensors.
|
||||
*
|
||||
* The class use state vector with 13 follows values
|
||||
* X[0..3] - attitude quaternion
|
||||
* X[4..6] - gyroscope bias error, rad/sec
|
||||
* X[7..9] - magnetometer vector value - magn_ampl
|
||||
* X[10..12] - magnetometer offset value - magn_offset
|
||||
*
|
||||
* where, reference magnetometer value = magn_ampl*rotation_matrix' + magn_offset
|
||||
*/
|
||||
class ekf_imu13states: public ekf {
|
||||
public:
|
||||
ekf_imu13states();
|
||||
virtual ~ekf_imu13states();
|
||||
virtual void Init();
|
||||
|
||||
// Method calculates Xdot values depends on U
|
||||
// U - gyroscope values in radian per seconds (rad/sec)
|
||||
virtual dspm::Mat StateXdot(dspm::Mat &x, float *u);
|
||||
virtual void LinearizeFG(dspm::Mat &x, float *u);
|
||||
|
||||
// Methods for tests only.
|
||||
void Test();
|
||||
void TestFull(bool enable_att);
|
||||
|
||||
// Initial reference valies magnetometer and accelerometer
|
||||
dspm::Mat mag0;
|
||||
dspm::Mat accel0;
|
||||
|
||||
int NUMU; // number of control measurements
|
||||
|
||||
/**
|
||||
* Update part of system state by reference measurements accelerometer and magnetometer.
|
||||
* Only attitude and gyro bias will be updated.
|
||||
* This method should be used as main method after calibration.
|
||||
*
|
||||
* @param[in] accel_data: accelerometer measurement vector XYZ in g, where 1 g ~ 9.81 m/s^2
|
||||
* @param[in] magn_data: magnetometer measurement vector XYZ
|
||||
* @param[in] R: measurement noise covariance values for diagonal covariance matrix. Then smaller value, then more you trust them.
|
||||
*/
|
||||
void UpdateRefMeasurement(float *accel_data, float *magn_data, float R[6]);
|
||||
/**
|
||||
* Update full system state by reference measurements accelerometer and magnetometer.
|
||||
* This method should be used at calibration phase.
|
||||
*
|
||||
* @param[in] accel_data: accelerometer measurement vector XYZ in g, where 1 g ~ 9.81 m/s^2
|
||||
* @param[in] magn_data: magnetometer measurement vector XYZ
|
||||
* @param[in] R: measurement noise covariance values for diagonal covariance matrix. Then smaller value, then more you trust them.
|
||||
*/
|
||||
void UpdateRefMeasurementMagn(float *accel_data, float *magn_data, float R[6]);
|
||||
/**
|
||||
* Update system state by reference measurements accelerometer, magnetometer and attitude quaternion.
|
||||
* This method could be used when system on constant state or in initialization phase.
|
||||
* @param[in] accel_data: accelerometer measurement vector XYZ in g, where 1 g ~ 9.81 m/s^2
|
||||
* @param[in] magn_data: magnetometer measurement vector XYZ
|
||||
* @param[in] attitude: attitude quaternion
|
||||
* @param[in] R: measurement noise covariance values for diagonal covariance matrix. Then smaller value, then more you trust them.
|
||||
*/
|
||||
void UpdateRefMeasurement(float *accel_data, float *magn_data, float *attitude, float R[10]);
|
||||
|
||||
};
|
||||
|
||||
#endif // _ekf_imu13states_H_
|
@ -52,6 +52,27 @@ public:
|
||||
* @param[in] src: source matrix
|
||||
*/
|
||||
Mat(const Mat &src);
|
||||
|
||||
/**
|
||||
* Make copy of matrix.
|
||||
* @param[in] src: source matrix
|
||||
* @param[in] row_pos: start row position of destination matrix
|
||||
* @param[in] col_pos: start col position of destination matrix
|
||||
*/
|
||||
void Copy(const Mat &src, int row_pos, int col_pos);
|
||||
|
||||
/**
|
||||
* Make copy of matrix.
|
||||
* @param[in] row_start: start row position of source matrix to copy
|
||||
* @param[in] row_size: size of wor elements of source matrix to copy
|
||||
* @param[in] col_start: start col position of source matrix to copy
|
||||
* @param[in] col_size: size of wor elements of source matrix to copy
|
||||
*
|
||||
* @return
|
||||
* - result matrix size row_size x col_size
|
||||
*/
|
||||
Mat Get(int row_start, int row_size, int col_start, int col_size);
|
||||
|
||||
/**
|
||||
* Copy operator
|
||||
*
|
||||
@ -356,10 +377,18 @@ public:
|
||||
int length; /*!< Total amount of data in data array*/
|
||||
|
||||
static float abs_tol; /*!< Max acceptable absolute tolerance*/
|
||||
|
||||
/**
|
||||
* Find determinant
|
||||
* @param[in] n: element number in first row
|
||||
*
|
||||
* @return
|
||||
* - determinant value
|
||||
*/
|
||||
float det(int n);
|
||||
private:
|
||||
Mat cofactor(int row, int col, int n);
|
||||
float det(int n);
|
||||
Mat adjoint();
|
||||
Mat cofactor(int row, int col, int n);
|
||||
Mat adjoint();
|
||||
|
||||
void allocate(); // Allocate buffer
|
||||
Mat expHelper(const Mat &m, int num);
|
||||
|
@ -91,9 +91,10 @@ namespace dl
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CONSTANT,
|
||||
EDGE,
|
||||
REFLECT,
|
||||
SYMMETRIC,
|
||||
PADDING_EMPTY,
|
||||
PADDING_CONSTANT,
|
||||
PADDING_EDGE,
|
||||
PADDING_REFLECT,
|
||||
PADDING_SYMMETRIC,
|
||||
} padding_mode_t;
|
||||
} // namespace dl
|
||||
|
@ -72,7 +72,7 @@ namespace dl
|
||||
{
|
||||
this->output = new Tensor<feature_t>;
|
||||
}
|
||||
this->output->set_exponent(this->output_exponent);
|
||||
this->output->set_exponent(input0.exponent);
|
||||
this->output->set_shape(this->output_shape);
|
||||
this->output->free_element();
|
||||
}
|
||||
|
169
tools/sdk/esp32/include/esp-face/include/layer/dl_layer_pad.hpp
Normal file
169
tools/sdk/esp32/include/esp-face/include/layer/dl_layer_pad.hpp
Normal file
@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
|
||||
#include "dl_nn_pad.hpp"
|
||||
#include "dl_layer_base.hpp"
|
||||
|
||||
namespace dl
|
||||
{
|
||||
namespace layer
|
||||
{
|
||||
/**
|
||||
* @brief Pad.
|
||||
*
|
||||
* @tparam feature_t supports int16_t and int8_t,
|
||||
* - int16_t: stands for operation in int16_t quantize
|
||||
* - int8_t: stands for operation in int8_t quantize
|
||||
*/
|
||||
template <typename feature_t>
|
||||
class Pad : public Layer
|
||||
{
|
||||
private:
|
||||
std::vector<int> paddings;
|
||||
std::vector<feature_t> constant_values;
|
||||
padding_mode_t mode;
|
||||
Tensor<feature_t> *output; /*<! output ptr of Pad >*/
|
||||
std::vector<int> output_shape; /*<! output shape of Pad >*/
|
||||
|
||||
public:
|
||||
Pad(std::vector<int> paddings,
|
||||
std::vector<feature_t> constant_values = {0},
|
||||
padding_mode_t mode = PADDING_CONSTANT,
|
||||
const char *name = "Pad") : Layer(name),
|
||||
paddings(paddings),
|
||||
constant_values(constant_values),
|
||||
mode(mode)
|
||||
{
|
||||
this->output = new Tensor<feature_t>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy the Pad object.
|
||||
*
|
||||
*/
|
||||
~Pad()
|
||||
{
|
||||
if (this->output != NULL)
|
||||
{
|
||||
delete this->output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update output padding and input padding.
|
||||
*
|
||||
* @param input as an input
|
||||
* @param print_shape whether to print the output shape.
|
||||
*/
|
||||
void build(Tensor<feature_t> &input, bool print_shape = false)
|
||||
{
|
||||
assert(this->paddings.size() > 0);
|
||||
int input_dims = input.shape.size();
|
||||
int padding_dims = input_dims * 2;
|
||||
if (this->paddings.size() == 1)
|
||||
{
|
||||
std::vector<int> _paddings(padding_dims, 0);
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_paddings[i] = this->paddings[0];
|
||||
}
|
||||
this->paddings = _paddings;
|
||||
}
|
||||
else if (this->paddings.size() == 2)
|
||||
{
|
||||
std::vector<int> _paddings(padding_dims, 0);
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_paddings[2 * i] = this->paddings[0];
|
||||
_paddings[2 * i + 1] = this->paddings[1];
|
||||
}
|
||||
this->paddings = _paddings;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(this->paddings.size() == padding_dims);
|
||||
}
|
||||
|
||||
if (this->mode == PADDING_CONSTANT)
|
||||
{
|
||||
if (this->constant_values.size() == 1)
|
||||
{
|
||||
std::vector<feature_t> _constant_values(padding_dims, 0);
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_constant_values[i] = this->constant_values[0];
|
||||
}
|
||||
this->constant_values = _constant_values;
|
||||
}
|
||||
else if (this->constant_values.size() == 2)
|
||||
{
|
||||
std::vector<feature_t> _constant_values(padding_dims, 0);
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_constant_values[2 * i] = this->constant_values[0];
|
||||
_constant_values[2 * i + 1] = this->constant_values[1];
|
||||
}
|
||||
this->constant_values = _constant_values;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(constant_values.size() == padding_dims);
|
||||
}
|
||||
}
|
||||
this->output_shape = input.shape;
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
this->output_shape[i] += (this->paddings[2 * i] + this->paddings[2 * i + 1]);
|
||||
}
|
||||
|
||||
this->output->set_shape(this->output_shape);
|
||||
this->output->set_exponent(input.exponent);
|
||||
this->output->free_element();
|
||||
|
||||
if (print_shape)
|
||||
{
|
||||
std::cout << this->name << " | ";
|
||||
this->output->print_shape();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the output
|
||||
*
|
||||
* @return Tensor<feature_t>& Pad result
|
||||
*/
|
||||
Tensor<feature_t> &get_output()
|
||||
{
|
||||
return *this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call Pad operation
|
||||
*
|
||||
* @param input as an input.
|
||||
* @param autoload_enable one of true or false,
|
||||
* - true: load input and output from PSRAM to CACHE automatically
|
||||
* - false: do not
|
||||
* @param assign_core not effective yet
|
||||
* @return Pad result
|
||||
*/
|
||||
Tensor<feature_t> &call(Tensor<feature_t> &input, const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE)
|
||||
{
|
||||
DL_LOG_LAYER_LATENCY_INIT();
|
||||
|
||||
DL_LOG_LAYER_LATENCY_START();
|
||||
if (this->output->shape != this->output_shape)
|
||||
{
|
||||
this->output->set_shape(this->output_shape);
|
||||
}
|
||||
this->output->malloc_element();
|
||||
this->output->set_exponent(input.exponent);
|
||||
DL_LOG_LAYER_LATENCY_END(this->name, "apply");
|
||||
|
||||
DL_LOG_LAYER_LATENCY_START();
|
||||
nn::pad(*this->output, input, this->paddings, this->constant_values, this->mode, assign_core);
|
||||
DL_LOG_LAYER_LATENCY_END(this->name, "pad");
|
||||
return *this->output;
|
||||
}
|
||||
};
|
||||
} // namespace layer
|
||||
} // namespace dl
|
120
tools/sdk/esp32/include/esp-face/include/nn/dl_nn_pad.hpp
Normal file
120
tools/sdk/esp32/include/esp-face/include/nn/dl_nn_pad.hpp
Normal file
@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
#include "dl_constant.hpp"
|
||||
#include "dl_variable.hpp"
|
||||
#include "dl_nn.hpp"
|
||||
|
||||
namespace dl
|
||||
{
|
||||
namespace nn
|
||||
{
|
||||
/**
|
||||
* @brief pad(input)
|
||||
*
|
||||
* @tparam feature_t
|
||||
* @param output as an output
|
||||
* @param input as an input
|
||||
* @param paddings number of values padded to the edges of each dim
|
||||
* @param constant_values used in PADDING_CONSTANT, the values to set the padded values for each dim
|
||||
* @param mode One of the following: PADDING_EMPTY, PADDING_CONSTANT, PADDING_EDGE, PADDING_REFLECT, PADDING_SYMMETRIC
|
||||
* @param assign_core not effective yet
|
||||
*/
|
||||
template <typename feature_t>
|
||||
void pad(Tensor<feature_t> &output,
|
||||
Tensor<feature_t> &input,
|
||||
std::vector<int> paddings,
|
||||
std::vector<feature_t> constant_values,
|
||||
padding_mode_t mode,
|
||||
const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE);
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @tparam feature_t
|
||||
* @param input as an input
|
||||
* @param paddings number of values padded to the edges of each dim
|
||||
* @param constant_values used in PADDING_CONSTANT, the values to set the padded values for each dim
|
||||
* @param mode One of the following: PADDING_EMPTY, PADDING_CONSTANT, PADDING_EDGE, PADDING_REFLECT, PADDING_SYMMETRIC
|
||||
* @param assign_core not effective yet
|
||||
* @return Tensor<feature_t> the padded Tensor
|
||||
*/
|
||||
template <typename feature_t>
|
||||
Tensor<feature_t> pad(Tensor<feature_t> &input,
|
||||
std::vector<int> paddings,
|
||||
std::vector<feature_t> constant_values,
|
||||
padding_mode_t mode,
|
||||
const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE)
|
||||
{
|
||||
DL_LOG_NN_LATENCY_INIT();
|
||||
|
||||
DL_LOG_NN_LATENCY_START();
|
||||
|
||||
assert(paddings.size() > 0);
|
||||
int input_dims = input.shape.size();
|
||||
int padding_dims = input_dims * 2;
|
||||
std::vector<int> _paddings(padding_dims, 0);
|
||||
if (paddings.size() == 1)
|
||||
{
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_paddings[i] = paddings[0];
|
||||
}
|
||||
}
|
||||
else if (paddings.size() == 2)
|
||||
{
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_paddings[2 * i] = paddings[0];
|
||||
_paddings[2 * i + 1] = paddings[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(paddings.size() == padding_dims);
|
||||
_paddings = paddings;
|
||||
}
|
||||
|
||||
std::vector<feature_t> _constant_values(padding_dims, 0);
|
||||
if (mode == PADDING_CONSTANT)
|
||||
{
|
||||
if (constant_values.size() == 1)
|
||||
{
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_constant_values[i] = constant_values[0];
|
||||
}
|
||||
}
|
||||
else if (constant_values.size() == 2)
|
||||
{
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_constant_values[2 * i] = constant_values[0];
|
||||
_constant_values[2 * i + 1] = constant_values[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(constant_values.size() == padding_dims);
|
||||
_constant_values = constant_values;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> output_shape = input.shape;
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
output_shape[i] += (_paddings[2 * i] + _paddings[2 * i + 1]);
|
||||
}
|
||||
|
||||
Tensor<feature_t> output;
|
||||
output.set_exponent(input.exponent).set_shape(output_shape).malloc_element();
|
||||
DL_LOG_NN_LATENCY_END("apply");
|
||||
|
||||
DL_LOG_NN_LATENCY_START();
|
||||
pad(output, input, _paddings, _constant_values, mode, assign_core);
|
||||
DL_LOG_NN_LATENCY_END("pad");
|
||||
|
||||
return output;
|
||||
}
|
||||
} // namespace nn
|
||||
} // namespace dl
|
@ -71,7 +71,7 @@ namespace dl
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief copy the element of the input Tensor.
|
||||
*
|
||||
* @param input an input Tensor
|
||||
* @param deep one of true or false
|
||||
@ -258,6 +258,56 @@ namespace dl
|
||||
return this->element[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the all the element to value.
|
||||
*
|
||||
* @param value target value
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(T value);
|
||||
|
||||
/**
|
||||
* @brief Set the the element to value
|
||||
*
|
||||
* @param value target value, it will be broadcast automatically.
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(Tensor<T> &value);
|
||||
|
||||
/**
|
||||
* @brief Set the sliced element to value
|
||||
*
|
||||
* @param axis_index_range range of slices
|
||||
* @param value target value
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(std::vector<int> axis_index_range, T value);
|
||||
|
||||
/**
|
||||
* @brief Set the sliced element to value
|
||||
*
|
||||
* @param axis_index_range range of slices
|
||||
* @param value target value, it will be broadcast automatically.
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(std::vector<int> axis_index_range, Tensor<T> &value);
|
||||
|
||||
/**
|
||||
* @brief Extracts a slice from the Tensor.
|
||||
*
|
||||
* @param axis_index_range range of slices
|
||||
* @return Tensor<T> output
|
||||
*/
|
||||
Tensor<T> slice(std::vector<int> axis_index_range);
|
||||
|
||||
/**
|
||||
* @brief Reverses specific dims of the tensor.
|
||||
*
|
||||
* @param axis The dims to be reversed
|
||||
* @return Tensor<T>&
|
||||
*/
|
||||
Tensor<T> &reverse(std::vector<int> axis);
|
||||
|
||||
/**
|
||||
* @brief Get the size of Tensor.
|
||||
*
|
||||
@ -491,5 +541,16 @@ namespace dl
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
static Tensor<T> arange(int size)
|
||||
{
|
||||
Tensor<T> output;
|
||||
output.set_auto_free(true).set_exponent(0).set_shape({size}).malloc_element();
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
output.element[i] = i;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
};
|
||||
} // namespace dl
|
@ -85,6 +85,13 @@ uint8_t phy_dig_reg_backup(bool backup_en, uint32_t *mem_addr);
|
||||
void phy_freq_mem_backup(bool backup_en, uint32_t *mem);
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_PHY_ENABLE_USB
|
||||
/**
|
||||
* @brief Enable or disable USB when phy init.
|
||||
*/
|
||||
void phy_bbpll_en_usb(bool en);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -4,8 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
// Allow for this warning suppression only in IDF_CI_BUILD
|
||||
#if !defined(ESP_OPENSSL_SUPPRESS_LEGACY_WARNING) || !defined(IDF_CI_BUILD)
|
||||
#if !defined(ESP_OPENSSL_SUPPRESS_LEGACY_WARNING)
|
||||
#warning "OpenSSL component will be removed from ESP-IDF in v5.0, please use esp_tls instead"
|
||||
#endif
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/ld/libcolor_detect.a
Normal file
BIN
tools/sdk/esp32/ld/libcolor_detect.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32/ld/libmfn.a
Normal file
BIN
tools/sdk/esp32/ld/libmfn.a
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
/* Automatically generated file; DO NOT EDIT */
|
||||
/* Espressif IoT Development Framework Linker Script */
|
||||
/* Generated from: /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/ld/esp32/sections.ld.in */
|
||||
/* Generated from: /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/ld/esp32/sections.ld.in */
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user