2626#ifndef CONFIG_PM_ENABLE
2727#define CONFIG_PM_ENABLE 0
2828#endif
29- #include "esp-idf/components/driver/i2c/i2c_private.h"
29+
30+ // i2c_private.h uses `#if` with some macros that may be undefined and taken as 0.
31+ #pragma GCC diagnostic push
32+ #pragma GCC diagnostic ignored "-Wundef"
33+ #include "esp-idf/components/esp_driver_i2c/i2c_private.h"
34+ #pragma GCC diagnostic pop
3035
3136#include "esp-camera/driver/private_include/cam_hal.h"
3237
@@ -90,13 +95,12 @@ void common_hal_espcamera_camera_construct(
9095
9196 self -> i2c = i2c ;
9297
93- self -> camera_config .pin_pwdn = common_hal_mcu_pin_number (powerdown_pin );
94- self -> camera_config .pin_reset = common_hal_mcu_pin_number (reset_pin );
95- self -> camera_config .pin_xclk = common_hal_mcu_pin_number (external_clock_pin );
98+ // These pins might be NULL because they were not specified.
99+ self -> camera_config .pin_pwdn = powerdown_pin ? common_hal_mcu_pin_number (powerdown_pin ) : NO_PIN ;
100+ self -> camera_config .pin_reset = reset_pin ? common_hal_mcu_pin_number (reset_pin ) : NO_PIN ;
101+ self -> camera_config .pin_xclk = external_clock_pin ? common_hal_mcu_pin_number (external_clock_pin ) : NO_PIN ;
96102
97- self -> camera_config .pin_sccb_sda = NO_PIN ;
98- self -> camera_config .pin_sccb_scl = NO_PIN ;
99- /* sccb i2c port set below */
103+ self -> camera_config .sccb_i2c_master_bus_handle = self -> i2c -> handle ;
100104
101105 self -> camera_config .pin_d7 = data_pins [7 ];
102106 self -> camera_config .pin_d6 = data_pins [6 ];
@@ -119,7 +123,7 @@ void common_hal_espcamera_camera_construct(
119123 self -> camera_config .fb_count = framebuffer_count ;
120124 self -> camera_config .grab_mode = grab_mode ;
121125
122- self -> camera_config . sccb_i2c_port = self -> i2c -> handle -> base -> port_num ;
126+
123127
124128 i2c_lock (self );
125129 esp_err_t result = esp_camera_init (& self -> camera_config );
@@ -135,6 +139,7 @@ extern void common_hal_espcamera_camera_deinit(espcamera_camera_obj_t *self) {
135139
136140 common_hal_pwmio_pwmout_deinit (& self -> pwm );
137141
142+ // Does nothing if pin is NO_PIN (-1).
138143 reset_pin_number (self -> camera_config .pin_pwdn );
139144 reset_pin_number (self -> camera_config .pin_reset );
140145 reset_pin_number (self -> camera_config .pin_xclk );
0 commit comments