⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s29gl064a90.c.old

📁 umon bootloader source code, support mips cpu.
💻 OLD
📖 第 1 页 / 共 2 页
字号:
    rPIF_PCMCIA_DATA = NOR_FLASH_RD_SR;
    
    PifWaitTillDone();         // Wait till the first cycle complete	
    
    NorFlashRd(0, &status, 1);
    return(status);
}

/*
*********************************************************************************************
*                                       NorFlashRdID
*
* Description: read the manufacture ID, device ID, and block lock configuration.
*
* Arguments  : mID              is the manufacture ID pointer.
*              deviceID         is the device ID pointer.
*              block_lock_cfg   is the block lock configuration.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/
void NorFlashRdID(short *mID, short *deviceID, short *block_lock_cfg)
{
    short status;
    	
    PIF_WRITE_SET();
    rPIF_PCI_LEN = 2;
    PIF_START();
    rPIF_PCMCIA_DATA = NOR_FLASH_RD_ID;
    
    PifWaitTillDone();         // Wait till the first cycle complete	
    
    NorFlashRd(0, mID, 1);
    NorFlashRd(2, deviceID, 1);
    NorFlashRd(4, block_lock_cfg, 1);
}

/*
*********************************************************************************************
*                                       NorFlashRdData
*
* Description: read the data from the specified address.
*
* Arguments  : start_addr       is the start byte address.
*              data             is the data pointer.
*              number           is the data of number to be read. It is counted by half-words.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/
void NorFlashRdData(int start_addr, short *data, int number)
{
    int i;	
#if 0	
    /* The read array command */	
    PIF_WRITE_SET();
    rPIF_PCI_LEN = 2;
    PIF_START();
    rPIF_PCMCIA_DATA = NOR_FLASH_RD_ARRAY;
    
    PifWaitTillDone();           // Wait till the first cycle complete
 #endif   
    NorFlashRd(start_addr, data, number);    	
}

/*
*********************************************************************************************
*                                       NorFlashRdDataBurst
*
* Description: read the data from the specified address.
*
* Arguments  : start_addr       is the start byte address.
*              data             is the data pointer.
*              number           is the data of number to be read. It is counted by half-words.
*                               Maximum is 2047. 
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/
void NorFlashRdDataBurst(int start_addr, unsigned short *data, int number)
{
    int i;	
	
#if 0	
    /* The read array command */	
    PIF_WRITE_SET();
    rPIF_PCI_LEN = 2;
    PIF_START();
    rPIF_PCMCIA_DATA = NOR_FLASH_RD_ARRAY;
    
    PifWaitTillDone();           // Wait till the first cycle complete
 #endif   
    
    NorFlashRd1(start_addr, data, number);    	
}

/*
*********************************************************************************************
*                                       NorFlashRd1
*
* Description: read the data from the specified address.
*
* Arguments  : start_addr       is the start byte address.
*              data             is the data pointer.
*              number           is the data of number to be read. Counted by short integers.
*
* Return     : none.
*
* Note(s)    : number should be less than 2047.
*********************************************************************************************
*/
void NorFlashRd1(int start_addr, short *data, int number)
{
    unsigned int i, tmp, iN, word_number;	
    
    start_addr = start_addr * 1;
  	
    //number &= 0x7ff;         // Maxium of byte length of the transfer is 4096 bytes
    if(number & 0x1) {
        word_number = number/2 + 1;
    } else
        word_number = number/2;     	
    
    iN = 0;

    PIF_READ_SET();
    rPIF_PCI_LEN = number * 2;     // rPIF_PCI_LEN is counted by bytes.
    rPIF_PCI_DEV_A = start_addr;   // the byte address
    PifPCMCIAModeRegSet(PIF_CBUS_MODE, PCMCIA_MSTR_BS_8BYTE);    
    PIF_START();
    
    for(i = 0; i < word_number; i++) {
        tmp = rPIF_PCMCIA_DATA;	
        *data++ = tmp & 0xffff;
        iN++;
        if (iN == number)
            break;
        *data++ = (tmp >> 16);
        iN++;
    }
}

