mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
ports/stm32: Implement shutdown op.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
031d86a248
commit
64fa8c472f
@ -179,6 +179,14 @@ static int stm_csi_config(omv_csi_t *csi, omv_csi_config_t config) {
|
|||||||
NVIC_SetPriority(DCMI_IRQn, IRQ_PRI_DCMI);
|
NVIC_SetPriority(DCMI_IRQn, IRQ_PRI_DCMI);
|
||||||
HAL_NVIC_EnableIRQ(DCMI_IRQn);
|
HAL_NVIC_EnableIRQ(DCMI_IRQn);
|
||||||
#endif
|
#endif
|
||||||
|
} else if (config == OMV_CSI_CONFIG_DEINIT) {
|
||||||
|
#if USE_DCMI
|
||||||
|
HAL_NVIC_DisableIRQ(DCMI_IRQn);
|
||||||
|
HAL_DCMI_DeInit(&csi->dcmi);
|
||||||
|
#else
|
||||||
|
HAL_NVIC_DisableIRQ(DCMIPP_IRQn);
|
||||||
|
HAL_DCMIPP_DeInit(&csi->dcmi);
|
||||||
|
#endif
|
||||||
} else if (config == OMV_CSI_CONFIG_PIXFORMAT) {
|
} else if (config == OMV_CSI_CONFIG_PIXFORMAT) {
|
||||||
#if USE_DCMI
|
#if USE_DCMI
|
||||||
DCMI->CR &= ~(DCMI_CR_JPEG_Msk << DCMI_CR_JPEG_Pos);
|
DCMI->CR &= ~(DCMI_CR_JPEG_Msk << DCMI_CR_JPEG_Pos);
|
||||||
@ -354,6 +362,16 @@ static int stm_csi_abort(omv_csi_t *csi, bool fifo_flush, bool in_irq) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int stm_csi_shutdown(omv_csi_t *csi, int enable) {
|
||||||
|
int ret = 0;
|
||||||
|
if (enable) {
|
||||||
|
ret = omv_csi_config(csi, OMV_CSI_CONFIG_DEINIT);
|
||||||
|
} else {
|
||||||
|
ret = omv_csi_config(csi, OMV_CSI_CONFIG_INIT);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t omv_csi_get_clk_frequency() {
|
uint32_t omv_csi_get_clk_frequency() {
|
||||||
omv_csi_t *csi = omv_csi_get(-1);
|
omv_csi_t *csi = omv_csi_get(-1);
|
||||||
|
|
||||||
@ -429,37 +447,6 @@ int omv_csi_set_clk_frequency(uint32_t frequency) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int omv_csi_shutdown(omv_csi_t *csi, int enable) {
|
|
||||||
int ret = 0;
|
|
||||||
omv_csi_abort(csi, true, false);
|
|
||||||
|
|
||||||
if (enable) {
|
|
||||||
#if defined(OMV_CSI_POWER_PIN)
|
|
||||||
if (csi->power_pol == OMV_CSI_ACTIVE_HIGH) {
|
|
||||||
omv_gpio_write(OMV_CSI_POWER_PIN, 1);
|
|
||||||
} else {
|
|
||||||
omv_gpio_write(OMV_CSI_POWER_PIN, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if USE_DCMI
|
|
||||||
HAL_NVIC_DisableIRQ(DCMI_IRQn);
|
|
||||||
HAL_DCMI_DeInit(&csi->dcmi);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
#if defined(OMV_CSI_POWER_PIN)
|
|
||||||
if (csi->power_pol == OMV_CSI_ACTIVE_HIGH) {
|
|
||||||
omv_gpio_write(OMV_CSI_POWER_PIN, 0);
|
|
||||||
} else {
|
|
||||||
omv_gpio_write(OMV_CSI_POWER_PIN, 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ret = omv_csi_config(csi, OMV_CSI_CONFIG_INIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
mp_hal_delay_ms(10);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int omv_csi_set_vsync_callback(omv_csi_t *csi, omv_csi_cb_t cb) {
|
int omv_csi_set_vsync_callback(omv_csi_t *csi, omv_csi_cb_t cb) {
|
||||||
if (cb.fun == NULL) {
|
if (cb.fun == NULL) {
|
||||||
#if (DCMI_VSYNC_EXTI_SHARED == 0)
|
#if (DCMI_VSYNC_EXTI_SHARED == 0)
|
||||||
@ -1093,6 +1080,7 @@ int omv_csi_init() {
|
|||||||
csi->fb = framebuffer_get(-1);
|
csi->fb = framebuffer_get(-1);
|
||||||
csi->abort = stm_csi_abort;
|
csi->abort = stm_csi_abort;
|
||||||
csi->config = stm_csi_config;
|
csi->config = stm_csi_config;
|
||||||
|
csi->shutdown = stm_csi_shutdown;
|
||||||
csi->snapshot = stm_csi_snapshot;
|
csi->snapshot = stm_csi_snapshot;
|
||||||
csi->color_palette = rainbow_table;
|
csi->color_palette = rainbow_table;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user