1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

63 Commits

Author SHA1 Message Date
david gauchard
9a2ed274f3 polledTimeout: add option to use CPU count instead of millis() (#5870)
* polledTimeout: add option to use CPU count instead of millis()

* use more "using" alias

* more c++/clear code, using typename (thanks @devyte)

* rename class name to include unit, introduce timeMax() and check it with assert()

* remove useless defines

* improve api readability, add micro-second unit

* update example

* mock: emulate getCycleCount, add/fix polledTimeout CI test

* + nano-seconds, assert -> message, comments, host test

* allow 0 for timeout (enables immediate timeout, fix division by 0)

* typo, set member instead of local variable

* unify error message

* slight change on checkExpired() allows "never expired"
also removed printed message, add YieldAndDelay, simplify calculations

* remove traces of debug.h/cpp in this PR

* include missing <limits> header

* back to original expired test, introduce boolean _neverExpires, fix reset(), getTimeout() is invalid

* fix expiredOneShot with _timeout==0 check

* reenable getTimeout()

* expose checkExpired with unit conversion

* fix timing comments, move critical code to iram

* add member ::neverExpires and use it where relevant

* improve clarity

* remove exposed checkExpired(), adapt LEAmDNS with equivalent

* add API ::resetToNeverExpires(), use it in LEAmDNS

* remove offending constness from ::flagged() LEAmDNS (due do API fix in PolledTimeout)

* simplify "Fast" base classes

* minor variable rename

* Fix examples

* compliance with good c++ manners

* minor changes for consistency

* add missing const

* expired() and bool() moved to iram

* constexpr compensation computing

* add/update comments

* move neverExpires and alwaysExpired
2019-04-05 10:50:53 -03:00
david gauchard
dc03293d82
(re)introduce timeout in HardwareSerial::readBytes(buffer, size) (#5558)
(re)introduce timeout in HardwareSerial::readBytes(buffer, size), add HardwareSerial::read(buffer, size) + visual test
2019-01-08 04:01:21 +01:00
Jeroen88
e4d9c279ef Function added to detect baudrate (#4978)
* Function added to detect baudrate

* Added uart_start_detect_baudrate, detectBaudrate() wrappers for HardwareSerial and an example usage SerialDetectBaudrate.ino

* Some layout changes to pass Travis tests

* Some more nitty-gritty layout changes to pass Travis tests

* Some even more nitty-gritty layout changes to pass Travis tests

* renamed one function to testBaudrate() and updated doc/reference.rst

* Minor updates to doc/reference.rst

* New lines added
2018-08-01 15:33:25 -04:00
Bryce Schober
3a110aa698 Allow other ESP debug port class types (#4611)
... by casting to void pointers before comparison to avoid compile error
2018-04-06 11:23:46 +02:00
david gauchard
f8f205d54a
Inefficient Print::write(data,len) shows message if used (only in debug mode) (#4537)
* inefficient Print::write(data,len) shows message if used (only in debug mode)
* make HardwareSerial's write(data,len) efficient
* HardwareSerial: remove duplicate tests, move trivial code from .cpp to .h
2018-03-22 01:23:58 +01:00
david gauchard
8053f285b1 provide full version descriptor, displayed in debug mode (#4467)
* provide full version descriptor, displayed in debug mode

* unix: shows core version like under windows when git is unavailable

* store strings in progmem

* version string honours NDEBUG

* add ARDUINO_ESP8266_GIT_DESC
restore ARDUINO_ESP8266_GIT_VER
restore global variable "core_version"
don't print full version on setDebugOutput(true)
set platform.txt version to 2.4.1-pre
hide irrelevant boot version
fix typo

* lwip2: fix disconnection/reconnection issue
also:
improve version string
remove useless message

* lwip2: bump tag before 2.4.1

* lwip2: improve netif flags management on git side

* full-version string: remove useless NDEBUG in separate source file

* do not automatically enable sdk messages along with core messages

* automatically reenable sdk messages along with core messages *before* setup not after

* check serial port when showing version-string + move sdk messages enabler in hardware serial

* + license header

* updated and tested windows commands in platform.txt (without git)

* updated and tested windows commands in platform.txt (without git)

* update package builder accordingly
2018-03-08 11:37:03 +08:00
Victor Tseng
2b868aac00 allow disabling global Serial and Serial1 object (#2807)
allow the user to disable specific global `Serial` objects to save
memory.

that's 0x1c bytes per object.
2017-12-29 11:11:00 -03:00
WereCatf
9fce9c792c Add a workaround-delay in Serial.flush() (#3714)
* Add a workaround-delay in Serial.flush()

In relation to #2536 and #2502

Tested at 80MHz and 160MHz with flash-frequency at both 40MHz and 80MHz, the bug mentioned in the above issues manifests in all cases. The proposed workaround seems to work fine, I tested at 2400bps, 9600bps, 115200bps, 230400bps and 2Mbps and didn't see anomalous output.

* Remove extraneous character

* Update HardwareSerial.cpp
2017-10-15 02:05:49 -05:00
Me No Dev
f8a8a2a359 Implement Serial RX Buffer (#2239)
In connection with:
https://github.com/esp8266/Arduino/issues/2237
https://github.com/esp8266/Arduino/issues/2037
https://github.com/esp8266/Arduino/issues/1683
2016-07-08 10:11:14 +08:00
Charles
44d27228c5 Added Serial.baudRate() to get current baud rate (#2079)
* Changed WifInfo settings and WeMos board name

* Added board name to have in sketch and MDNS/OTA

* board naming convention

https://github.com/esp8266/Arduino/pull/2054

* Added Serial.baudRate() to get current baud rate

* Added more description

- Added note about Software Serial Implementation
- Indicate this will works on ESP8266 boards only
2016-06-15 18:35:33 +08:00
Markus Sattler
28e6f33142 not keep freed pointer of uart handler 2016-02-22 18:24:10 +01:00
Ivan Grokhotkov
d1149c53e6 Remove UART register reference from HardwareSerial 2016-01-26 22:58:00 +03:00
Ivan Grokhotkov
16c0f3f1d5 Implement HardwareSerial::peek 2016-01-26 22:58:00 +03:00
Ivan Grokhotkov
7960b63357 Move UART HAL into separate file, clean up code 2016-01-26 22:57:59 +03:00
Me No Dev
e255f25cfd Bufferless and Interruptless HardwareSerial
Let's use the onboard buffers :)
2016-01-26 22:57:59 +03:00
Markus Sattler
531d748936 rename cbuf::getSize to cbuf::available (return available Bytes in cbuf)
add cbuf::size (return size of cbuf)
2016-01-26 18:21:42 +01:00
Kaloyan Kovachev
d68b9717b5 Use explicit TX pin number and add pins setting method 2016-01-14 17:55:57 +02:00
Kaloyan Kovachev
e97bc80cee Allow setting alternate TX for UART 0, so GPIO1 is available as SPI_CS1 2016-01-14 14:18:52 +02:00
Christopher Pascoe
bc9493e690 Remove tracking of whether write() was called.
Tracking _written was required on AVR devices to work around a hardware
limitation when implementing flush().  The ESP8266 doesn't have the same
issue, so we can remove the tracking and make write() more lightweight.

The cost is a minor increase in work done in flush() when write() was not
previously called, but this should be much rarer than individual character
writes.
2015-12-29 12:46:25 -05:00
Christopher Pascoe
4ef0466578 Don't trip the WDT if interrupts are disabled during write() or flush().
Prior to this change, if interrupts were disabled during a call to
HardwareSerial::write() when the circular buffer was full, or
HardwareSerial::flush() when the circular buffer was non-empty,
we would loop forever and trip a watchdog timeout.
2015-12-29 12:05:15 -05:00
Christopher Pascoe
c8772cfcd0 Make HardwareSerial::begin() and end() interrupt safe and disable TX/RX if we can't allocate a buffer for them.
Prior to this change, the interrupt could fire during initialisation,
necessitating a deep check that the HardwareSerial structure had valid
_tx_buffer or _rx_buffer each time an interrupt occurred.

By keeping uart_t's and HardwareSerial's (txEnabled, _tx_buffer) and
(rxEnabled, _rx_buffer) in sync, we can remove this extra check, as
well as fixing a null pointer dereference if e.g. _tx_buffer allocation
failed and write() was subsequently called.
2015-12-28 19:11:12 -05:00
Christopher Pascoe
cfe7ae1118 Put HardwareSerial and cbuf methods called from interrupt context in RAM.
This is required per the non-OS SDK doc, which states:
  "Using non-OS SDK, please do not call any function defined with
  ICACHE_FLASH_ATTR in the interrupt handler."

This avoids an "Illegal instruction" exception with epc1 pointing at a valid
instruction (in flash) for one of the moved methods.
2015-12-28 18:35:27 -05:00
Christopher Pascoe
83398f6011 Don't bother testing isRxEnabled() on UART1 - it is always false. 2015-12-28 17:55:16 -05:00
Christopher Pascoe
e147314f97 Re-enable interrupts before directly enqueuing characters in the UART FIFO.
Not sure why, but this reduces the occurrence rate of an occasional ~3.25 or
~7μs intercharacter delay, which was interfering with use of the UART to
generate precise timing pulses (such as driving WS2812 LEDs).
2015-12-28 17:44:28 -05:00
Christopher Pascoe
55e0dab799 Protect HardwareSerial's cbuf usage with InterruptLock. 2015-12-13 19:39:47 -08:00
Christopher Pascoe
cc0a8ead55 Always arm the "TX FIFO Empty" interrupt after we write into _tx_buffer.
This avoids a race where the interrupt handler detects an empty _tx_buffer
just before we write data into it.

Note that commit d6f62943d4b511e7d5fe6147096c8979890416f5 works around
this race when data is continually added to _tx_buffer in the hung state.
We revert that change here as the race should no longer occur.

Testing performed:
 - set UART_CONF1.txfifo_empty_thrhd=0x70 (which exacerbates the issue)
 - generate a ~240 byte burst of data, sent in back-to-back Serial1.write(, 4)
   calls, optionally followed by a Serial1.flush()
Test results:
 - before this change, observe occasional unsent data and hang in flush()
   (if used).
 - after this change, data is sent as expected.
2015-12-06 21:03:05 -08:00
Ivan Grokhotkov
32cc374921 Force disable IOSWAP for UART0 in HardwareSerial initialization (#744) 2015-09-09 13:39:55 +03:00
Ivan Grokhotkov
e5d2ba5db8 Pass timeout to optimistic_yield, add cont_can_yield check 2015-07-20 15:48:25 +03:00
Makuna
17de2d7a4e define in header
remove extern from cpp files
2015-07-15 16:32:49 -07:00
Makuna
d815c36753 optimistic_yield()
this introduces optimistic_yield() used for when standard library
methods are normally used in tight loops waiting for something to
happen, like available().
2015-07-13 13:47:13 -07:00
Ivan Grokhotkov
fc83952685 Merge pull request #438 from Links2004/esp8266
update SDK to esp_iot_sdk_v1.1.2_15_06_16_p1
2015-06-26 20:33:02 +03:00
John Doe
ca8ebdbb97 Enable Serial RX/TX Only mode (needed by I2S) 2015-06-20 23:26:26 +03:00
Markus Sattler
d6f62943d4 fix problems with serial and cbuf (some times freeze on high load) 2015-06-19 10:41:20 +02:00
John Doe
6ab3c76e03 register and clock changes 2015-06-02 00:11:20 +03:00
Markus Sattler
5b5deb5a77 improve os_printf handling when buffer full.
- wait for free buffer in hw fifo
2015-05-17 13:43:49 +02:00
Markus Sattler
b4a8bb0653 fix bug when TX buffer is full and os will write.
in this case we hang endless or until wtd triggers.

new:
 now we overdrive the data in FIFO --> no hang / crash but we loss chars.
 only happens by extensive use of os_printf!
2015-05-14 21:45:19 +02:00
ficeto
669609f3d7 fix uart receive 2015-05-12 18:44:31 +03:00
Ivan Grokhotkov
34b09f7e23 small clean up of HardwareSerial 2015-05-05 13:27:28 +03:00
ficeto
b752822aef fix UART clock divider
UART clock is constant
2015-05-03 20:56:58 +03:00
ficeto
fcbd7dbed0 Change UART register access methods 2015-05-03 16:44:19 +03:00
ficeto
66ded562f3 Revert "Revert "disable debug on Serial.end() if debug on this interface.""
This reverts commit b2d41697340ca11273c9a66b13a6c1f0d1d9bcc2.
2015-05-01 16:15:58 +03:00
ficeto
bbba691cac Revert "disable debug on Serial.end() if debug on this interface."
This reverts commit 28a868d6dd5e6e92fac5998f53dcd2256e9292f7.
2015-05-01 16:09:46 +03:00
Markus Sattler
a250492c20 disable debug on Serial.end() if debug on this interface. 2015-05-01 14:58:48 +02:00
Markus Sattler
2b3302c714 add new macro for force function to ram
move uart_interrupt_handler in ram
2015-04-29 07:01:19 +08:00
Thomas Flayols
be5f1f83c1 HardwareSerial: add other configs than 8N1 2015-04-26 00:20:39 +02:00
Markus Sattler
1d6fc00fdb uart_interrupt_handler is now in ram 2015-04-24 21:15:41 +02:00
Markus Sattler
021ca1972b fix bug #98 2015-04-22 16:44:30 +02:00
Markus Sattler
273ee1a3b7 fix possible null ptrs in HardwareSerial.cpp 2015-04-11 10:14:38 +02:00
Markus Sattler
f165a0afcd use Eclipse auto Format to get rip auf the tab, space and code style inconsistency 2015-04-06 19:33:50 +02:00
Markus Sattler
0276148613 fix printf corrupts Serial.print 2015-04-06 19:15:10 +02:00