Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/shields/weact_ov5640_cam_module/Kconfig.shield
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Charles Dias
# SPDX-License-Identifier: Apache-2.0

config SHIELD_WEACT_OV5640_CAM_MODULE
def_bool $(shields_list_contains,weact_ov5640_cam_module)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2024 Charles Dias <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#

CONFIG_VIDEO_HFLIP=y
CONFIG_VIDEO_VFLIP=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) Copyright (c) 2024 Charles Dias
*
* SPDX-License-Identifier: Apache-2.0
*/

/* AHB clocks must respect the minimum ratio AHB / DCMI_PIXCLK of 2.5 (AN5020 - Rev 3).
* The OV2640 PCLK is around 72 MHz for QQVGA resolution (160x120) with MCO1_SEL_HSI48
* and MCO1_PRE_DIV_4.
*/
&rcc {
clocks = <&pll>;
clock-frequency = <DT_FREQ_M(240)>;
d1cpre = <1>;
hpre = <1>;
d1ppre = <2>;
d2ppre1 = <2>;
d2ppre2 = <2>;
d3ppre = <2>;
};

/* See reference manual (RM0433 Rev 8) page 390:
* 100: HSI48 clock selected (hsi48_ck)
*/
#define MCO1_SEL_HSI48 4

/* See reference manual (RM0433 Rev 8) page 391:
* 0100: division by 4
*/
#define MCO1_PRE_DIV_4 4

&mco1 {
status = "okay";
clocks = <&rcc STM32_SRC_HSI48 MCO1_SEL(MCO1_SEL_HSI48)>;
prescaler = <MCO1_PRE(MCO1_PRE_DIV_4)>;
pinctrl-0 = <&rcc_mco_1_pa8>;
pinctrl-names = "default";
};

&zephyr_camera_i2c {
ov5640: ov5640@3C {
supply-gpios = <&dcmi_camera_connector 8 GPIO_ACTIVE_HIGH>;
clock-rate-control = <0x80>;
};
};

&zephyr_camera_dvp {
dmas = <&dma1 0 75 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC |
STM32_DMA_MEM_INC | STM32_DMA_PERIPH_8BITS | STM32_DMA_MEM_32BITS |
STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>;
};

&dma1 {
status = "okay";
};

&dmamux1 {
status = "okay";
};
82 changes: 82 additions & 0 deletions boards/shields/weact_ov5640_cam_module/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.. _weact_ov5640_cam_module:

WeAct Studio MiniSTM32H7xx ov5640 Camera Sensor
###############################################

Overview
********

The ov5640 camera sensor is designed to interface with the WeAct Studio
MiniSTM32H7xx boards, providing camera sensor capabilities. This shield
integrates the ov5640 camera module, which is capable of capturing images
and video with a resolution of up to 5 megapixels.

.. figure:: ov5640.webp
:align: center
:alt: ov5640 Camera Sensor

More information about the ov5640 camera sensor can be found on the
`MiniSTM32H7xx GitHub`_ and in the `ov5640 datasheet`_.

Requirements
************

Your board needs to have a ``zephyr_camera_dvp`` device tree label to work with this shield.

Pin Assignments
===============

The shield connects to the WeAct Studio MiniSTM32H7xx board via the
following pins:

+--------------+-----------+-----------------------------+
| Shield Pin | Board Pin | Function |
+==============+===========+=============================+
| DCMI_D0 | PC6 | DCMI Data Line 0 |
+--------------+-----------+-----------------------------+
| DCMI_D1 | PC7 | DCMI Data Line 1 |
+--------------+-----------+-----------------------------+
| DCMI_D2 | PE0 | DCMI Data Line 2 |
+--------------+-----------+-----------------------------+
| DCMI_D3 | PE1 | DCMI Data Line 3 |
+--------------+-----------+-----------------------------+
| DCMI_D4 | PE4 | DCMI Data Line 4 |
+--------------+-----------+-----------------------------+
| DCMI_D5 | PD3 | DCMI Data Line 5 |
+--------------+-----------+-----------------------------+
| DCMI_D6 | PE5 | DCMI Data Line 6 |
+--------------+-----------+-----------------------------+
| DCMI_D7 | PE6 | DCMI Data Line 7 |
+--------------+-----------+-----------------------------+
| DCMI_HSYNC | PA4 | DCMI HSYNC |
+--------------+-----------+-----------------------------+
| DCMI_VSYNC | PB7 | DCMI VSYNC |
+--------------+-----------+-----------------------------+
| DCMI_PIXCLK | PA6 | DCMI Pixel Clock |
+--------------+-----------+-----------------------------+
| I2C_SDA | PB9 | I2C Data Line |
+--------------+-----------+-----------------------------+
| I2C_SCL | PB8 | I2C Clock Line |
+--------------+-----------+-----------------------------+
| RCC_MCO1 | PA8 | Clock Output |
+--------------+-----------+-----------------------------+
| SUPPLY | PA7 | Power Supply Control (GPIO) |
+--------------+-----------+-----------------------------+

Programming
***********

Set ``--shield weact_ov5640_cam_module`` when you invoke ``west build``. For example:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/video/capture_to_lvgl/
:board: mini_stm32h743
:shield: weact_ov5640_cam_module
:gen-args: -DCONFIG_BOOT_DELAY=2000
:goals: build

.. _MiniSTM32H7xx GitHub:
https://github.com/WeActStudio/MiniSTM32H7xx

.. _ov5640 datasheet:
https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) Copyright (c) 2024 Charles Dias
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
chosen {
zephyr,camera = &zephyr_camera_dvp;
};
};

&zephyr_camera_i2c {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;

ov5640: ov5640@3C {
compatible = "ovti,ov5640";
reg = <0x3C>;
status = "okay";

port {
ov5640_ep_out: endpoint {
remote-endpoint = <&dcmi_ep_in>;
};
};
};
};

&zephyr_camera_dvp {
status = "okay";
sensor = <&ov5640>;
bus-width = <8>;
hsync-active = <0>;
vsync-active = <0>;
pixelclk-active = <1>;
capture-rate = <1>;

port {
dcmi_ep_in: endpoint {
remote-endpoint = <&ov5640_ep_out>;
};
};
};
Loading