Skip to content

Commit

Permalink
fix(build): Initial changes to build against IDF v5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev committed Aug 19, 2024
1 parent def319a commit 4b88a3a
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 87 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ jobs:
- name: Build Sketches
run: bash ./.github/scripts/on-push.sh 1 1 #equal and non-zero to trigger PIO

# ESP-IDF component build
build-esp-idf-component:
name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
needs: gen-chunks
Expand All @@ -231,7 +232,7 @@ jobs:
# See https://hub.docker.com/r/espressif/idf/tags and
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
# for details.
idf_ver: ["release-v5.1"]
idf_ver: ["release-v5.3"]
idf_target: ["esp32", "esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2"]
container: espressif/idf:${{ matrix.idf_ver }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# export ARDUINO_SKIP_IDF_VERSION_CHECK=1
# idf.py build

set(min_supported_idf_version "5.1.0")
set(max_supported_idf_version "5.1.99")
set(min_supported_idf_version "5.3.0")
set(max_supported_idf_version "5.3.99")
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")

if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
class Client : public Stream {
public:
virtual int connect(IPAddress ip, uint16_t port) = 0;
virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
virtual int connect(const char *host, uint16_t port) = 0;
virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
virtual size_t write(uint8_t) = 0;
virtual size_t write(const uint8_t *buf, size_t size) = 0;
virtual int available() = 0;
Expand Down
16 changes: 8 additions & 8 deletions cores/esp32/HWCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ bool HWCDC::deinit(void *busptr) {
running = true;
// Setting USB D+ D- pins
bool retCode = true;
retCode &= perimanClearPinBus(USB_DM_GPIO_NUM);
retCode &= perimanClearPinBus(USB_DP_GPIO_NUM);
retCode &= perimanClearPinBus(USB_INT_PHY0_DM_GPIO_NUM);
retCode &= perimanClearPinBus(USB_INT_PHY0_DP_GPIO_NUM);
if (retCode) {
// Force the host to re-enumerate (BUS_RESET)
pinMode(USB_DM_GPIO_NUM, OUTPUT_OPEN_DRAIN);
pinMode(USB_DP_GPIO_NUM, OUTPUT_OPEN_DRAIN);
digitalWrite(USB_DM_GPIO_NUM, LOW);
digitalWrite(USB_DP_GPIO_NUM, LOW);
pinMode(USB_INT_PHY0_DM_GPIO_NUM, OUTPUT_OPEN_DRAIN);
pinMode(USB_INT_PHY0_DP_GPIO_NUM, OUTPUT_OPEN_DRAIN);
digitalWrite(USB_INT_PHY0_DM_GPIO_NUM, LOW);
digitalWrite(USB_INT_PHY0_DP_GPIO_NUM, LOW);
}
// release the flag
running = false;
Expand Down Expand Up @@ -323,11 +323,11 @@ void HWCDC::begin(unsigned long baud) {
// delay(10); // USB Host has to enumerate it again

// Peripheral Manager setting for USB D+ D- pins
uint8_t pin = USB_DM_GPIO_NUM;
uint8_t pin = USB_INT_PHY0_DM_GPIO_NUM;
if (!perimanSetPinBus(pin, ESP32_BUS_TYPE_USB_DM, (void *)this, -1, -1)) {
goto err;
}
pin = USB_DP_GPIO_NUM;
pin = USB_INT_PHY0_DP_GPIO_NUM;
if (!perimanSetPinBus(pin, ESP32_BUS_TYPE_USB_DP, (void *)this, -1, -1)) {
goto err;
}
Expand Down
24 changes: 12 additions & 12 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@
void serialEvent(void) __attribute__((weak));
void serialEvent(void) {}

#if SOC_UART_NUM > 1
#if SOC_UART_HP_NUM > 1
void serialEvent1(void) __attribute__((weak));
void serialEvent1(void) {}
#endif /* SOC_UART_NUM > 1 */
#endif /* SOC_UART_HP_NUM > 1 */

#if SOC_UART_NUM > 2
#if SOC_UART_HP_NUM > 2
void serialEvent2(void) __attribute__((weak));
void serialEvent2(void) {}
#endif /* SOC_UART_NUM > 2 */
#endif /* SOC_UART_HP_NUM > 2 */

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
// There is always Seria0 for UART0
HardwareSerial Serial0(0);
#if SOC_UART_NUM > 1
#if SOC_UART_HP_NUM > 1
HardwareSerial Serial1(1);
#endif
#if SOC_UART_NUM > 2
#if SOC_UART_HP_NUM > 2
HardwareSerial Serial2(2);
#endif

Expand Down Expand Up @@ -72,12 +72,12 @@ void serialEventRun(void) {
if (Serial0.available()) {
serialEvent();
}
#if SOC_UART_NUM > 1
#if SOC_UART_HP_NUM > 1
if (Serial1.available()) {
serialEvent1();
}
#endif
#if SOC_UART_NUM > 2
#if SOC_UART_HP_NUM > 2
if (Serial2.available()) {
serialEvent2();
}
Expand Down Expand Up @@ -279,8 +279,8 @@ void HardwareSerial::_uartEventTask(void *args) {
}

void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd) {
if (_uart_nr >= SOC_UART_NUM) {
log_e("Serial number is invalid, please use a number from 0 to %u", SOC_UART_NUM - 1);
if (_uart_nr >= SOC_UART_HP_NUM) {
log_e("Serial number is invalid, please use a number from 0 to %u", SOC_UART_HP_NUM - 1);
return;
}

Expand All @@ -305,7 +305,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
txPin = _txPin < 0 ? (int8_t)SOC_TX0 : _txPin;
}
break;
#if SOC_UART_NUM > 1 // may save some flash bytes...
#if SOC_UART_HP_NUM > 1 // may save some flash bytes...
case UART_NUM_1:
if (rxPin < 0 && txPin < 0) {
// do not change RX1/TX1 if it has already been set before
Expand All @@ -314,7 +314,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
}
break;
#endif
#if SOC_UART_NUM > 2 // may save some flash bytes...
#if SOC_UART_HP_NUM > 2 // may save some flash bytes...
case UART_NUM_2:
if (rxPin < 0 && txPin < 0) {
// do not change RX2/TX2 if it has already been set before
Expand Down
30 changes: 15 additions & 15 deletions cores/esp32/esp32-hal-i2c-slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

#define I2C_SLAVE_USE_RX_QUEUE 0 // 1: Queue, 0: RingBuffer

#if SOC_I2C_NUM > 1
#if SOC_HP_I2C_NUM > 1
#define I2C_SCL_IDX(p) ((p == 0) ? I2CEXT0_SCL_OUT_IDX : ((p == 1) ? I2CEXT1_SCL_OUT_IDX : 0))
#define I2C_SDA_IDX(p) ((p == 0) ? I2CEXT0_SDA_OUT_IDX : ((p == 1) ? I2CEXT1_SDA_OUT_IDX : 0))
#else
Expand Down Expand Up @@ -99,14 +99,14 @@ typedef union {
uint32_t val;
} i2c_slave_queue_event_t;

static i2c_slave_struct_t _i2c_bus_array[SOC_I2C_NUM] = {
static i2c_slave_struct_t _i2c_bus_array[SOC_HP_I2C_NUM] = {
{&I2C0, 0, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
#if !CONFIG_DISABLE_HAL_LOCKS
,
NULL
#endif
},
#if SOC_I2C_NUM > 1
#if SOC_HP_I2C_NUM > 1
{&I2C1, 1, -1, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
#if !CONFIG_DISABLE_HAL_LOCKS
,
Expand Down Expand Up @@ -210,7 +210,7 @@ static bool i2cSlaveDetachBus(void *bus_i2c_num);
//=====================================================================================================================

esp_err_t i2cSlaveAttachCallbacks(uint8_t num, i2c_slave_request_cb_t request_callback, i2c_slave_receive_cb_t receive_callback, void *arg) {
if (num >= SOC_I2C_NUM) {
if (num >= SOC_HP_I2C_NUM) {
log_e("Invalid port num: %u", num);
return ESP_ERR_INVALID_ARG;
}
Expand All @@ -224,7 +224,7 @@ esp_err_t i2cSlaveAttachCallbacks(uint8_t num, i2c_slave_request_cb_t request_ca
}

esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t frequency, size_t rx_len, size_t tx_len) {
if (num >= SOC_I2C_NUM) {
if (num >= SOC_HP_I2C_NUM) {
log_e("Invalid port num: %u", num);
return ESP_ERR_INVALID_ARG;
}
Expand Down Expand Up @@ -309,14 +309,14 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t

if (i2c->num == 0) {
periph_ll_enable_clk_clear_rst(PERIPH_I2C0_MODULE);
#if SOC_I2C_NUM > 1
#if SOC_HP_I2C_NUM > 1
} else {
periph_ll_enable_clk_clear_rst(PERIPH_I2C1_MODULE);
#endif
}

i2c_ll_slave_init(i2c->dev);
i2c_ll_set_fifo_mode(i2c->dev, true);
i2c_ll_slave_set_fifo_mode(i2c->dev, true);
i2c_ll_set_slave_addr(i2c->dev, slaveID, false);
i2c_ll_set_tout(i2c->dev, I2C_LL_MAX_TIMEOUT);
i2c_slave_set_frequency(i2c, frequency);
Expand All @@ -337,13 +337,13 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t

i2c_ll_disable_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
i2c_ll_clear_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
i2c_ll_set_fifo_mode(i2c->dev, true);
i2c_ll_slave_set_fifo_mode(i2c->dev, true);

if (!i2c->intr_handle) {
uint32_t flags = ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED;
if (i2c->num == 0) {
ret = esp_intr_alloc(ETS_I2C_EXT0_INTR_SOURCE, flags, &i2c_slave_isr_handler, i2c, &i2c->intr_handle);
#if SOC_I2C_NUM > 1
#if SOC_HP_I2C_NUM > 1
} else {
ret = esp_intr_alloc(ETS_I2C_EXT1_INTR_SOURCE, flags, &i2c_slave_isr_handler, i2c, &i2c->intr_handle);
#endif
Expand Down Expand Up @@ -375,7 +375,7 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
}

esp_err_t i2cSlaveDeinit(uint8_t num) {
if (num >= SOC_I2C_NUM) {
if (num >= SOC_HP_I2C_NUM) {
log_e("Invalid port num: %u", num);
return ESP_ERR_INVALID_ARG;
}
Expand All @@ -398,7 +398,7 @@ esp_err_t i2cSlaveDeinit(uint8_t num) {
}

size_t i2cSlaveWrite(uint8_t num, const uint8_t *buf, uint32_t len, uint32_t timeout_ms) {
if (num >= SOC_I2C_NUM) {
if (num >= SOC_HP_I2C_NUM) {
log_e("Invalid port num: %u", num);
return 0;
}
Expand Down Expand Up @@ -515,16 +515,16 @@ static bool i2c_slave_set_frequency(i2c_slave_struct_t *i2c, uint32_t clk_speed)

i2c_hal_clk_config_t clk_cal;
#if SOC_I2C_SUPPORT_APB
i2c_ll_cal_bus_clk(APB_CLK_FREQ, clk_speed, &clk_cal);
i2c_ll_master_cal_bus_clk(APB_CLK_FREQ, clk_speed, &clk_cal);
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_APB); /*!< I2C source clock from APB, 80M*/
#elif SOC_I2C_SUPPORT_XTAL
i2c_ll_cal_bus_clk(XTAL_CLK_FREQ, clk_speed, &clk_cal);
i2c_ll_master_cal_bus_clk(XTAL_CLK_FREQ, clk_speed, &clk_cal);
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_XTAL); /*!< I2C source clock from XTAL, 40M */
#endif
i2c_ll_set_txfifo_empty_thr(i2c->dev, a);
i2c_ll_set_rxfifo_full_thr(i2c->dev, SOC_I2C_FIFO_LEN - a);
i2c_ll_set_bus_timing(i2c->dev, &clk_cal);
i2c_ll_set_filter(i2c->dev, 3);
i2c_ll_master_set_bus_timing(i2c->dev, &clk_cal);
i2c_ll_master_set_filter(i2c->dev, 3);
return true;
}

Expand Down
34 changes: 17 additions & 17 deletions cores/esp32/esp32-hal-touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
Internal Private Touch Data Structure and Functions
*/

#if SOC_TOUCH_VERSION_1 // ESP32
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
static uint16_t __touchSleepCycles = 0x1000;
static uint16_t __touchMeasureCycles = 0x1000;
#elif SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
static uint16_t __touchSleepCycles = TOUCH_PAD_SLEEP_CYCLE_DEFAULT;
static uint16_t __touchMeasureCycles = TOUCH_PAD_MEASURE_CYCLE_DEFAULT;
#endif
Expand All @@ -37,7 +37,7 @@ typedef struct {
voidFuncPtr fn;
bool callWithArgs;
void *arg;
#if SOC_TOUCH_VERSION_2 // Only for ESP32S2 and ESP32S3
#if SOC_TOUCH_SENSOR_VERSION == 2 // Only for ESP32S2 and ESP32S3
bool lastStatusIsPressed;
#endif
} TouchInterruptHandle_t;
Expand All @@ -51,7 +51,7 @@ static bool initialized = false;
static bool channels_initialized[SOC_TOUCH_SENSOR_NUM] = {false};

static void ARDUINO_ISR_ATTR __touchISR(void *arg) {
#if SOC_TOUCH_VERSION_1 // ESP32
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
uint32_t pad_intr = touch_pad_get_status();
//clear interrupt
touch_pad_clear_status();
Expand All @@ -68,7 +68,7 @@ static void ARDUINO_ISR_ATTR __touchISR(void *arg) {
}
}
}
#elif SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
touch_pad_intr_mask_t evt = touch_pad_read_intr_status_mask();
uint8_t pad_num = touch_pad_get_current_meas_channel();
if (evt & TOUCH_PAD_INTR_MASK_ACTIVE) {
Expand All @@ -93,9 +93,9 @@ static void ARDUINO_ISR_ATTR __touchISR(void *arg) {
static void __touchSetCycles(uint16_t measure, uint16_t sleep) {
__touchSleepCycles = sleep;
__touchMeasureCycles = measure;
#if SOC_TOUCH_VERSION_1 // ESP32
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
touch_pad_set_measurement_clock_cycles(measure);
#elif SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
touch_pad_set_charge_discharge_times(measure);
#endif
touch_pad_set_measurement_interval(sleep);
Expand Down Expand Up @@ -123,7 +123,7 @@ static void __touchInit() {

esp_err_t err = ESP_OK;

#if SOC_TOUCH_VERSION_1 // ESP32
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
err = touch_pad_init();
if (err != ESP_OK) {
goto err;
Expand All @@ -144,7 +144,7 @@ static void __touchInit() {
goto err;
}
touch_pad_intr_enable(); // returns ESP_OK
#elif SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
err = touch_pad_init();
if (err != ESP_OK) {
goto err;
Expand Down Expand Up @@ -179,11 +179,11 @@ static void __touchChannelInit(int pad) {
return;
}

#if SOC_TOUCH_VERSION_1 // ESP32
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
// Initial no Threshold and setup
__touchInterruptHandlers[pad].fn = NULL;
touch_pad_config(pad, SOC_TOUCH_PAD_THRESHOLD_MAX); // returns ESP_OK
#elif SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
touch_pad_config(pad, TOUCH_PAD_THRESHOLD_MAX); // returns ESP_OK
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
// Initial no Threshold and setup
__touchInterruptHandlers[pad].fn = NULL;
touch_pad_config(pad); // returns ESP_OK
Expand Down Expand Up @@ -238,7 +238,7 @@ static void __touchConfigInterrupt(uint8_t pin, void (*userFunc)(void), void *Ar
if (userFunc == NULL) {
// detach ISR User Call
__touchInterruptHandlers[pad].fn = NULL;
threshold = SOC_TOUCH_PAD_THRESHOLD_MAX; // deactivate the ISR with SOC_TOUCH_PAD_THRESHOLD_MAX
threshold = TOUCH_PAD_THRESHOLD_MAX; // deactivate the ISR with SOC_TOUCH_PAD_THRESHOLD_MAX
} else {
// attach ISR User Call
__touchInit();
Expand Down Expand Up @@ -270,15 +270,15 @@ static void __touchDettachInterrupt(uint8_t pin) {
External Public Touch API Functions
*/

#if SOC_TOUCH_VERSION_1 // Only for ESP32 SoC
#if SOC_TOUCH_SENSOR_VERSION == 1 // Only for ESP32 SoC
void touchInterruptSetThresholdDirection(bool mustbeLower) {
if (mustbeLower) {
touch_pad_set_trigger_mode(TOUCH_TRIGGER_BELOW);
} else {
touch_pad_set_trigger_mode(TOUCH_TRIGGER_ABOVE);
}
}
#elif SOC_TOUCH_VERSION_2 // Only for ESP32S2 and ESP32S3
#elif SOC_TOUCH_SENSOR_VERSION == 2 // Only for ESP32S2 and ESP32S3
// returns true if touch pad has been and continues pressed and false otherwise
bool touchInterruptGetLastStatus(uint8_t pin) {
int8_t pad = digitalPinToTouchChannel(pin);
Expand Down Expand Up @@ -307,10 +307,10 @@ void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold) {
return;
}
}
#if SOC_TOUCH_VERSION_1 // Only for ESP32 SoC
#if SOC_TOUCH_SENSOR_VERSION == 1 // Only for ESP32 SoC
touch_pad_set_thresh(pad, threshold);

#elif SOC_TOUCH_VERSION_2
#elif SOC_TOUCH_SENSOR_VERSION == 2
touch_pad_sleep_channel_enable(pad, true);
touch_pad_sleep_set_threshold(pad, threshold);

Expand Down
Loading

0 comments on commit 4b88a3a

Please sign in to comment.