Skip to content

PR: update camera.cpp for the PortentaM4 Core #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions libraries/Camera/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define ALIGN_PTR(p,a) ((p & (a-1)) ?(((uintptr_t)p + a) & ~(uintptr_t)(a-1)) : p)

// Include all image sensor drivers here.
#ifdef ARDUINO_PORTENTA_H7_M7
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)

#define DCMI_TIM (TIM1)
#define DCMI_TIM_PIN (GPIO_PIN_1)
Expand Down Expand Up @@ -65,7 +65,7 @@ arduino::MbedI2C CameraWire(I2C_SDA2, I2C_SCL2);

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

#ifdef ARDUINO_PORTENTA_H7_M7
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
/* Enable GPIO clocks */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
Expand Down Expand Up @@ -365,7 +365,7 @@ Camera::Camera(ImageSensor &sensor) :

int Camera::reset()
{
#ifdef ARDUINO_PORTENTA_H7_M7
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
// Reset sensor.
digitalWrite(PC_13, LOW);
HAL_Delay(10);
Expand Down Expand Up @@ -605,9 +605,10 @@ int Camera::grabFrame(FrameBuffer &fb, uint32_t timeout)

HAL_DCMI_Suspend(&hdcmi);

// Invalidate buffer after DMA transfer.
SCB_InvalidateDCache_by_Addr((uint32_t*) framebuffer, framesize);

#ifndef ARDUINO_PORTENTA_H7_M4 // do not invalidate if Portenta M4 Core
// Invalidate buffer after DMA transfer.
SCB_InvalidateDCache_by_Addr((uint32_t*) framebuffer, framesize);
#endif
return 0;
}

Expand Down