4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-28 05:17:05 +08:00

[bsp][gd32]fixed sf probe error

This commit is contained in:
JasonCang 2023-06-03 16:28:05 +08:00 committed by Man, Jianting (Meco)
parent bf07f4183e
commit 1c7e7738a7

View File

@ -6,6 +6,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2021-12-31 BruceOu first implementation * 2021-12-31 BruceOu first implementation
* 2023-06-03 CX fixed sf probe error bug
*/ */
#include <board.h> #include <board.h>
#include "drv_spi.h" #include "drv_spi.h"
@ -22,7 +23,8 @@
#define SPI_DEVICE_NAME "spi01" #define SPI_DEVICE_NAME "spi01"
#define SPI_FLASH_DEVICE_NAME "gd25q" #define SPI_FLASH_DEVICE_NAME "gd25q"
#define GD25Q_SPI_CS_GPIOX GPIOE #define GD25Q_SPI_CS_GPIOX_CLK RCU_GPIOE
#define GD25Q_SPI_CS_GPIOX GPIOE
#define GD25Q_SPI_CS_GPIOX_PIN_X GPIO_PIN_3 #define GD25Q_SPI_CS_GPIOX_PIN_X GPIO_PIN_3
static int rt_hw_spi_flash_init(void) static int rt_hw_spi_flash_init(void)
@ -33,6 +35,7 @@ static int rt_hw_spi_flash_init(void)
spi_cs.GPIOx = GD25Q_SPI_CS_GPIOX; spi_cs.GPIOx = GD25Q_SPI_CS_GPIOX;
spi_cs.GPIO_Pin = GD25Q_SPI_CS_GPIOX_PIN_X; spi_cs.GPIO_Pin = GD25Q_SPI_CS_GPIOX_PIN_X;
rcu_periph_clock_enable(GD25Q_SPI_CS_GPIOX_CLK);
#if defined SOC_SERIES_GD32F4xx #if defined SOC_SERIES_GD32F4xx
gpio_mode_set(spi_cs.GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, spi_cs.GPIO_Pin); gpio_mode_set(spi_cs.GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, spi_cs.GPIO_Pin);
gpio_output_options_set(spi_cs.GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, spi_cs.GPIO_Pin); gpio_output_options_set(spi_cs.GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, spi_cs.GPIO_Pin);
@ -57,7 +60,7 @@ INIT_DEVICE_EXPORT(rt_hw_spi_flash_init);
#ifdef RT_USING_SFUD #ifdef RT_USING_SFUD
static int rt_hw_spi_flash_with_sfud_init(void) static int rt_hw_spi_flash_with_sfud_init(void)
{ {
if (RT_NULL == rt_sfud_flash_probe(SPI_FLASH_CHIP, SPI_FLASH_DEVICE_NAME)) if (RT_NULL == rt_sfud_flash_probe(SPI_FLASH_DEVICE_NAME, SPI_DEVICE_NAME))
{ {
return -RT_ERROR; return -RT_ERROR;
}; };