Select one of the symbols to view example projects that use it.
 
Outline
#include "stm32446e_eval_camera.h"
camera_drv
hDcmiEval
currentResolution
cameraHwAddress
BSP_CAMERA_Init(uint32_t)
BSP_CAMERA_DeInit()
BSP_CAMERA_ContinuousStart(uint8_t *)
BSP_CAMERA_SnapshotStart(uint8_t *)
BSP_CAMERA_Suspend()
BSP_CAMERA_Resume()
BSP_CAMERA_Stop()
BSP_CAMERA_HwReset()
BSP_CAMERA_PwrDown()
BSP_CAMERA_ContrastBrightnessConfig(uint32_t, uint32_t)
BSP_CAMERA_BlackWhiteConfig(uint32_t)
BSP_CAMERA_ColorEffectConfig(uint32_t)
BSP_CAMERA_IRQHandler()
BSP_CAMERA_DMA_IRQHandler()
GetSize(uint32_t)
BSP_CAMERA_MspInit(DCMI_HandleTypeDef *, void *)
BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *, void *)
HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *)
BSP_CAMERA_LineEventCallback()
HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *)
BSP_CAMERA_VsyncEventCallback()
HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *)
BSP_CAMERA_FrameEventCallback()
HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *)
BSP_CAMERA_ErrorCallback()
Files
loading...
SourceVuSTM32 Libraries and SamplesSTM32446E_EVALstm32446e_eval_camera.c
 
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
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
478
479
480
481
482
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
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file stm32446e_eval_camera.c * @author MCD Application Team * @brief This file includes the driver for Camera modules mounted on * STM32446E-EVAL evaluation board. ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* File Info: ------------------------------------------------------------------ User NOTES 1. How to use this driver: -------------------------- - This driver is used to drive the camera. - The S5K5CAG component driver MUST be included with this driver. 2. Driver description: --------------------- + Initialization steps: o Initialize the camera using the BSP_CAMERA_Init() function. o Start the camera capture/snapshot using the CAMERA_Start() function. o Suspend, resume or stop the camera capture using the following functions: - BSP_CAMERA_Suspend() - BSP_CAMERA_Resume() - BSP_CAMERA_Stop() + Options o Increase or decrease on the fly the brightness and/or contrast using the following function: - BSP_CAMERA_ContrastBrightnessConfig o Add a special effect on the fly using the following functions: - BSP_CAMERA_BlackWhiteConfig() - BSP_CAMERA_ColorEffectConfig() ------------------------------------------------------------------------------*//* ... */ /* Includes ------------------------------------------------------------------*/ #include "stm32446e_eval_camera.h" /** @addtogroup BSP * @{ *//* ... */ /** @addtogroup STM32446E_EVAL * @{ *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA STM32446E EVAL CAMERA * @{ *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA_Private_TypesDefinitions STM32446E EVAL CAMERA Private TypesDefinitions * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA_Private_Defines STM32446E EVAL CAMERA Private Defines * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA_Private_Macros STM32446E EVAL CAMERA Private Macros * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA_Private_Variables STM32446E EVAL CAMERA Private Variables * @{ *//* ... */ /* Note: camera_drv variable is not compliant to naming rules (upper case without "_" ), but we keep this naming for compatibility, in fact these variables (not static) could have been used by the application, example the stm32f4xx_it.c. *//* ... */ CAMERA_DrvTypeDef *camera_drv; static DCMI_HandleTypeDef hDcmiEval; uint32_t currentResolution; static uint32_t cameraHwAddress; /** * @} *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA_Private_FunctionPrototypes STM32446E EVAL CAMERA Private FunctionPrototypes * @{ *//* ... */ static uint32_t GetSize(uint32_t Resolution); /** * @} *//* ... */ /** @defgroup STM32446E_EVAL_CAMERA_Private_Functions STM32446E EVAL CAMERA Private Functions * @{ *//* ... */ /** * @brief Initializes the camera. * @param Resolution: camera resolution * @retval Camera status *//* ... */ uint8_t BSP_CAMERA_Init(uint32_t Resolution) { DCMI_HandleTypeDef *phdcmi; uint8_t ret = CAMERA_ERROR; /* Get the DCMI handle structure */ phdcmi = &hDcmiEval; /*** Configures the DCMI to interface with the camera module ***/ /* DCMI configuration */ phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_HIGH; phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH; phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; phdcmi->Init.ByteSelectMode = DCMI_BSM_ALL; phdcmi->Init.ByteSelectStart = DCMI_OEBS_ODD; phdcmi->Init.LineSelectMode = DCMI_LSM_ALL; phdcmi->Init.LineSelectStart = DCMI_OELS_ODD; phdcmi->Instance = DCMI; /* Configure IO functionalities for CAMERA detect pin */ BSP_IO_Init(); /* Apply Camera hardware reset */ BSP_CAMERA_HwReset(); /* Check if the CAMERA is plugged */ if(BSP_IO_ReadPin(CAM_PLUG_PIN)) { return CAMERA_ERROR; }if (BSP_IO_ReadPin(CAM_PLUG_PIN)) { ... } if (s5k5cag_ReadID(CAMERA_I2C_ADDRESS) == S5K5CAG_ID) { /* Initialize the camera driver structure */ camera_drv = &s5k5cag_drv; cameraHwAddress = CAMERA_I2C_ADDRESS; /* DCMI Initialization */ BSP_CAMERA_MspInit(&hDcmiEval, NULL); HAL_DCMI_Init(phdcmi); /* Camera Init */ camera_drv->Init(cameraHwAddress, Resolution); currentResolution = Resolution; /* Return CAMERA_OK status */ ret = CAMERA_OK; }if (s5k5cag_ReadID(CAMERA_I2C_ADDRESS) == S5K5CAG_ID) { ... } else if(ov5640_ReadID(CAMERA_I2C_ADDRESS_2) == OV5640_ID) { /* Initialize the camera driver structure */ camera_drv = &ov5640_drv; cameraHwAddress = CAMERA_I2C_ADDRESS_2; /* DCMI Initialization */ BSP_CAMERA_MspInit(&hDcmiEval, NULL); HAL_DCMI_Init(phdcmi); /* Camera Module Initialization via I2C to the wanted 'Resolution' */ camera_drv->Init(cameraHwAddress, Resolution); currentResolution = Resolution; /* Return CAMERA_OK status */ ret = CAMERA_OK; }else if (ov5640_ReadID(CAMERA_I2C_ADDRESS_2) == OV5640_ID) { ... } else { /* No supported camera sensor found */ ret = CAMERA_ERROR; }else { ... } return ret; }{ ... } /** * @brief DeInitializes the camera. * @retval Camera status *//* ... */ uint8_t BSP_CAMERA_DeInit(void) { hDcmiEval.Instance = DCMI; HAL_DCMI_DeInit(&hDcmiEval); BSP_CAMERA_MspDeInit(&hDcmiEval, NULL); return CAMERA_OK; }{ ... } /** * @brief Starts the camera capture in continuous mode. * @param buff: pointer to the camera output buffer *//* ... */ void BSP_CAMERA_ContinuousStart(uint8_t *buff) { /* Start the camera capture */ HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(currentResolution)); }{ ... } /** * @brief Starts the camera capture in snapshot mode. * @param buff: pointer to the camera output buffer *//* ... */ void BSP_CAMERA_SnapshotStart(uint8_t *buff) { /* Start the camera capture */ HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(currentResolution)); }{ ... } /** * @brief Suspend the CAMERA capture *//* ... */ void BSP_CAMERA_Suspend(void) { /* Suspend the Camera Capture */ HAL_DCMI_Suspend(&hDcmiEval); }{ ... } /** * @brief Resume the CAMERA capture *//* ... */ void BSP_CAMERA_Resume(void) { /* Start the Camera Capture */ HAL_DCMI_Resume(&hDcmiEval); }{ ... } /** * @brief Stop the CAMERA capture * @retval Camera status *//* ... */ uint8_t BSP_CAMERA_Stop(void) { DCMI_HandleTypeDef *phdcmi; uint8_t ret = CAMERA_ERROR; /* Get the DCMI handle structure */ phdcmi = &hDcmiEval; if(HAL_DCMI_Stop(phdcmi) == HAL_OK) { ret = CAMERA_OK; }if (HAL_DCMI_Stop(phdcmi) == HAL_OK) { ... } /* Set Camera in Power Down */ BSP_CAMERA_PwrDown(); return ret; }{ ... } /** * @brief CAMERA hardware reset *//* ... */ void BSP_CAMERA_HwReset(void) { /* Camera sensor RESET sequence */ BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); /* Assert the camera STANDBY pin (active high) */ BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_SET); /* Assert the camera RSTI pin (active low) */ BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); HAL_Delay(100); /* RST and XSDN signals asserted during 100ms */ /* De-assert the camera STANDBY pin (active high) */ BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); HAL_Delay(3); /* RST de-asserted and XSDN asserted during 3ms */ /* De-assert the camera RSTI pin (active low) */ BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_SET); HAL_Delay(6); /* RST de-asserted during 3ms */ }{ ... } /** * @brief CAMERA power down *//* ... */ void BSP_CAMERA_PwrDown(void) { /* Camera power down sequence */ BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT); BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT); /* De-assert the camera STANDBY pin (active high) */ BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET); /* Assert the camera RSTI pin (active low) */ BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET); }{ ... } /** * @brief Configures the camera contrast and brightness. * @param contrast_level: Contrast level * This parameter can be one of the following values: * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 * @param brightness_level: Contrast level * This parameter can be one of the following values: * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 *//* ... */ void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) { if(camera_drv->Config != NULL) { camera_drv->Config(cameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); }if (camera_drv->Config != NULL) { ... } }{ ... } /** * @brief Configures the camera white balance. * @param Mode: black_white mode * This parameter can be one of the following values: * @arg CAMERA_BLACK_WHITE_BW * @arg CAMERA_BLACK_WHITE_NEGATIVE * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE * @arg CAMERA_BLACK_WHITE_NORMAL *//* ... */ void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) { if(camera_drv->Config != NULL) { camera_drv->Config(cameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0); }if (camera_drv->Config != NULL) { ... } }{ ... } /** * @brief Configures the camera color effect. * @param Effect: Color effect * This parameter can be one of the following values: * @arg CAMERA_COLOR_EFFECT_ANTIQUE * @arg CAMERA_COLOR_EFFECT_BLUE * @arg CAMERA_COLOR_EFFECT_GREEN * @arg CAMERA_COLOR_EFFECT_RED *//* ... */ void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) { if(camera_drv->Config != NULL) { camera_drv->Config(cameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0); }if (camera_drv->Config != NULL) { ... } }{ ... } /** * @brief Handles DCMI interrupt request. *//* ... */ void BSP_CAMERA_IRQHandler(void) { HAL_DCMI_IRQHandler(&hDcmiEval); }{ ... } /** * @brief Handles DMA interrupt request. *//* ... */ void BSP_CAMERA_DMA_IRQHandler(void) { HAL_DMA_IRQHandler(hDcmiEval.DMA_Handle); }{ ... } /** * @brief Get the capture size. * @param Resolution: the current resolution. * @retval capture size. *//* ... */ static uint32_t GetSize(uint32_t Resolution) { uint32_t size = 0; /* Get capture size */ switch (Resolution) { case CAMERA_R160x120: { size = 0x2580; ...} break; case CAMERA_R160x120: case CAMERA_R320x240: { size = 0x9600; ...} break;case CAMERA_R320x240: case CAMERA_R480x272: { size = 0xFF00; ...} break;case CAMERA_R480x272: case CAMERA_R640x480: { size = 0x25800; ...} break;case CAMERA_R640x480: default: { break; ...}default }switch (Resolution) { ... } return size; }{ ... } /** * @brief Initializes the DCMI MSP. * @param hdcmi: HDMI handle * @param Params: pointer on additional configuration parameters, can be NULL. *//* ... */ __weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params) { static DMA_HandleTypeDef hdma_eval; GPIO_InitTypeDef gpio_init_structure; /*** Enable peripherals and GPIO clocks ***/ /* Enable DCMI clock */ __HAL_RCC_DCMI_CLK_ENABLE(); /* Enable DMA2 clock */ __HAL_RCC_DMA2_CLK_ENABLE(); /* Enable GPIO clocks */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); /*** Configure the GPIO ***/ /* Configure DCMI GPIO as alternate function */ gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6; gpio_init_structure.Mode = GPIO_MODE_AF_PP; gpio_init_structure.Pull = GPIO_PULLUP; gpio_init_structure.Speed = GPIO_SPEED_HIGH; gpio_init_structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOA, &gpio_init_structure); #if !defined(USE_STM32446E_EVAL_REVA) gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9; #else gpio_init_structure.Pin = GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9; #endif // !USE_STM32446E_EVAL_REVA gpio_init_structure.Mode = GPIO_MODE_AF_PP; gpio_init_structure.Pull = GPIO_PULLUP; gpio_init_structure.Speed = GPIO_SPEED_HIGH; gpio_init_structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOB, &gpio_init_structure); gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |\ GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ GPIO_PIN_12; gpio_init_structure.Mode = GPIO_MODE_AF_PP; gpio_init_structure.Pull = GPIO_PULLUP; gpio_init_structure.Speed = GPIO_SPEED_HIGH; gpio_init_structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOC, &gpio_init_structure); #if !defined(USE_STM32446E_EVAL_REVA) gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_6; #else gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6; #endif // !USE_STM32446E_EVAL_REVA gpio_init_structure.Mode = GPIO_MODE_AF_PP; gpio_init_structure.Pull = GPIO_PULLUP; gpio_init_structure.Speed = GPIO_SPEED_HIGH; gpio_init_structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOD, &gpio_init_structure); /*** Configure the DMA ***/ /* Set the parameters to be configured */ hdma_eval.Init.Channel = DMA_CHANNEL_1; hdma_eval.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_eval.Init.PeriphInc = DMA_PINC_DISABLE; hdma_eval.Init.MemInc = DMA_MINC_ENABLE; hdma_eval.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_eval.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma_eval.Init.Mode = DMA_CIRCULAR; hdma_eval.Init.Priority = DMA_PRIORITY_HIGH; hdma_eval.Init.FIFOMode = DMA_FIFOMODE_DISABLE; hdma_eval.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma_eval.Init.MemBurst = DMA_MBURST_SINGLE; hdma_eval.Init.PeriphBurst = DMA_PBURST_SINGLE; hdma_eval.Instance = DMA2_Stream1; /* Associate the initialized DMA handle to the DCMI handle */ __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_eval); /*** Configure the NVIC for DCMI and DMA ***/ /* NVIC configuration for DCMI transfer complete interrupt */ HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DCMI_IRQn); /* NVIC configuration for DMA2D transfer complete interrupt */ HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); /* Configure the DMA stream */ HAL_DMA_Init(hdcmi->DMA_Handle); }{ ... } /** * @brief DeInitializes the DCMI MSP. * @param hdcmi: HDMI handle * @param Params: pointer on additional configuration parameters, can be NULL. *//* ... */ __weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params) { /* Disable NVIC for DCMI transfer complete interrupt */ HAL_NVIC_DisableIRQ(DCMI_IRQn); /* Disable NVIC for DMA2 transfer complete interrupt */ HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); /* Configure the DMA stream */ HAL_DMA_DeInit(hdcmi->DMA_Handle); /* Disable DCMI clock */ __HAL_RCC_DCMI_CLK_DISABLE(); /* GPIO pins clock and DMA clock can be shut down in the application by surcharging this __weak function *//* ... */ }{ ... } /** * @brief Line event callback * @param hdcmi: pointer to the DCMI handle *//* ... */ void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) { BSP_CAMERA_LineEventCallback(); }{ ... } /** * @brief Line Event callback. *//* ... */ __weak void BSP_CAMERA_LineEventCallback(void) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_DCMI_LineEventCallback could be implemented in the user file *//* ... */ }{ ... } /** * @brief VSYNC event callback * @param hdcmi: pointer to the DCMI handle *//* ... */ void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) { BSP_CAMERA_VsyncEventCallback(); }{ ... } /** * @brief VSYNC Event callback. *//* ... */ __weak void BSP_CAMERA_VsyncEventCallback(void) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_DCMI_VsyncEventCallback could be implemented in the user file *//* ... */ }{ ... } /** * @brief Frame event callback * @param hdcmi: pointer to the DCMI handle *//* ... */ void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) { BSP_CAMERA_FrameEventCallback(); }{ ... } /** * @brief Frame Event callback. *//* ... */ __weak void BSP_CAMERA_FrameEventCallback(void) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_DCMI_FrameEventCallback could be implemented in the user file *//* ... */ }{ ... } /** * @brief Error callback * @param hdcmi: pointer to the DCMI handle *//* ... */ void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) { BSP_CAMERA_ErrorCallback(); }{ ... } /** * @brief Error callback. *//* ... */ __weak void BSP_CAMERA_ErrorCallback(void) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_DCMI_ErrorCallback could be implemented in the user file *//* ... */ }{ ... } /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.