armink / SFUD

An using JEDEC's SFDP standard serial (SPI) flash universal driver library | 一款使用 JEDEC SFDP 标准的串行 (SPI) Flash 通用驱动库
MIT License
1.25k stars 444 forks source link

STM32H723+GD25Q256不正常工作 #91

Open pwwzlxz opened 5 months ago

pwwzlxz commented 5 months ago

我是用STM32H723+GD25Q256的方式,使用OSPI的4线或者1线模式可以读取sfdp信息,但是进行读写测试不能成功,读回来的数据都是0xff。请问这里大概会是什么原因呢?下面是我的port部分代码: /*

include

include

include

include

include "main.h"

include "cmsis_os.h"

static char log_buf[256];

void sfud_log_debug(const char file, const long line, const char format, ...);

void sfud_log_info(const char format, ...); sfud_err qspi_send_then_recv(const sfud_spi spi,const void send_buf, size_t send_length, void recv_buf, size_t recv_length); extern OSPI_HandleTypeDef hospi1;

typedef struct { OSPI_HandleTypeDef spix; GPIO_TypeDef cs_gpiox; uint16_t cs_gpio_pin; } spi_user_data, *spi_user_data_t;

static void spi_lock(const sfud_spi *spi) { //__disable_irq(); }

static void spi_unlock(const sfud_spi spi) { //__enable_irq(); } void cmdhandler_default(OSPI_RegularCmdTypeDef Cmdhandler) { Cmdhandler->OperationType = HAL_OSPI_OPTYPE_COMMON_CFG; Cmdhandler->FlashId = HAL_OSPI_FLASH_ID_1; Cmdhandler->Instruction = 0; Cmdhandler->InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE; Cmdhandler->InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS; Cmdhandler->InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;

Cmdhandler->Address = 0;
Cmdhandler->AddressSize = HAL_OSPI_ADDRESS_24_BITS;
Cmdhandler->AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
Cmdhandler->AddressMode = HAL_OSPI_ADDRESS_1_LINE;

Cmdhandler->AlternateBytes = 0;
Cmdhandler->AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
Cmdhandler->AlternateBytesSize = 0;
Cmdhandler->AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE;

Cmdhandler->NbData = 0;
Cmdhandler->DataMode = HAL_OSPI_DATA_1_LINE;
Cmdhandler->DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;

Cmdhandler->DummyCycles = 0;
Cmdhandler->SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
Cmdhandler->DQSMode = HAL_OSPI_DQS_DISABLE;

}

/**

ifdef SFUD_USING_QSPI

/**

/ about 100 microsecond delay / static void retry_delay_100us(void) { uint32_t delay = 2400; while (delay--); }

static spi_user_data spi1 = { .spix = &hospi1, .cs_gpiox = NULL, .cs_gpio_pin = NULL }; sfud_err sfud_spi_port_init(sfud_flash *flash) { sfud_err result = SFUD_SUCCESS;

/**
 * add your port spi bus and device object initialize code like this:
 * 1. rcc initialize
 * 2. gpio initialize
 * 3. spi device initialize
 * 4. flash->spi and flash->retry item initialize
 *    flash->spi.wr = spi_write_read; //Required
 *    flash->spi.qspi_read = qspi_read; //Required when QSPI mode enable
 *    flash->spi.lock = spi_lock;
 *    flash->spi.unlock = spi_unlock;
 *    flash->spi.user_data = &spix;
 *    flash->retry.delay = null;
 *    flash->retry.times = 10000; //Required
 */

/* set the interfaces and data */
flash->spi.wr = spi_write_read;
flash->spi.qspi_read = qspi_read;
flash->spi.lock = spi_lock;
flash->spi.unlock = spi_unlock;
flash->spi.user_data = &spi1;
/* about 100 microsecond delay */
flash->retry.delay = retry_delay_100us;
/* adout 60 seconds timeout */
flash->retry.times = 60 * 10000;

return result;

}

/**

/**