Skip to content

Add checks for SOC defines #8351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cores/esp32/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "USB.h"

#if SOC_USB_OTG_SUPPORTED
#if CONFIG_TINYUSB_ENABLED

#include "pins_arduino.h"
Expand Down Expand Up @@ -357,3 +359,4 @@ const char * ESPUSB::webUSBURL(void){
ESPUSB USB;

#endif /* CONFIG_TINYUSB_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
6 changes: 5 additions & 1 deletion cores/esp32/USB.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#pragma once

#include "soc/soc_caps.h"

#if SOC_USB_OTG_SUPPORTED

#include "sdkconfig.h"
#if CONFIG_TINYUSB_ENABLED

#include "esp_event.h"
#include "USBCDC.h"

Expand Down Expand Up @@ -116,4 +118,6 @@ class ESPUSB {

extern ESPUSB USB;


#endif /* CONFIG_TINYUSB_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
7 changes: 6 additions & 1 deletion cores/esp32/USBCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "USBCDC.h"

#if SOC_USB_OTG_SUPPORTED
#include "USB.h"
#if CONFIG_TINYUSB_CDC_ENABLED

#include "USBCDC.h"

#include "esp32-hal-tinyusb.h"
#include "rom/ets_sys.h"

Expand Down Expand Up @@ -456,3 +460,4 @@ USBCDC Serial(0);
#endif

#endif /* CONFIG_TINYUSB_CDC_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
4 changes: 4 additions & 0 deletions cores/esp32/USBCDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// limitations under the License.
#pragma once

#include "soc/soc_caps.h"
#if SOC_USB_OTG_SUPPORTED

#include "sdkconfig.h"
#if CONFIG_TINYUSB_CDC_ENABLED

Expand Down Expand Up @@ -143,3 +146,4 @@ extern USBCDC Serial;
#endif

#endif /* CONFIG_TINYUSB_CDC_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
3 changes: 3 additions & 0 deletions cores/esp32/USBMSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "USBMSC.h"

#if SOC_USB_OTG_SUPPORTED
#if CONFIG_TINYUSB_MSC_ENABLED

#include "esp32-hal-tinyusb.h"
Expand Down Expand Up @@ -258,3 +260,4 @@ void USBMSC::mediaPresent(bool media_present){
}

#endif /* CONFIG_TINYUSB_MSC_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
5 changes: 5 additions & 0 deletions cores/esp32/USBMSC.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
// limitations under the License.

#pragma once

#include "soc/soc_caps.h"
#if SOC_USB_OTG_SUPPORTED

#include <stdint.h>
#include <stdbool.h>
#include "sdkconfig.h"
Expand Down Expand Up @@ -49,3 +53,4 @@ class USBMSC
};

#endif /* CONFIG_TINYUSB_MSC_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
4 changes: 3 additions & 1 deletion cores/esp32/esp32-hal-bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "esp32-hal-bt.h"

#if SOC_BT_SUPPORTED
#ifdef CONFIG_BT_ENABLED

// user may want to change it to free resources
Expand Down Expand Up @@ -97,5 +98,6 @@ bool btStop()
return false;
}

#endif // CONFIG_BT_ENABLED
#endif /* CONFIG_BT_ENABLED */

#endif /* SOC_BT_SUPPORTED */
5 changes: 5 additions & 0 deletions cores/esp32/esp32-hal-bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifndef _ESP32_ESP32_HAL_BT_H_
#define _ESP32_ESP32_HAL_BT_H_

#include "soc/soc_caps.h"
#if SOC_BT_SUPPORTED

#include "esp32-hal.h"

#ifdef __cplusplus
Expand All @@ -29,4 +32,6 @@ bool btStop();
}
#endif

#endif /* SOC_BT_SUPPORTED */

#endif /* _ESP32_ESP32_HAL_BT_H_ */
5 changes: 5 additions & 0 deletions cores/esp32/esp32-hal-i2c-slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "soc/soc_caps.h"

