diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c6e82ba..5281813b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ set(CORE_SRCS cores/esp32/esp32-hal-touch.c cores/esp32/esp32-hal-rmt.c cores/esp32/FunctionalInterrupt.cpp - cores/esp32/IPv6Address.cpp cores/esp32/stdlib_noniso.c cores/esp32/USB.cpp cores/esp32/USBCDC.cpp diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 4ed088a8..436a0f03 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -20,24 +20,24 @@ #ifndef Arduino_h #define Arduino_h -#include -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include -#include "esp_arduino_version.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/semphr.h" -#include "esp32-hal.h" -#include "esp8266-compat.h" -#include "soc/gpio_reg.h" +//#include "esp_arduino_version.h" +//#include "freertos/FreeRTOS.h" +//#include "freertos/task.h" +//#include "freertos/semphr.h" +//#include "esp32-hal.h" +//#include "esp8266-compat.h" +//#include "soc/gpio_reg.h" -#include "stdlib_noniso.h" +//#include "stdlib_noniso.h" //#define PI 3.1415926535897932384626433832795 //#define HALF_PI 1.5707963267948966192313216916398 @@ -49,112 +49,102 @@ //#define SERIAL 0x0 //#define DISPLAY 0x1 -#define LSBFIRST 0 -#define MSBFIRST 1 - //Interrupt Modes -#define RISING 0x01 -#define FALLING 0x02 -#define CHANGE 0x03 -#define ONLOW 0x04 -#define ONHIGH 0x05 -#define ONLOW_WE 0x0C -#define ONHIGH_WE 0x0D +//#define RISING 0x01 +//#define FALLING 0x02 +//#define CHANGE 0x03 +//#define ONLOW 0x04 +//#define ONHIGH 0x05 +//#define ONLOW_WE 0x0C +//#define ONHIGH_WE 0x0D -#define DEFAULT 1 -#define EXTERNAL 0 +//#define DEFAULT 1 +//#define EXTERNAL 0 -#ifndef __STRINGIFY -#define __STRINGIFY(a) #a -#endif +//#ifndef __STRINGIFY +//#define __STRINGIFY(a) #a +//#endif -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) +//#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +//#define radians(deg) ((deg)*DEG_TO_RAD) +//#define degrees(rad) ((rad)*RAD_TO_DEG) +//#define sq(x) ((x)*(x)) -#define sei() -#define cli() -#define interrupts() sei() -#define noInterrupts() cli() +//#define sei() +//#define cli() +//#define interrupts() sei() +//#define noInterrupts() cli() -#define clockCyclesPerMicrosecond() ( (long int)getCpuFrequencyMhz() ) -#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) -#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) +//#define lowByte(w) ((uint8_t) ((w) & 0xff)) +//#define highByte(w) ((uint8_t) ((w) >> 8)) -#define lowByte(w) ((uint8_t) ((w) & 0xff)) -#define highByte(w) ((uint8_t) ((w) >> 8)) +//#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +//#define bitSet(value, bit) ((value) |= (1UL << (bit))) +//#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +//#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit)) -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit)) +//// avr-libc defines _NOP() since 1.6.2 +//#ifndef _NOP +//#define _NOP() do { __asm__ volatile ("nop"); } while (0) +//#endif -// avr-libc defines _NOP() since 1.6.2 -#ifndef _NOP -#define _NOP() do { __asm__ volatile ("nop"); } while (0) -#endif +//#define bit(b) (1UL << (b)) +//#define _BV(b) (1UL << (b)) -#define bit(b) (1UL << (b)) -#define _BV(b) (1UL << (b)) +//#define digitalPinToPort(pin) (((pin)>31)?1:0) +//#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-32):(pin))) +//#define digitalPinToTimer(pin) (0) +//#define analogInPinToBit(P) (P) +//#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG)) +//#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG)) +//#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG)) -#define digitalPinToPort(pin) (((pin)>31)?1:0) -#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-32):(pin))) -#define digitalPinToTimer(pin) (0) -#define analogInPinToBit(P) (P) -#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG)) -#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG)) -#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG)) +//#define NOT_A_PIN -1 +//#define NOT_A_PORT -1 +//#define NOT_AN_INTERRUPT -1 +//#define NOT_ON_TIMER 0 -#define NOT_A_PIN -1 -#define NOT_A_PORT -1 -#define NOT_AN_INTERRUPT -1 -#define NOT_ON_TIMER 0 +//typedef bool boolean; +//typedef uint8_t byte; +//typedef unsigned int word; -typedef bool boolean; -typedef uint8_t byte; -typedef unsigned int word; +//long map(long, long, long, long, long); -long map(long, long, long, long, long); +//#ifdef __cplusplus +//extern "C" { +//#endif -#ifdef __cplusplus -extern "C" { -#endif +//unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); +//unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); -unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); +//#ifdef __cplusplus +//} -uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); -void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); +//#include +//#include -#ifdef __cplusplus -} +//#include "WCharacter.h" -#include -#include +//using std::abs; +//using std::isinf; +//using std::isnan; +//using std::max; +//using std::min; +//using ::round; -#include "WCharacter.h" +//uint16_t makeWord(uint16_t w); +//uint16_t makeWord(byte h, byte l); -using std::abs; -using std::isinf; -using std::isnan; -using std::max; -using std::min; -using ::round; +//#define word(...) makeWord(__VA_ARGS__) -uint16_t makeWord(uint16_t w); -uint16_t makeWord(byte h, byte l); +//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); -#define word(...) makeWord(__VA_ARGS__) +//#endif /* __cplusplus */ -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); +//#define _min(a,b) ((a)<(b)?(a):(b)) +//#define _max(a,b) ((a)>(b)?(a):(b)) -#endif /* __cplusplus */ - -#define _min(a,b) ((a)<(b)?(a):(b)) -#define _max(a,b) ((a)>(b)?(a):(b)) - -#include "pins_arduino.h" +//#include "pins_arduino.h" #endif /* _ESP32_CORE_ARDUINO_H_ */ diff --git a/cores/esp32/FunctionalInterrupt.cpp b/cores/esp32/FunctionalInterrupt.cpp index c5a8d37f..a8f5518e 100644 --- a/cores/esp32/FunctionalInterrupt.cpp +++ b/cores/esp32/FunctionalInterrupt.cpp @@ -6,7 +6,7 @@ */ #include "FunctionalInterrupt.h" -#include "Arduino.h" +#include "esp32-hal.h" typedef void (*voidFuncPtr)(void); typedef void (*voidFuncPtrArg)(void*); diff --git a/cores/esp32/IPv6Address.cpp b/cores/esp32/IPv6Address.cpp deleted file mode 100644 index 179902f2..00000000 --- a/cores/esp32/IPv6Address.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - IPv6Address.cpp - Base class that provides IPv6Address - Copyright (c) 2011 Adrian McEwen. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -IPv6Address::IPv6Address() -{ - memset(_address.bytes, 0, sizeof(_address.bytes)); -} - -IPv6Address::IPv6Address(const uint8_t *address) -{ - memcpy(_address.bytes, address, sizeof(_address.bytes)); -} - -IPv6Address::IPv6Address(const uint32_t *address) -{ - memcpy(_address.bytes, (const uint8_t *)address, sizeof(_address.bytes)); -} - -IPv6Address& IPv6Address::operator=(const uint8_t *address) -{ - memcpy(_address.bytes, address, sizeof(_address.bytes)); - return *this; -} - -bool IPv6Address::operator==(const uint8_t* addr) const -{ - return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; -} - -//size_t IPv6Address::printTo(Print& p) const -//{ -// size_t n = 0; -// for(int i = 0; i < 16; i+=2) { -// if(i){ -// n += p.print(':'); -// } -// n += p.printf("%02x", _address.bytes[i]); -// n += p.printf("%02x", _address.bytes[i+1]); - -// } -// return n; -//} - -std::string IPv6Address::toString() const -{ - char szRet[40]; - sprintf(szRet,"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", - _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3], - _address.bytes[4], _address.bytes[5], _address.bytes[6], _address.bytes[7], - _address.bytes[8], _address.bytes[9], _address.bytes[10], _address.bytes[11], - _address.bytes[12], _address.bytes[13], _address.bytes[14], _address.bytes[15]); - return std::string(szRet); -} - -bool IPv6Address::fromString(const char *address) -{ - //format 0011:2233:4455:6677:8899:aabb:ccdd:eeff - if(strlen(address) != 39){ - return false; - } - char * pos = (char *)address; - size_t i = 0; - for(i = 0; i < 16; i+=2) { - if(!sscanf(pos, "%2hhx", &_address.bytes[i]) || !sscanf(pos+2, "%2hhx", &_address.bytes[i+1])){ - return false; - } - pos += 5; - } - return true; -} diff --git a/cores/esp32/IPv6Address.h b/cores/esp32/IPv6Address.h deleted file mode 100644 index d78dcf62..00000000 --- a/cores/esp32/IPv6Address.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - IPv6Address.h - Base class that provides IPv6Address - Copyright (c) 2011 Adrian McEwen. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef IPv6Address_h -#define IPv6Address_h - -#include -#include - -// A class to make it easier to handle and pass around IP addresses - -class IPv6Address -{ -private: - union { - uint8_t bytes[16]; // IPv4 address - uint32_t dword[4]; - } _address; - - // Access the raw byte array containing the address. Because this returns a pointer - // to the internal structure rather than a copy of the address this function should only - // be used when you know that the usage of the returned uint8_t* will be transient and not - // stored. - uint8_t* raw_address() - { - return _address.bytes; - } - -public: - // Constructors - IPv6Address(); - IPv6Address(const uint8_t *address); - IPv6Address(const uint32_t *address); - - bool fromString(const char *address); - bool fromString(const std::string &address) { return fromString(address.c_str()); } - - operator const uint8_t*() const - { - return _address.bytes; - } - operator const uint32_t*() const - { - return _address.dword; - } - bool operator==(const IPv6Address& addr) const - { - return (_address.dword[0] == addr._address.dword[0]) - && (_address.dword[1] == addr._address.dword[1]) - && (_address.dword[2] == addr._address.dword[2]) - && (_address.dword[3] == addr._address.dword[3]); - } - bool operator==(const uint8_t* addr) const; - - // Overloaded index operator to allow getting and setting individual octets of the address - uint8_t operator[](int index) const - { - return _address.bytes[index]; - } - uint8_t& operator[](int index) - { - return _address.bytes[index]; - } - - // Overloaded copy operators to allow initialisation of IPv6Address objects from other types - IPv6Address& operator=(const uint8_t *address); - -// virtual size_t printTo(Print& p) const; - std::string toString() const; - - friend class UDP; - friend class Client; - friend class Server; -}; - -#endif diff --git a/cores/esp32/WCharacter.h b/cores/esp32/WCharacter.h index 53428873..1678d7f3 100644 --- a/cores/esp32/WCharacter.h +++ b/cores/esp32/WCharacter.h @@ -25,83 +25,83 @@ #define toascii(__c) ((__c)&0177) // WCharacter.h prototypes -inline boolean isAlphaNumeric(int c) __attribute__((always_inline)); -inline boolean isAlpha(int c) __attribute__((always_inline)); -inline boolean isAscii(int c) __attribute__((always_inline)); -inline boolean isWhitespace(int c) __attribute__((always_inline)); -inline boolean isControl(int c) __attribute__((always_inline)); -inline boolean isDigit(int c) __attribute__((always_inline)); -inline boolean isGraph(int c) __attribute__((always_inline)); -inline boolean isLowerCase(int c) __attribute__((always_inline)); -inline boolean isPrintable(int c) __attribute__((always_inline)); -inline boolean isPunct(int c) __attribute__((always_inline)); -inline boolean isSpace(int c) __attribute__((always_inline)); -inline boolean isUpperCase(int c) __attribute__((always_inline)); -inline boolean isHexadecimalDigit(int c) __attribute__((always_inline)); +inline bool isAlphaNumeric(int c) __attribute__((always_inline)); +inline bool isAlpha(int c) __attribute__((always_inline)); +inline bool isAscii(int c) __attribute__((always_inline)); +inline bool isWhitespace(int c) __attribute__((always_inline)); +inline bool isControl(int c) __attribute__((always_inline)); +inline bool isDigit(int c) __attribute__((always_inline)); +inline bool isGraph(int c) __attribute__((always_inline)); +inline bool isLowerCase(int c) __attribute__((always_inline)); +inline bool isPrintable(int c) __attribute__((always_inline)); +inline bool isPunct(int c) __attribute__((always_inline)); +inline bool isSpace(int c) __attribute__((always_inline)); +inline bool isUpperCase(int c) __attribute__((always_inline)); +inline bool isHexadecimalDigit(int c) __attribute__((always_inline)); inline int toAscii(int c) __attribute__((always_inline)); inline int toLowerCase(int c) __attribute__((always_inline)); inline int toUpperCase(int c) __attribute__((always_inline)); // Checks for an alphanumeric character. // It is equivalent to (isalpha(c) || isdigit(c)). -inline boolean isAlphaNumeric(int c) +inline bool isAlphaNumeric(int c) { return (isalnum(c) == 0 ? false : true); } // Checks for an alphabetic character. // It is equivalent to (isupper(c) || islower(c)). -inline boolean isAlpha(int c) +inline bool isAlpha(int c) { return (isalpha(c) == 0 ? false : true); } // Checks whether c is a 7-bit unsigned char value // that fits into the ASCII character set. -inline boolean isAscii(int c) +inline bool isAscii(int c) { return ( isascii (c) == 0 ? false : true); } // Checks for a blank character, that is, a space or a tab. -inline boolean isWhitespace(int c) +inline bool isWhitespace(int c) { return (isblank(c) == 0 ? false : true); } // Checks for a control character. -inline boolean isControl(int c) +inline bool isControl(int c) { return (iscntrl(c) == 0 ? false : true); } // Checks for a digit (0 through 9). -inline boolean isDigit(int c) +inline bool isDigit(int c) { return (isdigit(c) == 0 ? false : true); } // Checks for any printable character except space. -inline boolean isGraph(int c) +inline bool isGraph(int c) { return (isgraph(c) == 0 ? false : true); } // Checks for a lower-case character. -inline boolean isLowerCase(int c) +inline bool isLowerCase(int c) { return (islower(c) == 0 ? false : true); } // Checks for any printable character including space. -inline boolean isPrintable(int c) +inline bool isPrintable(int c) { return (isprint(c) == 0 ? false : true); } // Checks for any printable character which is not a space // or an alphanumeric character. -inline boolean isPunct(int c) +inline bool isPunct(int c) { return (ispunct(c) == 0 ? false : true); } @@ -109,20 +109,20 @@ inline boolean isPunct(int c) // Checks for white-space characters. For the avr-libc library, // these are: space, formfeed ('\f'), newline ('\n'), carriage // return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). -inline boolean isSpace(int c) +inline bool isSpace(int c) { return (isspace(c) == 0 ? false : true); } // Checks for an uppercase letter. -inline boolean isUpperCase(int c) +inline bool isUpperCase(int c) { return (isupper(c) == 0 ? false : true); } // Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 // 8 9 a b c d e f A B C D E F. -inline boolean isHexadecimalDigit(int c) +inline bool isHexadecimalDigit(int c) { return (isxdigit(c) == 0 ? false : true); } diff --git a/cores/esp32/WMath.cpp b/cores/esp32/WMath.cpp index ebbd20c1..c3701706 100644 --- a/cores/esp32/WMath.cpp +++ b/cores/esp32/WMath.cpp @@ -27,20 +27,20 @@ extern "C" { #include "esp_system.h" } -long map(long x, long in_min, long in_max, long out_min, long out_max) { - const long dividend = out_max - out_min; - const long divisor = in_max - in_min; - const long delta = x - in_min; +//long map(long x, long in_min, long in_max, long out_min, long out_max) { +// const long dividend = out_max - out_min; +// const long divisor = in_max - in_min; +// const long delta = x - in_min; - return (delta * dividend + (divisor / 2)) / divisor + out_min; -} +// return (delta * dividend + (divisor / 2)) / divisor + out_min; +//} -unsigned int makeWord(unsigned int w) -{ - return w; -} +//unsigned int makeWord(unsigned int w) +//{ +// return w; +//} -unsigned int makeWord(unsigned char h, unsigned char l) -{ - return (h << 8) | l; -} +//unsigned int makeWord(unsigned char h, unsigned char l) +//{ +// return (h << 8) | l; +//} diff --git a/cores/esp32/esp32-hal-adc.c b/cores/esp32/esp32-hal-adc.c index 2638d1e9..382e328c 100644 --- a/cores/esp32/esp32-hal-adc.c +++ b/cores/esp32/esp32-hal-adc.c @@ -42,6 +42,7 @@ static uint8_t __analogVRefPin = 0; #include "rom/ets_sys.h" #include "esp_intr.h" #endif +#include "esp32-hal-gpio.h" static uint8_t __analogAttenuation = 3;//11db static uint8_t __analogWidth = 3;//12 bits diff --git a/cores/esp32/esp32-hal-cpu.h b/cores/esp32/esp32-hal-cpu.h index 646b5985..8c2aa717 100644 --- a/cores/esp32/esp32-hal-cpu.h +++ b/cores/esp32/esp32-hal-cpu.h @@ -45,4 +45,8 @@ uint32_t getApbFrequency(); // In Hz } #endif +#define clockCyclesPerMicrosecond() ( (long int)getCpuFrequencyMhz() ) +#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) +#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) + #endif /* _ESP32_HAL_CPU_H_ */ diff --git a/cores/esp32/esp32-hal-dac.c b/cores/esp32/esp32-hal-dac.c index d083e29e..126748ed 100644 --- a/cores/esp32/esp32-hal-dac.c +++ b/cores/esp32/esp32-hal-dac.c @@ -20,6 +20,7 @@ #include "soc/sens_reg.h" #include "soc/sens_struct.h" #include "driver/dac.h" +#include "esp32-hal-gpio.h" #if CONFIG_IDF_TARGET_ESP32 #define DAC1 25 diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index f07f67d4..0fd95b3d 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -25,6 +25,8 @@ #include "esp_attr.h" #include "esp32-hal-cpu.h" // cpu clock change support 31DEC2018 #include "esp32-hal-log.h" +#include "esp32-hal-gpio.h" +#include "esp32-hal-matrix.h" #include "esp_system.h" #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ @@ -38,6 +40,7 @@ #else // ESP32 Before IDF 4.0 #include "rom/ets_sys.h" #endif +#include "driver/gpio.h" #if CONFIG_IDF_TARGET_ESP32 diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 3f972306..ceda0956 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -21,6 +21,9 @@ #include "soc/dport_reg.h" #include "soc/ledc_reg.h" #include "soc/ledc_struct.h" +#include "esp32-hal-cpu.h" +#include "esp32-hal-gpio.h" +#include "esp32-hal-ledc.h" #include "esp_system.h" #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ diff --git a/cores/esp32/esp32-hal-rmt.c b/cores/esp32/esp32-hal-rmt.c index e0906980..f03cd86f 100644 --- a/cores/esp32/esp32-hal-rmt.c +++ b/cores/esp32/esp32-hal-rmt.c @@ -25,6 +25,9 @@ #include "esp_intr_alloc.h" #include "hal/rmt_ll.h" #include "driver/rmt.h" +#include "esp32-hal-rmt.h" +#include "esp32-hal-gpio.h" +#include "esp32-hal-matrix.h" // RMTMEM address is declared in .peripherals.ld extern rmt_mem_t RMTMEM; diff --git a/cores/esp32/esp32-hal-sigmadelta.c b/cores/esp32/esp32-hal-sigmadelta.c index df52393f..b0342ff9 100644 --- a/cores/esp32/esp32-hal-sigmadelta.c +++ b/cores/esp32/esp32-hal-sigmadelta.c @@ -20,6 +20,8 @@ #include "soc/gpio_sd_reg.h" #include "soc/gpio_sd_struct.h" #include "freertos/semphr.h" +#include "esp32-hal-cpu.h" +#include "esp32-hal-gpio.h" #include "esp_system.h" #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ diff --git a/cores/esp32/esp32-hal-spi.c b/cores/esp32/esp32-hal-spi.c index 524c3749..be477b58 100644 --- a/cores/esp32/esp32-hal-spi.c +++ b/cores/esp32/esp32-hal-spi.c @@ -43,6 +43,9 @@ #include "rom/gpio.h" #include "esp_intr.h" #endif +#include "esp32-hal-gpio.h" +#include "esp32-hal-matrix.h" +#include "esp32-hal-cpu.h" struct spi_struct_t { spi_dev_t * dev; diff --git a/cores/esp32/esp32-hal-touch.c b/cores/esp32/esp32-hal-touch.c index e22cec76..2191bb01 100644 --- a/cores/esp32/esp32-hal-touch.c +++ b/cores/esp32/esp32-hal-touch.c @@ -31,13 +31,14 @@ #include "esp32s2/rom/ets_sys.h" #include "esp_intr_alloc.h" #include "soc/periph_defs.h" -#else +#else #error Target CONFIG_IDF_TARGET is not supported #endif #else // ESP32 Before IDF 4.0 #include "rom/ets_sys.h" #include "esp_intr.h" #endif +#include "esp32-hal-gpio.h" static uint16_t __touchSleepCycles = 0x1000; static uint16_t __touchMeasureCycles = 0x1000; diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 19819c64..167cefc7 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -61,18 +61,18 @@ void yield(void); #define NOP() asm volatile ("nop") //#include "esp32-hal-log.h" -#include "esp32-hal-matrix.h" -#include "esp32-hal-gpio.h" -#include "esp32-hal-touch.h" -#include "esp32-hal-dac.h" -#include "esp32-hal-adc.h" -#include "esp32-hal-spi.h" -#include "esp32-hal-i2c.h" -#include "esp32-hal-ledc.h" -#include "esp32-hal-rmt.h" -#include "esp32-hal-sigmadelta.h" -#include "esp32-hal-psram.h" -#include "esp32-hal-cpu.h" +//#include "esp32-hal-matrix.h" +//#include "esp32-hal-gpio.h" +//#include "esp32-hal-touch.h" +//#include "esp32-hal-dac.h" +//#include "esp32-hal-adc.h" +//#include "esp32-hal-spi.h" +//#include "esp32-hal-i2c.h" +//#include "esp32-hal-ledc.h" +//#include "esp32-hal-rmt.h" +//#include "esp32-hal-sigmadelta.h" +//#include "esp32-hal-psram.h" +//#include "esp32-hal-cpu.h" //returns chip temperature in Celsius float temperatureRead(); diff --git a/cores/esp32/wiring_shift.c b/cores/esp32/wiring_shift.c index 41cf8a0f..d6658150 100644 --- a/cores/esp32/wiring_shift.c +++ b/cores/esp32/wiring_shift.c @@ -17,8 +17,10 @@ $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ */ +#include "wiring_shift.h" #include "esp32-hal.h" #include "wiring_private.h" +#include "esp32-hal-gpio.h" uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { uint8_t value = 0; diff --git a/cores/esp32/wiring_shift.h b/cores/esp32/wiring_shift.h new file mode 100644 index 00000000..c5652640 --- /dev/null +++ b/cores/esp32/wiring_shift.h @@ -0,0 +1,9 @@ +#pragma once + +#define LSBFIRST 0 +#define MSBFIRST 1 + +#include + +uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); +void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); diff --git a/libraries/FS/src/FS.cpp b/libraries/FS/src/FS.cpp index 0dda18b1..4cd8678a 100644 --- a/libraries/FS/src/FS.cpp +++ b/libraries/FS/src/FS.cpp @@ -153,7 +153,7 @@ const char* File::name() const } //to implement -boolean File::isDirectory(void) +bool File::isDirectory(void) { if (!_p) { return false; diff --git a/libraries/FS/src/FS.h b/libraries/FS/src/FS.h index fe3870d7..e2c0b213 100644 --- a/libraries/FS/src/FS.h +++ b/libraries/FS/src/FS.h @@ -75,7 +75,7 @@ public: time_t getLastWrite(); const char* name() const; - boolean isDirectory(void); + bool isDirectory(void); File openNextFile(const char* mode = FILE_READ); void rewindDirectory(void); diff --git a/libraries/FS/src/FSImpl.h b/libraries/FS/src/FSImpl.h index 70e5cb1e..741f1fa3 100644 --- a/libraries/FS/src/FSImpl.h +++ b/libraries/FS/src/FSImpl.h @@ -39,7 +39,7 @@ public: virtual void close() = 0; virtual time_t getLastWrite() = 0; virtual const char* name() const = 0; - virtual boolean isDirectory(void) = 0; + virtual bool isDirectory(void) = 0; virtual FileImplPtr openNextFile(const char* mode) = 0; virtual void rewindDirectory(void) = 0; virtual operator bool() = 0; diff --git a/libraries/FS/src/vfs_api.cpp b/libraries/FS/src/vfs_api.cpp index 72f38b40..8c7d11ea 100644 --- a/libraries/FS/src/vfs_api.cpp +++ b/libraries/FS/src/vfs_api.cpp @@ -16,6 +16,8 @@ #include "esp32-hal-log.h" +#include + using namespace fs; FileImplPtr VFSImpl::open(const char* path, const char* mode) @@ -385,7 +387,7 @@ const char* VFSFileImpl::name() const } //to implement -boolean VFSFileImpl::isDirectory(void) +bool VFSFileImpl::isDirectory(void) { return _isDirectory; } diff --git a/libraries/FS/src/vfs_api.h b/libraries/FS/src/vfs_api.h index c5649130..b4c8ea28 100644 --- a/libraries/FS/src/vfs_api.h +++ b/libraries/FS/src/vfs_api.h @@ -68,7 +68,7 @@ public: void close() override; const char* name() const override; time_t getLastWrite() override; - boolean isDirectory(void) override; + bool isDirectory(void) override; FileImplPtr openNextFile(const char* mode) override; void rewindDirectory(void) override; operator bool(); diff --git a/libraries/SPI/src/SPI.cpp b/libraries/SPI/src/SPI.cpp index f0bd0bb4..9f296900 100644 --- a/libraries/SPI/src/SPI.cpp +++ b/libraries/SPI/src/SPI.cpp @@ -21,6 +21,8 @@ #include "SPI.h" +#include "pins_arduino.h" + SPIClass::SPIClass(uint8_t spi_bus) :_spi_num(spi_bus) ,_spi(NULL) diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index 33bf5886..4896d27a 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -22,7 +22,6 @@ #define _SPI_H_INCLUDED #include -#include "pins_arduino.h" #include "esp32-hal-spi.h" #define SPI_HAS_TRANSACTION diff --git a/libraries/SPIFFS/src/SPIFFS.cpp b/libraries/SPIFFS/src/SPIFFS.cpp index 5860968d..ad12261e 100644 --- a/libraries/SPIFFS/src/SPIFFS.cpp +++ b/libraries/SPIFFS/src/SPIFFS.cpp @@ -25,6 +25,8 @@ extern "C" { #include "esp32-hal-log.h" +#include + using namespace fs; class SPIFFSImpl : public VFSImpl diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 82355225..57667fcc 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -35,7 +35,7 @@ extern "C" { #include "esp32-hal-i2c.h" #include "esp32-hal-log.h" #include "Wire.h" -#include "Arduino.h" +#include "pins_arduino.h" std::string toString(i2c_err_t val) { diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index acfbfc48..7447b395 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -29,6 +29,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/queue.h" #include +#include "esp32-hal-i2c.h" #define STICKBREAKER 'V1.1.0' #define I2C_BUFFER_LENGTH 128