Commit Graph

263 Commits

Author SHA1 Message Date
me-no-dev
f32083a6d0 Fix timerRestart
Closes: https://github.com/espressif/arduino-esp32/issues/2944

Thanks @atanisoft
2019-09-24 19:25:27 +03:00
Dirk O. Kaar
7fe2812f7f Inline ESP::getCycleCount() to make it safe to call from ISRs (#3165)
* Inline ESP::getCycleCount() to make it safe to call from ISRs

* Attribute IRAM_ATTR ISR-safe function in addition to inlining.
2019-09-11 14:29:53 +03:00
Me No Dev
f5cacfee1a
Remove extra connects from Client.h (#3191) 2019-09-09 09:36:22 +03:00
Jeroen88
f71a4bd406 Bugfix/detect baudrate (#3188)
* Expose uartStartDetectBaudrate(uart_t *) in esp32-hal-uart.h and call it from HardwareSerial::begin() if baudrate detection is requested (by passing a baudrate of 0) to solve baudrate detection problems

* Avoid a division by zero error in uartGetBaudRate()
2019-09-09 00:59:32 +03:00
Me No Dev
5f77b0108b
Fix return of Print::print(timeinfo, format) (#3189) 2019-09-09 00:36:30 +03:00
Tijs van Roon
717ca79ecb #3181 printf double vsnprintf() fix, malloc, va_end (#3184)
* Use loc_buf for small strings, check for error return from vsnprintf

* cleanup arg when bailing out of new

* Use malloc/free instead of new/delete in printf

* Return actual bytes written in printf

* FIX: write before free
2019-09-08 23:49:32 +03:00
Me No Dev
80ea521940
Add support for 160MHz rated CPUs (#3135)
Some ESP32 chips are rated only to 160MHz. This change adds support for them and does not allow frequency to be switched to 240MHz
2019-09-05 12:30:43 +03:00
Earle F. Philhower, III
fd089d8fd3 Pull in ESP8266 String::replace() fixes, others (#3143)
Pull in bugfixes from the ESP8266 repo for problems in the SSO
implementation of replace().  See the following patches for full
details:

54240d2cc5 (diff-8d9e71e16d437343017df828f0528f63)
78a1a66e6d (diff-8d9e71e16d437343017df828f0528f63)
4e9358445a (diff-8d9e71e16d437343017df828f0528f63)

Fixes #3140
2019-08-27 20:05:36 +03:00
Roman Savrulin
03066e42ef Flush UART RX queue too (#3009) 2019-08-20 16:48:52 +03:00
lbernstone
cd5257ad78 ESP.getCpuFreqMHz fix (#3007)
* ESP.getCpuFreqMHz was returning the CONFIG_ variable.  Now calls the getCpuFrequencyMhz function.

* Changed the Esp function to uint32_t to match
2019-08-20 16:48:26 +03:00
A C SREEDHAR REDDY
2a1fde7736 Include stdint for uint16_t (#3069) 2019-08-20 16:39:31 +03:00
Mike Dunston
007a93ec7e Update Print.cpp (#3060)
#2891
2019-08-20 16:36:04 +03:00
Brian Park
56ce580b0e Fix incorrect definition of FPSTR() and move from pgmspace.h to WString.h (#1371) (#2961) 2019-07-17 10:16:47 +03:00
chuck todd
d2816b2f32 Fix Unused Variable Warning (#2940)
Some Debugging variables were enabled at ERROR level instead of DEBUG.  Specifically `tAfter` and `tBefore`
2019-07-09 19:24:35 +03:00
Artur Bieniek
89feacb813 Fix map() division by zero (#2848) 2019-06-05 13:48:13 +02:00
Angus Gratton
2f249edb8e Use std::abs for a float-compatible abs() function (#2738)
* Other Arduino cores uses a macro to redefine libc abs() to take any
  type, meaning abs(-3.3) == 3.3 not the normal libc result of 3.

* 1e4bf14a3 (#1783) replaced similar min, max macros with c++ stdlib. However
  this change includes <algorithm> after the line which defines the abs() macro.
  <algorithm> includes <cstdlib> which undefines abs() and re-defines it.

* This means abs() becomes the plain libc version again which only takes
  integers, so abs(-3.3) == 3. As reported here:
  https://github.com/espressif/esp-idf/issues/3405

This fix tries to keep in the spirit of #1783 by using libstdc++. The other
option would be to include <cstdlib> before defining the abs() macro, so it
doesn't get undef-ed again later on.
2019-05-11 11:18:39 +03:00
Earle F. Philhower, III
bd57ff4ab4 StreamString SSO fix (#2736)
As found by @mongozmaki in https://github.com/esp8266/Arduino/pull/6035

With SSO implementation in String, StreamString::write generates wrong
strings under some circumstances.  Reason is that String::len() returns
strlen(sso_buf) if SSO=true but with newly written data
(in StreamString::write) the null-termination missing at the time len()
is called.

Furthermore, len() is called twice which is inefficient if SSO=true.
2019-05-11 11:16:05 +03:00
Me No Dev
50d142950d
Update esp32-hal-rmt.c 2019-05-01 20:10:41 +03:00
Earle F. Philhower, III
d13de284b8 Undo the redefinition of FPSTR from 8266 merge (#2726)
Fixes Arduino.h redefinition errors.
2019-04-30 16:52:14 +03:00
Earle F. Philhower, III
ab309e40d5 Copy ESP8266 String w/SSO to ESP32 repo (#2715)
I redid the ESP8266 WString library to enable small string optimization
(SSO) a while back, and think it would be helpful even on the ESP32 with
its higher memory complement.

SSO avoids lots of tiny mallocs() on the heap which cause fragmentation
by using the memory in the class object itself to store the actual
string and only mallocing() for buffers that are larger than what can
fit in thie class object.  Modern C++ std::string implementations have
this optimization as well, but since we're using Arduino strings we had
to roll our own.
2019-04-26 19:41:42 +03:00
Dirk O. Kaar
119ece2b0f Portability from ESP8266, virtual Stream member functions. (#2701) 2019-04-23 17:56:49 +03:00
me-no-dev
9a9ff62216 Add connect with timeout to Client class 2019-04-15 18:01:43 +02:00
me-no-dev
fa74767b2e Allow selecting in IDF the running core for Arduino's core tasks 2019-04-13 17:13:13 +02:00
me-no-dev
6dab3f6777 Fix LEDC channels above 8 not properly clearing
Fixes: https://github.com/espressif/arduino-esp32/issues/2660
2019-04-12 17:49:44 +02:00
Victor Aprea
25c0b52212 Alternative Improve _uploadReadByte (#2656)
* add opportunity for more than one retry to _uploadReadByte

* an alternative timeout-based method to making _uploadReadByte more resilient

* move timing variables in the correct scope

* implement and use client.getTimeout instead of hard-coded timeout in _uploadReadByte

* add missing return

* some refactoring to address respecting the timeout in a potentially deadlocked connection

* fix spelling in comment

* address review comments; move impl to cpp file for getTimeout, and remove local variable for currentMillis

* remove redundant cast

* need to check for timeout outside the inner while as well

* update WebUpdate example to print something in unexpected callback condition

* update log_e messages per review comments
2019-04-12 12:45:35 +02:00
chuck todd
91508030d8 Hide log_v behind conditional define, reduce excessive logging (#2641)
@cyberman54 from #2250 recommended reducing unnecessary logging.
2019-04-10 02:43:21 +02:00
A C SREEDHAR REDDY
0906bf580f update getLocalTime(). (#2629)
* update getLocalTime().

* change count to millis in getLocalTime

* timeout logic.
2019-04-10 02:39:14 +02:00
lbernstone
8e8c5035ea Added rmtDeinit to header. Fixes #2585 (#2587)
* Added rmtDeinit to header. Fixes #2585

* oops.  missing ;
2019-04-09 21:09:40 +02:00
Mike Dunston
f3c1a91f8e adding uartRxActive to expose the RX state machine status as a boolean value (#2457) 2019-03-03 15:47:24 +01:00
lbernstone
2bb32bd4b0 Unbiased random (#2468)
* An example to read high frequency analog data using i2s_adc

* Changed random() to use Lemire's method for bounding
2019-02-18 12:18:49 +02:00
Me No Dev
010a7c60f7
Update IDF to abea9e4c0 (#2458)
* Update IDF to abea9e4c0

* Update esptool

* Enable PSRAM for PICO D4

* Enable APP_ROLLBACK_ENABLE
2019-02-14 16:49:30 +01:00
Nguyen Hong Thiet
c0345eafbf fix missing the first bit in HC589 shift in (#2448) 2019-02-14 13:11:08 +01:00
Jeroen88
71ec3c3e31 Correct millis() error causes by micros() overflow every about 72 minutes (#2438) 2019-02-14 13:09:51 +01:00
chuck todd
8ec76405b9 Fix compile warning, esp32-hal-i2c.c (#2434)
@tread-Qualitrol discovered this error.
2019-02-14 13:09:05 +01:00
HanCheol Cho
8cbc60edbc fixed rmt receive data pointer position. (#2353) 2019-01-22 17:29:32 +08:00
Me No Dev
6cf307dbd1
Fix copy/paste error in RMT
Fixes: https://github.com/espressif/arduino-esp32/issues/2316
2019-01-14 19:30:07 +08:00
me-no-dev
81844f5360 Add API to feed the loop WDT (call from loop only) 2019-01-12 13:02:38 +01:00
chuck todd
9a7946e685 I2C fix READ of zero bytes hardware hang (#2301)
The i2c peripheral will hang if a READ request is issued with a zero data length.  The peripheral
drops into a continuous timeout interrupt response.  The STOP command can not be set out to the I2C
bus. The SLAVE device correctly ACK'd the address byte, with READ bit set, it has control of the SDA
 pin.  The ESP32 send out the next SCL HIGH pulse but, since the SLAVE is in READ Mode, and the First
bit it is sending happened to be a ZERO, the ESP32 cannot send the STOP.  When it releases SDA during
the SCL HIGH, the pin does not change state.  The pin stays low because the SLAVE is outputing a LOW!
The ESP32 drops into a perminent WAIT state waiting for SDA to go HIGH (the STOP).

**esp32-hal-i2c.c**
* add databuff length checks to `i2cRead()` and `i2cWrite()`
2019-01-10 21:37:13 +01:00
me-no-dev
70656aa129 fix leak in log_printf 2019-01-09 21:37:31 +01:00
Me No Dev
2fd39b1aff
Handle APB frequency change (#2250)
* Add APB change callbacks and move cpu code to own file

* Properly set esp_timer and FreeRTOS tick dividers

* Improve updated devisors

* No need to update REF_TICK yet

* Add initial handling for UART baud change

* fix uartWriteBuf and uartDetectBaudrate

* trigger callbacks even when APB did not change

* toggle UART ISR on CPU change

* add XTAL freq getter and add cpu freq validation

* Support CPU frequency changes in I2C (#2287)

**esp32-hal-i2c.c**
* add callback for cpu frequency changes
* adjust fifo thresholds based on cpu frequency and i2c bus frequency
* reduce i2c bus frequency if differential is too small
**Wire.h**
* version to 1.1.0

* Implement clock change for the other peripherals

* remove bad CPU clock values from the menu

* Add note to CPU freqs that support WiFi and BT
2019-01-09 10:07:54 +01:00
me-no-dev
28ea39cf05 Add WDT API for Core 0 and disable it while SPIFFS is formatting 2018-12-28 21:14:46 +02:00
Me No Dev
f49c854ff3
Update IDF to 97eecfa, enable reboot on WDT and add WDT API (#2248)
* Update IDF to 97eecfa and enable reboot on WDT

* Add API to enable/disable WDT for Core 1 and Arduino Loop
2018-12-28 20:37:33 +02:00
me-no-dev
879388e170 Update esp32-hal-gpio.c
fix copy/paste error
2018-12-28 19:14:15 +02:00
Me No Dev
1085e9a8f0
Fix bad multiplier calculation 2018-12-24 13:55:08 +02:00
Tomasz Ścisłowicz
5af139bb74 HardwareSerial - add changeBaudRate method (#2223)
* Add updateBaudRate to hardware serial

* remove flush

* Fix tab
2018-12-23 21:15:06 +02:00
atanisoft
4f9a90fa0e fix #2232 and #2033 (#2233) 2018-12-23 19:06:43 +02:00
chuck todd
310e78e6fd Support CPU frequency changes (#2222)
The I2C hardware has limitations on min and max bus frequency directly related to CPU frequency, bus speed cannot be greater than 1/100 CPU clock, nor less than CPU clock / 8192.
2018-12-20 08:56:02 +01:00
Me No Dev
c827bb4177
CPU and APB Frequency support (#2220)
* Add support to HAL for APB frequencies different than 80MHz

* Add support for CPU frequencies in the IDE board menu

* Switch to fast set_config

* Add method to uart so debug can be reassigned after apb frequency switch

* Return real APB frequency
2018-12-20 01:57:32 +01:00
me-no-dev
3e66aeff84 Handle better 160MHz cpu clock 2018-12-18 22:04:02 +01:00
me-no-dev
66d33f792c Add support for CPU Frequency switching
Experimental!
2018-12-18 20:04:16 +01:00