STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_dcmi.c
Go to the documentation of this file.
1
124/* Includes ------------------------------------------------------------------*/
125#include "stm32f4xx_hal.h"
126
135#ifdef HAL_DCMI_MODULE_ENABLED
136
137#if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) ||\
138 defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) ||\
139 defined(STM32F479xx)
140/* Private typedef -----------------------------------------------------------*/
141/* Private define ------------------------------------------------------------*/
142#define HAL_TIMEOUT_DCMI_STOP 14U /* Set timeout to 1s */
143/* Private macro -------------------------------------------------------------*/
144/* Private variables ---------------------------------------------------------*/
145/* Private function prototypes -----------------------------------------------*/
146static void DCMI_DMAXferCplt(DMA_HandleTypeDef *hdma);
147static void DCMI_DMAError(DMA_HandleTypeDef *hdma);
148
149/* Exported functions --------------------------------------------------------*/
150
178{
179 /* Check the DCMI peripheral state */
180 if(hdcmi == NULL)
181 {
182 return HAL_ERROR;
183 }
184
185 /* Check function parameters */
186 assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
194
195 if(hdcmi->State == HAL_DCMI_STATE_RESET)
196 {
197 /* Allocate lock resource and initialize it */
198 hdcmi->Lock = HAL_UNLOCKED;
199 /* Init the low level hardware */
200 /* Init the DCMI Callback settings */
201#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
202 hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback; /* Legacy weak FrameEventCallback */
203 hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback; /* Legacy weak VsyncEventCallback */
204 hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback; /* Legacy weak LineEventCallback */
205 hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback; /* Legacy weak ErrorCallback */
206
207 if(hdcmi->MspInitCallback == NULL)
208 {
209 /* Legacy weak MspInit Callback */
210 hdcmi->MspInitCallback = HAL_DCMI_MspInit;
211 }
212 /* Initialize the low level hardware (MSP) */
213 hdcmi->MspInitCallback(hdcmi);
214#else
215 /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
216 HAL_DCMI_MspInit(hdcmi);
217#endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */
218 HAL_DCMI_MspInit(hdcmi);
219 }
220
221 /* Change the DCMI state */
222 hdcmi->State = HAL_DCMI_STATE_BUSY;
223
224 /* Set DCMI parameters */
225 /* Configures the HS, VS, DE and PC polarity */
226 hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |
227 DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |
228 DCMI_CR_ESS);
229 hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate | \
230 hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity | \
231 hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode | \
232 hdcmi->Init.JPEGMode);
233
235 {
236 hdcmi->Instance->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) |
238 ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << DCMI_POSITION_ESCR_LEC) |
239 ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << DCMI_POSITION_ESCR_FEC));
240 }
241
242 /* Enable the Line, Vsync, Error and Overrun interrupts */
244
245 /* Update error code */
247
248 /* Initialize the DCMI state*/
250
251 return HAL_OK;
252}
253
263{
264#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
265 if(hdcmi->MspDeInitCallback == NULL)
266 {
267 hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
268 }
269 /* De-Initialize the low level hardware (MSP) */
270 hdcmi->MspDeInitCallback(hdcmi);
271#else
272 /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
273 HAL_DCMI_MspDeInit(hdcmi);
274#endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */
275
276 /* Update error code */
278
279 /* Initialize the DCMI state*/
281
282 /* Release Lock */
283 __HAL_UNLOCK(hdcmi);
284
285 return HAL_OK;
286}
287
295{
296 /* Prevent unused argument(s) compilation warning */
297 UNUSED(hdcmi);
298 /* NOTE : This function Should not be modified, when the callback is needed,
299 the HAL_DCMI_MspInit could be implemented in the user file
300 */
301}
302
310{
311 /* Prevent unused argument(s) compilation warning */
312 UNUSED(hdcmi);
313 /* NOTE : This function Should not be modified, when the callback is needed,
314 the HAL_DCMI_MspDeInit could be implemented in the user file
315 */
316}
317
347HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
348{
349 /* Initialize the second memory address */
350 uint32_t SecondMemAddress = 0U;
351
352 /* Check function parameters */
354
355 /* Process Locked */
356 __HAL_LOCK(hdcmi);
357
358 /* Lock the DCMI peripheral state */
359 hdcmi->State = HAL_DCMI_STATE_BUSY;
360
361 /* Enable DCMI by setting DCMIEN bit */
362 __HAL_DCMI_ENABLE(hdcmi);
363
364 /* Configure the DCMI Mode */
365 hdcmi->Instance->CR &= ~(DCMI_CR_CM);
366 hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode);
367
368 /* Set the DMA memory0 conversion complete callback */
370
371 /* Set the DMA error callback */
373
374 /* Set the dma abort callback */
375 hdcmi->DMA_Handle->XferAbortCallback = NULL;
376
377 /* Reset transfer counters value */
378 hdcmi->XferCount = 0U;
379 hdcmi->XferTransferNumber = 0U;
380
381 if(Length <= 0xFFFFU)
382 {
383 /* Enable the DMA Stream */
384 HAL_DMA_Start_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, Length);
385 }
386 else /* DCMI_DOUBLE_BUFFER Mode */
387 {
388 /* Set the DMA memory1 conversion complete callback */
390
391 /* Initialize transfer parameters */
392 hdcmi->XferCount = 1U;
393 hdcmi->XferSize = Length;
394 hdcmi->pBuffPtr = pData;
395
396 /* Get the number of buffer */
397 while(hdcmi->XferSize > 0xFFFFU)
398 {
399 hdcmi->XferSize = (hdcmi->XferSize/2U);
400 hdcmi->XferCount = hdcmi->XferCount*2U;
401 }
402
403 /* Update DCMI counter and transfer number*/
404 hdcmi->XferCount = (hdcmi->XferCount - 2U);
405 hdcmi->XferTransferNumber = hdcmi->XferCount;
406
407 /* Update second memory address */
408 SecondMemAddress = (uint32_t)(pData + (4U*hdcmi->XferSize));
409
410 /* Start DMA multi buffer transfer */
411 HAL_DMAEx_MultiBufferStart_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, SecondMemAddress, hdcmi->XferSize);
412 }
413
414 /* Enable Capture */
415 hdcmi->Instance->CR |= DCMI_CR_CAPTURE;
416
417 /* Release Lock */
418 __HAL_UNLOCK(hdcmi);
419
420 /* Return function status */
421 return HAL_OK;
422}
423
431{
432 __IO uint32_t count = SystemCoreClock / HAL_TIMEOUT_DCMI_STOP;
433 HAL_StatusTypeDef status = HAL_OK;
434
435 /* Process locked */
436 __HAL_LOCK(hdcmi);
437
438 /* Lock the DCMI peripheral state */
439 hdcmi->State = HAL_DCMI_STATE_BUSY;
440
441 /* Disable Capture */
442 hdcmi->Instance->CR &= ~(DCMI_CR_CAPTURE);
443
444 /* Check if the DCMI capture effectively disabled */
445 do
446 {
447 if (count-- == 0U)
448 {
449 /* Update error code */
451
452 status = HAL_TIMEOUT;
453 break;
454 }
455 }
456 while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0U);
457
458 /* Disable the DCMI */
459 __HAL_DCMI_DISABLE(hdcmi);
460
461 /* Disable the DMA */
463
464 /* Update error code */
466
467 /* Change DCMI state */
469
470 /* Process Unlocked */
471 __HAL_UNLOCK(hdcmi);
472
473 /* Return function status */
474 return status;
475}
476
484{
485 __IO uint32_t count = SystemCoreClock / HAL_TIMEOUT_DCMI_STOP;
486 HAL_StatusTypeDef status = HAL_OK;
487
488 /* Process locked */
489 __HAL_LOCK(hdcmi);
490
491 if(hdcmi->State == HAL_DCMI_STATE_BUSY)
492 {
493 /* Change DCMI state */
495
496 /* Disable Capture */
497 hdcmi->Instance->CR &= ~(DCMI_CR_CAPTURE);
498
499 /* Check if the DCMI capture effectively disabled */
500 do
501 {
502 if (count-- == 0U)
503 {
504 /* Update error code */
506
507 /* Change DCMI state */
509
510 status = HAL_TIMEOUT;
511 break;
512 }
513 }
514 while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0);
515 }
516 /* Process Unlocked */
517 __HAL_UNLOCK(hdcmi);
518
519 /* Return function status */
520 return status;
521}
522
530{
531 /* Process locked */
532 __HAL_LOCK(hdcmi);
533
534 if(hdcmi->State == HAL_DCMI_STATE_SUSPENDED)
535 {
536 /* Change DCMI state */
537 hdcmi->State = HAL_DCMI_STATE_BUSY;
538
539 /* Disable Capture */
540 hdcmi->Instance->CR |= DCMI_CR_CAPTURE;
541 }
542 /* Process Unlocked */
543 __HAL_UNLOCK(hdcmi);
544
545 /* Return function status */
546 return HAL_OK;
547}
548
556{
557 uint32_t isr_value = READ_REG(hdcmi->Instance->MISR);
558
559 /* Synchronization error interrupt management *******************************/
560 if((isr_value & DCMI_FLAG_ERRRI) == DCMI_FLAG_ERRRI)
561 {
562 /* Clear the Synchronization error flag */
564
565 /* Update error code */
567
568 /* Change DCMI state */
570
571 /* Set the synchronization error callback */
573
574 /* Abort the DMA Transfer */
576 }
577 /* Overflow interrupt management ********************************************/
578 if((isr_value & DCMI_FLAG_OVRRI) == DCMI_FLAG_OVRRI)
579 {
580 /* Clear the Overflow flag */
582
583 /* Update error code */
585
586 /* Change DCMI state */
588
589 /* Set the overflow callback */
591
592 /* Abort the DMA Transfer */
594 }
595 /* Line Interrupt management ************************************************/
596 if((isr_value & DCMI_FLAG_LINERI) == DCMI_FLAG_LINERI)
597 {
598 /* Clear the Line interrupt flag */
600
601 /* Line interrupt Callback */
602#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
603 /*Call registered DCMI line event callback*/
604 hdcmi->LineEventCallback(hdcmi);
605#else
607#endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
608 }
609 /* VSYNC interrupt management ***********************************************/
610 if((isr_value & DCMI_FLAG_VSYNCRI) == DCMI_FLAG_VSYNCRI)
611 {
612 /* Clear the VSYNC flag */
614
615 /* VSYNC Callback */
616#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
617 /*Call registered DCMI vsync event callback*/
618 hdcmi->VsyncEventCallback(hdcmi);
619#else
621#endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
622 }
623 /* FRAME interrupt management ***********************************************/
624 if((isr_value & DCMI_FLAG_FRAMERI) == DCMI_FLAG_FRAMERI)
625 {
626 /* When snapshot mode, disable Vsync, Error and Overrun interrupts */
627 if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT)
628 {
629 /* Disable the Line, Vsync, Error and Overrun interrupts */
631 }
632
633 /* Disable the Frame interrupt */
635
636 /* Frame Callback */
637#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
638 /*Call registered DCMI frame event callback*/
639 hdcmi->FrameEventCallback(hdcmi);
640#else
642#endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
643 }
644}
645
653{
654 /* Prevent unused argument(s) compilation warning */
655 UNUSED(hdcmi);
656 /* NOTE : This function Should not be modified, when the callback is needed,
657 the HAL_DCMI_ErrorCallback could be implemented in the user file
658 */
659}
660
668{
669 /* Prevent unused argument(s) compilation warning */
670 UNUSED(hdcmi);
671 /* NOTE : This function Should not be modified, when the callback is needed,
672 the HAL_DCMI_LineEventCallback could be implemented in the user file
673 */
674}
675
683{
684 /* Prevent unused argument(s) compilation warning */
685 UNUSED(hdcmi);
686 /* NOTE : This function Should not be modified, when the callback is needed,
687 the HAL_DCMI_VsyncEventCallback could be implemented in the user file
688 */
689}
690
698{
699 /* Prevent unused argument(s) compilation warning */
700 UNUSED(hdcmi);
701 /* NOTE : This function Should not be modified, when the callback is needed,
702 the HAL_DCMI_FrameEventCallback could be implemented in the user file
703 */
704}
705
735HAL_StatusTypeDef HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)
736{
737 /* Process Locked */
738 __HAL_LOCK(hdcmi);
739
740 /* Lock the DCMI peripheral state */
741 hdcmi->State = HAL_DCMI_STATE_BUSY;
742
743 /* Check the parameters */
748
749 /* Configure CROP */
750 hdcmi->Instance->CWSIZER = (XSize | (YSize << DCMI_POSITION_CWSIZE_VLINE));
751 hdcmi->Instance->CWSTRTR = (X0 | (Y0 << DCMI_POSITION_CWSTRT_VST));
752
753 /* Initialize the DCMI state*/
755
756 /* Process Unlocked */
757 __HAL_UNLOCK(hdcmi);
758
759 return HAL_OK;
760}
761
769{
770 /* Process Locked */
771 __HAL_LOCK(hdcmi);
772
773 /* Lock the DCMI peripheral state */
774 hdcmi->State = HAL_DCMI_STATE_BUSY;
775
776 /* Disable DCMI Crop feature */
777 hdcmi->Instance->CR &= ~(uint32_t)DCMI_CR_CROP;
778
779 /* Change the DCMI state*/
781
782 /* Process Unlocked */
783 __HAL_UNLOCK(hdcmi);
784
785 return HAL_OK;
786}
787
795{
796 /* Process Locked */
797 __HAL_LOCK(hdcmi);
798
799 /* Lock the DCMI peripheral state */
800 hdcmi->State = HAL_DCMI_STATE_BUSY;
801
802 /* Enable DCMI Crop feature */
803 hdcmi->Instance->CR |= (uint32_t)DCMI_CR_CROP;
804
805 /* Change the DCMI state*/
807
808 /* Process Unlocked */
809 __HAL_UNLOCK(hdcmi);
810
811 return HAL_OK;
812}
813
823{
824 /* Process Locked */
825 __HAL_LOCK(hdcmi);
826
827 /* Lock the DCMI peripheral state */
828 hdcmi->State = HAL_DCMI_STATE_BUSY;
829
830 /* Write DCMI embedded synchronization unmask register */
831 hdcmi->Instance->ESUR = (((uint32_t)SyncUnmask->FrameStartUnmask) |\
832 ((uint32_t)SyncUnmask->LineStartUnmask << DCMI_ESUR_LSU_Pos)|\
833 ((uint32_t)SyncUnmask->LineEndUnmask << DCMI_ESUR_LEU_Pos)|\
834 ((uint32_t)SyncUnmask->FrameEndUnmask << DCMI_ESUR_FEU_Pos));
835
836 /* Change the DCMI state*/
838
839 /* Process Unlocked */
840 __HAL_UNLOCK(hdcmi);
841
842 return HAL_OK;
843}
844
875
883{
884 return hdcmi->ErrorCode;
885}
886
887#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
896HAL_StatusTypeDef HAL_DCMI_RegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback)
897{
898 HAL_StatusTypeDef status = HAL_OK;
899
900 if(pCallback == NULL)
901 {
902 /* update the error code */
903 hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
904 /* update return status */
905 status = HAL_ERROR;
906 }
907 else
908 {
909 if(hdcmi->State == HAL_DCMI_STATE_READY)
910 {
911 switch (CallbackID)
912 {
913 case HAL_DCMI_FRAME_EVENT_CB_ID :
914 hdcmi->FrameEventCallback = pCallback;
915 break;
916
917 case HAL_DCMI_VSYNC_EVENT_CB_ID :
918 hdcmi->VsyncEventCallback = pCallback;
919 break;
920
921 case HAL_DCMI_LINE_EVENT_CB_ID :
922 hdcmi->LineEventCallback = pCallback;
923 break;
924
925 case HAL_DCMI_ERROR_CB_ID :
926 hdcmi->ErrorCallback = pCallback;
927 break;
928
929 case HAL_DCMI_MSPINIT_CB_ID :
930 hdcmi->MspInitCallback = pCallback;
931 break;
932
933 case HAL_DCMI_MSPDEINIT_CB_ID :
934 hdcmi->MspDeInitCallback = pCallback;
935 break;
936
937 default :
938 /* Return error status */
939 status = HAL_ERROR;
940 break;
941 }
942 }
943 else if(hdcmi->State == HAL_DCMI_STATE_RESET)
944 {
945 switch (CallbackID)
946 {
947 case HAL_DCMI_MSPINIT_CB_ID :
948 hdcmi->MspInitCallback = pCallback;
949 break;
950
951 case HAL_DCMI_MSPDEINIT_CB_ID :
952 hdcmi->MspDeInitCallback = pCallback;
953 break;
954
955 default :
956 /* update the error code */
957 hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
958 /* update return status */
959 status = HAL_ERROR;
960 break;
961 }
962 }
963 else
964 {
965 /* update the error code */
966 hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
967 /* update return status */
968 status = HAL_ERROR;
969 }
970 }
971
972 return status;
973}
974
981HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID)
982{
983 HAL_StatusTypeDef status = HAL_OK;
984
985 if(hdcmi->State == HAL_DCMI_STATE_READY)
986 {
987 switch (CallbackID)
988 {
989 case HAL_DCMI_FRAME_EVENT_CB_ID :
990 hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback; /* Legacy weak FrameEventCallback */
991 break;
992
993 case HAL_DCMI_VSYNC_EVENT_CB_ID :
994 hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback; /* Legacy weak VsyncEventCallback */
995 break;
996
997 case HAL_DCMI_LINE_EVENT_CB_ID :
998 hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback; /* Legacy weak LineEventCallback */
999 break;
1000
1001 case HAL_DCMI_ERROR_CB_ID :
1002 hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback; /* Legacy weak ErrorCallback */
1003 break;
1004
1005 case HAL_DCMI_MSPINIT_CB_ID :
1006 hdcmi->MspInitCallback = HAL_DCMI_MspInit;
1007 break;
1008
1009 case HAL_DCMI_MSPDEINIT_CB_ID :
1010 hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
1011 break;
1012
1013 default :
1014 /* update the error code */
1015 hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1016 /* update return status */
1017 status = HAL_ERROR;
1018 break;
1019 }
1020 }
1021 else if(hdcmi->State == HAL_DCMI_STATE_RESET)
1022 {
1023 switch (CallbackID)
1024 {
1025 case HAL_DCMI_MSPINIT_CB_ID :
1026 hdcmi->MspInitCallback = HAL_DCMI_MspInit;
1027 break;
1028
1029 case HAL_DCMI_MSPDEINIT_CB_ID :
1030 hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
1031 break;
1032
1033 default :
1034 /* update the error code */
1035 hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1036 /* update return status */
1037 status = HAL_ERROR;
1038 break;
1039 }
1040 }
1041 else
1042 {
1043 /* update the error code */
1044 hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1045 /* update return status */
1046 status = HAL_ERROR;
1047 }
1048
1049 return status;
1050}
1051#endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
1052
1056/* Private functions ---------------------------------------------------------*/
1068{
1069 uint32_t tmp = 0U;
1070
1071 DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
1072
1073 if(hdcmi->XferCount != 0U)
1074 {
1075 /* Update memory 0 address location */
1076 tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT);
1077 if(((hdcmi->XferCount % 2U) == 0U) && (tmp != 0U))
1078 {
1079 tmp = hdcmi->DMA_Handle->Instance->M0AR;
1080 HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8U*hdcmi->XferSize)), MEMORY0);
1081 hdcmi->XferCount--;
1082 }
1083 /* Update memory 1 address location */
1084 else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U)
1085 {
1086 tmp = hdcmi->DMA_Handle->Instance->M1AR;
1087 HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8U*hdcmi->XferSize)), MEMORY1);
1088 hdcmi->XferCount--;
1089 }
1090 }
1091 /* Update memory 0 address location */
1092 else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0U)
1093 {
1094 hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr;
1095 }
1096 /* Update memory 1 address location */
1097 else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U)
1098 {
1099 tmp = hdcmi->pBuffPtr;
1100 hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4U*hdcmi->XferSize));
1101 hdcmi->XferCount = hdcmi->XferTransferNumber;
1102 }
1103
1104 /* Check if the frame is transferred */
1105 if(hdcmi->XferCount == hdcmi->XferTransferNumber)
1106 {
1107 /* Enable the Frame interrupt */
1109
1110 /* When snapshot mode, set dcmi state to ready */
1111 if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT)
1112 {
1114 }
1115 }
1116}
1117
1125{
1126 DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
1127
1129 {
1130 /* Initialize the DCMI state*/
1131 hdcmi->State = HAL_DCMI_STATE_READY;
1132 }
1133
1134 /* DCMI error Callback */
1135#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
1136 /*Call registered DCMI error callback*/
1137 hdcmi->ErrorCallback(hdcmi);
1138#else
1140#endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
1141
1142}
1143
1151#endif /* STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
1152 STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
1153 STM32F479xx */
1154#endif /* HAL_DCMI_MODULE_ENABLED */
#define DCMI_POSITION_ESCR_FEC
#define DCMI_POSITION_ESCR_LSC
#define DCMI_POSITION_ESCR_LEC
#define DCMI_MODE_SNAPSHOT
#define HAL_DCMI_ERROR_NONE
#define HAL_DCMI_ERROR_TIMEOUT
#define HAL_DCMI_ERROR_OVR
#define HAL_DCMI_ERROR_SYNC
void HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi)
Initializes the DCMI MSP.
void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef *hdcmi)
DeInitializes the DCMI MSP.
HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi)
Deinitializes the DCMI peripheral registers to their default reset values.
HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
Initializes the DCMI according to the specified parameters in the DCMI_InitTypeDef and create the ass...
void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi)
Handles DCMI interrupt request.
void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
Line Event callback.
HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef *hdcmi)
Disable DCMI DMA request and Disable DCMI capture.
void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
VSYNC Event callback.
HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef *hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
Enables DCMI DMA request and enables DCMI capture.
HAL_StatusTypeDef HAL_DCMI_Resume(DCMI_HandleTypeDef *hdcmi)
Resume DCMI capture
void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
Error DCMI callback.
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
Frame Event callback.
HAL_StatusTypeDef HAL_DCMI_Suspend(DCMI_HandleTypeDef *hdcmi)
Suspend DCMI capture
HAL_StatusTypeDef HAL_DCMI_EnableCrop(DCMI_HandleTypeDef *hdcmi)
Enable the Crop feature.
HAL_StatusTypeDef HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)
Configure the DCMI CROP coordinate.
HAL_StatusTypeDef HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef *hdcmi, DCMI_SyncUnmaskTypeDef *SyncUnmask)
Set embedded synchronization delimiters unmasks.
HAL_StatusTypeDef HAL_DCMI_DisableCrop(DCMI_HandleTypeDef *hdcmi)
Disable the Crop feature.
uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi)
Return the DCMI error code.
HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi)
Return the DCMI state.
#define __HAL_DCMI_DISABLE(__HANDLE__)
Disable the DCMI.
#define __HAL_DCMI_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the DCMI pending flags.
#define __HAL_DCMI_DISABLE_IT(__HANDLE__, __INTERRUPT__)
Disable the specified DCMI interrupts.
#define __HAL_DCMI_ENABLE(__HANDLE__)
Enable the DCMI.
#define __HAL_DCMI_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable the specified DCMI interrupts.
HAL_DCMI_StateTypeDef
HAL DCMI State structures definition.
@ HAL_DCMI_STATE_RESET
@ HAL_DCMI_STATE_READY
@ HAL_DCMI_STATE_SUSPENDED
@ HAL_DCMI_STATE_ERROR
@ HAL_DCMI_STATE_BUSY
#define DCMI_FLAG_LINERI
#define DCMI_FLAG_ERRRI
#define DCMI_FLAG_OVRRI
#define DCMI_FLAG_VSYNCRI
#define DCMI_FLAG_FRAMERI
DCMI RIS register.
#define IS_DCMI_PCKPOLARITY(POLARITY)
#define IS_DCMI_SYNCHRO(MODE)
#define IS_DCMI_CAPTURE_MODE(MODE)
#define IS_DCMI_WINDOW_HEIGHT(HEIGHT)
#define IS_DCMI_MODE_JPEG(JPEG_MODE)
#define IS_DCMI_VSPOLARITY(POLARITY)
#define IS_DCMI_HSPOLARITY(POLARITY)
#define IS_DCMI_WINDOW_COORDINATE(COORDINATE)
#define IS_DCMI_EXTENDED_DATA(DATA)
#define IS_DCMI_CAPTURE_RATE(RATE)
#define DCMI_SYNCHRO_EMBEDDED
#define DCMI_POSITION_CWSIZE_VLINE
#define DCMI_POSITION_CWSTRT_VST
#define DCMI_IT_OVR
#define DCMI_IT_LINE
#define DCMI_IT_VSYNC
#define DCMI_IT_FRAME
#define DCMI_IT_ERR
static void DCMI_DMAError(DMA_HandleTypeDef *hdma)
DMA error callback.
static void DCMI_DMAXferCplt(DMA_HandleTypeDef *hdma)
DMA conversion complete callback.
#define HAL_TIMEOUT_DCMI_STOP
HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory)
Change the memory0 or memory1 address on the fly.
HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength)
Starts the multi_buffer DMA Transfer with interrupt enabled.
#define HAL_DMA_ERROR_FE
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer.
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
#define assert_param(expr)
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef
HAL Status structures definition
@ HAL_TIMEOUT
@ HAL_ERROR
@ HAL_OK
#define UNUSED(X)
#define __HAL_UNLOCK(__HANDLE__)
@ HAL_UNLOCKED
#define __HAL_LOCK(__HANDLE__)
DCMI_CodesInitTypeDef SyncroCode
DCMI Embedded Synchronisation CODE Init structure definition.
DCMI handle Structure definition.
DMA_HandleTypeDef * DMA_Handle
__IO HAL_DCMI_StateTypeDef State
DMA handle Structure definition.
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
DMA_Stream_TypeDef * Instance
void(* XferM1CpltCallback)(struct __DMA_HandleTypeDef *hdma)