From af4f2d5e28814608da2070b9b5655ef6ea7b6307 Mon Sep 17 00:00:00 2001 From: Markus Sattler Date: Fri, 19 Jun 2015 10:53:35 +0200 Subject: [PATCH] sync with arduino avr src --- cores/esp8266/Arduino.h | 4 +++- cores/esp8266/Print.cpp | 3 +-- cores/esp8266/Stream.h | 2 ++ cores/esp8266/WMath.cpp | 2 +- cores/esp8266/core_esp8266_wiring_pulse.c | 4 ++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 89bf32685..49420d0e4 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -195,6 +195,7 @@ unsigned long micros(void); void delay(unsigned long); void delayMicroseconds(unsigned int us); unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); @@ -243,6 +244,7 @@ uint16_t makeWord(byte h, byte l); #define word(...) makeWord(__VA_ARGS__) unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); void noTone(uint8_t _pin); @@ -250,7 +252,7 @@ void noTone(uint8_t _pin); // WMath prototypes long random(long); long random(long, long); -void randomSeed(unsigned int); +void randomSeed(unsigned long); long map(long, long, long, long, long); diff --git a/cores/esp8266/Print.cpp b/cores/esp8266/Print.cpp index 1f924248a..efd6b9f17 100644 --- a/cores/esp8266/Print.cpp +++ b/cores/esp8266/Print.cpp @@ -127,8 +127,7 @@ size_t ICACHE_FLASH_ATTR Print::print(const Printable& x) { } size_t ICACHE_FLASH_ATTR Print::println(void) { - size_t n = print("\r\n"); - return n; + return print("\r\n"); } size_t ICACHE_FLASH_ATTR Print::println(const String &s) { diff --git a/cores/esp8266/Stream.h b/cores/esp8266/Stream.h index 6d08ef1dc..14eacbf6c 100644 --- a/cores/esp8266/Stream.h +++ b/cores/esp8266/Stream.h @@ -69,6 +69,8 @@ class Stream: public Print { } // returns true if target string is found, false if timed out + bool find(char target) { return find (&target, 1); } + bool findUntil(const char *target, const char *terminator); // as find but search ends if the terminator string is found bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((char *) target, terminator); diff --git a/cores/esp8266/WMath.cpp b/cores/esp8266/WMath.cpp index dcd51f1f2..da46a3ddb 100644 --- a/cores/esp8266/WMath.cpp +++ b/cores/esp8266/WMath.cpp @@ -27,7 +27,7 @@ extern "C" { #include } -void randomSeed(unsigned int seed) { +void randomSeed(unsigned long seed) { if(seed != 0) { srand(seed); } diff --git a/cores/esp8266/core_esp8266_wiring_pulse.c b/cores/esp8266/core_esp8266_wiring_pulse.c index 16b2ccc06..bb13e31c1 100644 --- a/cores/esp8266/core_esp8266_wiring_pulse.c +++ b/cores/esp8266/core_esp8266_wiring_pulse.c @@ -30,3 +30,7 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) { while(digitalRead(pin) == state && (micros() - start) < timeout); return micros() - start; } + +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) { + return pulseIn(pin, state, timeout); +}