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

📄 m512_mtd.c

📁 M-System DOC(Disk on a Chip) Flash芯片的诊断工具, 可以从Flash芯片中获取特定的数据信息, 用于判断芯片当前的状态.
💻 C
📖 第 1 页 / 共 5 页
字号:
                                          LastOperationResults *completeOpStruct,
                                          completeOpVarsStruct *completeOpVars) ;
#endif

FLStatus M512_completeOperation          (FLFlash *flashPtr) ;
FLStatus M512_asicSetInNormalMode        (FLFlash *flashPtr) ;
FLStatus M512_ReadProductType            (FLFlash *flashPtr,FLByte *bProductType) ;    
FLStatus M512_deepPowerDownMode          (FLFlash *flashPtr,FLWord wState) ;
void     M512_restoreRegistersCurrentState (FLFlash *flashPtr) ;
static void M512_flashEccInit            (FLFlash *flashPtr,FLByte HM_DATA_NUM);

#ifdef FL_PLANT_BBT_FOR_TESTING
extern FLStatus plantedIsGoodBlock(FLFlash * flashPtr, FLWord wBlockNo,FLBoolean * bCurBlockStatus);
#endif /* FL_PLANT_BBT_FOR_TESTING */ 
#ifdef STORE_DPS_BEFORE_DOWNLOAD
extern FLStatus QA_DPS_BeforeDownload(FLFlash *callingFlashPtr);
#endif /* STORE_DPS_BEFORE_DOWNLOAD */
#ifdef FL_PLANT_BBT_FOR_TESTING
extern FLStatus informOfOperation(FLFlash * flash, FLDword start, FLDword length , FLByte bType);
#endif /* FL_PLANT_BBT_FOR_TESTING */ 

/*****************************    Macros      **************************/

/***********************************************************************
 *  Name: M512_Write16BitReg                                                                                   
 *    Write to 16 bit register                                 
 *                                                                      
 * Parameters:
 *      flashPtr             : Pointer identifying drive                      
 *      wOffset              : The Offset of register from base address
 *      wValue               : The 16 bit value that should be written 
 *                             to this register.
 * Returns: Value of the 16 bit register
 * Note:    In big endian the word in RAM memory as:
 *          Offset 0 - Msb byte 
 *          Offset 1 - Lsb byte  
 *          But the M512 16 bit registers work in Little endian 
 *          which means that the data is stored as follows 
 *          Offset 0 - Lsb byte 
 *          Offset 1 - Msb byte  
 *          In order to convert wValue from big to little endian format
 *          we convert it to LEushort format which store the word in little
 *          endian format and write it to ASIC
 ***********************************************************************/
#ifndef FL_BIG_ENDIAN
#define M512_Write16BitReg(flashPtr,wOffset,wValue) \
  M512_DirectWrite16BitReg (flashPtr,wOffset,wValue) 
#else
#define M512_Write16BitReg(flashPtr,wOffset,wValue) \
{ \
  LEushort LEus_Temp ; \
  toLE2 (LEus_Temp,wValue) ; \
  M512_DirectWrite16BitReg (flashPtr,wOffset,*(FLWord *)LEus_Temp) ; \
} 
#endif

/***********************************************************************
 *  Name: M512_Write8BitToDataReg
 *    Write 8 bit to Data register   
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *      bValue               : The value that needs to be written.                                                                 
 * Returns: None 0 => not RESET mode 
 *          0      => RESET mode 
 ***********************************************************************/
#define M512_Write8BitToDataReg(flashPtr,bValue) \
  M512_Write16BitReg (flashPtr,M512_READ_ADDRESS_REG,(FLWord)(M512_FLASH_DATA_REG_ALIASED|M512_ADDR_ACCESS_ONE_BYTE)) ; \
  M512_Write8BitReg (flashPtr,M512_FLASH_DATA_REG_ALIASED,bValue) 

/***********************************************************************
 *  Name: M512_asicIsAsicNotInResetMode
 *    Checks if the ASIC is not in RESET mode  
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 * Returns: None 0 => not RESET mode 
 *          0      => RESET mode 
 ***********************************************************************/
#define M512_asicIsAsicNotInResetMode(flashPtr) \
        (M512_Read8BitReg(flashPtr,M512_DOC_CONTROL_REG)) 

