Skip to content

Commit 9b93ffb

Browse files
committed
boards: shields: add suport for weact_ov2640_cam_module
Add support for WeAct Studio MiniSTM32H7xx OV2640 camera sensor. Signed-off-by: Charles Dias <[email protected]>
1 parent 1ec5ce0 commit 9b93ffb

File tree

8 files changed

+257
-0
lines changed

8 files changed

+257
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Charles Dias
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SHIELD_WEACT_OV2640_CAM_MODULE
5+
def_bool $(shields_list_contains,weact_ov2640_cam_module)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2024 Charles Dias <[email protected]>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
CONFIG_VIDEO_HFLIP=y
8+
CONFIG_VIDEO_VFLIP=y
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2024 Charles Dias
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* AHB clocks must respect the minimum ratio AHB / DCMI_PIXCLK of 2.5 (AN5020 - Rev 3).
8+
* The OV2640 PCLK is around 72 MHz for QQVGA resolution (160x120) with MCO1_SEL_HSI48
9+
* and MCO1_PRE_DIV_4.
10+
*/
11+
&rcc {
12+
clocks = <&pll>;
13+
clock-frequency = <DT_FREQ_M(240)>;
14+
d1cpre = <1>;
15+
hpre = <1>;
16+
d1ppre = <2>;
17+
d2ppre1 = <2>;
18+
d2ppre2 = <2>;
19+
d3ppre = <2>;
20+
};
21+
22+
/* See reference manual (RM0433 Rev 8) page 390:
23+
* 100: HSI48 clock selected (hsi48_ck)
24+
*/
25+
#define MCO1_SEL_HSI48 4
26+
27+
/* See reference manual (RM0433 Rev 8) page 391:
28+
* 0100: division by 4
29+
*/
30+
#define MCO1_PRE_DIV_4 4
31+
32+
&mco1 {
33+
status = "okay";
34+
clocks = <&rcc STM32_SRC_HSI48 MCO1_SEL(MCO1_SEL_HSI48)>;
35+
prescaler = <MCO1_PRE(MCO1_PRE_DIV_4)>;
36+
pinctrl-0 = <&rcc_mco_1_pa8>;
37+
pinctrl-names = "default";
38+
};
39+
40+
&zephyr_camera_i2c {
41+
ov2640: ov2640@30 {
42+
supply-gpios = <&dcmi_camera_connector 8 GPIO_ACTIVE_HIGH>;
43+
clock-rate-control = <0x80>;
44+
};
45+
};
46+
47+
&zephyr_camera_dvp {
48+
dmas = <&dma1 0 75 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC |
49+
STM32_DMA_MEM_INC | STM32_DMA_PERIPH_8BITS | STM32_DMA_MEM_32BITS |
50+
STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>;
51+
};
52+
53+
&dma1 {
54+
status = "okay";
55+
};
56+
57+
&dmamux1 {
58+
status = "okay";
59+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
.. _weact_ov2640_cam_module:
2+
3+
WeAct Studio MiniSTM32H7xx OV2640 Camera Sensor
4+
###############################################
5+
6+
Overview
7+
********
8+
9+
The OV2640 camera sensor is designed to interface with the WeAct Studio
10+
MiniSTM32H7xx boards, providing camera sensor capabilities. This shield
11+
integrates the OV2640 camera module, which is capable of capturing images
12+
and video with a resolution of up to 2 megapixels.
13+
14+
.. figure:: ov2640.webp
15+
:align: center
16+
:alt: OV2640 Camera Sensor
17+
18+
More information about the OV2640 camera sensor can be found on the
19+
`MiniSTM32H7xx GitHub`_ and in the `OV2640 datasheet`_.
20+
21+
Requirements
22+
************
23+
24+
Your board needs to have a ``zephyr_camera_dvp`` device tree label to work with this shield.
25+
26+
Pin Assignments
27+
===============
28+
29+
The shield connects to the WeAct Studio MiniSTM32H7xx board via the
30+
following pins:
31+
32+
+--------------+-----------+-----------------------------+
33+
| Shield Pin | Board Pin | Function |
34+
+==============+===========+=============================+
35+
| DCMI_D0 | PC6 | DCMI Data Line 0 |
36+
+--------------+-----------+-----------------------------+
37+
| DCMI_D1 | PC7 | DCMI Data Line 1 |
38+
+--------------+-----------+-----------------------------+
39+
| DCMI_D2 | PE0 | DCMI Data Line 2 |
40+
+--------------+-----------+-----------------------------+
41+
| DCMI_D3 | PE1 | DCMI Data Line 3 |
42+
+--------------+-----------+-----------------------------+
43+
| DCMI_D4 | PE4 | DCMI Data Line 4 |
44+
+--------------+-----------+-----------------------------+
45+
| DCMI_D5 | PD3 | DCMI Data Line 5 |
46+
+--------------+-----------+-----------------------------+
47+
| DCMI_D6 | PE5 | DCMI Data Line 6 |
48+
+--------------+-----------+-----------------------------+
49+
| DCMI_D7 | PE6 | DCMI Data Line 7 |
50+
+--------------+-----------+-----------------------------+
51+
| DCMI_HSYNC | PA4 | DCMI HSYNC |
52+
+--------------+-----------+-----------------------------+
53+
| DCMI_VSYNC | PB7 | DCMI VSYNC |
54+
+--------------+-----------+-----------------------------+
55+
| DCMI_PIXCLK | PA6 | DCMI Pixel Clock |
56+
+--------------+-----------+-----------------------------+
57+
| I2C_SDA | PB9 | I2C Data Line |
58+
+--------------+-----------+-----------------------------+
59+
| I2C_SCL | PB8 | I2C Clock Line |
60+
+--------------+-----------+-----------------------------+
61+
| RCC_MCO1 | PA8 | Clock Output |
62+
+--------------+-----------+-----------------------------+
63+
| SUPPLY | PA7 | Power Supply Control (GPIO) |
64+
+--------------+-----------+-----------------------------+
65+
66+
Programming
67+
***********
68+
69+
Set ``--shield weact_ov2640_cam_module`` when you invoke ``west build``. For example:
70+
71+
.. zephyr-app-commands::
72+
:zephyr-app: samples/drivers/video/capture_to_lvgl/
73+
:board: mini_stm32h743
74+
:shield: weact_ov2640_cam_module
75+
:gen-args: -DCONFIG_BOOT_DELAY=2000
76+
:goals: build
77+
78+
.. _MiniSTM32H7xx GitHub:
79+
https://github.com/WeActStudio/MiniSTM32H7xx
80+
81+
.. _OV2640 datasheet:
82+
https://www.uctronics.com/download/cam_module/OV2640DS.pdf
37.4 KB
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2024 Charles Dias
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,camera = &zephyr_camera_dvp;
10+
};
11+
};
12+
13+
&zephyr_camera_i2c {
14+
status = "okay";
15+
clock-frequency = <I2C_BITRATE_FAST>;
16+
17+
ov2640: ov2640@30 {
18+
compatible = "ovti,ov2640";
19+
reg = <0x30>;
20+
status = "okay";
21+
22+
port {
23+
ov2640_ep_out: endpoint {
24+
remote-endpoint = <&zephyr_camera_dvp_in>;
25+
};
26+
};
27+
};
28+
};
29+
30+
&zephyr_camera_dvp {
31+
status = "okay";
32+
sensor = <&ov2640>;
33+
bus-width = <8>;
34+
hsync-active = <0>;
35+
vsync-active = <0>;
36+
pixelclk-active = <1>;
37+
capture-rate = <1>;
38+
39+
port {
40+
zephyr_camera_dvp_in: endpoint {
41+
remote-endpoint = <&ov2640_ep_out>;
42+
};
43+
};
44+
};

