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

📄 c2635.h

📁 Flash Memory 依據標準CFI CMD做Erase/Program過程的參考碼
💻 H
📖 第 1 页 / 共 4 页
字号:
#ifdef VERBOSE
   byte *FlashErrorStr( ReturnType rErrNum );
#endif

static void    FlashPause(udword udMicroSeconds);
ReturnType  FlashResponseIntegrityCheck( uCPUBusType *ucpFlashResponse );
ReturnType  FlashTimeOut( udword udSeconds );
/******************************************************************************* 
Specific Function Prototypes
********************************************************************************/


/******************************************************************************* 
Protection Function Prototypes
********************************************************************************/
ReturnType  FlashCheckBlockProtection( uBlockType ublBlockNr );
          void  FlashEnterExtendedBlock( void );
          void  FlashExitExtendedBlock( void );
ReturnType  FlashReadExtendedBlockVerifyCode( uCPUBusType *ucpVerifyCode );


ReturnType FlashCheckProtectionMode( void );

ReturnType FlashSetNVProtectionMode( void );
ReturnType FlashSetPasswordProtectionMode( void );
ReturnType FlashSetExtendedBlockProtection( void );

ReturnType FlashSetNVPBLockBit( void );
ReturnType FlashCheckNVPBLockBit( void );

ReturnType FlashCheckBlockNVPB( uBlockType ublBlockNr );
ReturnType FlashClearBlockNVPB(  );
ReturnType FlashSetBlockNVPB( uBlockType ublBlockNr );

ReturnType FlashCheckBlockVPB( uBlockType ublBlockNr );
ReturnType FlashClearBlockVPB( uBlockType ublBlockNr );
ReturnType FlashSetBlockVPB( uBlockType ublBlockNr );

ReturnType FlashPasswordProgram( uCPUBusType *uwPWD );
ReturnType FlashVerifyPassword( uCPUBusType *pwd );
ReturnType FlashPasswordProtectionUnlock( uCPUBusType *pwd );