/*
*********************************************************************************************
*                                       NorFlashRd
*
* Description: read the data from the specified address.
*
* Arguments  : start_addr       is the start byte address.
*              data             is the data pointer.
*              number           is the data of number to be read. It is counted by half-words.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/
void NorFlashRd(int start_addr, short *data, int number)
{
    unsigned int i, tmp;	        

    start_addr = start_addr * 1;

    PIF_READ_SET();
    rPIF_PCI_LEN = 2;          // rPIF_PCI_LEN is counted by bytes.  	
        
    for(i = 0; i < number; i++) {
    	rPIF_PCI_DEV_A = start_addr;    // the byte address
    	start_addr += 2;	    	
	PifPCMCIAModeRegSet(PIF_CBUS_MODE, PCMCIA_MSTR_BS_8BYTE);    
    	PIF_START();    	
        *data++ = rPIF_PCMCIA_DATA;	        
    }
}

/*
*********************************************************************************************
*                               Following functions will be used in NOR-FLASH testing!
*********************************************************************************************
*/

/*
*********************************************************************************************
*                                       NorflashSectorVerify
*
* Description: Read the short integers from the sector one by one, compare with verify_data.
*
* Arguments  : verify_data    is the short int compared.
*
* Return     : SUCCESSFUL:    all the short integers are equal to verify_data.
*              FAILED:        at least one short integer is not qeual to verify_data.
*
* Note(s)    : 
*********************************************************************************************
*/

int NorFlashSectorVerify(int no_sector, short int verify_data)
{   
    int i, j;
    int tmp1, tmp2;
    
    tmp2 = 0x400;
    tmp1 = NOR_FLASH_BYTES_PER_SECTOR / (2 * tmp2); 
    
    short int rd_data[tmp2];
    
    for(i = 0; i < tmp1; i++) {    	
        NorFlashRdData(no_sector * NOR_FLASH_BYTES_PER_SECTOR + i * tmp2 * 2, rd_data, tmp2);	
        for(j = 0; j < tmp2; j++) {
            if(rd_data[j] != verify_data) {         
  	     return FAILED;	
            }
        }
    }                
    return SUCCESSFUL;          
}

/*
*********************************************************************************************
*                                       NorflashSectorVerify1
*
* Description: Read the short integers from the sector one by one, compare with verify_data.
*
* Arguments  : verify_data    is the short int compared.
*
* Return     : SUCCESSFUL:    all the short integers are equal to verify_data.
*              FAILED:        at least one short integer is not qeual to verify_data.
*
* Note(s)    : 
*********************************************************************************************
*/
int NorFlashSectorVerify1(int no_sector, short int verify_data)
{ 
    char receive;	  
    int i, j;
    int tmp1, tmp2;
    int addr;
    
    tmp2 = 0x400;
    tmp1 = NOR_FLASH_BYTES_PER_SECTOR / (2 * tmp2); 
    
    short int rd_data[tmp2];
    
    for(i = 0; i < tmp1; i++) {    	
        NorFlashRdDataBurst(no_sector * NOR_FLASH_BYTES_PER_SECTOR + i * tmp2 * 2, rd_data, tmp2);
        for(j = 0; j < tmp2; j++) {
            if(rd_data[j] != verify_data) {
            	addr = no_sector * NOR_FLASH_BYTES_PER_SECTOR + i * tmp2 * 2 + j * 2;            	            	
            	printf("\r\nverify_data = 0x%x, flash data = 0x%x, byte addr = 0x%x, half-word addr = 0x%x", verify_data, rd_data[j], addr, addr/2);                               
            	//receive = WaitPressKey();            	
            	verify_data++;
              //  if(receive == 'e')
             //       return FAILED;
              //  if(receive == 'b')
              //      break;                    	
            } else
                verify_data++;            
        }
    }                
    return SUCCESSFUL;          
}

/*
*********************************************************************************************
*                                       PifNorFlashProgSector
*
* Description: program a half-word into the specified sector
*
* Arguments  : sec_no     is the sector number. 
*              data       is the half-word to be programmed.
*
* Return     : SUCCESSFUL  shows the erasure is successful.
*              FAILED      shows the erasure is failed.
*
* Note(s)    : addr should be 2-byte aligned.
*********************************************************************************************
*/
int NorFlashProgSector(int sec_no, short data)
{
    int i;	
    
    for(i = 0; i < NOR_FLASH_BYTES_PER_SECTOR; i+=2) {
        NorFlashProg(sec_no * NOR_FLASH_BYTES_PER_SECTOR + i, data);
      //  if(NorFlashProg(sec_no * NOR_FLASH_BYTES_PER_SECTOR + i, data) == FAILED)
     //       return FAILED;    
    }
    return SUCCESSFUL;
}       
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -