diff --git a/boards/shields/weact_ov5640_cam_module/Kconfig.shield b/boards/shields/weact_ov5640_cam_module/Kconfig.shield new file mode 100644 index 0000000000000..0bbe0868956e3 --- /dev/null +++ b/boards/shields/weact_ov5640_cam_module/Kconfig.shield @@ -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) diff --git a/boards/shields/weact_ov5640_cam_module/boards/mini_stm32h743.conf b/boards/shields/weact_ov5640_cam_module/boards/mini_stm32h743.conf new file mode 100644 index 0000000000000..48b3a8db88d7a --- /dev/null +++ b/boards/shields/weact_ov5640_cam_module/boards/mini_stm32h743.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2024 Charles Dias +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_VIDEO_HFLIP=y +CONFIG_VIDEO_VFLIP=y diff --git a/boards/shields/weact_ov5640_cam_module/boards/mini_stm32h743.overlay b/boards/shields/weact_ov5640_cam_module/boards/mini_stm32h743.overlay new file mode 100644 index 0000000000000..a4a451caa391f --- /dev/null +++ b/boards/shields/weact_ov5640_cam_module/boards/mini_stm32h743.overlay @@ -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 = ; + 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 = ; + 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"; +}; diff --git a/boards/shields/weact_ov5640_cam_module/doc/index.rst b/boards/shields/weact_ov5640_cam_module/doc/index.rst new file mode 100644 index 0000000000000..07a78b5df85f5 --- /dev/null +++ b/boards/shields/weact_ov5640_cam_module/doc/index.rst @@ -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 diff --git a/boards/shields/weact_ov5640_cam_module/doc/ov5640.webp b/boards/shields/weact_ov5640_cam_module/doc/ov5640.webp new file mode 100644 index 0000000000000..8043befcf75b0 Binary files /dev/null and b/boards/shields/weact_ov5640_cam_module/doc/ov5640.webp differ diff --git a/boards/shields/weact_ov5640_cam_module/weact_ov5640_cam_module.overlay b/boards/shields/weact_ov5640_cam_module/weact_ov5640_cam_module.overlay new file mode 100644 index 0000000000000..2c29a8c73742d --- /dev/null +++ b/boards/shields/weact_ov5640_cam_module/weact_ov5640_cam_module.overlay @@ -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 = ; + + 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>; + }; + }; +};