[platform][stm32f7xx][qspi] refactor clock/irq out of target
-Removes a call to QSPI_Deinit -Makes sure the target doesn't initialize the irq handler to a bad priority
This commit is contained in:
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <pow2.h>
|
#include <pow2.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -418,11 +440,12 @@ status_t qspi_flash_init(void)
|
|||||||
|
|
||||||
HAL_StatusTypeDef status;
|
HAL_StatusTypeDef status;
|
||||||
|
|
||||||
status = HAL_QSPI_DeInit(&qspi_handle);
|
// Enable the QuadSPI memory interface clock
|
||||||
if (status != HAL_OK) {
|
__HAL_RCC_QSPI_CLK_ENABLE();
|
||||||
result = hal_error_to_status(status);
|
|
||||||
goto err;
|
// Reset the QuadSPI memory interface
|
||||||
}
|
__HAL_RCC_QSPI_FORCE_RESET();
|
||||||
|
__HAL_RCC_QSPI_RELEASE_RESET();
|
||||||
|
|
||||||
// Setup the QSPI Flash device.
|
// Setup the QSPI Flash device.
|
||||||
qspi_handle.Init.ClockPrescaler = 1;
|
qspi_handle.Init.ClockPrescaler = 1;
|
||||||
@@ -440,6 +463,9 @@ status_t qspi_flash_init(void)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enable the qspi interrupt
|
||||||
|
NVIC_EnableIRQ(QUADSPI_IRQn);
|
||||||
|
|
||||||
result = qspi_reset_memory_unsafe(&qspi_handle);
|
result = qspi_reset_memory_unsafe(&qspi_handle);
|
||||||
if (result != NO_ERROR) {
|
if (result != NO_ERROR) {
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
@@ -291,11 +291,6 @@ void HAL_QSPI_MspInit(QSPI_HandleTypeDef *hqspi)
|
|||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
||||||
/* Enable the QuadSPI memory interface clock */
|
|
||||||
__HAL_RCC_QSPI_CLK_ENABLE();
|
|
||||||
/* Reset the QuadSPI memory interface */
|
|
||||||
__HAL_RCC_QSPI_FORCE_RESET();
|
|
||||||
__HAL_RCC_QSPI_RELEASE_RESET();
|
|
||||||
/* Enable GPIO clocks */
|
/* Enable GPIO clocks */
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||||
@@ -334,10 +329,5 @@ void HAL_QSPI_MspInit(QSPI_HandleTypeDef *hqspi)
|
|||||||
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
||||||
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*##-3- Configure the NVIC for QSPI #########################################*/
|
|
||||||
/* NVIC configuration for QSPI interrupt */
|
|
||||||
HAL_NVIC_SetPriority(QUADSPI_IRQn, 0x0F, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(QUADSPI_IRQn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,18 +191,10 @@ void HAL_QSPI_MspInit(QSPI_HandleTypeDef *hqspi)
|
|||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
||||||
/* Enable the QuadSPI memory interface clock */
|
|
||||||
__HAL_RCC_QSPI_CLK_ENABLE();
|
|
||||||
/* Reset the QuadSPI memory interface */
|
|
||||||
__HAL_RCC_QSPI_FORCE_RESET();
|
|
||||||
__HAL_RCC_QSPI_RELEASE_RESET();
|
|
||||||
/* Enable GPIO clocks */
|
/* Enable GPIO clocks */
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
||||||
|
|
||||||
/*##-2- Configure peripheral GPIO ##########################################*/
|
/*##-2- Configure peripheral GPIO ##########################################*/
|
||||||
/* QSPI CS GPIO pin configuration */
|
/* QSPI CS GPIO pin configuration */
|
||||||
@@ -238,9 +230,4 @@ void HAL_QSPI_MspInit(QSPI_HandleTypeDef *hqspi)
|
|||||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*##-3- Configure the NVIC for QSPI #########################################*/
|
|
||||||
/* NVIC configuration for QSPI interrupt */
|
|
||||||
HAL_NVIC_SetPriority(QUADSPI_IRQn, 0x0F, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(QUADSPI_IRQn);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user