赞
踩
winbond型号例程main函数读写操作步骤:
1.初始化spi驱动
ConfigPtr = XSpi_LookupConfig(SPI_DEVICE_ID);
XSpi_CfgInitialize(&Spi, ConfigPtr, ConfigPtr->BaseAddress);
2.把spi驱动连接到中断子系统SetupInterruptSystem(&Spi);
3.设置中断处理函数XSpi_SetStatusHandler(&Spi, &Spi, (XSpi_StatusHandler)SpiHandler);
4.设置器件为主模式和手动片选模式XSpi_SetOptions(&Spi, XSP_MASTER_OPTION |
XSP_MANUAL_SSELECT_OPTION);
5.通过片选选择要读写的器件XSpi_SetSlaveSelect(&Spi, SPI_SELECT);
6.start使能中断和器件XSpi_Start(&Spi);
7.指定擦、写、读操作的地址Address = FLASH_TEST_ADDRESS;
8.写使能SpiFlashWriteEnable(&Spi);
9.sector块擦除SpiFlashSectorErase(&Spi, Address);
10.设置quad模式使能SpiFlashQuadEnable(&Spi);
11.写使能SpiFlashWriteEnable(&Spi);
12.页写操作SpiFlashWrite(&Spi, Address, 256, 0x2);
//SpiFlashWrite(XSpi *SpiPtr, u32 Addr, u32 ByteCount, u8 WriteCmd)
13
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。