/** * @brief Polls the status of the Write In Progress (WIP) flag in the * FLASH's status register and loop until write opertaion * has completed. * @param None * @retval : None */ void SPI_FLASH_WaitForWriteEnd(void) { uint16_t i = 0; uint8_t FLASH_Status = 0; /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read Status Register" instruction */ SPI_FLASH_SendByte(RDSR); /* Loop as long as the memory is busy with a write cycle */ do { /* Send a dummy byte to generate the clock needed by the FLASH and put the value of the status register in FLASH_Status variable */ FLASH_Status = SPI_FLASH_GetByte(); i++; if (i >= 60000) break; } while ((FLASH_Status & WIP_Flag) == SET); /* Write in progress */ /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); SPI_FLASH_WriteDisable(); }
/********************************************************************************************************* ** Function name : flash_read_data ** Descriptions : Read flash memory ** Input parameters : RAddr -- the start address to read ** Output parameters : buf -- the buffer to receive the read data ** RLength -- the length of the data to read ** Returned value : The operation result. 1 -- sucess, 0 -- false *********************************************************************************************************/ uint8_t flash_read_data (uint32_t RAddr, uint8_t *buf, uint32_t RLength) { uint8_t Temp; uint32_t i; if (RLength == 0) { return 0; } /* * Check the state register. If it's busy , wait until it's free */ while(1) { Temp = flash_read_status( ); Temp &= 0x01; if(Temp == 0x00) break; for(i=0; i<10; i++); } SPI_FLASH_CS_LOW(); /* P0.2--0,CS = 0 选中SPI Flash */ Send_Byte(0x03); Send_Byte((RAddr & 0xFF0000) >> 16); Send_Byte((RAddr & 0x00FF00) >> 8); Send_Byte((RAddr & 0x0000FF)); for (i=0; i<RLength; i++) { buf[i] = Send_Byte(0xff); } SPI_FLASH_CS_HIGH(); /* P0.2--1,CS = 1 释放SPI Flash */ return 1; }
/*static void w25x64_write_disable(void) { SPI_FLASH_CS_LOW(); SPI_FLASH_SendByte(WriteDisable); SPI_FLASH_CS_HIGH(); }*/ void w25x64_read(unsigned int addr,void *pbuf,unsigned int bytes) { u8* data_buf = pbuf; if(addr+bytes>W25X64_SIZE) return; /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read from Memory " instruction */ SPI_FLASH_SendByte(Read_Data); /* Send ReadAddr high nibble address byte to read from */ SPI_FLASH_SendByte((addr & 0xFF0000) >> 16); /* Send ReadAddr medium nibble address byte to read from */ SPI_FLASH_SendByte((addr& 0xFF00) >> 8); /* Send ReadAddr low nibble address byte to read from */ SPI_FLASH_SendByte(addr & 0xFF); while (bytes--) /* while there is data to be read */ { /* Read a byte from the FLASH */ *data_buf = SPI_FLASH_SendByte(Dummy_Byte); /* Point to the next location where the byte read will be saved */ data_buf++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); }
void w25x64_sector_erase(unsigned int addr) { if(addr>=W25X64_SECTORS) return; addr *= W25X64_SECTOR_SIZE; /* Send write enable instruction */ w25x64_write_enble(); /* Sector Erase */ /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send Sector Erase instruction */ SPI_FLASH_SendByte(SectorErace); /* Send SectorAddr high nibble address byte */ SPI_FLASH_SendByte((addr & 0xFF0000) >> 16); /* Send SectorAddr medium nibble address byte */ SPI_FLASH_SendByte((addr & 0xFF00) >> 8); /* Send SectorAddr low nibble address byte */ SPI_FLASH_SendByte(addr & 0xFF); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* Wait the end of Flash writing */ SPI_FLASH_WaitForWriteEnd(); }
/********************************************************************************************************* ** Function name : flash_write_sector ** Descriptions : Write flash memory , just in one page memory ** Input parameters : WAddr -- the start address to write ** Output parameters : buf -- the buffer to write the data ** RLength -- the length of the data to write ** Returned value : The operation result. 1 -- sucess, 0 -- false *********************************************************************************************************/ uint8_t flash_write_sector (uint32_t WAddr, uint8_t *buf, uint32_t WLength) { uint32_t i; if (WLength == 0) { return 0; } flash_write_enable(); /* Write enable */ SPI_FLASH_CS_LOW(); /* P0.2--0,CS = 0 选中SPI Flash */ Send_Byte(0x02); Send_Byte((WAddr & 0xFF0000) >> 16); Send_Byte((WAddr & 0x00FF00) >> 8); Send_Byte((WAddr & 0x0000FF)); for (i=0; i<WLength; i++) { Send_Byte(buf[i]); } SPI_FLASH_CS_HIGH(); /* P0.2--1,CS = 1 释放SPI Flash */ while (flash_read_status() & 0x01 != 0x00); return 1; }
/******************************************************************************* * Function Name : SPI_FLASH_BufferRead * Description : Reads a block of data from the FLASH. * Input : - pBuffer : pointer to the buffer that receives the data read * from the FLASH. * - ReadAddr : FLASH's internal address to read from. * - NumByteToRead : number of bytes to read from the FLASH. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_BufferRead(u8* pBuffer, u32 ReadAddr, u16 NumByteToRead) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read from Memory " instruction */ SPI_FLASH_SendByte(W25X_ReadData); /* Send ReadAddr high nibble address byte to read from */ SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16); /* Send ReadAddr medium nibble address byte to read from */ SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8); /* Send ReadAddr low nibble address byte to read from */ SPI_FLASH_SendByte(ReadAddr & 0xFF); while (NumByteToRead--) /* while there is data to be read */ { /* Read a byte from the FLASH */ *pBuffer = SPI_FLASH_SendByte(Dummy_Byte); /* Point to the next location where the byte read will be saved */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); }
/** * @brief Polls the status of the Write In Progress (WIP) flag in the * FLASH's status register and loop until write opertaion * has completed. * @param None * @retval 0: 成功 * -1: 超时 */ int spi_flash_wait_for_write_end(void) { OS_CPU_SR cpu_sr = 0; unsigned char FLASH_Status = 0; volatile unsigned int i = 0; /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read Status Register" instruction */ spi_flash_send_byte(RDSR); /* Loop as long as the memory is busy with a write cycle */ do { /* Send a dummy byte to generate the clock needed by the FLASH and put the value of the status register in FLASH_Status variable */ FLASH_Status = spi_flash_send_byte(Dummy_Byte); i++; if (i > 0xFFFFFFFE) //测试超时 { /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); OS_EXIT_CRITICAL(); return -1; } } while ((FLASH_Status & WIP_Flag) == SET); /* Write in progress */ /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); //spi_flash_busy_flag = 0; OS_EXIT_CRITICAL(); return 0; }
/** * @brief Reads FLASH identification. * @param None * @retval : FLASH identification */ unsigned int spi_flash_read_id(void) { unsigned int Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0; OS_CPU_SR cpu_sr = 0; OS_ENTER_CRITICAL(); /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "RDID " instruction */ spi_flash_send_byte(0x9F); /* Read a byte from the FLASH */ Temp0 = spi_flash_send_byte(Dummy_Byte); /* Read a byte from the FLASH */ Temp1 = spi_flash_send_byte(Dummy_Byte); /* Read a byte from the FLASH */ Temp2 = spi_flash_send_byte(Dummy_Byte); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2; OS_EXIT_CRITICAL(); return Temp; }
/** * @brief Reads FLASH identification. * @param None * @retval FLASH identification */ uint32_t SPI_FLASH_ReadID(void) { uint32_t Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0; /* 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); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2; return Temp; }
/** * @brief Writes more than one byte to the FLASH with a single WRITE * cycle(Page WRITE sequence). The number of byte can't exceed * the FLASH page size. * @param pBuffer : pointer to the buffer containing the data to be * written to the FLASH. * @param WriteAddr : FLASH's internal address to write to. * @param NumByteToWrite : number of bytes to write to the FLASH, * must be equal or less than "SPI_FLASH_PageSize" value. * @retval 0: 成功 * -1: 超时 */ int spi_flash_page_write(unsigned char* pBuffer, unsigned int WriteAddr, unsigned short NumByteToWrite) { /* Enable the write access to the FLASH */ OS_CPU_SR cpu_sr = 0; OS_ENTER_CRITICAL(); spi_flash_write_enable(); /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Write to Memory " instruction */ spi_flash_send_byte(WRITE); /* Send WriteAddr high nibble address byte to write to */ spi_flash_send_byte((WriteAddr & 0xFF0000) >> 16); /* Send WriteAddr medium nibble address byte to write to */ spi_flash_send_byte((WriteAddr & 0xFF00) >> 8); /* Send WriteAddr low nibble address byte to write to */ spi_flash_send_byte(WriteAddr & 0xFF); /* while there is data to be written on the FLASH */ while (NumByteToWrite--) { /* Send the current byte */ spi_flash_send_byte(*pBuffer); /* Point on the next byte to be written */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* Wait the end of Flash writing */ return spi_flash_wait_for_write_end(); }
/** * @brief Reads a block of data from the FLASH. * @param pBuffer : pointer to the buffer that receives the data read * from the FLASH. * @param ReadAddr : FLASH's internal address to read from. * @param NumByteToRead : number of bytes to read from the FLASH. * @retval : None */ void spi_flash_raddr(unsigned int ReadAddr,unsigned int NumByteToRead, unsigned char *pBuffer) { /* Select the FLASH: Chip Select low */ OS_CPU_SR cpu_sr = 0; OS_ENTER_CRITICAL(); SPI_FLASH_CS_LOW(); /* Send "Read from Memory " instruction */ spi_flash_send_byte(READ); /* Send ReadAddr high nibble address byte to read from */ spi_flash_send_byte((ReadAddr & 0xFF0000) >> 16); /* Send ReadAddr medium nibble address byte to read from */ spi_flash_send_byte((ReadAddr& 0xFF00) >> 8); /* Send ReadAddr low nibble address byte to read from */ spi_flash_send_byte(ReadAddr & 0xFF); while (NumByteToRead--) /* while there is data to be read */ { /* Read a byte from the FLASH */ *pBuffer = spi_flash_send_byte(Dummy_Byte); /* Point to the next location where the byte read will be saved */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); OS_EXIT_CRITICAL(); }
/****************************************************************************************** *函数名:SPI_FLASH_PageWrite() * 参数:uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite 数据指针,写入地址,写入的个数 * 返回值:void * 功能:SPIFLASH页写入数据函数,外部调用 *********************************************************************************************/ void SPI_FLASH_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { /*使能写入*/ SPI_FLASH_WriteEnable(); /*使能片选*/ SPI_FLASH_CS_LOW(); /* 发送页写入指令*/ SSP0_SendByte(W25X_PageProgram); /*发送高8位数据地址*/ SSP0_SendByte((WriteAddr & 0xFF0000) >> 16); /*发送中8位数据地址*/ SSP0_SendByte((WriteAddr & 0xFF00) >> 8); /*发送低8位数据地址*/ SSP0_SendByte(WriteAddr & 0xFF); /*检测写入的数据是否超出页的容量大小*/ if (NumByteToWrite > SPI_FLASH_PerWritePageSize) { NumByteToWrite = SPI_FLASH_PerWritePageSize; } /*循环写入数据*/ while (NumByteToWrite--) { /*发送数据*/ SSP0_SendByte(*pBuffer); /* 指针移到下一个写入数据 */ pBuffer++; } /*失能片选*/ SPI_FLASH_CS_HIGH(); /* 等待写完成*/ SPI_FLASH_WaitForWriteEnd(); }
/******************************************************************************* * Function Name : SPI_FLASH_PageWrite * Description : Writes more than one byte to the FLASH with a single WRITE * cycle(Page WRITE sequence). The number of byte can't exceed * the FLASH page size. * Input : - pBuffer : pointer to the buffer containing the data to be * written to the FLASH. * - WriteAddr : FLASH's internal address to write to. * - NumByteToWrite : number of bytes to write to the FLASH, * must be equal or less than "SPI_FLASH_PageSize" value. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { /* Enable the write access to the FLASH */ SPI_FLASH_WriteEnable(); /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Write to Memory " instruction */ SPI_FLASH_SendByte(WRITE); /* Send WriteAddr high nibble address byte to write to */ SPI_FLASH_SendByte((WriteAddr & 0xFF0000) >> 16); /* Send WriteAddr medium nibble address byte to write to */ SPI_FLASH_SendByte((WriteAddr & 0xFF00) >> 8); /* Send WriteAddr low nibble address byte to write to */ SPI_FLASH_SendByte(WriteAddr & 0xFF); /* while there is data to be written on the FLASH */ while (NumByteToWrite--) { /* Send the current byte */ SPI_FLASH_SendByte(*pBuffer); /* Point on the next byte to be written */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* Wait the end of Flash writing */ SPI_FLASH_WaitForWriteEnd(); }
/******************************************************************************* * Function Name : SPI_FLASH_ReadID * Description : Reads FLASH identification. * Input : None * Output : None * Return : FLASH identification *******************************************************************************/ u32 SPI_FLASH_ReadID(void) { u32 Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0; /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "RDID " instruction */ SPI_FLASH_SendByte(W25X_JedecDeviceID); /* 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); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2; return Temp; }
/** * @brief Reads a block of data from the FLASH. * @param pBuffer: pointer to the buffer that receives the data read from the FLASH. * @param ReadAddr: FLASH's internal address to read from. * @param NumByteToRead: number of bytes to read from the FLASH. * @retval None */ void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read from Memory " instruction */ SPI_FLASH_SendByte(CMD_READ); /* Send ReadAddr high nibble address byte to read from */ SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16); /* Send ReadAddr medium nibble address byte to read from */ SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8); /* Send ReadAddr low nibble address byte to read from */ SPI_FLASH_SendByte(ReadAddr & 0xFF); while (NumByteToRead--) /* while there is data to be read */ { /* Read a byte from the FLASH */ *pBuffer = SPI_FLASH_SendByte(DUMMY_BYTE); /* Point to the next location where the byte read will be saved */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); }
void SPI_FLASH_WriteDisable(void) { SPI_FLASH_CS_LOW(); SPI_FLASH_SendByte(WRDIS); SPI_FLASH_CS_HIGH(); GPIO_ResetBits(GPIOC, GPIO_Pin_13); }
/*********************************************************************//** * @author * @brief * @date * @version * @description * @param[in] None. * @param[out] None. * @return * **********************************************************************/ void SFlash_Write_Status_Rregister(uint8_t statusByte) { SFlash_Enable_Write_Status_Register(); SFlash_Write_Enable(); SPI_FLASH_CS_LOW(); Flash_ReadWriteByte(WRSR_OPCODE); /* Send write status register command */ Flash_ReadWriteByte(statusByte); /* chip can be written */ SPI_FLASH_CS_HIGH(); }
/******************************************************************************* SPI_FLASH_WaitForWriteEnd *******************************************************************************/ void SPI_FLASH_WaitForWriteEnd(void) { u8 FLASH_Status = 0; SPI_FLASH_CS_LOW(); SPI_FLASH_SendByte(RDSR); do { FLASH_Status = SPI_FLASH_SendByte(Dummy_Byte); } while((FLASH_Status & WIP_Flag) == SET); // Write in progress SPI_FLASH_CS_HIGH(); }
/****************************************************************************************** *函数名:SPI_Flash_WAKEUP() * 参数:void * 返回值:void * 功能:SPIFLASH唤醒掉电模式函数,外部调用 *********************************************************************************************/ void SPI_Flash_WAKEUP(void) { /* 使能片选 */ SPI_FLASH_CS_LOW(); /* 发送退出掉电模式指令 */ SSP0_SendByte(W25X_ReleasePowerDown); /*失能片选*/ SPI_FLASH_CS_HIGH(); }
/****************************************************************************************** *函数名:SPI_Flash_PowerDown() * 参数:void * 返回值:void * 功能:SPIFLASH进入掉电模式函数,外部调用 *********************************************************************************************/ void SPI_Flash_PowerDown(void) { /* 使能片选 */ SPI_FLASH_CS_LOW(); /*发送掉电指令 */ SSP0_SendByte(W25X_PowerDown); /*失能片选*/ SPI_FLASH_CS_HIGH(); }
/****************************************************************************************** *函数名:SPI_FLASH_WriteEnable() * 参数:void * 返回值:void * 功能:SPIFLASH写使能函数,外部调用 *********************************************************************************************/ void SPI_FLASH_WriteEnable(void) { /* 使能片选 */ SPI_FLASH_CS_LOW(); /*发送写使能指令*/ SSP0_SendByte(W25X_WriteEnable); /*失能片选*/ SPI_FLASH_CS_HIGH(); }
/********************************************************************************************************* ** Function name : W25X10_ReadStatus ** Descriptions : Read the state register in the flash memory ** Input parameters : none ** Output parameters : The value of the state register ** Returned value : none *********************************************************************************************************/ uint8_t flash_read_status ( void ) { uint8_t status; SPI_FLASH_CS_LOW(); /* 选中SPI Flash */ Send_Byte(0x05); status = Send_Byte(0xff); SPI_FLASH_CS_HIGH(); /* P0.2--1,CS = 1 释放SPI Flash */ return status; /* Return Reg 1's Content */ }
uint8_t flash_write_word (uint32_t WAddr, uint16_t *buf, uint32_t WLength) { uint32_t i; if (WLength == 0) { return 0; } if(WLength%2!=0) { return 0; } WLength/=2; EBSY(); WREN(); SPI_FLASH_CS_LOW(); Send_Byte(SPI_FLASH_CMD_SST_AAI_WORD_PROGRAM); /* send AAI command */ Send_Byte(((WAddr & 0xFFFFFF) >> 16)); /* send 3 address bytes */ Send_Byte(((WAddr & 0xFFFF) >> 8)); Send_Byte(WAddr & 0xFF); for (i=0; i<WLength; i++) { APP_TRACE("%d ",i); Send_Byte(buf[i] & 0xFF); Send_Byte(((buf[i] & 0xFFFF) >> 8)); SPI_FLASH_CS_HIGH(); CheckBusy(); if(i<WLength-1) { SPI_FLASH_CS_LOW(); Send_Byte(SPI_FLASH_CMD_SST_AAI_WORD_PROGRAM); /* send AAI command */ } } WRDI(); DBSY(); while (flash_read_status() & 0x01 != 0x00); return 1; }
/*********************************************************************//** * @author * @brief * @date * @version * @description * @param[in] None. * @param[out] None. * @return * **********************************************************************/ uint8_t SFlash_Read_Status_Register(void) { uint8_t temp; SPI_FLASH_CS_LOW(); Flash_ReadWriteByte(RDSR_OPCODE); /* Send Read Status Register command */ temp = Flash_ReadWriteByte(0xFF); /* Save the read status register value */ SPI_FLASH_CS_HIGH(); return temp; }
/** * @brief Enables the write access to the FLASH. * @param None * @retval : None */ void SPI_FLASH_WriteEnable(void) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Write Enable" instruction */ SPI_FLASH_SendByte(WREN); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); }
//进入掉电模式 void SPI_Flash_PowerDown(void) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Power Down" instruction */ SPI_FLASH_SendByte(W25X_PowerDown); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); }
//唤醒 void SPI_Flash_WAKEUP(void) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Power Down" instruction */ SPI_FLASH_SendByte(W25X_ReleasePowerDown); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); //等待TRES1 }
/** * @brief Enables the write access to the FLASH. * @param None * @retval : None */ void spi_flash_write_enable(void) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Write Enable" instruction */ spi_flash_send_byte(WREN); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); }
/*********************************************************************//** * @author * @brief * @date * @version * @description * @param[in] None. * @param[out] None. * @return * **********************************************************************/ void SFlash_Chip_Erase(void) { SFlash_Write_Status_Rregister(0x00); SFlash_Write_Enable(); SPI_FLASH_CS_LOW(); Flash_ReadWriteByte(ERASE_CHIP_OPCODE); SPI_FLASH_CS_HIGH(); delay_ms(1000); WaitBusy(); }
uint8_t SPI_FLASH_ReadStatus(uint8_t Status) { uint8_t FLASH_Status; SPI_FLASH_WriteEnable(); SPI_FLASH_CS_LOW(); SPI_FLASH_SendByte(Status); FLASH_Status = SPI_FLASH_GetByte(); SPI_FLASH_CS_HIGH(); //SPI_FLASH_WriteDisable(); return FLASH_Status; }