diff --git a/cores/esp32/esp32-hal-adc.h b/cores/esp32/esp32-hal-adc.h index 1c5ea23c..46963c8d 100644 --- a/cores/esp32/esp32-hal-adc.h +++ b/cores/esp32/esp32-hal-adc.h @@ -24,7 +24,9 @@ extern "C" { #endif -#include "esp32-hal.h" +#include +#include +//#include "esp32-hal.h" typedef enum { ADC_0db, diff --git a/cores/esp32/esp32-hal-cpu.h b/cores/esp32/esp32-hal-cpu.h index 8c2aa717..c3e9d636 100644 --- a/cores/esp32/esp32-hal-cpu.h +++ b/cores/esp32/esp32-hal-cpu.h @@ -45,6 +45,14 @@ uint32_t getApbFrequency(); // In Hz } #endif +#ifndef F_CPU +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 +#define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U) +#elif CONFIG_IDF_TARGET_ESP32S2 +#define F_CPU (CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000U) +#endif +#endif + #define clockCyclesPerMicrosecond() ( (long int)getCpuFrequencyMhz() ) #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) diff --git a/cores/esp32/esp32-hal-dac.h b/cores/esp32/esp32-hal-dac.h index 47b22658..cfd7d798 100644 --- a/cores/esp32/esp32-hal-dac.h +++ b/cores/esp32/esp32-hal-dac.h @@ -24,9 +24,6 @@ extern "C" { #endif -#include "esp32-hal.h" -#include "driver/gpio.h" - void dacWrite(uint8_t pin, uint8_t value); #ifdef __cplusplus diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 787c58e5..d66e943a 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "esp32-hal.h" #include "esp32-hal-gpio.h" #include "pins_arduino.h" #include "freertos/FreeRTOS.h" diff --git a/cores/esp32/esp32-hal-gpio.h b/cores/esp32/esp32-hal-gpio.h index f3a61ff9..7620629e 100644 --- a/cores/esp32/esp32-hal-gpio.h +++ b/cores/esp32/esp32-hal-gpio.h @@ -24,7 +24,7 @@ extern "C" { #endif -#include "esp32-hal.h" +#include "stdint.h" #include "soc/soc_caps.h" #if (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3) diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index 0fd95b3d..eac951d0 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -12,13 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "esp32-hal-i2c.h" #include "esp32-hal.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "freertos/event_groups.h" -#include "driver/periph_ctrl.h" +#include "esp_private/periph_ctrl.h" #include "soc/i2c_reg.h" #include "soc/i2c_struct.h" #include "soc/dport_reg.h" @@ -27,6 +29,7 @@ #include "esp32-hal-log.h" #include "esp32-hal-gpio.h" #include "esp32-hal-matrix.h" +#include "esp32-hal-misc.h" #include "esp_system.h" #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ diff --git a/cores/esp32/esp32-hal-matrix.c b/cores/esp32/esp32-hal-matrix.c index caa58d86..a8455589 100644 --- a/cores/esp32/esp32-hal-matrix.c +++ b/cores/esp32/esp32-hal-matrix.c @@ -14,6 +14,7 @@ #include "esp32-hal-matrix.h" #include "esp_attr.h" +#include "esp32-hal.h" #include "esp_system.h" #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ diff --git a/cores/esp32/esp32-hal-matrix.h b/cores/esp32/esp32-hal-matrix.h index 3bc90498..60485dc3 100644 --- a/cores/esp32/esp32-hal-matrix.h +++ b/cores/esp32/esp32-hal-matrix.h @@ -20,7 +20,8 @@ extern "C" { #endif -#include "esp32-hal.h" +#include +#include #include "soc/gpio_sig_map.h" void pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable); diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index aafa1d4e..dcca7c33 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -13,6 +13,8 @@ // limitations under the License. #include "sdkconfig.h" +#include "esp32-hal-misc.h" +#include "esp32-hal.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_attr.h" @@ -29,7 +31,6 @@ #include "soc/rtc_cntl_reg.h" #include "soc/apb_ctrl_reg.h" #include "esp_task_wdt.h" -#include "esp32-hal.h" #include "esp_system.h" #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ diff --git a/cores/esp32/esp32-hal-misc.h b/cores/esp32/esp32-hal-misc.h new file mode 100644 index 00000000..abb0e3a0 --- /dev/null +++ b/cores/esp32/esp32-hal-misc.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +void yield(void); + +unsigned long micros(); +void delayMicroseconds(uint32_t us); diff --git a/cores/esp32/esp32-hal-psram.c b/cores/esp32/esp32-hal-psram.c index 7a8cc0be..6735f05c 100644 --- a/cores/esp32/esp32-hal-psram.c +++ b/cores/esp32/esp32-hal-psram.c @@ -14,6 +14,9 @@ #include "esp32-hal.h" +#include +#include + #if CONFIG_SPIRAM_SUPPORT || CONFIG_SPIRAM #include "soc/efuse_reg.h" #include "esp_heap_caps.h" diff --git a/cores/esp32/esp32-hal-spi.c b/cores/esp32/esp32-hal-spi.c index be477b58..fc0b3540 100644 --- a/cores/esp32/esp32-hal-spi.c +++ b/cores/esp32/esp32-hal-spi.c @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "esp32-hal-spi.h" #include "esp32-hal.h" #include "freertos/FreeRTOS.h" diff --git a/cores/esp32/esp32-hal-touch.c b/cores/esp32/esp32-hal-touch.c index 2191bb01..394aec0c 100644 --- a/cores/esp32/esp32-hal-touch.c +++ b/cores/esp32/esp32-hal-touch.c @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "esp32-hal.h" #include "esp32-hal-touch.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/cores/esp32/esp32-hal-touch.h b/cores/esp32/esp32-hal-touch.h index 6f3b0fd0..611924a3 100644 --- a/cores/esp32/esp32-hal-touch.h +++ b/cores/esp32/esp32-hal-touch.h @@ -24,7 +24,7 @@ extern "C" { #endif -#include "esp32-hal.h" +#include /* * Set cycles that measurement operation takes diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 167cefc7..9cd9464a 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -20,29 +20,21 @@ #ifndef HAL_ESP32_HAL_H_ #define HAL_ESP32_HAL_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include "sdkconfig.h" -#include "esp_system.h" -#include "esp_sleep.h" +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include "sdkconfig.h" +//#include "esp_system.h" +//#include "esp_sleep.h" -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef F_CPU -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 -#define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U) -#elif CONFIG_IDF_TARGET_ESP32S2 -#define F_CPU (CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000U) -#endif -#endif +//#ifdef __cplusplus +//extern "C" { +//#endif #if CONFIG_ARDUINO_ISR_IRAM #define ARDUINO_ISR_ATTR IRAM_ATTR @@ -52,36 +44,32 @@ extern "C" { #define ARDUINO_ISR_FLAG (0) #endif -//forward declaration from freertos/portmacro.h -void vPortYield(void); -void yield(void); -#define optimistic_yield(u) +////forward declaration from freertos/portmacro.h +//void vPortYield(void); +//#define optimistic_yield(u) #define ESP_REG(addr) *((volatile uint32_t *)(addr)) #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-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" -//returns chip temperature in Celsius -float temperatureRead(); +////returns chip temperature in Celsius +//float temperatureRead(); -unsigned long micros(); -void delayMicroseconds(uint32_t us); - -#ifdef __cplusplus -} -#endif +//#ifdef __cplusplus +//} +//#endif #endif /* HAL_ESP32_HAL_H_ */ diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index 7447b395..19ee1a4e 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -25,10 +25,11 @@ #ifndef TwoWire_h #define TwoWire_h -#include +#include +#include + #include "freertos/FreeRTOS.h" #include "freertos/queue.h" -#include #include "esp32-hal-i2c.h" #define STICKBREAKER 'V1.1.0'