26
26
#ifndef CONFIG_PM_ENABLE
27
27
#define CONFIG_PM_ENABLE 0
28
28
#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
30
35
31
36
#include "esp-camera/driver/private_include/cam_hal.h"
32
37
@@ -90,13 +95,12 @@ void common_hal_espcamera_camera_construct(
90
95
91
96
self -> i2c = i2c ;
92
97
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 ;
96
102
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 ;
100
104
101
105
self -> camera_config .pin_d7 = data_pins [7 ];
102
106
self -> camera_config .pin_d6 = data_pins [6 ];
@@ -119,7 +123,7 @@ void common_hal_espcamera_camera_construct(
119
123
self -> camera_config .fb_count = framebuffer_count ;
120
124
self -> camera_config .grab_mode = grab_mode ;
121
125
122
- self -> camera_config . sccb_i2c_port = self -> i2c -> handle -> base -> port_num ;
126
+
123
127
124
128
i2c_lock (self );
125
129
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) {
135
139
136
140
common_hal_pwmio_pwmout_deinit (& self -> pwm );
137
141
142
+ // Does nothing if pin is NO_PIN (-1).
138
143
reset_pin_number (self -> camera_config .pin_pwdn );
139
144
reset_pin_number (self -> camera_config .pin_reset );
140
145
reset_pin_number (self -> camera_config .pin_xclk );
0 commit comments