mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 04:56:53 +03:00
v10.2.0
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "sccb.h"
|
||||
#include "xclk.h"
|
||||
#include "ov5640.h"
|
||||
#include "ov5640_regs.h"
|
||||
#include "ov5640_settings.h"
|
||||
@@ -196,7 +197,7 @@ static int calc_sysclk(int xclk, bool pll_bypass, int pll_multiplier, int pll_sy
|
||||
|
||||
unsigned int SYSCLK = PLL_CLK / 4;
|
||||
|
||||
ESP_LOGD(TAG, "Calculated XVCLK: %d Hz, REFIN: %u Hz, VCO: %u Hz, PLL_CLK: %u Hz, SYSCLK: %u Hz, PCLK: %u Hz", xclk, REFIN, VCO, PLL_CLK, SYSCLK, PCLK);
|
||||
ESP_LOGI(TAG, "Calculated XVCLK: %d Hz, REFIN: %u Hz, VCO: %u Hz, PLL_CLK: %u Hz, SYSCLK: %u Hz, PCLK: %u Hz", xclk, REFIN, VCO, PLL_CLK, SYSCLK, PCLK);
|
||||
return SYSCLK;
|
||||
}
|
||||
|
||||
@@ -209,6 +210,7 @@ static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sy
|
||||
if(multiplier > 127){
|
||||
multiplier &= 0xFE;//only even integers above 127
|
||||
}
|
||||
ESP_LOGI(TAG, "Set PLL: bypass: %u, multiplier: %u, sys_div: %u, pre_div: %u, root_2x: %u, pclk_root_div: %u, pclk_manual: %u, pclk_div: %u", bypass, multiplier, sys_div, pre_div, root_2x, pclk_root_div, pclk_manual, pclk_div);
|
||||
|
||||
calc_sysclk(sensor->xclk_freq_hz, bypass, multiplier, sys_div, pre_div, root_2x, pclk_root_div, pclk_manual, pclk_div);
|
||||
|
||||
@@ -432,14 +434,22 @@ static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||
if (sensor->pixformat == PIXFORMAT_JPEG) {
|
||||
//10MHz PCLK
|
||||
uint8_t sys_mul = 200;
|
||||
if(framesize < FRAMESIZE_QVGA){
|
||||
if(framesize < FRAMESIZE_QVGA || sensor->xclk_freq_hz == 16000000){
|
||||
sys_mul = 160;
|
||||
} else if(framesize < FRAMESIZE_XGA){
|
||||
sys_mul = 180;
|
||||
}
|
||||
ret = set_pll(sensor, false, sys_mul, 4, 2, false, 2, true, 4);
|
||||
//Set PLL: bypass: 0, multiplier: sys_mul, sys_div: 4, pre_div: 2, root_2x: 0, pclk_root_div: 2, pclk_manual: 1, pclk_div: 4
|
||||
} else {
|
||||
ret = set_pll(sensor, false, 10, 1, 1, false, 1, true, 4);
|
||||
//ret = set_pll(sensor, false, 8, 1, 1, false, 1, true, 4);
|
||||
if (framesize > FRAMESIZE_HVGA) {
|
||||
ret = set_pll(sensor, false, 10, 1, 2, false, 1, true, 2);
|
||||
} else if (framesize >= FRAMESIZE_QVGA) {
|
||||
ret = set_pll(sensor, false, 8, 1, 1, false, 1, true, 4);
|
||||
} else {
|
||||
ret = set_pll(sensor, false, 20, 1, 1, false, 1, true, 8);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
@@ -1025,7 +1035,6 @@ static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, i
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz);
|
||||
static int set_xclk(sensor_t *sensor, int timer, int xclk)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -1064,6 +1073,22 @@ static int init_status(sensor_t *sensor)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ov5640_detect(int slv_addr, sensor_id_t *id)
|
||||
{
|
||||
if (OV5640_SCCB_ADDR == slv_addr) {
|
||||
uint8_t h = SCCB_Read16(slv_addr, 0x300A);
|
||||
uint8_t l = SCCB_Read16(slv_addr, 0x300B);
|
||||
uint16_t PID = (h<<8) | l;
|
||||
if (OV5640_PID == PID) {
|
||||
id->PID = PID;
|
||||
return PID;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Mismatch PID=0x%x", PID);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ov5640_init(sensor_t *sensor)
|
||||
{
|
||||
sensor->reset = reset;
|
||||
|
||||
Reference in New Issue
Block a user