OV9655 camera on the PC UVC suddenly does not display

Post here first, or if you can't find a relevant section!
Post Reply
jacobli
Posts: 42
Joined: Fri Jun 11, 2021 3:40 am

OV9655 camera on the PC UVC suddenly does not display

Post by jacobli »

Stm32f746g-Disco development board connected to OV9655 camera on the PC UVC suddenly does not display what is the reason?

1. My environment
-Stm32f746g-Disco development board connected to OV9655 camera
-usb connection cable connected to Windows PC
-Stm32f746g-Disco development board connected to OV9655 camera
-St_link connects another usb cable to PC
1590894980_761603.jpg
1590894980_761603.jpg (65.55 KiB) Viewed 1750 times
2. Normal display UVC code as follows

Code: Select all

#include "main.h"
#include "usb_device.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32746g_discovery.h"
#include "stm32746g_discovery_camera.h"
#include "camera.h"
#include "stm32746g_discovery_sdram.h"
#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal_conf.h"

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

const unsigned char OV9655_YUV_QVGA[][2]= {
{ 0x12, 0x80 },
{ 0x00, 0x00 },
{ 0x01, 0x80 },
{ 0x02, 0x80 },
{ 0x03, 0x02 },
{ 0x04, 0x03 },
{ 0x0e, 0x61 },
{ 0x0f, 0x42 },
{ 0x11, 0x01 },
{ 0x12, 0x62 },
{ 0x13, 0xe7 },
{ 0x14, 0x3a },
{ 0x16, 0x24 },
{ 0x17, 0x18 },
{ 0x18, 0x04 },
{ 0x19, 0x01 },
{ 0x1a, 0x81 },
{ 0x1e, 0x04 },
{ 0x24, 0x3c },
{ 0x25, 0x36 },
{ 0x26, 0x72 },
{ 0x27, 0x08 },
{ 0x28, 0x08 },
{ 0x29, 0x15 },
{ 0x2a, 0x00 },
{ 0x2b, 0x00 },
{ 0x2c, 0x08 },
{ 0x32, 0x24 },
{ 0x33, 0x00 },
{ 0x34, 0x3f },
{ 0x35, 0x00 },
{ 0x36, 0x3a },
{ 0x38, 0x72 },
{ 0x39, 0x57 },
{ 0x3a, 0x04 }, // No delay this affect the YUYV Sequence
{ 0x3b, 0x04 },
{ 0x3d, 0x99 },
{ 0x3e, 0x0e },
{ 0x3f, 0xc1 },
{ 0x40, 0xc0 },
{ 0x41, 0x01 },
{ 0x42, 0xc0 },
{ 0x43, 0x0a },
{ 0x44, 0xf0 },
{ 0x45, 0x46 },
{ 0x46, 0x62 },
{ 0x47, 0x2a },
{ 0x48, 0x3c },
{ 0x4a, 0xfc },
{ 0x4b, 0xfc },
{ 0x4c, 0x7f },
{ 0x4d, 0x7f },
{ 0x4e, 0x7f },
{ 0x52, 0x28 },
{ 0x53, 0x88 },
{ 0x54, 0xb0 },
{ 0x4f, 0x98 },
{ 0x50, 0x98 },
{ 0x51, 0x00 },
{ 0x58, 0x1a },
{ 0x59, 0x85 },
{ 0x5a, 0xa9 },
{ 0x5b, 0x64 },
{ 0x5c, 0x84 },
{ 0x5d, 0x53 },
{ 0x5e, 0x0e },
{ 0x5f, 0xf0 },
{ 0x60, 0xf0 },
{ 0x61, 0xf0 },
{ 0x62, 0x00 },
{ 0x63, 0x00 },
{ 0x64, 0x02 },
{ 0x65, 0x20 },
{ 0x66, 0x00 },
{ 0x69, 0x0a },
{ 0x6b, 0x5a },
// { 0x6b, 0x4a }, // use internal regulator
{ 0x6c, 0x04 },
{ 0x6d, 0x55 },
{ 0x6e, 0x00 },
{ 0x6f, 0x9d },
{ 0x70, 0x21 },
{ 0x71, 0x78 },
{ 0x72, 0x11 },
{ 0x73, 0x01 },
{ 0x74, 0x10 },
{ 0x75, 0x10 },
{ 0x76, 0x01 },
{ 0x77, 0x02 },
{ 0x7a, 0x12 },
{ 0x7b, 0x08 },
{ 0x7c, 0x15 },
{ 0x7d, 0x24 },
{ 0x7e, 0x45 },
{ 0x7f, 0x55 },
{ 0x80, 0x6a },
{ 0x81, 0x78 },
{ 0x82, 0x87 },
{ 0x83, 0x96 },
{ 0x84, 0xa3 },
{ 0x85, 0xb4 },
{ 0x86, 0xc3 },
{ 0x87, 0xd6 },
{ 0x88, 0xe6 },
{ 0x89, 0xf2 },
{ 0x8a, 0x24 },
{ 0x8c, 0x80 },
{ 0x90, 0x7d },
{ 0x91, 0x7b },
{ 0x9d, 0x02 },
{ 0x9e, 0x02 },
{ 0x9f, 0x7a },
{ 0xa0, 0x79 },
{ 0xa1, 0x40 },
{ 0xa4, 0x50 },
{ 0xa5, 0x68 },
{ 0xa6, 0x4a },
{ 0xa8, 0xc1 },
{ 0xa9, 0xef },
{ 0xaa, 0x92 },
{ 0xab, 0x04 },
{ 0xac, 0x80 },
{ 0xad, 0x80 },
{ 0xae, 0x80 },
{ 0xaf, 0x80 },
{ 0xb2, 0xf2 },
{ 0xb3, 0x20 },
{ 0xb4, 0x20 },
{ 0xb5, 0x00 },
{ 0xb6, 0xaf },
{ 0xbb, 0xae },
{ 0xbc, 0x7f },
{ 0xbd, 0x7f },
{ 0xbe, 0x7f },
{ 0xbf, 0x7f },
{ 0xc0, 0xaa },
{ 0xc1, 0xc0 },
{ 0xc2, 0x01 },
{ 0xc3, 0x4e },
{ 0xc6, 0x05 },
{ 0xc7, 0x81 },
{ 0xc9, 0xe0 },
{ 0xca, 0xe8 },
{ 0xcb, 0xf0 },
{ 0xcc, 0xd8 },
{ 0xcd, 0x93 },
{ 0xcd, 0x93 },
{ 0xFF, 0xFF }
};
const unsigned char ov9655_yuv_vga[][2]= {

{ 0x12, 0x80 },
{ 0x00, 0x00 },
{ 0x01, 0x80 },
{ 0x02, 0x80 },
{ 0x03, 0x12 },
{ 0x04, 0x03 },
{ 0x0e, 0x61 },
{ 0x0f, 0x42 },
{ 0x11, 0x01 },
 
{ 0x12, 0x62 }, // YUV 30fps 0x62>>0x63
{ 0x13, 0xe7 },
{ 0x14, 0x1a },
{ 0x16, 0x24 },
{ 0x17, 0x16 },
{ 0x18, 0x02 },
{ 0x19, 0x01 },
{ 0x1a, 0x3d },
 
{ 0x1e, 0x04 },
{ 0x24, 0x3c },
{ 0x25, 0x36 },
{ 0x26, 0x72 },
{ 0x27, 0x08 },
 
{ 0x28, 0x08 },
{ 0x29, 0x15 },
{ 0x2a, 0x00 },
{ 0x2b, 0x00 },
{ 0x2c, 0x08 },
{ 0x32, 0xff },
{ 0x33, 0x00 },
{ 0x34, 0x3F },
 
{ 0x35, 0x00 },
{ 0x36, 0xfa },
{ 0x38, 0x72 },
{ 0x39, 0x57 },
{ 0x3a, 0x04 },  // No delay 0x04 >>
 
{ 0x3b, 0x04 },
{ 0x3d, 0x99 },
{ 0x3e, 0x0c },
{ 0x3f, 0xc1 },
{ 0x40, 0xc0 },
{ 0x41, 0x00 },
{ 0x42, 0xc0 },
{ 0x43, 0x0a },
{ 0x44, 0xf0 },
{ 0x45, 0x46 },
{ 0x46, 0x62 },
{ 0x47, 0x2a },
{ 0x48, 0x3c },
{ 0x4a, 0xfc },
{ 0x4b, 0xfc },
{ 0x4c, 0x7f },
{ 0x4d, 0x7f },
{ 0x4e, 0x7f },
 
{ 0x52, 0x28 },
{ 0x53, 0x88 },
{ 0x54, 0xb0 },
{ 0x4f, 0x98 },
{ 0x50, 0x98 },
{ 0x51, 0x0  },
{ 0x58, 0x1a },
 
{ 0x59, 0x85 },
{ 0x5a, 0xa9 },
{ 0x5b, 0x64 },
{ 0x5c, 0x84 },
{ 0x5d, 0x53 },
{ 0x5e, 0x0e },
{ 0x5f, 0xf0 },
{ 0x60, 0xf0 },
{ 0x61, 0xf0 },
{ 0x62, 0x00 },
{ 0x63, 0x00 },
{ 0x64, 0x02 },
{ 0x65, 0x20 },
{ 0x66, 0x00 },
{ 0x69, 0x0a },
{ 0x6b, 0x5a }, //bypass internal regulator
// { 0x6b, 0x4a }, // use internal regulator
{ 0x6c, 0x04 },
{ 0x6d, 0x55 },
{ 0x6e, 0x00 },
{ 0x6f, 0x9d },
{ 0x70, 0x21 },
{ 0x71, 0x78 },
{ 0x72, 0x00 },
{ 0x73, 0x00 },
{ 0x74, 0x3a },
{ 0x75, 0x35 },
{ 0x76, 0x01 },
{ 0x77, 0x02 },

{ 0x7a, 0x12 },
{ 0x7b, 0x08 },
{ 0x7c, 0x15 },
{ 0x7d, 0x24 },
{ 0x7e, 0x45 },
{ 0x7f, 0x55 },
{ 0x80, 0x6a },
{ 0x81, 0x78 },
{ 0x82, 0x87 },
{ 0x83, 0x96 },
{ 0x84, 0xa3 },
{ 0x85, 0xb4 },
{ 0x86, 0xc3 },
{ 0x87, 0xd6 },
{ 0x88, 0xe6 },
{ 0x89, 0xf2 },
 
{ 0x8c, 0x8d },
{ 0x90, 0x7d },
{ 0x91, 0x7b },
{ 0x9d, 0x02 },
{ 0x9e, 0x02 },
{ 0x9f, 0x7a },
{ 0xa0, 0x79 },
{ 0xa1, 0x40 },
{ 0xa4, 0x50 },
{ 0xa5, 0x68 },
{ 0xa6, 0x4a },
{ 0xa8, 0xc1 },
{ 0xa9, 0xef },
{ 0xaa, 0x92 },
{ 0xab, 0x04 },
{ 0xac, 0x80 },
{ 0xad, 0x80 },
{ 0xae, 0x80 },
{ 0xaf, 0x80 },
{ 0xb2, 0xf2 },
{ 0xb3, 0x20 },
{ 0xb4, 0x20 },
{ 0xb5, 0x00 },
{ 0xb6, 0xaf },
{ 0xbb, 0xae },
{ 0xbc, 0x7f },
{ 0xbd, 0x7f },
{ 0xbe, 0x7f },
{ 0xbf, 0x7f },
{ 0xc0, 0xaa },
{ 0xc1, 0xc0 },
{ 0xc2, 0x01 },
{ 0xc3, 0x4e },
{ 0xc6, 0x05 },
{ 0xc7, 0x80 },
{ 0xc9, 0xe0 },
{ 0xca, 0xe8 },
{ 0xcb, 0xf0 },
{ 0xcc, 0xd8 },
{ 0xcd, 0x93 },
{ 0xcd, 0x93 },
{ 0xFF, 0xFF }
};

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

