FLASH_ID = SPI_FLASH_ReadID(); u32 SPI_FLASH_ReadID(void) { u32 Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0, Temp3;
/* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW();
/* Send "RDID " instruction */ SPI_FLASH_SendByte(0x9F); /**--------------------------------**/
/* Read a byte from the FLASH */ Temp0 = SPI_FLASH_SendByte(Dummy_Byte);
/* Read a byte from the FLASH */ Temp1 = SPI_FLASH_SendByte(Dummy_Byte);
/* Read a byte from the FLASH */ Temp2 = SPI_FLASH_SendByte(Dummy_Byte);
/* Read a byte from the FLASH */ Temp3 = SPI_FLASH_SendByte(Dummy_Byte); /*** 0xff */ /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); Temp = (Temp0 << 24) | (Temp1 << 16) | (Temp2<<8) | Temp3; return Temp; }
|