/***********************************************************************
 *  Name: M512_ReadMaxId
 *    Reads the MAX_ID bits in M512_CONFIGURATION_REG
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 * Returns: None 0 => not RESET mode 
 *          0      => RESET mode 
 ***********************************************************************/
#define M512_ReadMaxId(flashPtr) \
        ((M512_Read8BitReg(flashPtr,M512_CONFIGURATION_REG) & M512_MAX_ID_BITS)>>4) 
 
/***********************************************************************
 *  Name: M512_ReadFirstGoodUnit
 *    Reads the first good unit 
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 * Returns: The first Good Unit
 *         
 ***********************************************************************/
#define M512_ReadFirstGoodUnit(flashPtr) \
        (M512_Read8BitReg(flashPtr,M512_FIRST_GOOD_UNIT_REG)&M512_GOOD_UNIT_NUM_BITS) 

/***********************************************************************
 *  Name: M512_IsPowerDownOK                                                         
 *    Check if we can enter power down mode  
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 * Returns: 0        -> We cannot enter power down mode at this moment
 *          None 0   -> We can enter power down mode   
 ***********************************************************************/
#define M512_IsPowerDownOK(flashPtr) \
    (M512_Read8BitReg(flashPtr,M512_DPD_CONTROL_REG))

/***********************************************************************
 *  Name: M512_WriteEnableToFirstGoodBlock                                                          
 *    Removes the WP from the first good unit 
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 ***********************************************************************/
#define M512_WriteEnableToFirstGoodBlock(flashPtr,FirstGoodUnit) \
    (M512_Write8BitReg(flashPtr,M512_FIRST_GOOD_UNIT_REG,(FLByte)(M512_GOOD_UNIT_WRITE_EN|FirstGoodUnit)))

/***********************************************************************
 *  Name: M512_IsDownloadInProgress                                                          
 *    Check if the download is in progress
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 * Returns: 0        -> Download finished 
 *          None 0   -> Download in progress                   
 ***********************************************************************/
#define M512_IsDownloadInProgress(flashPtr) \
    (M512_DirectRead8BitReg(flashPtr,M512_DOWNLOAD_STATUS_REG) & \
    (Reg8bitType)M512_DOWNLOAD_IN_PROGRESS)

/***********************************************************************
 *  Name: M512_EnterTurboMode                                                          
 *    Enter Turbo Mode.
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 ***********************************************************************/
#define M512_EnterTurboMode(flashPtr) \
    (M512_Write8BitReg(flashPtr,M512_OUTPUT_CONTROL_REG,M512_TURBO_MODE)) 

/***********************************************************************
 *  Name: M512_IsFlashReady                                                          
 *                                                                      
 * Poll the selected flash busy signal.                                 
 *                                                                      
 * Parameters:                                                          
 *      flashPtr             : Pointer identifying drive                      
 *                                                                      
 * Returns: 0        -> Flash Busy
 *          None 0   -> Flash Ready                   
 ***********************************************************************/
#define M512_IsFlashReady(flashPtr) \
    (M512_Read8BitReg(flashPtr,M512_FLASH_CONTROL_REG) & \
    (Reg8bitType)M512_FLASH_READY)

/***********************************************************************
 * Name : M512_ReadChipID               
 *  Returns the controller (ASIC) chipID 
 *
 ***********************************************************************/
#define M512_ReadChipID(flashPtr) \
    M512_Read16BitReg(flashPtr,M512_CHIP_ID_REG)

/***********************************************************************
 * Name : ReadChipID_Confirm               
 *  Returns the controller (ASIC) chipID confirmation value 
 *
 ***********************************************************************/
#define M512_ReadChipID_Confirm(flashPtr) \
    M512_Read16BitReg(flashPtr,M512_CHIP_ID_CONFIRM_REG)

/***********************************************************************
 * Name : Find_IF_CFG                                                 
 *   Return the IF_CFG
 *         
 *     8 : IF_CFG = 8    
 *     16: IF_CFG = 16
 ***********************************************************************/
#define M512_Find_IF_CFG(flashPtr) \
    ((M512_Read8BitReg(flashPtr,M512_CONFIGURATION_REG) & \
      (Reg8bitType)M512_IF_CFG_STATUS) ? 16:8)

 /***********************************************************************
 * Name : M512_IsSequenceOrProtectionError
 *
 *        None 0  - Sequence ERROR
 *        0       - SEQUENCE OK
 ***********************************************************************/
