common/csi: Add power-on flag.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-06-29 10:26:05 +02:00
parent 58d69cd571
commit 90a568fde5
2 changed files with 15 additions and 9 deletions

View File

@ -204,7 +204,9 @@ __weak int omv_csi_abort(omv_csi_t *csi, bool fifo_flush, bool in_irq) {
__weak int omv_csi_reset(omv_csi_t *csi, bool hard) {
// Disable any ongoing frame capture.
omv_csi_abort(csi, true, false);
if (csi->power_on) {
omv_csi_abort(csi, true, false);
}
// Reset the csi state
csi->sde = 0;
@ -224,16 +226,15 @@ __weak int omv_csi_reset(omv_csi_t *csi, bool hard) {
#else
csi->auto_rotation = false;
#endif // MICROPY_PY_IMU
csi->vsync_cb = (omv_csi_cb_t) { NULL, NULL };
csi->frame_cb = (omv_csi_cb_t) { NULL, NULL };
// Reset default color palette.
csi->color_palette = rainbow_table;
csi->disable_full_flush = false;
csi->vsync_cb = (omv_csi_cb_t) { NULL, NULL };
csi->frame_cb = (omv_csi_cb_t) { NULL, NULL };
// Restore shutdown state on reset.
omv_csi_shutdown(csi, false);
if (!csi->power_on) {
omv_csi_shutdown(csi, false);
}
if (hard) {
// Disable the bus before reset.
@ -438,11 +439,12 @@ int omv_csi_probe(omv_i2c_t *i2c) {
for (size_t i=0; i<dev_count; i++) {
omv_csi_t *csi = &csi_all[i];
csi->detected = true;
csi->power_on = true;
csi->power_pol = power_pol;
csi->reset_pol = reset_pol;
csi->chip_id = dev_list[i].chip_id;
csi->slv_addr = dev_list[i].slv_addr;
csi->detected = true;
uint32_t clk_hz = 0;
sensor_init_t init_fun = NULL;
@ -586,6 +588,9 @@ __weak int omv_csi_shutdown(omv_csi_t *csi, int enable) {
return OMV_CSI_ERROR_CTL_FAILED;
}
// Update power-on flag.
csi->power_on = !enable;
return ret;
}

View File

@ -337,6 +337,7 @@ typedef struct _omv_csi {
bool transpose; // Transpose Image
bool auto_rotation; // Rotate Image Automatically
bool detected; // Set to true when the sensor is initialized.
bool power_on; // Set to true when the sensor is active.
omv_i2c_t *i2c; // SCCB/I2C bus.
framebuffer_t *fb; // Frame buffer pointer