//CRC_HandleTypeDef hcrc;

DCMI_HandleTypeDef hdcmi;
DMA_HandleTypeDef hdma_dcmi;

//DMA2D_HandleTypeDef hdma2d;

I2C_HandleTypeDef hi2c1;
I2C_HandleTypeDef hi2c3;

SDRAM_HandleTypeDef hsdram1;

/* USER CODE BEGIN PV /
//uint16_t *pBuf= (uint16_t)0xC0000000;; // 480x272x2=261,120Byte
/*
typedef enum
{
CAMERA_OK = 0x00,
CAMERA_ERROR = 0x01,
CAMERA_TIMEOUT = 0x02,
CAMERA_NOT_DETECTED = 0x03,
CAMERA_NOT_SUPPORTED = 0x04
}Camera_StatusTypeDef;
*/
CAMERA_DrvTypeDef *camera_driv;

/* Camera module I2C HW address */
static uint32_t CameraHwAddress = CAMERA_I2C_ADDRESS;

/* Image size */
uint32_t Im_size = 0; //size=320*240*2/4

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_DCMI_Init(void);
static void MX_FMC_Init(void);
static void MX_I2C1_Init(void);
static void MX_I2C3_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint8_t CAMERA_Init(uint32_t);
void OV9655_YUV_Init(uint16_t);