#if SOC_I2C_SUPPORT_SLAVE
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
Expand Down Expand Up @@ -874,3 +877,5 @@ static bool i2cSlaveDetachBus(void * bus_i2c_num){
}
return true;
}

#endif /* SOC_I2C_SUPPORT_SLAVE */
5 changes: 5 additions & 0 deletions cores/esp32/esp32-hal-i2c-slave.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#pragma once

#include "soc/soc_caps.h"
#if SOC_I2C_SUPPORT_SLAVE

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -33,3 +36,5 @@ size_t i2cSlaveWrite(uint8_t num, const uint8_t *buf, uint32_t len, uint32_t tim
#ifdef __cplusplus
}
#endif

#endif /* SOC_I2C_SUPPORT_SLAVE */
4 changes: 4 additions & 0 deletions cores/esp32/esp32-hal-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

#include "esp32-hal-i2c.h"

#if SOC_I2C_SUPPORTED
#include "esp32-hal.h"
#if !CONFIG_DISABLE_HAL_LOCKS
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -390,3 +392,5 @@ esp_err_t i2cGetClock(uint8_t i2c_num, uint32_t * frequency){
*frequency = bus[i2c_num].frequency;
return ESP_OK;
}

#endif /* SOC_I2C_SUPPORTED */
4 changes: 4 additions & 0 deletions cores/esp32/esp32-hal-i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#ifndef _ESP32_HAL_I2C_H_
#define _ESP32_HAL_I2C_H_

#include "soc/soc_caps.h"
#if SOC_I2C_SUPPORTED

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -38,4 +41,5 @@ bool i2cIsInit(uint8_t i2c_num);
}
#endif

#endif /* SOC_I2C_SUPPORTED */
#endif /* _ESP32_HAL_I2C_H_ */
7 changes: 6 additions & 1 deletion cores/esp32/esp32-hal-ledc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "esp32-hal.h"
#include "soc/soc_caps.h"

#if SOC_LEDC_SUPPORTED
#include "esp32-hal.h"
#include "esp32-hal-ledc.h"
#include "driver/ledc.h"
#include "esp32-hal-periman.h"

Expand Down Expand Up @@ -382,3 +385,5 @@ void analogWriteResolution(uint8_t pin, uint8_t resolution) {
}
analog_resolution = resolution;
}

#endif /* SOC_LEDC_SUPPORTED */
4 changes: 4 additions & 0 deletions cores/esp32/esp32-hal-ledc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifndef _ESP32_HAL_LEDC_H_
#define _ESP32_HAL_LEDC_H_

#include "soc/soc_caps.h"
#if SOC_LEDC_SUPPORTED

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -59,4 +62,5 @@ bool ledcFadeWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_
}
#endif

#endif /* SOC_LEDC_SUPPORTED */
#endif /* _ESP32_HAL_LEDC_H_ */
13 changes: 8 additions & 5 deletions cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,26 @@

#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+

#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/rtc.h"
#include "driver/temperature_sensor.h"
#elif CONFIG_IDF_TARGET_ESP32S3
#include "esp32s3/rom/rtc.h"
#include "driver/temperature_sensor.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/rtc.h"
#include "driver/temperature_sensor.h"
#elif CONFIG_IDF_TARGET_ESP32C6
#include "esp32c6/rom/rtc.h"
#include "driver/temperature_sensor.h"

#else
#error Target CONFIG_IDF_TARGET is not supported
#endif

#if SOC_TEMP_SENSOR_SUPPORTED
#include "driver/temperature_sensor.h"
#endif

#else // ESP32 Before IDF 4.0
#include "rom/rtc.h"
#endif
Expand All @@ -68,7 +71,7 @@ float temperatureRead()
{
return (temprature_sens_read() - 32) / 1.8;
}
#else
#elif SOC_TEMP_SENSOR_SUPPORTED
static temperature_sensor_handle_t temp_sensor = NULL;

