Skip to content

Commit 19ab395

Browse files
committed
Merge branch 'feat/csi_dsi_example_v5.3' into 'release/v5.3'
example: csi dsi example and isp af dsi example(v5.3) See merge request espressif/esp-idf!30913
2 parents a726640 + 5f07f64 commit 19ab395

28 files changed

+1199
-16
lines changed

components/esp_driver_cam/csi/src/esp_cam_ctlr_csi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ static bool csi_dma_trans_done_callback(dw_gdma_channel_handle_t chan, const dw_
300300
bool need_yield = false;
301301
BaseType_t high_task_woken = pdFALSE;
302302
csi_controller_t *ctlr = (csi_controller_t *)user_data;
303+
bool has_new_trans = false;
303304
bool use_backup = false;
304305

305306
dw_gdma_block_transfer_config_t csi_dma_transfer_config = {};
@@ -328,12 +329,14 @@ static bool csi_dma_trans_done_callback(dw_gdma_channel_handle_t chan, const dw_
328329
use_backup = true;
329330
} else {
330331
csi_dma_transfer_config.dst.addr = (uint32_t)(new_trans.buffer);
332+
has_new_trans = true;
331333
}
332334
} else if (xQueueReceiveFromISR(ctlr->trans_que, &new_trans, &high_task_woken) == pdTRUE) {
333335
if (!(new_trans.buffer) || new_trans.buflen < ctlr->fb_size_in_bytes) {
334336
use_backup = true;
335337
} else {
336338
csi_dma_transfer_config.dst.addr = (uint32_t)(new_trans.buffer);
339+
has_new_trans = true;
337340
}
338341
} else if (!ctlr->bk_buffer_dis) {
339342
use_backup = true;
@@ -344,7 +347,9 @@ static bool csi_dma_trans_done_callback(dw_gdma_channel_handle_t chan, const dw_
344347
new_trans.buflen = ctlr->fb_size_in_bytes;
345348
ESP_EARLY_LOGD(TAG, "no new buffer or no long enough new buffer, use driver internal buffer");
346349
csi_dma_transfer_config.dst.addr = (uint32_t)ctlr->backup_buffer;
347-
} else {
350+
}
351+
352+
if (!has_new_trans) {
348353
assert(false && "no new buffer, and no driver internal buffer");
349354
}
350355

components/esp_driver_isp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ endif()
99

1010
idf_component_register(SRCS ${srcs}
1111
INCLUDE_DIRS ${public_include}
12+
PRIV_REQUIRES esp_driver_gpio
1213
)

components/esp_driver_isp/src/isp_af.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ esp_err_t esp_isp_af_controller_set_env_detector(isp_af_ctrlr_t af_ctrlr, const
241241
isp_ll_af_env_monitor_set_period(af_ctrlr->isp_proc->hal.hw, 0);
242242
isp_ll_clear_intr(af_ctrlr->isp_proc->hal.hw, ISP_LL_EVENT_AF_ENV);
243243

244+
isp_ll_af_env_monitor_set_mode(af_ctrlr->isp_proc->hal.hw, ISP_LL_AF_ENV_MONITOR_MODE_ABS);
245+
isp_ll_af_env_monitor_set_period(af_ctrlr->isp_proc->hal.hw, af_ctrlr->config.interval);
246+
isp_ll_enable_intr(af_ctrlr->isp_proc->hal.hw, ISP_LL_EVENT_AF_ENV, true);
247+
244248
return ESP_OK;
245249
}
246250

@@ -267,7 +271,7 @@ esp_err_t esp_isp_af_env_detector_register_event_callbacks(isp_af_ctrlr_t af_ctr
267271
return ESP_OK;
268272
}
269273

270-
esp_err_t esp_isp_af_env_detector_set_threshold(isp_af_ctrlr_t af_ctrlr, int definition_thresh, int luminance_thresh)
274+
esp_err_t esp_isp_af_controller_set_env_detector_threshold(isp_af_ctrlr_t af_ctrlr, int definition_thresh, int luminance_thresh)
271275
{
272276
ESP_RETURN_ON_FALSE_ISR(af_ctrlr, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
273277
ESP_RETURN_ON_FALSE_ISR(af_ctrlr->fsm == ISP_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "detector isn't in enable state");

examples/peripherals/.build-test-rules.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ examples/peripherals/analog_comparator:
2424
- esp_driver_gpio
2525
- esp_driver_ana_cmpr
2626

27+
examples/peripherals/camera/camera_dsi:
28+
disable:
29+
- if: SOC_MIPI_CSI_SUPPORTED != 1 or SOC_MIPI_DSI_SUPPORTED != 1
30+
depends_components:
31+
- esp_lcd
32+
- esp_driver_cam
33+
2734
examples/peripherals/dac:
2835
disable:
2936
- if: SOC_DAC_SUPPORTED != 1
@@ -118,11 +125,11 @@ examples/peripherals/i2s/i2s_recorder:
118125

119126
examples/peripherals/isp/auto_focus:
120127
disable:
121-
- if: INCLUDE_DEFAULT == 1
122-
temporary: true
123-
reason: disable build temporarily # TODO: IDF-8895
128+
- if: SOC_MIPI_CSI_SUPPORTED != 1 or SOC_MIPI_DSI_SUPPORTED != 1 or SOC_ISP_SUPPORTED != 1
124129
depends_components:
125130
- esp_driver_isp
131+
- esp_driver_cam
132+
- esp_lcd
126133

127134
examples/peripherals/jpeg/jpeg_decode:
128135
disable:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
project(camera_dsi)
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
| Supported Targets | ESP32-P4 |
2+
| ----------------- | -------- |
3+
4+
5+
# Camera display via DSI example
6+
7+
## Overview
8+
9+
This example demonstrates how to use the esp_driver_cam component to capture camera sensor signals and display it via DSI interface.
10+
11+
## Usage
12+
13+
The subsections below give only absolutely necessary information. For full steps to configure ESP-IDF and use it to build and run projects, see [ESP-IDF Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html#get-started).
14+
15+
16+
### Hardware Required
17+
18+
This example requires:
19+
20+
- OV5647 camera sensor
21+
- ILI9881C LCD screen
22+
- ESP32P4 devkit
23+
24+
25+
GND GND
26+
┌────────────────────────────────────────────────┐ ┌─────────────────────────────────────────────────────────┐
27+
│ │ │ │
28+
│ │ │ │
29+
│ │ │ │
30+
│ │ │ │
31+
│ │ │ │
32+
│ │ │ │
33+
│ │ │ │
34+
│ │ │ │
35+
│ ┌───────────────┴─────────────┴──────────────────┐ │
36+
│ │ │ ┌──────────┴───────────┐
37+
│ │ │ DSI DATA 1P │ │
38+
│ │ ├───────────────────────────┤ │
39+
┌───────────┴─────────┐ CSI DATA 1P │ │ │ │
40+
│ ├──────────────────────┤ │ DSI DATA 1N │ │
41+
│ │ │ ├───────────────────────────┤ │
42+
│ │ CSI DATA 1N │ ESP32-P4 │ │ │
43+
│ OV5647 ├──────────────────────┤ │ DSI CLK N │ ILI9881C │
44+
│ │ │ ├───────────────────────────┤ │
45+
│ │ CSI CLK N │ │ │ │
46+
│ ├──────────────────────┤ │ DSI CLK P │ │
47+
│ │ │ ├───────────────────────────┤ │
48+
│ │ CSI CLK P │ │ │ │
49+
│ ├──────────────────────┤ │ DSI DATA 0P │ │
50+
│ │ │ ├───────────────────────────┤ │
51+
│ │ CSI DATA 0P │ │ │ │
52+
│ ├──────────────────────┤ │ DSI DATA 0N │ │
53+
│ │ │ ├───────────────────────────┤ │
54+
│ │ CSI DATA 0N │ │ │ │
55+
│ ├──────────────────────┤ │ └──────────────────────┘
56+
│ │ │ │
57+
└───────┬──┬──────────┘ │ │
58+
│ │ I2C SCL │ │
59+
│ └─────────────────────────────────┤ │
60+
│ I2C SDA │ │
61+
└────────────────────────────────────┤ │
62+
└────────────────────────────────────────────────┘
63+
64+
65+
### Set Chip Target
66+
67+
First of all, your target must be supported by both:
68+
69+
- **By your ESP-IDF version**: For the full list of supported targets, run:
70+
```
71+
idf.py --list-targets
72+
```
73+
- **By this example**: For the full list of supported targets, refer to the supported targets table at the top of this README.
74+
75+
After you make sure that your target is supported, go to your example project directory and [set the chip target](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/tools/idf-py.html#select-the-target-chip-set-target):
76+
77+
```
78+
idf.py set-target <target>
79+
```
80+
81+
For example, to set esp32-P4 as the chip target, run:
82+
83+
```
84+
idf.py set-target esp32p4
85+
```
86+
87+
88+
### Configure the Project
89+
90+
For information about Kconfig options, see [Project Configuration](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/kconfig.html) > _Name of relevant section(s)_.
91+
92+
To conveniently check or modify Kconfig options for this example in a project configuration menu, run:
93+
94+
```
95+
idf.py menuconfig
96+
```
97+
98+
```
99+
Set CONFIG_CAMERA_OV5647 to y
100+
```
101+
102+
103+
### Build and Flash
104+
105+
Execute the following command to build the project, flash it to your development board, and run the monitor tool to view the serial output:
106+
107+
```
108+
idf.py build flash monitor
109+
```
110+
111+
This command can be reduced to `idf.py flash monitor`.
112+
113+
If the above command fails, check the log on the serial monitor which usually provides information on the possible cause of the issue.
114+
115+
To exit the serial monitor, use `Ctrl` + `]`.
116+
117+
118+
## Example Output
119+
120+
If you see the following console output, your example should be running correctly:
121+
122+
```
123+
I (1085) main_task: Calling app_main()
124+
I (1095) ili9881c: ID1: 0x98, ID2: 0x81, ID3: 0x5c
125+
I (1125) gpio: GPIO[31]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0
126+
I (1125) gpio: GPIO[34]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0
127+
I (1295) ov5647: Detected Camera sensor PID=0x5647 with index 0
128+
I (1305) cam_dsi: fmt[0].name:MIPI_2lane_24Minput_RAW8_800x1280_50fps
129+
I (1305) cam_dsi: fmt[1].name:MIPI_2lane_24Minput_RAW8_800x640_50fps
130+
I (1315) cam_dsi: fmt[2].name:MIPI_2lane_24Minput_RAW8_800x800_50fps
131+
I (1355) cam_dsi: Format in use:MIPI_2lane_24Minput_RAW8_800x640_50fps
132+
```
133+
134+
135+
## Reference
136+
137+
- Link to the ESP-IDF feature's API reference, for example [ESP-IDF: Camera Controller Driver](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/camera_driver.html)
138+
- [ESP-IDF Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html#get-started)
139+
- [Project Configuration](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/kconfig.html) (Kconfig Options)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
idf_component_register(SRCS "camera_dsi_main.c"
2+
INCLUDE_DIRS "."
3+
REQUIRES esp_mm esp_driver_isp esp_driver_cam esp_driver_i2c esp_lcd dsi_init
4+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
menu "Example Configuration"
2+
config EXAMPLE_USED_LDO_CHAN_ID
3+
int "example used LDO channel ID"
4+
default 3
5+
help
6+
Example used LDO channel ID, you may check datasheet to know more details.
7+
8+
config EXAMPLE_USED_LDO_VOLTAGE_MV
9+
int "example used LDO voltage in mV"
10+
default 2500
11+
range 0 3300
12+
help
13+
Example used LDO voltage, in mV
14+
15+
choice EXAMPLE_MIPI_CSI_DISP_HRES
16+
bool "Set MIPI CSI horizontal resolution"
17+
default EXAMPLE_MIPI_CSI_HRES_800
18+
19+
config EXAMPLE_MIPI_CSI_HRES_800
20+
bool "800"
21+
endchoice
22+
23+
config EXAMPLE_MIPI_CSI_DISP_HRES
24+
int
25+
default 800 if EXAMPLE_MIPI_CSI_HRES_800
26+
27+
choice EXAMPLE_MIPI_CSI_DISP_VRES
28+
bool "Set MIPI CSI vertical resolution"
29+
default EXAMPLE_MIPI_CSI_VRES_640
30+
31+
config EXAMPLE_MIPI_CSI_VRES_640
32+
bool "640"
33+
config EXAMPLE_MIPI_CSI_VRES_1280
34+
bool "1280"
35+
endchoice
36+
37+
config EXAMPLE_MIPI_CSI_DISP_VRES
38+
int
39+
default 640 if EXAMPLE_MIPI_CSI_VRES_640
40+
default 1280 if EXAMPLE_MIPI_CSI_VRES_1280
41+
endmenu

0 commit comments

Comments
 (0)