void  FlashExitProtection( void );
/******************************************************************************* 
List of Errors and Return values, Explanations and Help. 
******************************************************************************** 

Error Name:   Flash_AddressInvalid 
Description:  The address offset given is out of the range of the flash device. 
Solution:     Check the address offset whether it is in the valid range of the 
              flash device. 
******************************************************************************** 
 
Error Name:   Flash_BankEraseFailed 
Description:  The bank erase command did not finish successfully. 
Solution:     Check that Vpp is not floating. Try erasing the block again. If 
              this fails once more, the device may be faulty and needs to be
              replaced. 
******************************************************************************** 
 
Error Name:   Flash_BlockEraseFailed 
Description:  The block erase command did not finish successfully. 
Solution:     Check that Vpp is not floating. Try erasing the block again. If 
              this fails once more, the device may be faulty and needs to be
              replaced. 
******************************************************************************** 
 
Error Name:   Flash_BlockNrInvalid 
Note:         This is not a flash problem. 
Description:  A selection for a block has been made (Parameter), which is not 
              within the valid range. Valid block numbers are from 0 to
              NUM_BLOCKS-1. 
Solution:     Check that the block number given is in the valid range. 
******************************************************************************** 
 
Error Name:   Flash_BlockProtected               
Description:  The user has attempted to erase, program or protect a block of  
              the flash that is protected. The operation failed because the
              block in question is protected. This message appears also after
              checking the protection status of a block.  
Solutions:    Choose another (unprotected) block for erasing or programming. 
              Alternatively change the block protection status of the current
              block (see Datasheet for more details). In case of the user is
              protecting a block that is already protected, this warning notifies
              the user that the command had no effect.  
******************************************************************************** 

Error Name:   Flash_BlockProtectFailed 
Description:  This error return value indicates that a block protect command did 
              not finish successfully. 
Solution:     Check that Vpp is not floating but is tied to a valid voltage. Try 
              the command again. If it fails a second time then the block cannot
              be protected and it may be necessary to replace the device. 
******************************************************************************** 
 
Error Name:   Flash_BlockProtectionUnclear 
Description:  The user has attempted to erase, program or protect a block of  
              the flash which did not return a proper protection status. The
              operation has been cancelled. 
Solutions:    This should only happen in configurations with more than one 
              flash device. If the response of each device does not match, this
              return code is given. Mostly it means the usage of not properly
              initialized flash devices.   
******************************************************************************** 
 
Error Name:   Flash_BlockUnprotected 
Description:  This message appears after checking the block protection status.  
              This block is ready to get erased, programmed or protected.  
******************************************************************************** 

Error Name:   Flash_BlockUnprotectFailed 
Description:  This error return value indicates that a block unprotect command
              did not finish successfully. 
Solution:     Check that Vpp is not floating but is tied to a valid voltage. Try 
              the command again. If it fails a second time then the block cannot
              be unprotected and it may be necessary to replace the device. 
******************************************************************************** 
    
Error Name:   Flash_CfiFailed 
Description:  This return value indicates that a Common Flash Interface (CFI) 
              read access was unsuccessful. 
Solution:     Try to read the Identifier Codes (Manufacture ID, Device ID) 
              if these commands fail as well it is likely that the device is
              faulty or the interface to the flash is not correct. 
********************************************************************************    
 
Error Name:   Flash_ChipEraseFailed 
Description:  This message indicates that the erasure of the whole device has  
              failed. 
Solution:     Investigate this failure further by checking the results array
              (parameter), where all blocks and their erasure results are listed.
              What is more, try to erase each block individually. If erasing a
              single block still causes failure, then the Flash device may need
              to be replaced. 
******************************************************************************** 
 
Error Name:   Flash_ChipUnprotectFailed 
Description:  This return value indicates that the chip unprotect command  
              was unsuccessful. 
Solution:     Check that Vpp is not floating but is tied to a valid voltage. Try 
              the command again. If it fails a second time then it is likely that
              the device cannot be unprotected and will need to be replaced. 
******************************************************************************** 
 
Return Name:  Flash_FunctionNotSupported 
Description:  The user has attempted to make use of functionality not 
              available on this flash device (and thus not provided by the
              software drivers).   
Solution:     This can happen after changing Flash SW Drivers in existing 
              environments. For example an application tries to use 
              functionality which is then no longer provided with a new device. 
******************************************************************************** 

Error Name:   Flash_GroupProtectFailed 
Description:  This error return value indicates that a group protect command did 
              not finish successfully. 
Solution:     Check that Vpp is not floating but is tied to a valid voltage. Try 
              the command again. If it fails a second time then the group cannot
              be protected and it may be necessary to replace the device.
******************************************************************************** 
 
Return Name:  Flash_NoInformationAvailable
Description:  The system can't give any additional information about the error.
Solution:     None
******************************************************************************** 
 
Error Name:   Flash_NoOperationToSuspend
Description:  This message is returned by a suspend operation if there isn't 
              operation to suspend (i.e. the program/erase controller is inactive).
******************************************************************************** 
 
Error Name:   Flash_OperationOngoing 
Description:  This message is one of two messages which are given by the TimeOut 
              subroutine. That means the flash operation still operates within
              the defined time frame.  
******************************************************************************** 
 
Error Name:   Flash_OperationTimeOut 
Description:  The Program/Erase Controller algorithm could not finish an 
              operation successfully. It should have set bit 7 of the status
              register from 0 to 1, but that did not happen within a predefined
              time. The program execution has been, therefore, cancelled by a
              timeout. This may be because the device is damaged.  
Solution:     Try the previous command again. If it fails a second time then it 
              is likely that the device will need to be replaced. 
******************************************************************************** 
 
Error Name:   Flash_ProgramFailed 
Description:  The value that should be programmed has not been written correctly 
              to the flash. 
Solutions:    Make sure that the block which is supposed to receive the value 
              was erased successuly before programming. Try erasing the block and
              programming the value again. If it fails again then the device may
              be faulty. 
******************************************************************************** 
 
Error Name:   Flash_ResponseUnclear 
Description:  This message appears in multiple flash configurations, if the   
              single flash responses are different and, therefore, a sensible
              reaction of the SW driver is not possible. 
Solutions:    Check all the devices currently used and make sure they are all  
              working properly. Use only equal devices in multiple configurations.
              If it fails again then the devices may be faulty and need to be
              replaced. 
******************************************************************************** 

Error Name:   Flash_SpecificError
Description:  The function makes an error depending on the device.
              More information about the error are available into the ErrorInfo
              variable.
Solutions:    See SpecificReturnType remarks
******************************************************************************** 

Return Name:  Flash_Success 
Description:  This value indicates that the flash command has executed 
              correctly. 
******************************************************************************** 

Error Name:   Flash_VppInvalid  
Description:  A Program or a Block Erase has been attempted with the Vpp supply 
              voltage outside the allowed ranges. This command had no effect
              since an invalid Vpp has the effect of protecting the whole of
              flash device. 
Solution:     The (hardware) configuration of Vpp will need to be modified to  
              enable programming or erasing of the device.  
*******************************************************************************

Error Name:   Flash_WrongType 
Description:  This message appears if the Manufacture and Device ID read from 
              the current flash device do not match with the expected identifier
              codes. That means the source code is not explicitely written for
              the currently used flash chip. It may work, but it cannot be
              guaranteed. 
Solutions:    Use a different flash chip with the target hardware or contact 
              STMicroelectronics for a different source code library. 
********************************************************************************/
/*******************************************************************************
List of Specific Errors, Explanations and Help. 
******************************************************************************** 

 
Error Name:   FlashSpec_MpuTooSlow
Notes:        Applies to M29 series Flash only.
Description:  The MPU has not managed to write all of the selected blocks to the
              device before the timeout period expired. See BLOCK ERASE COMMAND
              section of the Data Sheet for details.
Solutions:    If this occurs occasionally then it may be because an interrupt is
              occuring between writing the blocks to be erased. Search for "DSI!" in
              the code and disable interrupts during the time critical sections.
              If this error condition always occurs then it may be time for a faster
              microprocessor, a better optimising C compiler or, worse still, learn
              assembly. The immediate solution is to only erase one block at a time.

********************************************************************************

Error Name:   FlashSpec_ToggleFailed
Notes:        This applies to M29 series Flash only.
Description:  The Program/Erase Controller algorithm has not managed to complete
              the command operation successfully. This may be because the device is
              damaged.
Solution:     Try the command again. If it fails a second time then it is likely that
              the device will need to be replaced.

******************************************************************************
Error Name:   FlashSpec_Too_ManyBlocks
Notes:        Applies to M29 series Flash only.
Description:  The user has chosen to erase more blocks than the device has.
              This may be because the array of blocks to erase contains the same
			  block more than once.
Solutions:    Check that the program is trying to erase valid blocks. The device
              will only have NUM_BLOCKS blocks (defined at the top of the file).
			  Also check that the same block has not been added twice or more to
			  the array.

*******************************************************************************/

#endif /* In order to avoid a repeated usage of the header file */

/*******************************************************************************  
     End of c2635.h
********************************************************************************/

⌨️ 快捷键说明

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