boards/weact/mini_stm32h743/mini_stm32h743.dts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@
8383
watchdog0 = &iwdg;
8484
sdhc0 = &sdmmc1;
8585
};
86+
87+
dcmi_camera_connector: connector_dcmi_camera {
88+
compatible = "weact,dcmi-camera-connector";
89+
#gpio-cells = <2>;
90+
gpio-map-mask = <0xffffffff 0xffffffc0>;
91+
gpio-map-pass-thru = <0 0x3f>;
92+
93+
gpio-map = <3 0 &gpiob 9 0>, /* DVP_SDA (I2C1_SDA) */
94+
<5 0 &gpiob 8 0>, /* DVP_SCL (I2C1_SCL) */
95+
<7 0 &gpiob 7 0>, /* DVP_VSYNC */
96+
<8 0 &gpioa 7 0>, /* DVP_PWDN */
97+
<9 0 &gpioa 4 0>, /* DVP_HSYNC */
98+
<12 0 &gpioe 6 0>, /* DVP_D7 */
99+
<13 0 &gpioa 8 0>, /* DVP_XCLK (RCC_MCO1) */
100+
<14 0 &gpioe 5 0>, /* DVP_D6 */
101+
<16 0 &gpiod 3 0>, /* DVP_D5 */
102+
<17 0 &gpioa 6 0>, /* DVP_PCLK */
103+
<18 0 &gpioe 4 0>, /* DVP_D4 */
104+
<19 0 &gpioc 6 0>, /* DVP_D0 */
105+
<20 0 &gpioe 1 0>, /* DVP_D3 */
106+
<21 0 &gpioc 7 0>, /* DVP_D1 */
107+
<22 0 &gpioe 0 0>; /* DVP_D2 */
108+
};
86109
};
87110

88111
&clk_lsi {
@@ -220,3 +243,15 @@ zephyr_udc0: &usbotg_fs {
220243
&iwdg1 {
221244
status = "okay";
222245
};
246+
247+
zephyr_camera_i2c: &i2c1 {
248+
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
249+
pinctrl-names = "default";
250+
};
251+
252+
zephyr_camera_dvp: &dcmi {
253+
pinctrl-0 = <&dcmi_hsync_pa4 &dcmi_pixclk_pa6 &dcmi_vsync_pb7
254+
&dcmi_d0_pc6 &dcmi_d1_pc7 &dcmi_d2_pe0 &dcmi_d3_pe1
255+
&dcmi_d4_pe4 &dcmi_d5_pd3 &dcmi_d6_pe5 &dcmi_d7_pe6>;
256+
pinctrl-names = "default";
257+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
description: |
4+
GPIO pins exposed on the DCMI camera connector used for interfacing
5+
with the OV2640, OV7670, and OV5640 camera sensors.
6+
7+
Connector layout (not mapped GPIOs in parentheses):
8+
9+
(1) OV_STROBE (Unused) (2) AGND
10+
3 DVP_SDA (4) AVDD-2V8
11+
5 DVP_SCL (6) DVP_RST
12+
7 DVP_VSYNC 8 DVP_PWDN
13+
9 DVP_HSYNC (10) DVDD-1V5
14+
(11) 2V8 12 DVP_D7
15+
13 DVP_XCLK 14 DVP_D6
16+
(15) GND 16 DVP_D5
17+
17 DVP_PCLK 18 DVP_D4
18+
19 DVP_D0 20 DVP_D3
19+
21 DVP_D1 22 DVP_D2
20+
(23) AF-2V8 (24) GND
21+
22+
compatible: "weact,dcmi-camera-connector"
23+
24+
include: [gpio-nexus.yaml, base.yaml]

0 commit comments

Comments
 (0)