mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1141 from openmv/sensor_xdown
Sensor shutdown fixes.
This commit is contained in:
commit
ad7fa68279
@ -546,16 +546,28 @@ int sensor_sleep(int enable)
|
|||||||
|
|
||||||
int sensor_shutdown(int enable)
|
int sensor_shutdown(int enable)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
dcmi_abort();
|
dcmi_abort();
|
||||||
|
|
||||||
if (enable) {
|
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 {
|
} 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);
|
systick_sleep(10);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sensor_read_reg(uint16_t reg_addr)
|
int sensor_read_reg(uint16_t reg_addr)
|
||||||
|
|||||||
@ -139,25 +139,27 @@ void HAL_MspInit(void)
|
|||||||
#if defined(DCMI_RESET_PIN) || defined(DCMI_PWDN_PIN) || defined(DCMI_FSYNC_PIN)
|
#if defined(DCMI_RESET_PIN) || defined(DCMI_PWDN_PIN) || defined(DCMI_FSYNC_PIN)
|
||||||
/* Configure DCMI GPIO */
|
/* Configure DCMI GPIO */
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
|
||||||
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
||||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
|
||||||
#if defined(DCMI_RESET_PIN)
|
#if defined(DCMI_RESET_PIN)
|
||||||
GPIO_InitStructure.Pin = DCMI_RESET_PIN;
|
GPIO_InitStructure.Pin = DCMI_RESET_PIN;
|
||||||
|
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
||||||
HAL_GPIO_Init(DCMI_RESET_PORT, &GPIO_InitStructure);
|
HAL_GPIO_Init(DCMI_RESET_PORT, &GPIO_InitStructure);
|
||||||
#endif
|
#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)
|
#if defined(DCMI_FSYNC_PIN)
|
||||||
GPIO_InitStructure.Pin = DCMI_FSYNC_PIN;
|
GPIO_InitStructure.Pin = DCMI_FSYNC_PIN;
|
||||||
|
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
||||||
HAL_GPIO_Init(DCMI_FSYNC_PORT, &GPIO_InitStructure);
|
HAL_GPIO_Init(DCMI_FSYNC_PORT, &GPIO_InitStructure);
|
||||||
#endif
|
#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
|
#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 */
|
/* Timer GPIO configuration */
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.Pin = DCMI_TIM_PIN;
|
GPIO_InitStructure.Pin = DCMI_TIM_PIN;
|
||||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
|
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
|
||||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStructure.Alternate = DCMI_TIM_AF;
|
GPIO_InitStructure.Alternate = DCMI_TIM_AF;
|
||||||
@ -255,7 +257,7 @@ void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
|
|||||||
|
|
||||||
/* DCMI GPIOs configuration */
|
/* DCMI GPIOs configuration */
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
|
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
|
||||||
GPIO_InitStructure.Alternate = GPIO_AF13_DCMI;
|
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)
|
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
|
||||||
{
|
{
|
||||||
#if defined(IMU_SPI)
|
#if defined(IMU_SPI)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user