From 5e419eedde69d1e39653bc6fb622739ff384e47a Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 4 Dec 2020 14:38:19 -0800 Subject: [PATCH] Fix OV5640 rev Y slock freq scaling --- src/omv/ov5640.c | 8 ++++++++ src/omv/ov5640_regs.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/omv/ov5640.c b/src/omv/ov5640.c index 998c8cc3f..d025a2c74 100644 --- a/src/omv/ov5640.c +++ b/src/omv/ov5640.c @@ -389,6 +389,14 @@ static int reset(sensor_t *sensor) ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, (default_regs[i][0] << 8) | (default_regs[i][1] << 0), default_regs[i][2]); } + #if defined(MCU_SERIES_H7) + // Rev V (480 MHz / 20) -> 24 MHz PCLK / 3 * 100 = 800 MHz / 10 = 80 MHz PCLK. + // Rev Y (400 MHz / 16) -> 25 MHz PCLK / 3 * 84 = 700 MHz / 10 = 70 MHz PCLK. + if (HAL_GetREVID() < 0x2003) { // Is this REV Y? + ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, SC_PLL_CONTRL2, 0x54); + } + #endif + // Delay 300 ms systick_sleep(300); diff --git a/src/omv/ov5640_regs.h b/src/omv/ov5640_regs.h index b4d8885b0..aeffe3679 100644 --- a/src/omv/ov5640_regs.h +++ b/src/omv/ov5640_regs.h @@ -17,7 +17,9 @@ #define SYSTEM_CTROL0 0x3008 +#define SC_PLL_CONTRL1 0x3035 #define SC_PLL_CONTRL2 0x3036 +#define SC_PLL_CONTRL3 0x3037 #define SCCB_SYSTEM_CTRL_1 0x3103