/** * @brief DMA conversion complete callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) { uint32_t tmp = 0; DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; hdcmi->State= HAL_DCMI_STATE_READY; if(hdcmi->XferCount != 0) { /* Update memory 0 address location */ tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT); if(((hdcmi->XferCount % 2) == 0) && (tmp != 0)) { tmp = hdcmi->DMA_Handle->Instance->M0AR; HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY0); hdcmi->XferCount--; } /* Update memory 1 address location */ else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0) { tmp = hdcmi->DMA_Handle->Instance->M1AR; HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY1); hdcmi->XferCount--; } } /* Update memory 0 address location */ else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0) { hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr; } /* Update memory 1 address location */ else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0) { tmp = hdcmi->pBuffPtr; hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4*hdcmi->XferSize)); hdcmi->XferCount = hdcmi->XferTransferNumber; } if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET) { /* Process Unlocked */ __HAL_UNLOCK(hdcmi); /* FRAME Callback */ HAL_DCMI_FrameEventCallback(hdcmi); } }
/** * @brief Handles DCMI interrupt request. * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for the DCMI. * @retval None */ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) { /* Synchronization error interrupt management *******************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_ERRRI) != RESET) { if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_ERR) != RESET) { /* Disable the Synchronization error interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_ERR); /* Clear the Synchronization error flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI); /* Update error code */ hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC; /* Change DCMI state */ hdcmi->State = HAL_DCMI_STATE_ERROR; /* Process Unlocked */ __HAL_UNLOCK(hdcmi); /* Abort the DMA Transfer */ HAL_DMA_Abort(hdcmi->DMA_Handle); /* Synchronization error Callback */ HAL_DCMI_ErrorCallback(hdcmi); } } /* Overflow interrupt management ********************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_OVFRI) != RESET) { if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_OVF) != RESET) { /* Disable the Overflow interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_OVF); /* Clear the Overflow flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVFRI); /* Update error code */ hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVF; /* Change DCMI state */ hdcmi->State = HAL_DCMI_STATE_ERROR; /* Process Unlocked */ __HAL_UNLOCK(hdcmi); /* Abort the DMA Transfer */ HAL_DMA_Abort(hdcmi->DMA_Handle); /* Overflow Callback */ HAL_DCMI_ErrorCallback(hdcmi); } } /* Line Interrupt management ************************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_LINERI) != RESET) { if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_LINE) != RESET) { /* Clear the Line interrupt flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI); /* Process Unlocked */ __HAL_UNLOCK(hdcmi); /* Line interrupt Callback */ HAL_DCMI_LineEventCallback(hdcmi); } } /* VSYNC interrupt management ***********************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_VSYNCRI) != RESET) { if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_VSYNC) != RESET) { /* Disable the VSYNC interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_VSYNC); /* Clear the VSYNC flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI); /* Process Unlocked */ __HAL_UNLOCK(hdcmi); /* VSYNC Callback */ HAL_DCMI_VsyncEventCallback(hdcmi); } } /* End of Frame interrupt management ****************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET) { if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_FRAME) != RESET) { /* Disable the End of Frame interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME); /* Clear the End of Frame flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_FRAMERI); /* Process Unlocked */ __HAL_UNLOCK(hdcmi); /* End of Frame Callback */ HAL_DCMI_FrameEventCallback(hdcmi); } } }
/** * @brief Handles DCMI interrupt request. * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains * the configuration information for the DCMI. * @retval None */ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) { uint32_t isr_value = READ_REG(hdcmi->Instance->MISR); /* Synchronization error interrupt management *******************************/ if((isr_value & DCMI_FLAG_ERRRI) == DCMI_FLAG_ERRRI) { /* Clear the Synchronization error flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI); /* Update error code */ hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC; /* Change DCMI state */ hdcmi->State = HAL_DCMI_STATE_ERROR; /* Set the synchronization error callback */ hdcmi->DMA_Handle->XferAbortCallback = DCMI_DMAError; /* Abort the DMA Transfer */ HAL_DMA_Abort_IT(hdcmi->DMA_Handle); } /* Overflow interrupt management ********************************************/ if((isr_value & DCMI_FLAG_OVRRI) == DCMI_FLAG_OVRRI) { /* Clear the Overflow flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVRRI); /* Update error code */ hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVR; /* Change DCMI state */ hdcmi->State = HAL_DCMI_STATE_ERROR; /* Set the overflow callback */ hdcmi->DMA_Handle->XferAbortCallback = DCMI_DMAError; /* Abort the DMA Transfer */ HAL_DMA_Abort_IT(hdcmi->DMA_Handle); } /* Line Interrupt management ************************************************/ if((isr_value & DCMI_FLAG_LINERI) == DCMI_FLAG_LINERI) { /* Clear the Line interrupt flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI); /* Line interrupt Callback */ HAL_DCMI_LineEventCallback(hdcmi); } /* VSYNC interrupt management ***********************************************/ if((isr_value & DCMI_FLAG_VSYNCRI) == DCMI_FLAG_VSYNCRI) { /* Clear the VSYNC flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI); /* VSYNC Callback */ HAL_DCMI_VsyncEventCallback(hdcmi); } /* FRAME interrupt management ***********************************************/ if((isr_value & DCMI_FLAG_FRAMERI) == DCMI_FLAG_FRAMERI) { /* When snapshot mode, disable Vsync, Error and Overrun interrupts */ if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT) { /* Disable the Line, Vsync, Error and Overrun interrupts */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR); } /* Disable the Frame interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME); /* Frame Callback */ HAL_DCMI_FrameEventCallback(hdcmi); } }