CubeMx生成的代码,使用SPI1,CS信号软件控制,时钟使用HSI 16MHz,
W25m02G 的 CS管脚上拉,WP管脚上拉,HOLD管脚上拉,
void USER_FlashReadStatus(void)
{
HAL_GPIO_WritePin(Flash_cs_GPIO_Port, Flash_cs_Pin, GPIO_PIN_RESET);
gSPI1WriteBuff[0] = 0x05;
gSPI1WriteBuff[1] = 0xA0;
HAL_SPI_Transmit(&hspi1, gSPI1WriteBuff, 2, 10000);
HAL_SPI_TransmitReceive(&hspi1, gSPI1WriteBuff, gSPI1ReadBuff, 20,100000);
HAL_GPIO_WritePin(Flash_cs_GPIO_Port, Flash_cs_Pin, GPIO_PIN_SET);
} |