#define M512_IsSequenceOrProtectionError(flashPtr) \
    (M512_Read8BitReg(flashPtr,M512_FLASH_CONTROL_REG) & (Reg8bitType)\
     (M512_SEQUENCE_ERROR_DETECTED | M512_PROTECTION_ERROR_DETECTED))         

 /***********************************************************************
 * Name : M512_IsSequenceError
 *
 *        None 0  - Sequence ERROR
 *        0       - SEQUENCE OK
 ***********************************************************************/
#define M512_IsSequenceError(flashPtr) \
    (M512_Read8BitReg(flashPtr,M512_FLASH_CONTROL_REG) & (Reg8bitType)\
     (M512_SEQUENCE_ERROR_DETECTED))         

 /***********************************************************************
 * Name : M512_IsProtectionError
 *
 *        None 0  - Sequence ERROR
 *        0       - SEQUENCE OK
 ***********************************************************************/
#define M512_IsProtectionError(flashPtr) \
    (M512_Read8BitReg(flashPtr,M512_FLASH_CONTROL_REG) & (Reg8bitType)\
    (M512_PROTECTION_ERROR_DETECTED))         
 
/***********************************************************************
 * Name : M512_ExecuteSequenceID
 *
 * Auxiliary routine for reading from flash I\O registers.
 *
 * Parameters:
 *       flashPtr    : Pointer identifying drive
 *       SEQ_ID      : One of the following sequences :
 *         RESET_SEQ                 = 00
 *         AREA_A_POINT_SEQ          = 14
 *         AREA_C_POINT_SEQ          = 16
 *         PAGE_SIZE_532_BYTES_SEQ   = 3       
 *         SET_FAST_MODE_SEQ         = 5  
 *         ENABLE_AUTO_PAGE_INC_SEQ  = 12
 *         READ_SEQ                  = 18
 *         PAGE_PROGRAM_SEQ          = 29
 *         ERASE_SEQ                 = 39
 *         STATUS_READ_SEQ           = 46
 *         STATUS_READ_MULTI_PLANE   = 49
 *         READ_ID_SEQ               = 52
 *         PAGE_BUFFER_LOOP_BACK     = 68
 ***********************************************************************/
#define M512_ExecuteSequenceID(flashPtr,SEQ_ID) \
    (M512_Write8BitReg (flashPtr,M512_FLASH_SEQUENCE_REG,(FLByte)(SEQ_ID)))

/***********************************************************************
 * Name : M512_FlashCommandRegWrite
 *
 * This Routine writes a command to the Flash Command Register
 *
 * Parameters:
 *       flashPtr    : Pointer identifying drive
 *       FLASH_CMD   : One of the flash Commands :
 *          ***   Read commands     ***
 *          READ_AREA_A_CMD          = 0x00,
 *          READ_AREA_B_CMD          = 0x01,
 *          READ_AREA_C_CMD          = 0x50, 
 *          MULTI_PLANE_READ         = 0x30, 
 *          ***   Output commands   ***
 *          READ_STATUS_CMD          = 0x70,   
 *          READ_STATUS_MULTI_CMD    = 0x71,
 *          READ_ID_CMD              = 0x90,
 *          ADDR_INPUT_FOR_REG_READ  = 0x05,
 *          ***   Program commands  ***
 *          PAGE_PROG_CYCLE_1_CMD    = 0x80, 
 *          PAGE_PROG_CYCLE_2_CMD    = 0x10,
 *          PAGE_PROG_DUMMY_CMD      = 0x11,
 *          ***  Erase commands     ***
 *          PAGE_ERASE_CYCLE_1_CMD   = 0x60,
 *          PAGE_ERASE_CYCLE_2_CMD   = 0xD0,
 *          *** Other commands      ***
 *          RESET_COMMAND            = 0xFF,
 *          *** Mode commands       ***
 *          SET_PAGE_SIZE_532_BYTES  = 0x3C,
 *          SET_FAST_MODE             = 0xA2,
 *          SET_PROG_VOLTAGE_TO_02_V = 0x22,
 *          SET_AUTO_PAGE_INC_ENABLE = 0xB3
 ************************************************************************/
#define M512_FlashCommandRegWrite(flashPtr,FLASH_CMD) \
    (M512_Write8BitReg (flashPtr,M512_FLASH_COMMAND_REG,(FLByte)(FLASH_CMD)))

⌨️ 快捷键说明

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