mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1195 from kwagyeman/kwabena/portena_poe_shield_fixes
Add support for the OV5640 to the Arduino Portenta
This commit is contained in:
commit
69fd21acd2
@ -39,6 +39,15 @@
|
||||
// Sensor Banding Filter Value
|
||||
#define OMV_OV7725_BANDING (0x7F)
|
||||
|
||||
// OV5640 Sensor Settings
|
||||
#define OMV_OV5640_XCLK_FREQ (24000000)
|
||||
#define OMV_OV5640_PLL_CTRL2 (0x64)
|
||||
#define OMV_OV5640_PLL_CTRL3 (0x13)
|
||||
#define OMV_OV5640_REV_Y_CHECK (1)
|
||||
#define OMV_OV5640_REV_Y_FREQ (25000000)
|
||||
#define OMV_OV5640_REV_Y_CTRL2 (0x54)
|
||||
#define OMV_OV5640_REV_Y_CTRL3 (0x13)
|
||||
|
||||
// Bootloader LED GPIO port/pin
|
||||
#define OMV_BOOTLDR_LED_PIN (GPIO_PIN_1)
|
||||
#define OMV_BOOTLDR_LED_PORT (GPIOC)
|
||||
|
||||
@ -43,6 +43,15 @@
|
||||
// Sensor Banding Filter Value
|
||||
#define OMV_OV7725_BANDING (0x7F)
|
||||
|
||||
// OV5640 Sensor Settings
|
||||
#define OMV_OV5640_XCLK_FREQ (24000000)
|
||||
#define OMV_OV5640_PLL_CTRL2 (0x64)
|
||||
#define OMV_OV5640_PLL_CTRL3 (0x13)
|
||||
#define OMV_OV5640_REV_Y_CHECK (1)
|
||||
#define OMV_OV5640_REV_Y_FREQ (25000000)
|
||||
#define OMV_OV5640_REV_Y_CTRL2 (0x54)
|
||||
#define OMV_OV5640_REV_Y_CTRL3 (0x13)
|
||||
|
||||
// Bootloader LED GPIO port/pin
|
||||
#define OMV_BOOTLDR_LED_PIN (GPIO_PIN_1)
|
||||
#define OMV_BOOTLDR_LED_PORT (GPIOC)
|
||||
|
||||
@ -40,6 +40,15 @@
|
||||
// Sensor Banding Filter Value
|
||||
#define OMV_OV7725_BANDING (0x7F)
|
||||
|
||||
// OV5640 Sensor Settings
|
||||
#define OMV_OV5640_XCLK_FREQ (24000000)
|
||||
#define OMV_OV5640_PLL_CTRL2 (0x64)
|
||||
#define OMV_OV5640_PLL_CTRL3 (0x13)
|
||||
#define OMV_OV5640_REV_Y_CHECK (1)
|
||||
#define OMV_OV5640_REV_Y_FREQ (25000000)
|
||||
#define OMV_OV5640_REV_Y_CTRL2 (0x54)
|
||||
#define OMV_OV5640_REV_Y_CTRL3 (0x13)
|
||||
|
||||
// Bootloader LED GPIO port/pin
|
||||
#define OMV_BOOTLDR_LED_PIN (GPIO_PIN_1)
|
||||
#define OMV_BOOTLDR_LED_PORT (GPIOC)
|
||||
|
||||
@ -37,6 +37,15 @@
|
||||
// Sensor Banding Filter Value
|
||||
#define OMV_OV7725_BANDING (0x7F)
|
||||
|
||||
// OV5640 Sensor Settings
|
||||
#define OMV_OV5640_XCLK_FREQ (12500000)
|
||||
#define OMV_OV5640_PLL_CTRL2 (0x7E)
|
||||
#define OMV_OV5640_PLL_CTRL3 (0x13)
|
||||
#define OMV_OV5640_REV_Y_CHECK (0)
|
||||
#define OMV_OV5640_REV_Y_FREQ (12500000)
|
||||
#define OMV_OV5640_REV_Y_CTRL2 (0x7E)
|
||||
#define OMV_OV5640_REV_Y_CTRL3 (0x13)
|
||||
|
||||
// Bootloader LED GPIO port/pin
|
||||
#define OMV_BOOTLDR_LED_PIN (GPIO_PIN_6)
|
||||
#define OMV_BOOTLDR_LED_PORT (GPIOK)
|
||||
@ -52,7 +61,7 @@
|
||||
|
||||
// Enable sensor drivers
|
||||
#define OMV_ENABLE_OV2640 (0)
|
||||
#define OMV_ENABLE_OV5640 (0)
|
||||
#define OMV_ENABLE_OV5640 (1)
|
||||
#define OMV_ENABLE_OV7690 (0)
|
||||
#define OMV_ENABLE_OV7725 (1)
|
||||
#define OMV_ENABLE_OV9650 (0)
|
||||
@ -60,10 +69,10 @@
|
||||
#define OMV_ENABLE_MT9V0XX (1)
|
||||
#define OMV_ENABLE_LEPTON (0)
|
||||
#define OMV_ENABLE_HM01B0 (1)
|
||||
#define OMV_ENABLE_GC2145 (1)
|
||||
#define OMV_ENABLE_GC2145 (0)
|
||||
|
||||
// Enable sensor features
|
||||
#define OMV_ENABLE_OV5640_AF (0)
|
||||
#define OMV_ENABLE_OV5640_AF (1)
|
||||
|
||||
// Enable WiFi debug
|
||||
#define OMV_ENABLE_WIFIDBG (0)
|
||||
|
||||
@ -172,6 +172,8 @@ __weak int sensor_reset()
|
||||
int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed)
|
||||
{
|
||||
int init_ret = 0;
|
||||
int freq;
|
||||
(void) freq;
|
||||
|
||||
// Do a power cycle
|
||||
DCMI_PWDN_HIGH();
|
||||
@ -320,7 +322,13 @@ int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed)
|
||||
|
||||
#if (OMV_ENABLE_OV5640 == 1)
|
||||
case OV5640_ID:
|
||||
if (sensor_set_xclk_frequency(OV5640_XCLK_FREQ) != 0) {
|
||||
freq = OMV_OV5640_XCLK_FREQ;
|
||||
#if (OMV_OV5640_REV_Y_CHECK == 1)
|
||||
if (HAL_GetREVID() < 0x2003) { // Is this REV Y?
|
||||
freq = OMV_OV5640_REV_Y_FREQ;
|
||||
}
|
||||
#endif
|
||||
if (sensor_set_xclk_frequency(freq) != 0) {
|
||||
return SENSOR_ERROR_TIM_INIT_FAILED;
|
||||
}
|
||||
init_ret = ov5640_init(&sensor);
|
||||
|
||||
@ -115,8 +115,8 @@ static const uint8_t default_regs[][3] = {
|
||||
{ 0x38, 0x15, 0x31 },
|
||||
{ 0x30, 0x34, 0x1a },
|
||||
{ 0x30, 0x35, 0x11 }, // { 0x30, 0x35, 0x21 },
|
||||
{ 0x30, 0x36, 0x64 }, // { 0x30, 0x36, 0x46 },
|
||||
{ 0x30, 0x37, 0x13 },
|
||||
{ 0x30, 0x36, OMV_OV5640_PLL_CTRL2 }, // { 0x30, 0x36, 0x46 },
|
||||
{ 0x30, 0x37, OMV_OV5640_PLL_CTRL3 },
|
||||
{ 0x30, 0x38, 0x00 },
|
||||
{ 0x30, 0x39, 0x00 },
|
||||
{ 0x38, 0x0c, 0x07 },
|
||||
@ -662,16 +662,24 @@ static int reset(sensor_t *sensor)
|
||||
|
||||
// Write default regsiters
|
||||
for (int i = 0; default_regs[i][0]; i++) {
|
||||
ret |= cambus_writeb2(&sensor->bus, sensor->slv_addr, (default_regs[i][0] << 8) | (default_regs[i][1] << 0), default_regs[i][2]);
|
||||
}
|
||||
int addr = (default_regs[i][0] << 8) | (default_regs[i][1] << 0);
|
||||
int data = 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->bus, sensor->slv_addr, SC_PLL_CONTRL2, 0x54);
|
||||
#if (OMV_OV5640_REV_Y_CHECK == 1)
|
||||
// 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?
|
||||
if (addr == SC_PLL_CONTRL2) {
|
||||
data = OMV_OV5640_REV_Y_CTRL2;
|
||||
}
|
||||
if (addr == SC_PLL_CONTRL3) {
|
||||
data = OMV_OV5640_REV_Y_CTRL3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret |= cambus_writeb2(&sensor->bus, sensor->slv_addr, addr, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (OMV_ENABLE_OV5640_AF == 1)
|
||||
ret |= cambus_writeb2(&sensor->bus, sensor->slv_addr, SYSTEM_RESET_00, 0x20); // force mcu reset
|
||||
@ -1087,7 +1095,7 @@ static int get_gain_db(sensor_t *sensor, float *gain_db)
|
||||
|
||||
static int calc_pclk_freq(uint8_t sc_pll_ctrl_0, uint8_t sc_pll_ctrl_1, uint8_t sc_pll_ctrl_2, uint8_t sc_pll_ctrl_3, uint8_t sys_root_div)
|
||||
{
|
||||
uint32_t pclk_freq = OV5640_XCLK_FREQ;
|
||||
uint32_t pclk_freq = sensor_get_xclk_frequency();
|
||||
pclk_freq /= ((sc_pll_ctrl_3 & 0x10) != 0x00) ? 2 : 1;
|
||||
pclk_freq /= ((sc_pll_ctrl_0 & 0x0F) == 0x0A) ? 10 : 8;
|
||||
switch (sc_pll_ctrl_3 & 0x0F)
|
||||
@ -1111,7 +1119,7 @@ static int calc_pclk_freq(uint8_t sc_pll_ctrl_0, uint8_t sc_pll_ctrl_1, uint8_t
|
||||
case 0x30: pclk_freq /= 8; break;
|
||||
default: pclk_freq /= 1; break;
|
||||
}
|
||||
return (int)pclk_freq;
|
||||
return (int) pclk_freq;
|
||||
}
|
||||
|
||||
static int set_auto_exposure(sensor_t *sensor, int enable, int exposure_us)
|
||||
|
||||
@ -10,6 +10,5 @@
|
||||
*/
|
||||
#ifndef __OV5640_H__
|
||||
#define __OV5640_H__
|
||||
#define OV5640_XCLK_FREQ 24000000
|
||||
int ov5640_init(sensor_t *sensor);
|
||||
#endif // __OV5640_H__
|
||||
|
||||
Loading…
Reference in New Issue
Block a user