Commit Graph

442 Commits

Author SHA1 Message Date
Rodrigo Garcia
1fed09bc74
Adds Arduino standard macro-functions (#6726)
* Adds Arduino standard functions

* Fixes round()

Adds Arduino basic math Macros with '_' prefix.
2022-05-11 12:57:50 +03:00
Kostis Anagnostopoulos
709029996f
fix: compiler warnings about printf-format for pointers in esp32-hal-cpu.c (#6705)
* fix(hal.cpu) compiler warn about printf-format for pointers >

warning was:
```
framework-arduinoespressif32/cores/esp32/esp32-hal-cpu.c:132:9: note: in expansion of macro 'log_e'
         log_e("not found func=%08X arg=%08X",cb,arg);
         ^~~~~
framework-arduinoespressif32/tools/sdk/esp32/include/log/include/esp_log.h:276:27: warning: format '%X' expects argument of type 'unsigned int', but argument 7 has type 'void *' [-Wformat=]

```

* fix(tone.cpp) compiler warn about printf-format for pointers >

format-str expected plain uint while `duration` is long-uint.

Warning was:
```
.../cores/esp32/esp32-hal-log.h:115:32: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
 #define log_d(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, TAG, format, ##__VA_ARGS__);}while(0)
                                ^~~~~~~~~~~~~~~~~~~
.../cores/esp32/Tone.cpp:31:9: note: in expansion of macro 'log_d'
         log_d("Task received from queue TONE_START: _pin=%d, frequency=%u Hz, duration=%u ms", tone_msg.pin, tone_msg.frequency, tone_msg.duration);
         ^~~~~
.../tools/sdk/esp32/include/log/include/esp_log.h:276:27: warning: format '%u' expects argument of type 'unsigned int', but argument 8 has type 'long unsigned int' [-Wformat=]
```
2022-05-09 23:40:44 +03:00
Tomáš Pilný
ca77502ceb
Added compiler.warning_flags to platform.txt; fixing #6118 (#6596)
Summary

Added compiler.warning_flags to all chips in platform.txt to reflect users setting of warning level output during compilation (set up in Arduino IDE preferences)

Impact

When a warning is set to none the compilation will no longer display warnings

Related links

Solves issue #6118
2022-05-09 23:17:12 +03:00
Jan Procházka
d302091267
Changed pinMode() default interrupt type DISABLED to previously set (#6695)
* Changed in pinMode() default  intr_type

pins default configuration has intr_type =  GPIO_INTR_DISABLE
With this implementation, it will set the intr_type to previously set intr_type. It will no longer disable interrupt, when pinmode is called multiple times on same pin with interrupt enabled.
2022-05-09 23:14:59 +03:00
Jan Procházka
85ec66a4e0
fixed timer_dev definition (#6716) 2022-05-09 16:00:09 +03:00
me-no-dev
0b3f1a9fa9 Update core version 2022-05-04 18:55:21 +03:00
Rodrigo Garcia
ce2cd111a1
Fixes INADDR_NONE (#6659)
Description of Change

Fixes IPAddress INADDR_NONE declaration when using Arduino WiFi or ETH.
This symbol was defined as 0xffffffff by lwip /inet.h, making it impossible to use INADDR_NONE correctly.

This PR only works when <wifi-provisioning/wifi_config.h> has a modification to include <lwip/ip4_addr.h> instead of <lwip/inet.h>. This will be done directly to the sdk folder in the github structure and it has been fixed in IDF by a separated Merge Request. This will be reflected in the future, for good.

Tests scenarios

This PR was tested with all Arduino WiFi examples, including AsyncUDP. Also with ETH examples.
It was also tested for #6610 test cases.
Testing done for ESP32, ESP32-S2, ESP32-C3 and ESP32-S3.

Related links

fixes #6610
fixes #6247
fixes #4732
2022-04-29 11:13:07 +03:00
Me No Dev
51bf1832b8
Fix onRequest being called for every slave address (#6649)
Fixes: https://github.com/espressif/arduino-esp32/issues/5907
2022-04-28 02:31:32 +03:00
Kostis Anagnostopoulos
0dd517dc9f
enh(log) salvage TAG from ESP_IDF log-statements > (#6567)
by converting result log-rows from the 1st line to the 2nd (`NET` is the tag):
```
[ 73419][D][telelogger.cpp:915] telemetry(): state: 33C

[ 73419][D][telelogger.cpp:915] telemetry(): [NET] state: 33C
```

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2022-04-26 14:46:42 +03:00
Paul
a9d33de70e
Call i2c_set_timeout in i2cSetClock (#6537) 2022-04-26 14:45:14 +03:00
Jan Procházka
f3bdfb31f9
Touch change to init only selected GPIO. (#6609)
* Separated init for touch / channel called by touchRead()

* compile error

* Fixed touch_V2 + ISR
2022-04-26 14:34:50 +03:00
Jan Procházka
e1c9606531
Changed type of LEDC frequency from double to uint32_t (#6570) 2022-04-21 17:50:55 +03:00
Jan Procházka
fb60efd592
Change pinMode OUTPUT to INPUT_OUTPUT (#6602)
* Change OUTPUT to INPUT_OUTPUT

To match the official Arduino API.
2022-04-21 17:49:54 +03:00
Dirk O. Kaar
6cfe4613e4
Amend "GPIO refactoring (#6259)" (#6527) 2022-04-05 11:28:59 +03:00
Rodrigo Garcia
aa783e6ac4
Reordering - HardwareSerial Constructor (#6492) 2022-03-28 17:04:38 +03:00
Gonzalo Brusco
c26e3f4299
Adds HardwareSerial::setRxTimeout() (#6397)
* Adds HardwareSerial::onReceiveTimeout()

* Fixed typo

* Changes requested

* Fix eventQueueReset

* Changed _onReceiveTimeout to _rxTimeout for consistency

* Uniform uart_set_rx_timeout condition

* test _uart not NULL in eventQueueReset()

check if _uart is not NULL before using it.

* revert last commit - no need for it

reverting last change made - it is not necessary.

* adds onReceive() parameter 

In order to allow the user to choose if onReceive() call back will be called only when UART Rx timeout happens or also when UART FIFO gets 120 bytes, 
a new parameter has been added to onReceive() with the default behavior based on timeout.

    void onReceive(OnReceiveCb function, bool onlyOnTimeout = true);

   onReceive will setup a callback that will be called whenever an UART interruption occurs (UART_INTR_RXFIFO_FULL or UART_INTR_RXFIFO_TOUT)
   UART_INTR_RXFIFO_FULL interrupt triggers at UART_FULL_THRESH_DEFAULT bytes received (defined as 120 bytes by default in IDF)
   UART_INTR_RXFIFO_TOUT interrupt triggers at UART_TOUT_THRESH_DEFAULT symbols passed without any reception (defined as 10 symbos by default in IDF)
   onlyOnTimeout parameter will define how onReceive will behave:
   Default: true -- The callback will only be called when RX Timeout happens. 
                           Whole stream of bytes will be ready for being read on the callback function at once.
                           This option may lead to Rx Overflow depending on the Rx Buffer Size and number of bytes received in the streaming
            false --    The callback will be called when FIFO reaches 120 bytes and also on RX Timeout.
                           The stream of incommig bytes will be "split" into blocks of 120 bytes on each callback.
                           This option avoid any sort of Rx Overflow, but leaves the UART packet reassembling work to the Application.

* Adds onReceive() parameter for timeout only

* Adds back setRxTimeout()

* Adds setRxTimeout()

* CI Syntax error - "," missing

Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
2022-03-28 14:18:30 +03:00
Me No Dev
8ee5f0a11e
Esp32 s3 support (#6341)
Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com>
Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com>
Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com>
Co-authored-by: Ivan Grokhotkov <ivan@espressif.com>
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
2022-03-28 12:09:41 +03:00
Rodrigo Garcia
6014ff433f
Fixes USB CDC setRxBufferSize(), begin(), _onRX() (#6413)
* Fixes USB CDC setRxBufferSize(), begin(), _onRX()

* Fixes SetRxBufferSize(0) with end()

* Fixes reset when 2x call to end()

* Adds RX_OVERFLOW_EVENT and Queue Copy in setBufferSize

* changed event name to ARDUINO_USB_CDC_RX_OVERFLOW_EVENT
2022-03-28 11:40:02 +03:00
Gonzalo Brusco
77e95311e0
Adds HardwareSerial::setTxBufferSize() (#6383)
* Adds HardwareSerial::setTxBufferSize()

* uartBegin def fix

* checks TXBufferSize  as defined in IDF

Makes sure that the buffer size will not cause a reset to the board.

* Removes double value in Rx/Tx Buffer Size 

Keeps Rx/Tx buffer size as set, not doubling it. It makes the process more clear.

Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
2022-03-28 11:37:12 +03:00
s-hadinger
8fe0efe8c0
Fix boot freeze when trying to init PSRAM on Pico D4 (#6434)
* Fix boot freeze when trying to init PSRAM on Pico D4

* Don't deconfigure GPIO16/17 in Pico D4
2022-03-23 13:10:21 +02:00
Tomáš Pilný
68daea4a4a
Implemented tone and noTone; fixes #980 (#6402)
* Implemented tone
* Tone uses queue; implemented setToneChannel
2022-03-10 17:26:30 +02:00
Rodrigo Garcia
883241229e
Allows setting only one pin (rx or tx) in the first begin() (#6394) 2022-03-10 15:33:27 +02:00
P-R-O-C-H-Y
66596fa581
Fix ledc panic’ed when wrong setup of frequency and bit width (#6371)
* Fixed LEDC panic when wrong bit widht / frequency set.

* Fixed ledc example to be working on all SOCs
2022-03-10 15:30:57 +02:00
Rodrigo Garcia
3a7dfa14db
Fixes rmtDeinit() and tests RX/TX before operations (#6369)
* Fixes rmtDeinit() and tests RX/TX before operations

* Optimizes final binary size

* Typo
2022-03-10 15:19:15 +02:00
Andreas Merkle
4da1051266
Bugfix of the following problems: Invalid variable argument list used to retrieve length. If length is greater or equal than the available buffer, a memory leak will happen because va_end() is missing. (#6360) 2022-03-02 15:25:59 +02:00
Rodrigo Garcia
7d4992a811
Adds C++ std::function to Serial.onReceive() (#6364)
* Adds C++ std::function to Serial.onReceive()

* fixes LOCK macro when disabled
2022-03-02 15:20:43 +02:00
Verkehrsrot
c2e5957f35
Update esp32-hal-log.h (#6358)
#ifdef added, to avoid compiler redefinition warnings for LOG_LOCAL_LEVEL if defined by application, and we USE_ESP_IDF_LOG
2022-02-28 16:50:07 +02:00
Verkehrsrot
4f7e88a177
Fixes build error if TAG is const (#6351) 2022-02-28 14:30:33 +02:00
P-R-O-C-H-Y
a57cac63e4
Timer API docs + esp32-hal-timer.h edit (#6335) 2022-02-23 15:59:20 +02:00
Rodrigo Garcia
50e9772ecf
Fixes UART pin setting + adds CTS/RTS HW Flow Control (#6272)
* fixes setPins and begin to keep rx/tx unmodified

* adds Hardware Flow Control mode and CTS/RTS pin setting

* adds Hardware Flow Control mode and CTS/RTS pin setting

* adds Hardware Flow Control mode and CTS/RTS pin setting

* adds Hardware Flow Control mode and CTS/RTS pin setting

* Code Review
2022-02-17 03:28:46 +02:00
P-R-O-C-H-Y
01303b700d
ADC esp32s2 attenuation fix for DAC pins (#6282)
* ADC esp32s2 attenuation fix for DAC pins

* Use soc define instead config target
2022-02-16 15:45:06 +02:00
P-R-O-C-H-Y
c7cc5c90eb
GPIO refactoring (#6259)
* GPIO refactoring

GPIO now using ESP-IDF API on all chips.
LEDC interrupt fix removed - no longer needed.
Edited pins_arduino.h in variants according to changes in gpio.

* Edited analog channels functions
2022-02-16 14:43:38 +02:00
Rodrigo Garcia
7eec41dcb5
Fixes Touch Sensor for ESP32-S3 and any future SoC (#6234)
* Fixes digitalPinToTouchChannel() for ESP32-S3
2022-02-05 11:54:01 +02:00
P-R-O-C-H-Y
9dbc908784
FIX ledc on ESP32C3 (#6229) 2022-02-04 15:55:28 +02:00
s-hadinger
6591f5bd4c
Fix replace() failing (#6224) 2022-02-03 20:07:34 +02:00
Rodrigo Garcia
0ea485e518
Touch Sensor IDF Refactoring (#6194)
Summary

Touch Sensor refactoring to be based on IDF 4.4.
Adds support to ESP32S2 and future ESP32S3.

Adds some new APIs:

For all chips:

void touchAttachInterruptArg(uint8_t pin, void (*userFunc)(void*), void *arg, uint32_t threshold);
This function allows the user to add and pass a void* parameter to the ISR user callback.

void touchDetachInterrupt(uint8_t pin);
This function detaches ISR call back for the touch pad pin.

Only ESP32 chip

void touchInterruptSetThresholdDirection(bool mustbeLower);
This function allows the user to set if the ISR callback will be activated when the touch sensor readings are lower or higher than the threshold defined. See example TouchButton.ino.

Only ESP32-S2 and ESP32-S3 chips

bool touchInterruptGetLastStatus(uint8_t pin);
This function reports if the touch pad pin is touched or untouched. It can be used with ISR to identify when it is touched and untouched (released). See example TouchButtonV2.ino.

Impact

None. ll original APIs and examples now run on ESP32 and ESP32-S2.

Related links

Fix #6095
Fix #6034
Fix #5799
Fix #5745
Fix #5527
Fix #5493
Fix #4321
Fix #4044
Fix #2722
Fix #2625
2022-02-03 19:06:12 +02:00
IanSC
5be3ff74ea
Unnecessary operation removed from map() in WMath.cpp (#6218)
* Unneccesary Operation Removed

(A) extra operation not needed and incorrect:
      wrong by 0.5 but happens to be thrown out

     ( delta * dividend + (divisor / 2) ) / divisor

        delta * dividend     divisor
    = ---------------- + -----------
        divisor                    2 * divisor

    = delta * dividend / divisor + 1/2

(B) check first before doing other computations

(C) changed to rise/run, easier for future maintainer
      since it's closer to equation of a line

(D) before: mult, shift, add, div, add
      now: mult, div, add

(E) error message easier to trace where thrown

* Update WMath.cpp

forgot to change variable name
2022-02-01 13:26:52 +02:00
mrengineer7777
9fe34f6553
Resolve WString TODO (#6190)
Resolve TODO (XXX) by logging warning message.
2022-01-31 13:07:37 +02:00
Rodrigo Garcia
39a2080922
Fixes onReceive deadlock (#6201) 2022-01-31 13:03:43 +02:00
Rodrigo Garcia
ce68d72157
Fixes UART1 and UART2 default pins for ESP32-S3 (#6202)
Summary

This PR fixes an issue with UART1 default pins.
When using pins RX_1 = 18 and TX_1 = 17, UART1 will display a Break Error on those pins when they are floting (not connected).

It also defines RX_2 = 19 and TX_2 = 20 as default pins for UART2.

Impact

The deaulf pins may look different from the original pinout diagram.
2022-01-31 12:46:09 +02:00
P-R-O-C-H-Y
a5932064f9
Fixing interrupts in LEDC (#6160)
Fixes: #6140
2022-01-20 13:09:25 +02:00
mrengineer7777
460af2e1a5
Fix I2C Slave Compile (#6108)
I2C Slave currently doesn't compile for projects where Arduino is an IDF component.  This adds missing conditionals.

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2022-01-17 16:29:50 +02:00
Juraj Andrássy
e84e9c153e
Print.flush() - Arduino API conformance (#6084) 2022-01-17 16:12:22 +02:00
vortigont
b3b3403296
NTP Examples: revert obsolete comment and updated Time example (#6073)
* Revert "Examples update, add a note for configTime() that only one ntp server is supported by lwip",
fixed in espressif/esp32-arduino-lib-builder#51

This reverts commit 6b1020967a.

* SimpleTime: add NTPoDHCP option and TimeZone env variable
2022-01-17 16:09:58 +02:00
Rodrigo Garcia
c014eaf352
Adds UART RX IRQ Callback with onReceive() (#6134)
* Adds UART RX IRQ Callback with onReceive()
2022-01-17 16:04:12 +02:00
Rodrigo Garcia
5ae3886c66
Fixes UART MODBUS and Loopback issue (#6133) 2022-01-17 14:54:13 +02:00
Rodrigo Garcia
1bbe61ab6f
Allows user to bypass PSRAM test and boot faster with WROVER (#6135)
Fixes #5737
2022-01-17 14:47:08 +02:00
Rodrigo Garcia
841599c248
Fixes String(float) issue with Stack Smashing (#6138)
Fixes #5873
2022-01-17 14:44:49 +02:00
P-R-O-C-H-Y
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
Rodrigo Garcia
44fbde0189
Fixes Lib Builder compiling errors (#6052) 2021-12-22 14:37:40 +02:00