Skip to content

Commit feccca1

Browse files
authored
Allow Camera capture for PortentaM4 Core (#512)
1 parent 5ff5c73 commit feccca1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

libraries/Camera/src/camera.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define ALIGN_PTR(p,a) ((p & (a-1)) ?(((uintptr_t)p + a) & ~(uintptr_t)(a-1)) : p)
2929

3030
// Include all image sensor drivers here.
31-
#ifdef ARDUINO_PORTENTA_H7_M7
31+
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
3232

3333
#define DCMI_TIM (TIM1)
3434
#define DCMI_TIM_PIN (GPIO_PIN_1)
@@ -65,7 +65,7 @@ arduino::MbedI2C CameraWire(I2C_SDA2, I2C_SCL2);
6565

6666
// DCMI GPIO pins struct
6767
static const struct { GPIO_TypeDef *port; uint16_t pin; } dcmi_pins[] = {
68-
#ifdef ARDUINO_PORTENTA_H7_M7
68+
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
6969
{GPIOA, GPIO_PIN_4 },
7070
{GPIOA, GPIO_PIN_6 },
7171
{GPIOI, GPIO_PIN_4 },
@@ -146,7 +146,7 @@ void HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi)
146146
hgpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
147147
hgpio.Alternate = GPIO_AF13_DCMI;
148148

149-
#ifdef ARDUINO_PORTENTA_H7_M7
149+
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
150150
/* Enable GPIO clocks */
151151
__HAL_RCC_GPIOA_CLK_ENABLE();
152152
__HAL_RCC_GPIOH_CLK_ENABLE();
@@ -365,7 +365,7 @@ Camera::Camera(ImageSensor &sensor) :
365365

366366
int Camera::reset()
367367
{
368-
#ifdef ARDUINO_PORTENTA_H7_M7
368+
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
369369
// Reset sensor.
370370
digitalWrite(PC_13, LOW);
371371
HAL_Delay(10);
@@ -605,9 +605,10 @@ int Camera::grabFrame(FrameBuffer &fb, uint32_t timeout)
605605

606606
HAL_DCMI_Suspend(&hdcmi);
607607

608-
// Invalidate buffer after DMA transfer.
609-
SCB_InvalidateDCache_by_Addr((uint32_t*) framebuffer, framesize);
610-
608+
#if defined(__CORTEX_M7) // only invalidate buffer for Cortex M7
609+
// Invalidate buffer after DMA transfer.
610+
SCB_InvalidateDCache_by_Addr((uint32_t*) framebuffer, framesize);
611+
#endif
611612
return 0;
612613
}
613614

0 commit comments

Comments
 (0)