-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/supported_camera_sc2336_lcd_ek79007' into 'master'
camera: supported camera related example using sc2336 and ek79007 Closes IDFGH-13634 See merge request espressif/esp-idf!33518
- Loading branch information
Showing
25 changed files
with
314 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
examples/peripherals/camera/camera_dsi/components/dsi_init/Kconfig.projbuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
menu "Example DSI Configuration" | ||
|
||
choice EXAMPLE_LCD_PATTERN | ||
prompt "Select MIPI LCD model" | ||
default EXAMPLE_LCD_PATTERN_EK79007 | ||
help | ||
Select LCD controller model. | ||
|
||
config EXAMPLE_LCD_PATTERN_EK79007 | ||
bool "EK79007" | ||
config EXAMPLE_LCD_PATTERN_ILI9881C | ||
bool "ILI9881C" | ||
endchoice | ||
|
||
choice EXAMPLE_MIPI_DSI_DISP_HRES | ||
bool "Set MIPI CSI horizontal resolution" | ||
default EXAMPLE_MIPI_DSI_DISP_HRES_800 if EXAMPLE_LCD_PATTERN_ILI9881C | ||
default EXAMPLE_MIPI_DSI_DISP_HRES_1024 if EXAMPLE_LCD_PATTERN_EK79007 | ||
default EXAMPLE_MIPI_DSI_DISP_HRES_800 | ||
|
||
config EXAMPLE_MIPI_DSI_DISP_HRES_800 | ||
bool "800" | ||
config EXAMPLE_MIPI_DSI_DISP_HRES_1024 | ||
bool "1024" | ||
endchoice | ||
|
||
config EXAMPLE_MIPI_DSI_DISP_HRES | ||
int | ||
default 800 if EXAMPLE_MIPI_DSI_DISP_HRES_800 | ||
default 1024 if EXAMPLE_MIPI_DSI_DISP_HRES_1024 | ||
|
||
choice EXAMPLE_MIPI_DSI_DISP_VRES | ||
bool "Set MIPI CSI vertical resolution" | ||
default EXAMPLE_MIPI_DSI_DISP_VRES_1280 if EXAMPLE_LCD_PATTERN_ILI9881C | ||
default EXAMPLE_MIPI_DSI_DISP_VRES_600 if EXAMPLE_LCD_PATTERN_EK79007 | ||
default EXAMPLE_MIPI_DSI_DISP_VRES_1280 | ||
|
||
config EXAMPLE_MIPI_DSI_DISP_VRES_600 | ||
bool "600" | ||
config EXAMPLE_MIPI_DSI_DISP_VRES_1280 | ||
bool "1280" | ||
endchoice | ||
|
||
config EXAMPLE_MIPI_DSI_DISP_VRES | ||
int | ||
default 600 if EXAMPLE_MIPI_DSI_DISP_VRES_600 | ||
default 1280 if EXAMPLE_MIPI_DSI_DISP_VRES_1280 | ||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
examples/peripherals/camera/camera_dsi/components/dsi_init/idf_component.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dependencies: | ||
esp_lcd_ili9881c: "~0.2.0" | ||
esp_lcd_ili9881c: "^1.0.0" | ||
esp_lcd_ek79007: "^1.0.0" | ||
idf: | ||
version: ">=5.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
examples/peripherals/camera/camera_dsi/components/sensor_init/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "example_sensor_init.c" | ||
INCLUDE_DIRS "include" | ||
) |
102 changes: 102 additions & 0 deletions
102
examples/peripherals/camera/camera_dsi/components/sensor_init/example_sensor_init.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "sdkconfig.h" | ||
#include "esp_attr.h" | ||
#include "esp_log.h" | ||
#include "esp_err.h" | ||
#include "driver/i2c_master.h" | ||
#include "esp_sccb_intf.h" | ||
#include "esp_sccb_i2c.h" | ||
#include "esp_cam_sensor.h" | ||
#include "esp_cam_sensor_detect.h" | ||
#include "example_sensor_init.h" | ||
#include "example_sensor_init_config.h" | ||
|
||
static const char *TAG = "sensor_init"; | ||
|
||
void example_sensor_init(int i2c_port, i2c_master_bus_handle_t *out_i2c_bus_handle) | ||
{ | ||
esp_err_t ret = ESP_FAIL; | ||
|
||
//---------------I2C Init------------------// | ||
i2c_master_bus_config_t i2c_bus_conf = { | ||
.clk_source = I2C_CLK_SRC_DEFAULT, | ||
.sda_io_num = EXAMPLE_CAM_SCCB_SDA_IO, | ||
.scl_io_num = EXAMPLE_CAM_SCCB_SCL_IO, | ||
.i2c_port = i2c_port, | ||
.flags.enable_internal_pullup = true, | ||
}; | ||
i2c_master_bus_handle_t i2c_bus_handle = NULL; | ||
ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_conf, &i2c_bus_handle)); | ||
|
||
//---------------SCCB Init------------------// | ||
esp_sccb_io_handle_t sccb_io_handle = NULL; | ||
esp_cam_sensor_config_t cam_config = { | ||
.sccb_handle = sccb_io_handle, | ||
.reset_pin = -1, | ||
.pwdn_pin = -1, | ||
.xclk_pin = -1, | ||
.sensor_port = ESP_CAM_SENSOR_MIPI_CSI, | ||
}; | ||
|
||
esp_cam_sensor_device_t *cam = NULL; | ||
for (esp_cam_sensor_detect_fn_t *p = &__esp_cam_sensor_detect_fn_array_start; p < &__esp_cam_sensor_detect_fn_array_end; ++p) { | ||
sccb_i2c_config_t i2c_config = { | ||
.scl_speed_hz = EXAMPLE_CAM_SCCB_FREQ, | ||
.device_address = p->sccb_addr, | ||
.dev_addr_length = I2C_ADDR_BIT_LEN_7, | ||
}; | ||
ESP_ERROR_CHECK(sccb_new_i2c_io(i2c_bus_handle, &i2c_config, &cam_config.sccb_handle)); | ||
|
||
cam = (*(p->detect))(&cam_config); | ||
if (cam) { | ||
if (p->port != ESP_CAM_SENSOR_MIPI_CSI) { | ||
ESP_LOGE(TAG, "detect a camera sensor with mismatched interface"); | ||
return; | ||
} | ||
break; | ||
} | ||
ESP_ERROR_CHECK(esp_sccb_del_i2c_io(cam_config.sccb_handle)); | ||
} | ||
|
||
if (!cam) { | ||
ESP_LOGE(TAG, "failed to detect camera sensor"); | ||
return; | ||
} | ||
|
||
esp_cam_sensor_format_array_t cam_fmt_array = {0}; | ||
esp_cam_sensor_query_format(cam, &cam_fmt_array); | ||
const esp_cam_sensor_format_t *parray = cam_fmt_array.format_array; | ||
for (int i = 0; i < cam_fmt_array.count; i++) { | ||
ESP_LOGI(TAG, "fmt[%d].name:%s", i, parray[i].name); | ||
} | ||
|
||
esp_cam_sensor_format_t *cam_cur_fmt = NULL; | ||
for (int i = 0; i < cam_fmt_array.count; i++) { | ||
if (!strcmp(parray[i].name, EXAMPLE_CAM_FORMAT)) { | ||
cam_cur_fmt = (esp_cam_sensor_format_t *) & (parray[i].name); | ||
} | ||
} | ||
|
||
ret = esp_cam_sensor_set_format(cam, (const esp_cam_sensor_format_t *) cam_cur_fmt); | ||
if (ret != ESP_OK) { | ||
ESP_LOGE(TAG, "Format set fail"); | ||
} else { | ||
ESP_LOGI(TAG, "Format in use:%s", cam_cur_fmt->name); | ||
} | ||
int enable_flag = 1; | ||
// Set sensor output stream | ||
ret = esp_cam_sensor_ioctl(cam, ESP_CAM_SENSOR_IOC_S_STREAM, &enable_flag); | ||
if (ret != ESP_OK) { | ||
ESP_LOGE(TAG, "Start stream fail"); | ||
} | ||
ESP_ERROR_CHECK(ret); | ||
|
||
*out_i2c_bus_handle = i2c_bus_handle; | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/peripherals/camera/camera_dsi/components/sensor_init/idf_component.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies: | ||
espressif/esp_cam_sensor: "^0.5.1" | ||
idf: | ||
version: ">=5.3.0" |
Oops, something went wrong.