1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
130
134
135
136
137
138
139
140
141
142
143
144
145
149
150
151
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
177
178
179
180
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
212
213
214
215
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
241
242
243
244
245
246
247
248
249
250
251
252
253
254
261
262
263
264
265
271
272
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
294
302
303
309
317
318
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
386
387
388
389
390
391
392
393
394
395
396
397
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
605
606
607
608
609
610
611
612
613
614
615
616
617
619
620
621
622
623
624
625
626
627
632
633
634
635
636
637
638
640
641
642
643
644
645
646
652
660
661
667
675
676
682
690
691
697
705
706
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
871
875
876
882
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
907
908
909
910
911
912
913
917
921
925
929
933
937
941
942
943
963
970
971
972
973
974
975
981
982
983
984
985
986
987
988
989
993
997
1001
1005
1009
1013
1019
1020
1021
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1056
1057
1060
1061
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1083
1084
1090
1091
1092
1096
1097
1103
1104
1105
1106
1107
1108
1109
1110
1111
1115
1116
1117
1118
1124
1125
1126
1127
1128
1133
1134
1135
1136
1138
1139
1140
1141
1142
1143
1144
1147
1148
1151
1154
1155
1158
1159
/* ... */
#include "stm32f4xx_hal.h"
/* ... */
/* ... */
#ifdef HAL_DCMI_MODULE_ENABLED
#if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) ||\
defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) ||\
defined(STM32F479xx)
#define HAL_TIMEOUT_DCMI_STOP 14U
static void DCMI_DMAXferCplt(DMA_HandleTypeDef *hdma);
static void DCMI_DMAError(DMA_HandleTypeDef *hdma);
Private function prototypes
/* ... */
/* ... */
/* ... */
__weak HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
{
if(hdcmi == NULL)
{
return HAL_ERROR;
}if (hdcmi == NULL) { ... }
assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
if(hdcmi->State == HAL_DCMI_STATE_RESET)
{
hdcmi->Lock = HAL_UNLOCKED;
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback;
hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback;
hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback;
hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback;
if(hdcmi->MspInitCallback == NULL)
{
hdcmi->MspInitCallback = HAL_DCMI_MspInit;
}if (hdcmi->MspInitCallback == NULL) { ... }
hdcmi->MspInitCallback(hdcmi);/* ... */
#else
HAL_DCMI_MspInit(hdcmi);/* ... */
#endif
HAL_DCMI_MspInit(hdcmi);
}if (hdcmi->State == HAL_DCMI_STATE_RESET) { ... }
hdcmi->State = HAL_DCMI_STATE_BUSY;
hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |
DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |
DCMI_CR_ESS);
hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate | \
hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity | \
hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode | \
hdcmi->Init.JPEGMode);
if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
{
hdcmi->Instance->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) |
((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << DCMI_POSITION_ESCR_LSC)|
((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << DCMI_POSITION_ESCR_LEC) |
((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << DCMI_POSITION_ESCR_FEC));
}if (hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED) { ... }
__HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR);
hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
hdcmi->State = HAL_DCMI_STATE_READY;
return HAL_OK;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi)
{
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
if(hdcmi->MspDeInitCallback == NULL)
{
hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
}if (hdcmi->MspDeInitCallback == NULL) { ... }
hdcmi->MspDeInitCallback(hdcmi);/* ... */
#else
HAL_DCMI_MspDeInit(hdcmi);/* ... */
#endif
hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
hdcmi->State = HAL_DCMI_STATE_RESET;
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
__weak void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
{
UNUSED(hdcmi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi)
{
UNUSED(hdcmi);
/* ... */
}{ ... }
/* ... */
/* ... */
/* ... */
HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
{
uint32_t SecondMemAddress = 0U;
assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));
__HAL_LOCK(hdcmi);
hdcmi->State = HAL_DCMI_STATE_BUSY;
__HAL_DCMI_ENABLE(hdcmi);
hdcmi->Instance->CR &= ~(DCMI_CR_CM);
hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode);
hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAXferCplt;
hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;
hdcmi->DMA_Handle->XferAbortCallback = NULL;
hdcmi->XferCount = 0U;
hdcmi->XferTransferNumber = 0U;
if(Length <= 0xFFFFU)
{
HAL_DMA_Start_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, Length);
}if (Length <= 0xFFFFU) { ... }
else
{
hdcmi->DMA_Handle->XferM1CpltCallback = DCMI_DMAXferCplt;
hdcmi->XferCount = 1U;
hdcmi->XferSize = Length;
hdcmi->pBuffPtr = pData;
while(hdcmi->XferSize > 0xFFFFU)
{
hdcmi->XferSize = (hdcmi->XferSize/2U);
hdcmi->XferCount = hdcmi->XferCount*2U;
}while (hdcmi->XferSize > 0xFFFFU) { ... }
hdcmi->XferCount = (hdcmi->XferCount - 2U);
hdcmi->XferTransferNumber = hdcmi->XferCount;
SecondMemAddress = (uint32_t)(pData + (4U*hdcmi->XferSize));
HAL_DMAEx_MultiBufferStart_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, SecondMemAddress, hdcmi->XferSize);
}else { ... }
hdcmi->Instance->CR |= DCMI_CR_CAPTURE;
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi)
{
__IO uint32_t count = SystemCoreClock / HAL_TIMEOUT_DCMI_STOP;
HAL_StatusTypeDef status = HAL_OK;
__HAL_LOCK(hdcmi);
hdcmi->State = HAL_DCMI_STATE_BUSY;
hdcmi->Instance->CR &= ~(DCMI_CR_CAPTURE);
do
{
if (count-- == 0U)
{
hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT;
status = HAL_TIMEOUT;
break;
}if (count-- == 0U) { ... }
...}
while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0U);
__HAL_DCMI_DISABLE(hdcmi);
HAL_DMA_Abort(hdcmi->DMA_Handle);
hdcmi->ErrorCode |= HAL_DCMI_ERROR_NONE;
hdcmi->State = HAL_DCMI_STATE_READY;
__HAL_UNLOCK(hdcmi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_Suspend(DCMI_HandleTypeDef* hdcmi)
{
__IO uint32_t count = SystemCoreClock / HAL_TIMEOUT_DCMI_STOP;
HAL_StatusTypeDef status = HAL_OK;
__HAL_LOCK(hdcmi);
if(hdcmi->State == HAL_DCMI_STATE_BUSY)
{
hdcmi->State = HAL_DCMI_STATE_SUSPENDED;
hdcmi->Instance->CR &= ~(DCMI_CR_CAPTURE);
do
{
if (count-- == 0U)
{
hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT;
hdcmi->State = HAL_DCMI_STATE_READY;
status = HAL_TIMEOUT;
break;
}if (count-- == 0U) { ... }
...}
while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0);
}if (hdcmi->State == HAL_DCMI_STATE_BUSY) { ... }
__HAL_UNLOCK(hdcmi);
return status;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_Resume(DCMI_HandleTypeDef* hdcmi)
{
__HAL_LOCK(hdcmi);
if(hdcmi->State == HAL_DCMI_STATE_SUSPENDED)
{
hdcmi->State = HAL_DCMI_STATE_BUSY;
hdcmi->Instance->CR |= DCMI_CR_CAPTURE;
}if (hdcmi->State == HAL_DCMI_STATE_SUSPENDED) { ... }
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi)
{
uint32_t isr_value = READ_REG(hdcmi->Instance->MISR);
if((isr_value & DCMI_FLAG_ERRRI) == DCMI_FLAG_ERRRI)
{
__HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI);
hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC;
hdcmi->State = HAL_DCMI_STATE_ERROR;
hdcmi->DMA_Handle->XferAbortCallback = DCMI_DMAError;
HAL_DMA_Abort_IT(hdcmi->DMA_Handle);
}if ((isr_value & DCMI_FLAG_ERRRI) == DCMI_FLAG_ERRRI) { ... }
if((isr_value & DCMI_FLAG_OVRRI) == DCMI_FLAG_OVRRI)
{
__HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVRRI);
hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVR;
hdcmi->State = HAL_DCMI_STATE_ERROR;
hdcmi->DMA_Handle->XferAbortCallback = DCMI_DMAError;
HAL_DMA_Abort_IT(hdcmi->DMA_Handle);
}if ((isr_value & DCMI_FLAG_OVRRI) == DCMI_FLAG_OVRRI) { ... }
if((isr_value & DCMI_FLAG_LINERI) == DCMI_FLAG_LINERI)
{
__HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI);
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
hdcmi->LineEventCallback(hdcmi);/* ... */
#else
HAL_DCMI_LineEventCallback(hdcmi);
#endif
}if ((isr_value & DCMI_FLAG_LINERI) == DCMI_FLAG_LINERI) { ... }
if((isr_value & DCMI_FLAG_VSYNCRI) == DCMI_FLAG_VSYNCRI)
{
__HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI);
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
hdcmi->VsyncEventCallback(hdcmi);/* ... */
#else
HAL_DCMI_VsyncEventCallback(hdcmi);
#endif
}if ((isr_value & DCMI_FLAG_VSYNCRI) == DCMI_FLAG_VSYNCRI) { ... }
if((isr_value & DCMI_FLAG_FRAMERI) == DCMI_FLAG_FRAMERI)
{
if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT)
{
__HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR);
}if ((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT) { ... }
__HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME);
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
hdcmi->FrameEventCallback(hdcmi);/* ... */
#else
HAL_DCMI_FrameEventCallback(hdcmi);
#endif
}if ((isr_value & DCMI_FLAG_FRAMERI) == DCMI_FLAG_FRAMERI) { ... }
}{ ... }
/* ... */
__weak void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
{
UNUSED(hdcmi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
{
UNUSED(hdcmi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
{
UNUSED(hdcmi);
/* ... */
}{ ... }
/* ... */
__weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
{
UNUSED(hdcmi);
/* ... */
}{ ... }
/* ... */
/* ... */
/* ... */
HAL_StatusTypeDef HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)
{
__HAL_LOCK(hdcmi);
hdcmi->State = HAL_DCMI_STATE_BUSY;
assert_param(IS_DCMI_WINDOW_COORDINATE(X0));
assert_param(IS_DCMI_WINDOW_COORDINATE(YSize));
assert_param(IS_DCMI_WINDOW_COORDINATE(XSize));
assert_param(IS_DCMI_WINDOW_HEIGHT(Y0));
hdcmi->Instance->CWSIZER = (XSize | (YSize << DCMI_POSITION_CWSIZE_VLINE));
hdcmi->Instance->CWSTRTR = (X0 | (Y0 << DCMI_POSITION_CWSTRT_VST));
hdcmi->State = HAL_DCMI_STATE_READY;
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_DisableCrop(DCMI_HandleTypeDef *hdcmi)
{
__HAL_LOCK(hdcmi);
hdcmi->State = HAL_DCMI_STATE_BUSY;
hdcmi->Instance->CR &= ~(uint32_t)DCMI_CR_CROP;
hdcmi->State = HAL_DCMI_STATE_READY;
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_EnableCrop(DCMI_HandleTypeDef *hdcmi)
{
__HAL_LOCK(hdcmi);
hdcmi->State = HAL_DCMI_STATE_BUSY;
hdcmi->Instance->CR |= (uint32_t)DCMI_CR_CROP;
hdcmi->State = HAL_DCMI_STATE_READY;
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef *hdcmi, DCMI_SyncUnmaskTypeDef *SyncUnmask)
{
__HAL_LOCK(hdcmi);
hdcmi->State = HAL_DCMI_STATE_BUSY;
hdcmi->Instance->ESUR = (((uint32_t)SyncUnmask->FrameStartUnmask) |\
((uint32_t)SyncUnmask->LineStartUnmask << DCMI_ESUR_LSU_Pos)|\
((uint32_t)SyncUnmask->LineEndUnmask << DCMI_ESUR_LEU_Pos)|\
((uint32_t)SyncUnmask->FrameEndUnmask << DCMI_ESUR_FEU_Pos));
hdcmi->State = HAL_DCMI_STATE_READY;
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}{ ... }
/* ... */
/* ... */
/* ... */
HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi)
{
return hdcmi->State;
}{ ... }
/* ... */
uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi)
{
return hdcmi->ErrorCode;
}{ ... }
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
/* ... */
HAL_StatusTypeDef HAL_DCMI_RegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback)
{
HAL_StatusTypeDef status = HAL_OK;
if(pCallback == NULL)
{
hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}if (pCallback == NULL) { ... }
else
{
if(hdcmi->State == HAL_DCMI_STATE_READY)
{
switch (CallbackID)
{
case HAL_DCMI_FRAME_EVENT_CB_ID :
hdcmi->FrameEventCallback = pCallback;
break;
case HAL_DCMI_FRAME_EVENT_CB_ID :
case HAL_DCMI_VSYNC_EVENT_CB_ID :
hdcmi->VsyncEventCallback = pCallback;
break;
case HAL_DCMI_VSYNC_EVENT_CB_ID :
case HAL_DCMI_LINE_EVENT_CB_ID :
hdcmi->LineEventCallback = pCallback;
break;
case HAL_DCMI_LINE_EVENT_CB_ID :
case HAL_DCMI_ERROR_CB_ID :
hdcmi->ErrorCallback = pCallback;
break;
case HAL_DCMI_ERROR_CB_ID :
case HAL_DCMI_MSPINIT_CB_ID :
hdcmi->MspInitCallback = pCallback;
break;
case HAL_DCMI_MSPINIT_CB_ID :
case HAL_DCMI_MSPDEINIT_CB_ID :
hdcmi->MspDeInitCallback = pCallback;
break;
case HAL_DCMI_MSPDEINIT_CB_ID :
default :
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}if (hdcmi->State == HAL_DCMI_STATE_READY) { ... }
else if(hdcmi->State == HAL_DCMI_STATE_RESET)
{
switch (CallbackID)
{
case HAL_DCMI_MSPINIT_CB_ID :
hdcmi->MspInitCallback = pCallback;
break;
case HAL_DCMI_MSPINIT_CB_ID :
case HAL_DCMI_MSPDEINIT_CB_ID :
hdcmi->MspDeInitCallback = pCallback;
break;
case HAL_DCMI_MSPDEINIT_CB_ID :
default :
hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}else if (hdcmi->State == HAL_DCMI_STATE_RESET) { ... }
else
{
hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
}else { ... }
return status;
}HAL_DCMI_RegisterCallback (DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback) { ... }
/* ... */
HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID)
{
HAL_StatusTypeDef status = HAL_OK;
if(hdcmi->State == HAL_DCMI_STATE_READY)
{
switch (CallbackID)
{
case HAL_DCMI_FRAME_EVENT_CB_ID :
hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback;
break;
case HAL_DCMI_FRAME_EVENT_CB_ID :
case HAL_DCMI_VSYNC_EVENT_CB_ID :
hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback;
break;
case HAL_DCMI_VSYNC_EVENT_CB_ID :
case HAL_DCMI_LINE_EVENT_CB_ID :
hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback;
break;
case HAL_DCMI_LINE_EVENT_CB_ID :
case HAL_DCMI_ERROR_CB_ID :
hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback;
break;
case HAL_DCMI_ERROR_CB_ID :
case HAL_DCMI_MSPINIT_CB_ID :
hdcmi->MspInitCallback = HAL_DCMI_MspInit;
break;
case HAL_DCMI_MSPINIT_CB_ID :
case HAL_DCMI_MSPDEINIT_CB_ID :
hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
break;
case HAL_DCMI_MSPDEINIT_CB_ID :
default :
hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}if (hdcmi->State == HAL_DCMI_STATE_READY) { ... }
else if(hdcmi->State == HAL_DCMI_STATE_RESET)
{
switch (CallbackID)
{
case HAL_DCMI_MSPINIT_CB_ID :
hdcmi->MspInitCallback = HAL_DCMI_MspInit;
break;
case HAL_DCMI_MSPINIT_CB_ID :
case HAL_DCMI_MSPDEINIT_CB_ID :
hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
break;
case HAL_DCMI_MSPDEINIT_CB_ID :
default :
hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
break;default
}switch (CallbackID) { ... }
}else if (hdcmi->State == HAL_DCMI_STATE_RESET) { ... }
else
{
hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
status = HAL_ERROR;
}else { ... }
return status;
}HAL_DCMI_UnRegisterCallback (DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID) { ... }
/* ... */#endif
/* ... */
Exported functions
/* ... */
/* ... */
static void DCMI_DMAXferCplt(DMA_HandleTypeDef *hdma)
{
uint32_t tmp = 0U;
DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
if(hdcmi->XferCount != 0U)
{
tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT);
if(((hdcmi->XferCount % 2U) == 0U) && (tmp != 0U))
{
tmp = hdcmi->DMA_Handle->Instance->M0AR;
HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8U*hdcmi->XferSize)), MEMORY0);
hdcmi->XferCount--;
}if (((hdcmi->XferCount % 2U) == 0U) && (tmp != 0U)) { ... }
else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U)
{
tmp = hdcmi->DMA_Handle->Instance->M1AR;
HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8U*hdcmi->XferSize)), MEMORY1);
hdcmi->XferCount--;
}else if ((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U) { ... }
}if (hdcmi->XferCount != 0U) { ... }
else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0U)
{
hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr;
}else if ((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0U) { ... }
else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U)
{
tmp = hdcmi->pBuffPtr;
hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4U*hdcmi->XferSize));
hdcmi->XferCount = hdcmi->XferTransferNumber;
}else if ((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U) { ... }
if(hdcmi->XferCount == hdcmi->XferTransferNumber)
{
__HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME);
if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT)
{
hdcmi->State= HAL_DCMI_STATE_READY;
}if ((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT) { ... }
}if (hdcmi->XferCount == hdcmi->XferTransferNumber) { ... }
}{ ... }
/* ... */
static void DCMI_DMAError(DMA_HandleTypeDef *hdma)
{
DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
if(hdcmi->DMA_Handle->ErrorCode != HAL_DMA_ERROR_FE)
{
hdcmi->State = HAL_DCMI_STATE_READY;
}if (hdcmi->DMA_Handle->ErrorCode != HAL_DMA_ERROR_FE) { ... }
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
hdcmi->ErrorCallback(hdcmi);/* ... */
#else
HAL_DCMI_ErrorCallback(hdcmi);
#endif
}{ ... }
/* ... */
/* ... */
/* ... */#endif
/* ... */
/* ... */#endif
/* ... */
/* ... */