Skip to content

Commit b44a1ab

Browse files
committed
boards: arduino_nicla_vision: add camera subsystem
initial support on device tree Signed-off-by: Felipe Neves <[email protected]>
1 parent 9d9089e commit b44a1ab

File tree

4 files changed

+127
-7
lines changed

4 files changed

+127
-7
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2024 Felipe Neves
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
zephyr_sources_ifdef(CONFIG_VIDEO camera_ext_clock.c)

boards/arduino/nicla_vision/arduino_nicla_vision_stm32h747xx_m7.dts

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
zephyr,sram = &sram0;
2323
zephyr,flash = &flash0;
2424
zephyr,code-partition = &slot0_partition;
25+
zephyr,camera = &dcmi;
2526
};
2627

2728
sdram1: sdram@c0000000 {
@@ -122,13 +123,6 @@
122123
};
123124
};
124125

125-
&i2c3 {
126-
status = "okay";
127-
pinctrl-0 = <&i2c3_scl_pa8 &i2c3_sda_pc9>;
128-
pinctrl-names = "default";
129-
clock-frequency = <I2C_BITRATE_FAST>;
130-
};
131-
132126
&spi4 {
133127
status = "okay";
134128
pinctrl-0 = <&spi4_nss_pe11 &spi4_sck_pe12
@@ -192,3 +186,81 @@ zephyr_udc0: &usbotg_hs {
192186
phys = <&otghs_ulpi_phy>;
193187
status = "okay";
194188
};
189+
190+
&i2c3 {
191+
status = "okay";
192+
pinctrl-0 = <&i2c3_scl_pa8 &i2c3_sda_pc9>;
193+
pinctrl-names = "default";
194+
clock-frequency = <I2C_BITRATE_FAST>;
195+
196+
gc2145: gc2145@3c {
197+
compatible = "galaxycore,gc2145";
198+
reg = <0x3c>;
199+
status = "okay";
200+
201+
port {
202+
gc2145_ep_out: endpoint {
203+
remote-endpoint = <&dcmi_ep_in>;
204+
};
205+
};
206+
207+
};
208+
};
209+
210+
&dcmi {
211+
pinctrl-0 = <&dcmi_d0_pc6 &dcmi_d1_pc7 &dcmi_d2_pe0 &dcmi_d3_pe1
212+
&dcmi_d4_pe4 &dcmi_d5_pd3 &dcmi_d6_pe5 &dcmi_d7_pe6
213+
&dcmi_pixclk_pa6 &dcmi_hsync_pa4 &dcmi_vsync_pg9>;
214+
215+
pinctrl-names = "default";
216+
status = "okay";
217+
218+
sensor = <&gc2145>;
219+
bus-width = <8>;
220+
hsync-active = <0>;
221+
vsync-active = <0>;
222+
pixelclk-active = <0>;
223+
capture-rate = <1>;
224+
dmas = <&dma1 0 38 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC |
225+
STM32_DMA_MEM_INC | STM32_DMA_PERIPH_8BITS | STM32_DMA_MEM_32BITS |
226+
STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>;
227+
228+
port {
229+
dcmi_ep_in: endpoint {
230+
remote-endpoint = <&gc2145_ep_out>;
231+
};
232+
};
233+
};
234+
235+
/* The Arduino nicla uses a PWM output to generate the clock for the
236+
* GC2145 sensor, so we need to configure the PWM generator...
237+
*/
238+
&timers3 {
239+
status = "okay";
240+
st,prescaler = <0>;
241+
242+
cam_clock_pwm: pwm {
243+
status = "okay";
244+
pinctrl-0 = <&tim3_ch2_pa7>;
245+
pinctrl-names = "default";
246+
};
247+
};
248+
249+
&cam_clock_pwm {
250+
/* ...then use the pwmclock node to start the clock generation */
251+
pwmclock: pwmclock {
252+
status = "okay";
253+
compatible = "pwm-clock";
254+
clock-frequency = <0>;
255+
#clock-cells = <1>;
256+
pwms = <&cam_clock_pwm 2 PWM_HZ(10000000) PWM_POLARITY_NORMAL>;
257+
};
258+
};
259+
260+
&dma1 {
261+
status = "okay";
262+
};
263+
264+
&dmamux1 {
265+
status = "okay";
266+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2024 Felipe Neves
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/device.h>
9+
#include <zephyr/drivers/clock_control.h>
10+
#include <zephyr/logging/log.h>
11+
12+
LOG_MODULE_REGISTER(camera_ext_clock, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
13+
14+
int camera_ext_clock_enable(void)
15+
{
16+
int ret;
17+
uint32_t rate;
18+
const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));
19+
20+
if (!device_is_ready(cam_ext_clk_dev)) {
21+
LOG_ERR("Camera external clock source device is not ready!");
22+
return -ENODEV;
23+
}
24+
25+
ret = clock_control_on(cam_ext_clk_dev, (clock_control_subsys_t)0);
26+
if (ret < 0) {
27+
LOG_ERR("Failed to enable camera external clock error: (%d)", ret);
28+
return ret;
29+
}
30+
31+
ret = clock_control_get_rate(cam_ext_clk_dev, (clock_control_subsys_t)0, &rate);
32+
if (ret < 0) {
33+
LOG_ERR("Failed to get camera external clock rate, error: (%d)", ret);
34+
return ret;
35+
}
36+
37+
LOG_INF("Camera external clock rate: (%u) Hz", rate);
38+
39+
return 0;
40+
}
41+
42+
SYS_INIT(camera_ext_clock_enable, POST_KERNEL, CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY);

boards/arduino/nicla_vision/doc/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ following hardware features:
6161
+-----------+------------+-------------------------------------+
6262
| SPI | on-chip | spi |
6363
+-----------+------------+-------------------------------------+
64+
| DCMI | on-chip | Parallel Camera interface |
65+
+-----------+------------+-------------------------------------+
6466
| IPM | on-chip | virtual mailbox based on HSEM |
6567
+-----------+------------+-------------------------------------+
6668
| RADIO | Murata 1DX | WiFi and Bluetooth module |

0 commit comments

Comments
 (0)