/* USER CODE END 0 */

/**

@brief The application entry point.
@retval int
/
int main(void)
{
/ USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals /
MX_GPIO_Init();
MX_DMA_Init();
MX_DCMI_Init();
MX_FMC_Init();
MX_I2C1_Init();
MX_I2C3_Init();
MX_USB_DEVICE_Init();
/ USER CODE BEGIN 2 */

BSP_SDRAM_Init();

// Initialize the Camera
BSP_CAMERA_Init(CAMERA_R640x480);
OV9655_YUV_Init(CameraHwAddress);
HAL_Delay(1000);

// Start the Camera Capture
BSP_CAMERA_ContinuousStart((uint32_t *)FRAME_BUFFER);

/* USER CODE END 2 */

/* Infinite loop /
/ USER CODE BEGIN WHILE /
while (1)
{
/ USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

/**

@brief System Clock Configuration
@retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};

/** Configure LSE Drive Capability
/
HAL_PWR_EnableBkUpAccess();
/* Configure the main internal regulator output voltage
/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Initializes the CPU, AHB and APB busses clocks
/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 400;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/* Activate the Over-Drive mode
/
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
{
Error_Handler();
}
/* Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_I2C3;
PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
PeriphClkInitStruct.I2c3ClockSelection = RCC_I2C3CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
}

/**

@brief DCMI Initialization Function
@param None
@retval None
*/
static void MX_DCMI_Init(void)
{

/* USER CODE BEGIN DCMI_Init 0 */

/* USER CODE END DCMI_Init 0 */

/* USER CODE BEGIN DCMI_Init 1 */

/* USER CODE END DCMI_Init 1 /
hdcmi.Instance = DCMI;
hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING;
hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW;
hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
hdcmi.Init.LineSelectMode = DCMI_LSM_ALL;
hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
if (HAL_DCMI_Init(&hdcmi) != HAL_OK)
{
Error_Handler();
}
/ USER CODE BEGIN DCMI_Init 2 */

/* USER CODE END DCMI_Init 2 */

}

