Merge pull request #2737 from kwagyeman/kwabena/fix_dual_csi
Some checks are pending
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Waiting to run
🔥 Firmware Build / build-firmware (DOCKER) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV2) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Waiting to run
🔥 Firmware Build / code-size-report (push) Blocked by required conditions
🔥 Firmware Build / stable-release (push) Blocked by required conditions
🔥 Firmware Build / development-release (push) Blocked by required conditions

common/omv_csi: Fix all sensors working on all boards.
This commit is contained in:
Ibrahim Abdelkader 2025-06-28 10:27:36 +03:00 committed by GitHub
commit 196006a924
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 50 additions and 40 deletions

View File

@ -46,6 +46,7 @@
#define OMV_OV7725_ENABLE (1)
#define OMV_OV7725_PLL_CONFIG (0x81) // x6
#define OMV_OV7725_BANDING (0x8F)
#define OMV_OV7725_CLK_FREQ (9000000)
// FIR drivers configuration.
#define OMV_FIR_MLX90621_ENABLE (1)

View File

@ -62,6 +62,7 @@
#define OMV_LEPTON_ENABLE (1)
#define OMV_PAG7920_ENABLE (1)
#define OMV_PAJ6100_ENABLE (1)
#define OMV_PAJ6100_GLITCH_RECONFIG (1)
#define OMV_FROGEYE2020_ENABLE (1)
// FIR drivers configuration.

View File

@ -48,6 +48,7 @@
#define OMV_LEPTON_ENABLE (1)
#define OMV_PAG7920_ENABLE (1)
#define OMV_PAJ6100_ENABLE (1)
#define OMV_PAJ6100_GLITCH_RECONFIG (1)
#define OMV_FROGEYE2020_ENABLE (1)
#define OMV_GENX320_EHC_ENABLE (1)

View File

