| | |
| | | * output: none |
| | | * return: 1 byte status data read from flash |
| | | *****************************************/ |
| | | uint8_t Flash_ReadSR(void) |
| | | u8 Flash_ReadSR(void) |
| | | { |
| | | uint8_t byte=0; |
| | | u8 byte=0; |
| | | FLASH_CS_ENABLE; |
| | | FLASH_ReadWriteByte(FLASH_RDSR); //send read status register instructon |
| | | byte=FLASH_ReadWriteByte(0Xff); |
| | |
| | | * output: none |
| | | * return: none |
| | | *****************************************/ |
| | | void FLASH_Write_SR(uint8_t sr) |
| | | void FLASH_Write_SR(u8 sr) |
| | | { |
| | | FLASH_Write_Enable(); |
| | | FLASH_CS_ENABLE; |
| | |
| | | |
| | | FLASH_CS_ENABLE; |
| | | FLASH_ReadWriteByte(FLASH_READ); //send read command |
| | | FLASH_ReadWriteByte((uint8_t)((ReadAddr)>>16)); //send 24bit address |
| | | FLASH_ReadWriteByte((uint8_t)((ReadAddr)>>8)); |
| | | FLASH_ReadWriteByte((uint8_t)ReadAddr); |
| | | FLASH_ReadWriteByte((u8)((ReadAddr)>>16)); //send 24bit address |
| | | FLASH_ReadWriteByte((u8)((ReadAddr)>>8)); |
| | | FLASH_ReadWriteByte((u8)ReadAddr); |
| | | for(i=0;i<NumByteToRead;i++) |
| | | { |
| | | pBuffer[i]=FLASH_ReadWriteByte(0XFF); |
| | |
| | | * output: none |
| | | * return: none |
| | | *****************************************/ |
| | | void Flash_Write_NoCheck(uint8_t* pBuffer,u32 WriteAddr,u16 NumByteToWrite) |
| | | void Flash_Write_NoCheck(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite) |
| | | { |
| | | u16 pageremain; |
| | | pageremain=256-WriteAddr%256; //µ¥Ò³Ê£ÓàÊý×Ö |
| | |
| | | u16 secoff; |
| | | u16 secremain; |
| | | u16 i; |
| | | uint8_t FLASH_BUF[OUT_FLASH_SECTOR_SIZE] = {0}; |
| | | u8 FLASH_BUF[OUT_FLASH_SECTOR_SIZE] = {0}; |
| | | |
| | | if((WriteAddr + NumByteToWrite ) >OUT_FLASH_ALL_SIZE) //³¬¹ý×ÜÈÝÁ¿²»ÔÊÐí²Ù×÷ |
| | | return; |
| | |
| | | * output: none |
| | | * return: none |
| | | *****************************************/ |
| | | void Flash_Write_Page(uint8_t* pBuffer,u32 WriteAddr,u16 NumByteToWrite) |
| | | void Flash_Write_Page(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite) |
| | | { |
| | | u16 i; |
| | | FLASH_Write_Enable(); //write enable |
| | | FLASH_CS_ENABLE; |
| | | FLASH_ReadWriteByte(FLASH_WRITE); //send write command |
| | | FLASH_ReadWriteByte((uint8_t)((WriteAddr)>>16)); //send 24bit address |
| | | FLASH_ReadWriteByte((uint8_t)((WriteAddr)>>8)); |
| | | FLASH_ReadWriteByte((uint8_t)WriteAddr); |
| | | FLASH_ReadWriteByte((u8)((WriteAddr)>>16)); //send 24bit address |
| | | FLASH_ReadWriteByte((u8)((WriteAddr)>>8)); |
| | | FLASH_ReadWriteByte((u8)WriteAddr); |
| | | for(i=0;i<NumByteToWrite;i++) |
| | | FLASH_ReadWriteByte(pBuffer[i]); |
| | | FLASH_CS_DISABLE; |
| | |
| | | uint8 data; |
| | | FLASH_CS_ENABLE; |
| | | FLASH_ReadWriteByte(FLASH_READ); //send read command |
| | | FLASH_ReadWriteByte((uint8_t)((ReadAddr)>>16)); //send 24bit address |
| | | FLASH_ReadWriteByte((uint8_t)((ReadAddr)>>8)); |
| | | FLASH_ReadWriteByte((uint8_t)ReadAddr); |
| | | FLASH_ReadWriteByte((u8)((ReadAddr)>>16)); //send 24bit address |
| | | FLASH_ReadWriteByte((u8)((ReadAddr)>>8)); |
| | | FLASH_ReadWriteByte((u8)ReadAddr); |
| | | |
| | | data=FLASH_ReadWriteByte(0XFF); |
| | | |
| | |
| | | Flash_Wait_Busy(); |
| | | FLASH_CS_ENABLE; |
| | | FLASH_ReadWriteByte(FLASH_SectorErase); //send sector erase instruction |
| | | FLASH_ReadWriteByte((uint8_t)((Dst_Addr)>>16)); |
| | | FLASH_ReadWriteByte((uint8_t)((Dst_Addr)>>8)); |
| | | FLASH_ReadWriteByte((uint8_t)Dst_Addr); |
| | | FLASH_ReadWriteByte((u8)((Dst_Addr)>>16)); |
| | | FLASH_ReadWriteByte((u8)((Dst_Addr)>>8)); |
| | | FLASH_ReadWriteByte((u8)Dst_Addr); |
| | | FLASH_CS_DISABLE; |
| | | Flash_Wait_Busy(); |
| | | } |
| | |
| | | |
| | | void OUT_FLASH_test(void) |
| | | { |
| | | uint8_t u8_temp_s[512]; |
| | | uint8_t u8_temp_s2[512]; |
| | | u8 u8_temp_s[512]; |
| | | u8 u8_temp_s2[512]; |
| | | u32 addr1; |
| | | u16 count_i = 0; |
| | | |
| | | for(count_i=0;count_i<512;count_i++) |
| | | { |
| | | u8_temp_s[count_i] =(uint8_t)count_i; |
| | | u8_temp_s[count_i] =(u8)count_i; |
| | | u8_temp_s2[count_i] = 0; |
| | | } |
| | | |