/**

@brief I2C1 Initialization Function
@param None
@retval None
*/
static void MX_I2C1_Init(void)
{

/* USER CODE BEGIN I2C1_Init 0 */

/* USER CODE END I2C1_Init 0 */

/* USER CODE BEGIN I2C1_Init 1 */

/* USER CODE END I2C1_Init 1 /
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x00C0EAFF;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
/* Configure Analogue filter
/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/* Configure Digital filter
/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
Error_Handler();
}
/ USER CODE BEGIN I2C1_Init 2 */

/* USER CODE END I2C1_Init 2 */

}

/**

@brief I2C3 Initialization Function
@param None
@retval None
*/
static void MX_I2C3_Init(void)
{

/* USER CODE BEGIN I2C3_Init 0 */

/* USER CODE END I2C3_Init 0 */

/* USER CODE BEGIN I2C3_Init 1 */

/* USER CODE END I2C3_Init 1 /
hi2c3.Instance = I2C3;
hi2c3.Init.Timing = 0x00C0EAFF;
hi2c3.Init.OwnAddress1 = 0;
hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c3.Init.OwnAddress2 = 0;
hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c3) != HAL_OK)
{
Error_Handler();
}
/* Configure Analogue filter
/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/* Configure Digital filter
/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
{
Error_Handler();
}
/ USER CODE BEGIN I2C3_Init 2 */

/* USER CODE END I2C3_Init 2 */

}

