Skip to content

Commit 5364216

Browse files
authored
Add checks for SOC defines (#8351)
* Add checks for SOC defines * Add SoC checks to BLE library * fix i2c compilation error * fix wrong placement of include * add check to SPI library * add check to USB library * add checks to Wire library
1 parent 42f216f commit 5364216

File tree

99 files changed

+444
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+444
-66
lines changed

cores/esp32/USB.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
#include "USB.h"
1516

17+
#if SOC_USB_OTG_SUPPORTED
1618
#if CONFIG_TINYUSB_ENABLED
1719

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

359361
#endif /* CONFIG_TINYUSB_ENABLED */
362+
#endif /* SOC_USB_OTG_SUPPORTED */

cores/esp32/USB.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
#pragma once
1515

1616
#include "soc/soc_caps.h"
17-
1817
#if SOC_USB_OTG_SUPPORTED
1918

19+
#include "sdkconfig.h"
20+
#if CONFIG_TINYUSB_ENABLED
21+
2022
#include "esp_event.h"
2123
#include "USBCDC.h"
2224

@@ -116,4 +118,6 @@ class ESPUSB {
116118

117119
extern ESPUSB USB;
118120

121+
122+
#endif /* CONFIG_TINYUSB_ENABLED */
119123
#endif /* SOC_USB_OTG_SUPPORTED */

cores/esp32/USBCDC.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
15+
#include "USBCDC.h"
16+
17+
#if SOC_USB_OTG_SUPPORTED
1418
#include "USB.h"
1519
#if CONFIG_TINYUSB_CDC_ENABLED
1620

17-
#include "USBCDC.h"
21+
1822
#include "esp32-hal-tinyusb.h"
1923
#include "rom/ets_sys.h"
2024

@@ -456,3 +460,4 @@ USBCDC Serial(0);
456460
#endif
457461

458462
#endif /* CONFIG_TINYUSB_CDC_ENABLED */
463+
#endif /* SOC_USB_OTG_SUPPORTED */

cores/esp32/USBCDC.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// limitations under the License.
1414
#pragma once
1515

16+
#include "soc/soc_caps.h"
17+
#if SOC_USB_OTG_SUPPORTED
18+
1619
#include "sdkconfig.h"
1720
#if CONFIG_TINYUSB_CDC_ENABLED
1821

@@ -143,3 +146,4 @@ extern USBCDC Serial;
143146
#endif
144147

145148
#endif /* CONFIG_TINYUSB_CDC_ENABLED */
149+
#endif /* SOC_USB_OTG_SUPPORTED */

cores/esp32/USBMSC.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
#include "USBMSC.h"
1516

17+
#if SOC_USB_OTG_SUPPORTED
1618
#if CONFIG_TINYUSB_MSC_ENABLED
1719

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

260262
#endif /* CONFIG_TINYUSB_MSC_ENABLED */
263+
#endif /* SOC_USB_OTG_SUPPORTED */

cores/esp32/USBMSC.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
// limitations under the License.
1414

1515
#pragma once
16+
17+
#include "soc/soc_caps.h"
18+
#if SOC_USB_OTG_SUPPORTED
19+
1620
#include <stdint.h>
1721
#include <stdbool.h>
1822
#include "sdkconfig.h"
@@ -49,3 +53,4 @@ class USBMSC
4953
};
5054

5155
#endif /* CONFIG_TINYUSB_MSC_ENABLED */
56+
#endif /* SOC_USB_OTG_SUPPORTED */

cores/esp32/esp32-hal-bt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "esp32-hal-bt.h"
1616

17+
#if SOC_BT_SUPPORTED
1718
#ifdef CONFIG_BT_ENABLED
1819

1920
// user may want to change it to free resources
@@ -97,5 +98,6 @@ bool btStop()
9798
return false;
9899
}
99100

100-
#endif // CONFIG_BT_ENABLED
101+
#endif /* CONFIG_BT_ENABLED */
101102

103+
#endif /* SOC_BT_SUPPORTED */

cores/esp32/esp32-hal-bt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#ifndef _ESP32_ESP32_HAL_BT_H_
1616
#define _ESP32_ESP32_HAL_BT_H_
1717

18+
#include "soc/soc_caps.h"
19+
#if SOC_BT_SUPPORTED
20+
1821
#include "esp32-hal.h"
1922

2023
#ifdef __cplusplus
@@ -29,4 +32,6 @@ bool btStop();
2932
}
3033
#endif
3134

35+
#endif /* SOC_BT_SUPPORTED */
36+
3237
#endif /* _ESP32_ESP32_HAL_BT_H_ */

cores/esp32/esp32-hal-i2c-slave.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include "soc/soc_caps.h"
16+
17+
#if SOC_I2C_SUPPORT_SLAVE
1518
#include <stdint.h>
1619
#include <stdbool.h>
1720
#include <stdio.h>
@@ -874,3 +877,5 @@ static bool i2cSlaveDetachBus(void * bus_i2c_num){
874877
}
875878
return true;
876879
}
880+
881+
#endif /* SOC_I2C_SUPPORT_SLAVE */

cores/esp32/esp32-hal-i2c-slave.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#pragma once
1616

17+
#include "soc/soc_caps.h"
18+
#if SOC_I2C_SUPPORT_SLAVE
19+
1720
#ifdef __cplusplus
1821
extern "C" {
1922
#endif
@@ -33,3 +36,5 @@ size_t i2cSlaveWrite(uint8_t num, const uint8_t *buf, uint32_t len, uint32_t tim
3336
#ifdef __cplusplus
3437
}
3538
#endif
39+
40+
#endif /* SOC_I2C_SUPPORT_SLAVE */

0 commit comments

Comments
 (0)