@ -493,10 +493,42 @@ static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
return 0;
}
static int config(omv_csi_t *csi, omv_csi_config_t config) {
if (config == OMV_CSI_CONFIG_INIT) {
if (reset(csi) != 0) {
return -1;
}
LEP_OEM_PART_NUMBER_T part;
if (LEP_GetOemFlirPartNumber(&lepton.port, &part) != LEP_OK) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
// 500 == Lepton
// xxxx == Version
// 01/00 == Shutter/NoShutter
if (!strncmp(part.value, "500-0771", 8)) {
csi->chip_id = LEPTON_3_5;
} else if (!strncmp(part.value, "500-0726", 8)) {
csi->chip_id = LEPTON_3_0;
} else if (!strncmp(part.value, "500-0763", 8)) {
csi->chip_id = LEPTON_2_5;
} else if (!strncmp(part.value, "500-0659", 8)) {
csi->chip_id = LEPTON_2_0;
} else if (!strncmp(part.value, "500-0690", 8)) {
csi->chip_id = LEPTON_1_6;
} else if (!strncmp(part.value, "500-0643", 8)) {
csi->chip_id = LEPTON_1_5;
}
}
return 0;
}
int lepton_init(omv_csi_t *csi) {
csi->reset = reset;
csi->sleep = sleep;
csi->config = NULL;
csi->config = config;
csi->abort = NULL;
csi->match = match;
csi->snapshot = snapshot;
@ -529,34 +561,6 @@ int lepton_init(omv_csi_t *csi) {
csi->frame_sync = 0;
csi->mono_bpp = 1;
// Extra delay after power-on
mp_hal_delay_ms(1000);
if (reset(csi) != 0) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
LEP_OEM_PART_NUMBER_T part;
if (LEP_GetOemFlirPartNumber(&lepton.port, &part) != LEP_OK) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
// 500 == Lepton
// xxxx == Version
// 01/00 == Shutter/NoShutter
if (!strncmp(part.value, "500-0771", 8)) {
csi->chip_id = LEPTON_3_5;
} else if (!strncmp(part.value, "500-0726", 8)) {
csi->chip_id = LEPTON_3_0;
} else if (!strncmp(part.value, "500-0763", 8)) {
csi->chip_id = LEPTON_2_5;
} else if (!strncmp(part.value, "500-0659", 8)) {
csi->chip_id = LEPTON_2_0;
} else if (!strncmp(part.value, "500-0690", 8)) {
csi->chip_id = LEPTON_1_6;
} else if (!strncmp(part.value, "500-0643", 8)) {
csi->chip_id = LEPTON_1_5;
}
return 0;
}
#endif // (OMV_LEPTON_ENABLE == 1)

View File

@ -446,6 +446,11 @@ static int set_framesize(omv_csi_t *csi, omv_csi_framesize_t framesize) {
lt_lockrange_out_ubound = (L_TARGET + AE_LOCK_RANGE_OUT) * w * h;
lt_lockrange_out_lbound = (L_TARGET - AE_LOCK_RANGE_OUT) * w * h;
// PAJ6100 crashes CSI hardware unless we recongfigure it.
#if (OMV_PAJ6100_GLITCH_RECONFIG == 1)
csi->config(csi, OMV_CSI_CONFIG_INIT);
#endif // (OMV_PAJ6100_GLITCH_RECONFIG == 1)
return 0;
}

View File

@ -219,9 +219,14 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) {
scfg.Format = DCMIPP_FORMAT_RAW8;
} else if (csi->pixformat == PIXFORMAT_RGB565) {
scfg.Format = DCMIPP_FORMAT_RGB565;
scfg.SwapCycles = DCMIPP_SWAPCYCLES_ENABLE;
scfg.SwapCycles = (csi->rgb_swap == 1) ? DCMIPP_SWAPCYCLES_DISABLE : DCMIPP_SWAPCYCLES_ENABLE;
} else if (csi->pixformat == PIXFORMAT_GRAYSCALE) {
scfg.Format = (csi->mono_bpp == 1) ? DCMIPP_FORMAT_MONOCHROME_8B : DCMIPP_FORMAT_YUV422;
} else if (csi->pixformat == PIXFORMAT_YUV422) {
scfg.Format = DCMIPP_FORMAT_YUV422;
scfg.SwapCycles = (csi->yuv_swap == 1) ? DCMIPP_SWAPCYCLES_ENABLE : DCMIPP_SWAPCYCLES_DISABLE;
} else if (csi->pixformat == PIXFORMAT_BAYER) {
scfg.Format = DCMIPP_FORMAT_RAW8;
} else {
return OMV_CSI_ERROR_PIXFORMAT_UNSUPPORTED;
}
@ -234,8 +239,10 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) {
DCMIPP_PipeConfTypeDef pcfg = { .FrameRate = DCMIPP_FRAME_RATE_ALL };
if (csi->pixformat == PIXFORMAT_RGB565) {
pcfg.PixelPackerFormat = DCMIPP_PIXEL_PACKER_FORMAT_RGB565_1;
} else if (csi->pixformat == PIXFORMAT_GRAYSCALE) {
} else if (csi->pixformat == PIXFORMAT_GRAYSCALE || csi->pixformat == PIXFORMAT_BAYER) {
pcfg.PixelPackerFormat = DCMIPP_PIXEL_PACKER_FORMAT_MONO_Y8_G8_1;
} else if (csi->pixformat == PIXFORMAT_YUV422) {
pcfg.PixelPackerFormat = DCMIPP_PIXEL_PACKER_FORMAT_YUV422_1;
} else {
return OMV_CSI_ERROR_PIXFORMAT_UNSUPPORTED;
}
@ -243,15 +250,6 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
// Swap RGB enabled.
if (csi->yuv_swap) {
HAL_DCMIPP_PIPE_EnableYUVSwap(&csi->dcmi, DCMIPP_PIPE);
}
// Swap YUV if enabled.
if (csi->rgb_swap) {
HAL_DCMIPP_PIPE_EnableRedBlueSwap(&csi->dcmi, DCMIPP_PIPE);
}
// Configure debayer.
if (csi->raw_output && csi->pixformat != PIXFORMAT_BAYER) {
DCMIPP_RawBayer2RGBConfTypeDef rawcfg = {