/**

Enable DMA controller clock
*/
static void MX_DMA_Init(void)
{

/* DMA controller clock enable */
__HAL_RCC_DMA2_CLK_ENABLE();

/* DMA interrupt init /
/ DMA2_Stream1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);

}

/* FMC initialization function */
static void MX_FMC_Init(void)
{

/* USER CODE BEGIN FMC_Init 0 */

/* USER CODE END FMC_Init 0 */

FMC_SDRAM_TimingTypeDef SdramTiming = {0};

/* USER CODE BEGIN FMC_Init 1 */

/* USER CODE END FMC_Init 1 */

/** Perform the SDRAM1 memory initialization sequence
/
hsdram1.Instance = FMC_SDRAM_DEVICE;
/ hsdram1.Init /
hsdram1.Init.SDBank = FMC_SDRAM_BANK1;
hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
/ SdramTiming */
SdramTiming.LoadToActiveDelay = 2;
SdramTiming.ExitSelfRefreshDelay = 7;
SdramTiming.SelfRefreshTime = 4;
SdramTiming.RowCycleDelay = 7;
SdramTiming.WriteRecoveryTime = 3;
SdramTiming.RPDelay = 2;
SdramTiming.RCDDelay = 2;

if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
{
Error_Handler( );
}

/* USER CODE BEGIN FMC_Init 2 */

/* USER CODE END FMC_Init 2 */
}

/**

@brief GPIO Initialization Function
@param None
@retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};

/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOJ_CLK_ENABLE();
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_GPIOK_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_13, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOI, ARDUINO_D7_Pin|ARDUINO_D8_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(DCMI_PWR_EN_GPIO_Port, DCMI_PWR_EN_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOG, ARDUINO_D2_Pin|EXT_RST_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin : LCD_B0_Pin */
GPIO_InitStruct.Pin = LCD_B0_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(LCD_B0_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : OTG_HS_OverCurrent_Pin */
GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : QSPI_D2_Pin */
GPIO_InitStruct.Pin = QSPI_D2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
HAL_GPIO_Init(QSPI_D2_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : RMII_TXD1_Pin RMII_TXD0_Pin RMII_TX_EN_Pin */
GPIO_InitStruct.Pin = RMII_TXD1_Pin|RMII_TXD0_Pin|RMII_TX_EN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_PWM_D3_Pin */
GPIO_InitStruct.Pin = ARDUINO_PWM_D3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
HAL_GPIO_Init(ARDUINO_PWM_D3_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : SPDIF_RX0_Pin */
GPIO_InitStruct.Pin = SPDIF_RX0_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF8_SPDIFRX;
HAL_GPIO_Init(SPDIF_RX0_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : SDMMC_CK_Pin SDMMC_D3_Pin SDMMC_D2_Pin PC9
PC8 */
GPIO_InitStruct.Pin = SDMMC_CK_Pin|SDMMC_D3_Pin|SDMMC_D2_Pin|GPIO_PIN_9
|GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_PWM_D9_Pin */
GPIO_InitStruct.Pin = ARDUINO_PWM_D9_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
HAL_GPIO_Init(ARDUINO_PWM_D9_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : VCP_RX_Pin */
GPIO_InitStruct.Pin = VCP_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(VCP_RX_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : QSPI_NCS_Pin */
GPIO_InitStruct.Pin = QSPI_NCS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
HAL_GPIO_Init(QSPI_NCS_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PJ13 */
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);

/*Configure GPIO pin : OTG_FS_VBUS_Pin */
GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : Audio_INT_Pin */
GPIO_InitStruct.Pin = Audio_INT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PA12 */
GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pins : SAI2_MCLKA_Pin SAI2_SCKA_Pin SAI2_FSA_Pin SAI2_SDA_Pin */
GPIO_InitStruct.Pin = SAI2_MCLKA_Pin|SAI2_SCKA_Pin|SAI2_FSA_Pin|SAI2_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF10_SAI2;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

/*Configure GPIO pins : LCD_DE_Pin LCD_B7_Pin LCD_B6_Pin LCD_B5_Pin
LCD_G6_Pin LCD_G7_Pin LCD_G5_Pin */
GPIO_InitStruct.Pin = LCD_DE_Pin|LCD_B7_Pin|LCD_B6_Pin|LCD_B5_Pin
|LCD_G6_Pin|LCD_G7_Pin|LCD_G5_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOK, &GPIO_InitStruct);

/*Configure GPIO pin : LCD_B4_Pin */
GPIO_InitStruct.Pin = LCD_B4_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF9_LTDC;
HAL_GPIO_Init(LCD_B4_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : SAI2_SDB_Pin */
GPIO_InitStruct.Pin = SAI2_SDB_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF10_SAI2;
HAL_GPIO_Init(SAI2_SDB_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : LCD_B2_Pin LCD_B3_Pin LCD_G4_Pin LCD_G1_Pin
LCD_G3_Pin LCD_G0_Pin LCD_G2_Pin LCD_R7_Pin
LCD_R5_Pin LCD_R6_Pin LCD_R4_Pin LCD_R3_Pin
LCD_R1_Pin LCD_R2_Pin */
GPIO_InitStruct.Pin = LCD_B2_Pin|LCD_B3_Pin|LCD_G4_Pin|LCD_G1_Pin
|LCD_G3_Pin|LCD_G0_Pin|LCD_G2_Pin|LCD_R7_Pin
|LCD_R5_Pin|LCD_R6_Pin|LCD_R4_Pin|LCD_R3_Pin
|LCD_R1_Pin|LCD_R2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);

/*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */
GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : ARDUINO_D7_Pin ARDUINO_D8_Pin LCD_DISP_Pin */
GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

/*Configure GPIO pins : OTG_FS_N_Pin OTG_FS_ID_Pin */
GPIO_InitStruct.Pin = OTG_FS_N_Pin|OTG_FS_ID_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pin : uSD_Detect_Pin */
GPIO_InitStruct.Pin = uSD_Detect_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(uSD_Detect_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : LCD_HSYNC_Pin LCD_VSYNC_Pin LCD_R0_Pin LCD_CLK_Pin */
GPIO_InitStruct.Pin = LCD_HSYNC_Pin|LCD_VSYNC_Pin|LCD_R0_Pin|LCD_CLK_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

/*Configure GPIO pin : LCD_BL_CTRL_Pin */
GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : OTG_FS_OverCurrent_Pin */
GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : SDMMC_CMD_Pin */
GPIO_InitStruct.Pin = SDMMC_CMD_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
HAL_GPIO_Init(SDMMC_CMD_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : TP3_Pin NC2_Pin */
GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_SCK_D13_Pin */
GPIO_InitStruct.Pin = ARDUINO_SCK_D13_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(ARDUINO_SCK_D13_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : DCMI_PWR_EN_Pin */
GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_PWM_CS_D5_Pin */
GPIO_InitStruct.Pin = ARDUINO_PWM_CS_D5_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
HAL_GPIO_Init(ARDUINO_PWM_CS_D5_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : VCP_TX_Pin */
GPIO_InitStruct.Pin = VCP_TX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(VCP_TX_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_PWM_D10_Pin */
GPIO_InitStruct.Pin = ARDUINO_PWM_D10_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(ARDUINO_PWM_D10_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : LCD_INT_Pin */
GPIO_InitStruct.Pin = LCD_INT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : ARDUINO_RX_D0_Pin ARDUINO_TX_D1_Pin */
GPIO_InitStruct.Pin = ARDUINO_RX_D0_Pin|ARDUINO_TX_D1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF8_USART6;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pins : ARDUINO_D2_Pin EXT_RST_Pin */
GPIO_InitStruct.Pin = ARDUINO_D2_Pin|EXT_RST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

/*Configure GPIO pins : ARDUINO_A4_Pin ARDUINO_A5_Pin ARDUINO_A1_Pin ARDUINO_A2_Pin
ARDUINO_A3_Pin */
GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin
|ARDUINO_A3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

/*Configure GPIO pins : RMII_MDC_Pin RMII_RXD0_Pin RMII_RXD1_Pin */
GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pin : PB2 */
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/*Configure GPIO pins : QSPI_D1_Pin QSPI_D3_Pin QSPI_D0_Pin */
GPIO_InitStruct.Pin = QSPI_D1_Pin|QSPI_D3_Pin|QSPI_D0_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

/*Configure GPIO pin : RMII_RXER_Pin */
GPIO_InitStruct.Pin = RMII_RXER_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : RMII_REF_CLK_Pin RMII_MDIO_Pin RMII_CRS_DV_Pin */
GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_A0_Pin */
GPIO_InitStruct.Pin = ARDUINO_A0_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(ARDUINO_A0_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : ARDUINO_PWM_D6_Pin */
GPIO_InitStruct.Pin = ARDUINO_PWM_D6_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF9_TIM12;
HAL_GPIO_Init(ARDUINO_PWM_D6_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : ARDUINO_MISO_D12_Pin ARDUINO_MOSI_PWM_D11_Pin */
GPIO_InitStruct.Pin = ARDUINO_MISO_D12_Pin|ARDUINO_MOSI_PWM_D11_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */
void OV9655_YUV_Init(uint16_t DeviceAddr)
{
uint32_t index;
for(index=0; index<(sizeof(ov9655_yuv_vga)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, ov9655_yuv_vga[index][0],ov9655_yuv_vga[index][1]);
CAMERA_Delay(1);
}
}

/* USER CODE END 4 */

/**

@brief Period elapsed callback in non blocking mode
@note This function is called when TIM6 interrupt took place, inside
HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
a global variable "uwTick" used as application time base.
@param htim : TIM handle
@retval None
/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/ USER CODE BEGIN Callback 0 */

/* USER CODE END Callback 0 /
if (htim->Instance == TIM6) {
HAL_IncTick();
}
/ USER CODE BEGIN Callback 1 */

/* USER CODE END Callback 1 */
}

/**

@brief This function is executed in case of error occurrence.
@retval None
/
void Error_Handler(void)
{
/ USER CODE BEGIN Error_Handler_Debug /
/ User can add his own implementation to report the HAL error return state */

/* USER CODE END Error_Handler_Debug */
}

#ifdef USE_FULL_ASSERT
/**

@brief Reports the name of the source file and the source line number
where the assert_param error has occurred.
@param file: pointer to the source file name
@param line: assert_param error line source number
@retval None / void assert_failed(uint8_t *file, uint32_t line) { / USER CODE BEGIN 6 / / User can add his own implementation to report the file name and line number, tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) / / USER CODE END 6 / } #endif / USE_FULL_ASSERT */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Post Reply

Return to “General discussion”