Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD32F407RET6使用本仓库的问题 #27

Open
how0723 opened this issue Dec 20, 2024 · 3 comments
Open

GD32F407RET6使用本仓库的问题 #27

how0723 opened this issue Dec 20, 2024 · 3 comments

Comments

@how0723
Copy link

how0723 commented Dec 20, 2024

Please ask your question

这是w25qxx_interface_spi_qspi_write_read函数
`
uint8_t w25qxx_interface_spi_qspi_write_read(
uint8_t instruction, uint8_t instruction_line, uint32_t address,
uint8_t address_line, uint8_t address_len, uint32_t alternate,
uint8_t alternate_line, uint8_t alternate_len, uint8_t dummy,
uint8_t *in_buf, uint32_t in_len, uint8_t *out_buf, uint32_t out_len,
uint8_t data_line) {
if ((instruction_line != 0) || (address_line != 0) || (alternate_line != 0) ||
(dummy != 0) || (data_line != 1)) {
return 1;
}

SPI2_CS_LOW();
if (in_len > 0) {
for (uint32_t i = 0; i < in_len; i++) {
while (RESET == spi_i2s_flag_get(SPI2, SPI_FLAG_TBE))
;
spi_i2s_data_transmit(SPI2, in_buf[i]);
while (RESET == spi_i2s_flag_get(SPI2, SPI_FLAG_RBNE))
;
(void)spi_i2s_data_receive(SPI2);
}
}

if (out_len > 0) {
for (uint32_t i = 0; i < out_len; i++) {
while (RESET == spi_i2s_flag_get(SPI2, SPI_FLAG_TBE))
;
spi_i2s_data_transmit(SPI2, 0xFF); // Send dummy byte to generate clock
while (RESET == spi_i2s_flag_get(SPI2, SPI_FLAG_RBNE))
;
out_buf[i] = spi_i2s_data_receive(SPI2);
}
}

SPI2_CS_HIGH();

return 0;
}
`

这是总线初始化代码:
` rcu_periph_clock_enable(RCU_GPIOC);
rcu_periph_clock_enable(RCU_SPI2);
gpio_af_set(GPIOC, GPIO_AF_6, GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10);
gpio_mode_set(GPIOC, GPIO_MODE_AF, GPIO_PUPD_NONE,
GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10);
gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,
GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10);
spi_parameter_struct spi_init_struct;
spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX;
spi_init_struct.device_mode = SPI_MASTER;
spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT;
spi_init_struct.clock_polarity_phase = SPI_CK_PL_HIGH_PH_2EDGE;
spi_init_struct.nss = SPI_NSS_SOFT;
spi_init_struct.prescale = SPI_PSC_8;
spi_init_struct.endian = SPI_ENDIAN_MSB;
spi_init(SPI2, &spi_init_struct);

spi_enable(SPI2);

rcu_periph_clock_enable(RCU_GPIOA);
gpio_mode_set(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO_PIN_15);
gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_15);
gpio_bit_set(GPIOA, GPIO_PIN_15);`
这是日志:
image

Additional context

No response

@libdriver
Copy link
Owner

非常感谢您使用LibDriver,从您的日志中看,似乎是读取出现问题了,第一个“release power down failed”,有可能是调用w25qxx_interface_spi_qspi_write_read参数不对返回的错误,如果您的芯片只使用或实现了SPI接口,w25qxx_set_dual_quad_spi一定设置为False

@how0723
Copy link
Author

how0723 commented Dec 20, 2024

是这个原因,已解决,非常感谢

@libdriver
Copy link
Owner

您客气了,祝您项目一切顺利

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants