common/csi: Track elapsed time since last hard-reset.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-07-27 22:41:46 +02:00
parent 79d2bf458a
commit 9bb174454b
2 changed files with 14 additions and 1 deletions

View File

@ -334,6 +334,17 @@ __weak int omv_csi_reset(omv_csi_t *csi, bool hard) {
mp_hal_delay_ms(10);
omv_gpio_write(OMV_CSI_RESET_PIN, 1);
}
// Track elapsed time since last hard-reset.
// Note hard-reset is shared between all CSIs.
uint32_t reset_time_ms = mp_hal_ticks_ms();
for (size_t i=0; i<OMV_CSI_MAX_DEVICES; i++) {
omv_csi_t *csi = &csi_all[i];
if (csi->detected) {
csi->reset_time_ms = reset_time_ms;
}
}
#endif
mp_hal_delay_ms(OMV_CSI_RESET_DELAY);
@ -501,7 +512,7 @@ int omv_csi_probe(omv_i2c_t *i2c) {
dev_count = omv_csi_detect(i2c, dev_list);
}
// Set the current ms for tracking elapsed time since power-on.
// Track elapsed time since power-on.
uint32_t power_time_ms = mp_hal_ticks_ms();
// Add special devices, such as SPI sensors, soft-CSI etc...
@ -537,6 +548,7 @@ int omv_csi_probe(omv_i2c_t *i2c) {
csi->chip_id = dev_list[i].chip_id;
csi->slv_addr = dev_list[i].slv_addr;
csi->power_time_ms = power_time_ms;
csi->reset_time_ms = power_time_ms;
// Find the sensors init function.
for (size_t i=0; i<OMV_ARRAY_SIZE(sensor_config_table); i++) {

View File

@ -355,6 +355,7 @@ typedef struct _omv_csi {
framebuffer_t *fb; // Frame buffer pointer
omv_clk_t *clk; // Clock controller.
uint32_t clk_hz; // Clock freqeuency request by this CSI.
uint32_t reset_time_ms; // To track elapsed time since hard-reset.
uint32_t power_time_ms; // To track elapsed time since power on.
#ifdef OMV_CSI_PORT_BITS