/** ****************************************************************************** * File Name : OCTOSPI.c * Description : This file provides code for the configuration * of the OCTOSPI instances. ****************************************************************************** * @attention * *

© Copyright (c) 2020 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "octospi.h" /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ OSPI_HandleTypeDef hospi1; /* OCTOSPI1 init function */ void MX_OCTOSPI1_Init(void) { hospi1.Instance = OCTOSPI1; hospi1.Init.FifoThreshold = 1; hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE; hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MICRON; hospi1.Init.DeviceSize = 32; hospi1.Init.ChipSelectHighTime = 1; hospi1.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE; hospi1.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0; hospi1.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED; hospi1.Init.ClockPrescaler = 1; hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE; hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE; hospi1.Init.ChipSelectBoundary = 0; hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_BYPASSED; hospi1.Init.Refresh = 0; if (HAL_OSPI_Init(&hospi1) != HAL_OK) { Error_Handler(); } } void HAL_OSPI_MspInit(OSPI_HandleTypeDef* ospiHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(ospiHandle->Instance==OCTOSPI1) { /* USER CODE BEGIN OCTOSPI1_MspInit 0 */ /* USER CODE END OCTOSPI1_MspInit 0 */ /** Initializes the peripherals clock */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_OSPI; PeriphClkInit.OspiClockSelection = RCC_OSPICLKSOURCE_SYSCLK; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } /* OCTOSPI1 clock enable */ __HAL_RCC_OSPI1_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**OCTOSPI1 GPIO Configuration PB0 ------> OCTOSPI1_IO1 PB1 ------> OCTOSPI1_IO0 PB10 ------> OCTOSPI1_CLK PB11 ------> OCTOSPI1_NCS */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11; 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_OCTOSPI1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* OCTOSPI1 interrupt Init */ HAL_NVIC_SetPriority(OCTOSPI1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(OCTOSPI1_IRQn); /* USER CODE BEGIN OCTOSPI1_MspInit 1 */ /* USER CODE END OCTOSPI1_MspInit 1 */ } } void HAL_OSPI_MspDeInit(OSPI_HandleTypeDef* ospiHandle) { if(ospiHandle->Instance==OCTOSPI1) { /* USER CODE BEGIN OCTOSPI1_MspDeInit 0 */ /* USER CODE END OCTOSPI1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_OSPI1_CLK_DISABLE(); /**OCTOSPI1 GPIO Configuration PB0 ------> OCTOSPI1_IO1 PB1 ------> OCTOSPI1_IO0 PB10 ------> OCTOSPI1_CLK PB11 ------> OCTOSPI1_NCS */ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11); /* OCTOSPI1 interrupt Deinit */ HAL_NVIC_DisableIRQ(OCTOSPI1_IRQn); /* USER CODE BEGIN OCTOSPI1_MspDeInit 1 */ /* USER CODE END OCTOSPI1_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/