Merge pull request #1141 from openmv/sensor_xdown

Sensor shutdown fixes.
This commit is contained in:
Ibrahim Abd Elkader 2021-01-25 22:37:05 +02:00 committed by GitHub
commit ad7fa68279
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 11 deletions

View File

@ -546,16 +546,28 @@ int sensor_sleep(int enable)
int sensor_shutdown(int enable)
{
int ret = 0;
dcmi_abort();
if (enable) {
DCMI_PWDN_HIGH();
if (sensor.pwdn_pol == ACTIVE_HIGH) {
DCMI_PWDN_HIGH();
} else {
DCMI_PWDN_LOW();
}
HAL_NVIC_DisableIRQ(DCMI_IRQn);
HAL_DCMI_DeInit(&DCMIHandle);
} else {
DCMI_PWDN_LOW();
if (sensor.pwdn_pol == ACTIVE_HIGH) {
DCMI_PWDN_LOW();
} else {
DCMI_PWDN_HIGH();
}
ret = dcmi_config(DCMI_JPEG_DISABLE);
}
systick_sleep(10);
return 0;
return ret;
}
int sensor_read_reg(uint16_t reg_addr)

View File

@ -139,25 +139,27 @@ void HAL_MspInit(void)
#if defined(DCMI_RESET_PIN) || defined(DCMI_PWDN_PIN) || defined(DCMI_FSYNC_PIN)
/* Configure DCMI GPIO */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
#if defined(DCMI_RESET_PIN)
GPIO_InitStructure.Pin = DCMI_RESET_PIN;
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(DCMI_RESET_PORT, &GPIO_InitStructure);
#endif
#if defined(DCMI_PWDN_PIN)
GPIO_InitStructure.Pin = DCMI_PWDN_PIN;
HAL_GPIO_Init(DCMI_PWDN_PORT, &GPIO_InitStructure);
#endif
#if defined(DCMI_FSYNC_PIN)
GPIO_InitStructure.Pin = DCMI_FSYNC_PIN;
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(DCMI_FSYNC_PORT, &GPIO_InitStructure);
#endif
#if defined(DCMI_PWDN_PIN)
GPIO_InitStructure.Pin = DCMI_PWDN_PIN;
GPIO_InitStructure.Pull = GPIO_PULLUP;
HAL_GPIO_Init(DCMI_PWDN_PORT, &GPIO_InitStructure);
#endif
#endif // DCMI_RESET_PIN || DCMI_PWDN_PIN || DCMI_FSYNC_PIN
}
@ -222,7 +224,7 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
/* Timer GPIO configuration */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = DCMI_TIM_PIN;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.Alternate = DCMI_TIM_AF;
@ -255,7 +257,7 @@ void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
/* DCMI GPIOs configuration */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_InitStructure.Alternate = GPIO_AF13_DCMI;
@ -272,6 +274,16 @@ void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
}
}
void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi)
{
/* DCMI clock enable */
__DCMI_CLK_DISABLE();
for (int i=0; i<NUM_DCMI_PINS; i++) {
HAL_GPIO_DeInit(dcmi_pins[i].port, dcmi_pins[i].pin);
}
}
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{
#if defined(IMU_SPI)