static bool temperatureReadInit()
Expand Down
5 changes: 5 additions & 0 deletions cores/esp32/esp32-hal-rmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "soc/soc_caps.h"

#if SOC_RMT_SUPPORTED
#include "esp32-hal.h"
#include "driver/gpio.h"
#include "driver/rmt_tx.h"
Expand Down Expand Up @@ -568,3 +571,5 @@ bool rmtInit(int pin, rmt_ch_dir_t channel_direction, rmt_reserve_memsize_t mem_
_rmtDetachBus((void *)bus);
return false;
}

#endif /* SOC_RMT_SUPPORTED */
6 changes: 5 additions & 1 deletion cores/esp32/esp32-hal-rmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifndef MAIN_ESP32_HAL_RMT_H_
#define MAIN_ESP32_HAL_RMT_H_

#include "soc/soc_caps.h"
#if SOC_RMT_SUPPORTED

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -214,4 +217,5 @@ bool rmtDeinit(int pin);
}
#endif

#endif /* MAIN_ESP32_HAL_RMT_H_ */
#endif /* SOC_RMT_SUPPORTED */
#endif /* MAIN_ESP32_HAL_RMT_H_ */
4 changes: 4 additions & 0 deletions cores/esp32/esp32-hal-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

#include "esp32-hal-spi.h"

#if SOC_GPSPI_SUPPORTED
#include "esp32-hal.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Expand Down Expand Up @@ -1577,3 +1579,5 @@ uint32_t spiFrequencyToClockDiv(uint32_t freq)
}
return bestReg.value;
}

#endif /* SOC_GPSPI_SUPPORTED */
4 changes: 4 additions & 0 deletions cores/esp32/esp32-hal-spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifndef MAIN_ESP32_HAL_SPI_H_
#define MAIN_ESP32_HAL_SPI_H_

#include "soc/soc_caps.h"
#if SOC_GPSPI_SUPPORTED

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -146,4 +149,5 @@ uint32_t spiClockDivToFrequency(uint32_t freq);
}
#endif

#endif /* SOC_GPSPI_SUPPORTED */
#endif /* MAIN_ESP32_HAL_SPI_H_ */
5 changes: 4 additions & 1 deletion cores/esp32/esp32-hal-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

#include "esp32-hal-timer.h"

#if SOC_GPTIMER_SUPPORTED
#include "driver/gptimer.h"
#include "soc/soc_caps.h"
#if defined __has_include && __has_include ("clk_tree.h")
#include "clk_tree.h"
#else
Expand Down Expand Up @@ -212,3 +213,5 @@ double timerReadSeconds(hw_timer_t * timer){
uint32_t frequency = timerGetFrequency(timer);
return (double)timer_val / frequency;
}

#endif /* SOC_GPTIMER_SUPPORTED */
5 changes: 5 additions & 0 deletions cores/esp32/esp32-hal-timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#pragma once

#include "soc/soc_caps.h"
#if SOC_GPTIMER_SUPPORTED

#include "esp32-hal.h"
#include "driver/gptimer_types.h"

Expand Down Expand Up @@ -53,3 +56,5 @@ void timerAlarm(hw_timer_t * timer, uint64_t alarm_value, bool autoreload, uint6
#ifdef __cplusplus
}
#endif

#endif /* SOC_GPTIMER_SUPPORTED */
3 changes: 3 additions & 0 deletions cores/esp32/esp32-hal-tinyusb.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "soc/soc_caps.h"

#if SOC_USB_OTG_SUPPORTED
#include "sdkconfig.h"
#if CONFIG_TINYUSB_ENABLED
#include <stdlib.h>
Expand Down Expand Up @@ -794,3 +796,4 @@ uint8_t tinyusb_get_free_out_endpoint(void){
}

#endif /* CONFIG_TINYUSB_ENABLED */
#endif /* SOC_USB_OTG_SUPPORTED */
Loading