forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

wujiazhi
2024-06-13 72def895431ad7a08e635b11f3da738e2b2c4618
Function/OFF_CHIP_FLASH/off_chip_flash.c
@@ -47,9 +47,9 @@
 * 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);               
@@ -65,7 +65,7 @@
 * output:  none
 * return:  none
 *****************************************/
void FLASH_Write_SR(uint8_t sr)
void FLASH_Write_SR(u8 sr)
{   
   FLASH_Write_Enable();
   FLASH_CS_ENABLE;                               
@@ -139,9 +139,9 @@
   
   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);    
@@ -159,7 +159,7 @@
 * 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;                           //µ¥Ò³Ê£ÓàÊý×Ö           
@@ -199,7 +199,7 @@
   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;
@@ -280,15 +280,15 @@
 * 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;                            
@@ -302,9 +302,9 @@
   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);    
    
@@ -345,9 +345,9 @@
   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();   
}  
@@ -555,14 +555,14 @@
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;
   }