Merge pull request #2785 from openmv/fix_vospi_resync
Some checks failed
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Has been cancelled
🔥 Firmware Build / build-firmware (DOCKER) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV2) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV3) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV4) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Has been cancelled
🔥 Firmware Build / code-size-report (push) Has been cancelled
🔥 Firmware Build / stable-release (push) Has been cancelled
🔥 Firmware Build / development-release (push) Has been cancelled

common/vospi: make vospi_restart() non-blocking.
This commit is contained in:
Ibrahim Abdelkader 2025-07-27 18:15:41 +03:00 committed by GitHub
commit 1ee8711e56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -501,6 +501,9 @@ 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.
uint32_t power_time_ms = mp_hal_ticks_ms();
// Add special devices, such as SPI sensors, soft-CSI etc...
#if OMV_SOFTCSI_ENABLE
if (dev_count < OMV_CSI_MAX_DEVICES) {
@ -533,6 +536,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->power_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 power_time_ms; // To track elapsed time since power on.
#ifdef OMV_CSI_PORT_BITS
// Additional port-specific members like device base pointer,

View File

@ -46,7 +46,7 @@
#define VOSPI_BUFFER_SIZE (VOSPI_PACKET_SIZE * 2) // 16-bits
#define VOSPI_CLOCK_SPEED 20000000 // hz
#define VOSPI_SYNC_MS 250 // ms
#define VOSPI_SYNC_MS 200 // ms
#define VOSPI_DONT_CARE_PACKET (0x0F00)
#define VOSPI_HEADER_DONT_CARE(x) (((x) & VOSPI_DONT_CARE_PACKET) == VOSPI_DONT_CARE_PACKET)
@ -66,6 +66,7 @@ typedef struct _vospi_state {
bool lepton_3;
omv_spi_t spi_bus;
volatile uint32_t flags;
uint32_t resync_ms;
} vospi_state_t;
static vospi_state_t vospi;
@ -182,7 +183,8 @@ int vospi_deinit() {
}
bool vospi_active(void) {
return vospi.flags & VOSPI_FLAG_CAPTURE;
return (vospi.flags & VOSPI_FLAG_CAPTURE) &&
(vospi.flags & VOSPI_FLAG_STREAM);
}
int vospi_abort(void) {
@ -190,6 +192,7 @@ int vospi_abort(void) {
int ret = omv_spi_transfer_abort(&vospi.spi_bus);
vospi.pid = 0;
vospi.sid = 0;
vospi.resync_ms = mp_hal_ticks_ms();
return ret;
}
@ -204,8 +207,8 @@ void vospi_restart(void) {
// Resume streaming.
vospi.flags |= VOSPI_FLAG_CAPTURE;
if (!(vospi.flags & VOSPI_FLAG_STREAM)) {
mp_hal_delay_ms(VOSPI_SYNC_MS);
if (!(vospi.flags & VOSPI_FLAG_STREAM) &&
(mp_hal_ticks_ms() - vospi.resync_ms) >= VOSPI_SYNC_MS) {
omv_spi_transfer_start(&vospi.spi_bus, &spi_xfer);
vospi.flags |= VOSPI_FLAG_STREAM;
}