@@ -12,6 +12,7 @@ static const int CamRes[][2] = {
12
12
{320 , 240 },
13
13
};
14
14
static __IO uint32_t camera_frame_ready = 0 ;
15
+ static md_callback_t user_md_callback = NULL ;
15
16
16
17
/* DCMI DMA Stream definitions */
17
18
#define CAMERA_DCMI_DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
@@ -349,8 +350,6 @@ static int extclk_config(int frequency)
349
350
*/
350
351
void BSP_CAMERA_PwrUp (void )
351
352
{
352
- GPIO_InitTypeDef gpio_init_structure;
353
-
354
353
mbed::DigitalOut* powerup = new mbed::DigitalOut (PC_13);
355
354
*powerup = 0 ;
356
355
delay (50 );
@@ -452,6 +451,13 @@ void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
452
451
453
452
}
454
453
454
+ void CameraClass::HIMAXIrqHandler ()
455
+ {
456
+ if (user_md_callback) {
457
+ user_md_callback ();
458
+ }
459
+ }
460
+
455
461
int CameraClass::begin (uint32_t resolution, uint32_t framerate)
456
462
{
457
463
if (resolution >= CAMERA_RMAX) {
@@ -477,6 +483,7 @@ int CameraClass::begin(uint32_t resolution, uint32_t framerate)
477
483
return -1 ;
478
484
}
479
485
486
+ user_md_callback = NULL ;
480
487
this ->initialized = true ;
481
488
this ->resolution = resolution;
482
489
return 0 ;
@@ -536,6 +543,74 @@ int CameraClass::standby(bool enable)
536
543
}
537
544
}
538
545
546
+ int CameraClass::setMDThreshold (uint32_t low, uint32_t high)
547
+ {
548
+ if (this ->initialized == false ) {
549
+ return -1 ;
550
+ }
551
+ return HIMAX_SetMDThreshold (low, high);
552
+ }
553
+
554
+ int CameraClass::setMDWindow (uint32_t x, uint32_t y, uint32_t w, uint32_t h)
555
+ {
556
+ uint32_t width, height;
557
+
558
+ if (this ->initialized == false ) {
559
+ return -1 ;
560
+ }
561
+
562
+ width = CamRes[this ->resolution ][0 ];
563
+ height= CamRes[this ->resolution ][1 ];
564
+
565
+ if (((x+w) > width) || ((y+h) > height)) {
566
+ return -1 ;
567
+ }
568
+ return HIMAX_SetLROI (x, y, x+w, y+h);
569
+ }
570
+
571
+ int CameraClass::enableMD (bool enable, md_callback_t callback)
572
+ {
573
+ if (this ->initialized == false ) {
574
+ return -1 ;
575
+ }
576
+
577
+ this ->md_irq .rise (0 );
578
+
579
+ if (enable == false ) {
580
+ user_md_callback = NULL ;
581
+ } else {
582
+ user_md_callback = callback;
583
+ this ->md_irq .rise (mbed::Callback<void ()>(this , &CameraClass::HIMAXIrqHandler));
584
+ this ->md_irq .enable_irq ();
585
+ }
586
+
587
+ return HIMAX_EnableMD (enable);
588
+ }
589
+
590
+ int CameraClass::pollMD ()
591
+ {
592
+ int ret = 0 ;
593
+
594
+ if (this ->initialized == false ) {
595
+ return -1 ;
596
+ }
597
+
598
+ ret = HIMAX_PollMD ();
599
+ if (ret == 1 ) {
600
+ HIMAX_ClearMD ();
601
+ }
602
+ return ret;
603
+ }
604
+
605
+ int CameraClass::clearMDFlag ()
606
+ {
607
+ if (this ->initialized == false ) {
608
+ return -1 ;
609
+ }
610
+
611
+ return HIMAX_ClearMD ();
612
+ }
613
+
539
614
int CameraClass::testPattern (bool walking)
540
615
{
541
616
if (this ->initialized == false ) {
0 commit comments