ports/all: Fix calls on uninitialized CSIs.

Detection flag should be set after CSIs are detected in
the scanning code, and functions that loop over CSIs
should check it.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-06-27 09:19:03 +02:00
parent 8cd7a309fd
commit a266ac33f1
5 changed files with 7 additions and 9 deletions

View File

@ -146,6 +146,10 @@ __weak void omv_csi_init0() {
omv_csi_t *csi = &csi_all[i];
omv_i2c_t *i2c = csi->i2c;
if (!csi->detected) {
continue;
}
// Abort ongoing transfer
omv_csi_abort(csi, true, false);
@ -459,6 +463,7 @@ int omv_csi_probe(omv_i2c_t *i2c) {
csi->reset_pol = reset_pol;
csi->chip_id = dev_list[i].chip_id;
csi->slv_addr = dev_list[i].slv_addr;
csi->detected = true;
switch (dev_list[i].chip_id) {
#if (OMV_OV2640_ENABLE == 1)
@ -700,7 +705,8 @@ int omv_csi_probe(omv_i2c_t *i2c) {
__weak int omv_csi_config(omv_csi_t *csi, omv_csi_config_t config) {
// Call the sensor specific function.
if (csi->config != NULL &&
if (csi->detected &&
csi->config != NULL &&
csi->config(csi, config) != 0) {
return OMV_CSI_ERROR_CTL_FAILED;
}

View File

@ -549,8 +549,6 @@ int omv_csi_init() {
if (omv_csi_config(csi, OMV_CSI_CONFIG_INIT) != 0) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
csi->detected = true;
}
// Clear fb_enabled flag.

View File

@ -256,8 +256,6 @@ int omv_csi_init() {
if (omv_csi_config(csi, OMV_CSI_CONFIG_INIT) != 0) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
csi->detected = true;
}
// Clear fb_enabled flag

View File

@ -279,8 +279,6 @@ int omv_csi_init() {
if (omv_csi_config(csi, OMV_CSI_CONFIG_INIT) != 0) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
csi->detected = true;
}
// Clear fb_enabled flag.

View File

@ -1128,8 +1128,6 @@ int omv_csi_init() {
if (omv_csi_config(csi, OMV_CSI_CONFIG_INIT) != 0) {
return OMV_CSI_ERROR_CSI_INIT_FAILED;
}
csi->detected = true;
}
// Clear fb_enabled flag.