📄 c1667.h
字号:
} ReadCfi; /**** ReadDeviceId Parameters ****/ struct { uCPUBusType ucDeviceId; } ReadDeviceId; /**** ReadManufacturerCode Parameters ****/ struct { uCPUBusType ucManufacturerCode; } ReadManufacturerCode; /**** Reset has no parameters ****/ /**** Resume has no parameters ****/ /**** SingleProgram Parameters ****/ struct { udword udAddrOff; uCPUBusType ucValue; } SingleProgram; /**** Suspend has no parameters ****/ /**** Write Parameters ****/ struct { udword udAddrOff; uCPUBusType ucValue; } Write; } ParameterType; /******** ErrorInfoType ********/ typedef struct { SpecificReturnType sprRetVal; udword udGeneralInfo[4];} ErrorInfoType;/****************************************************************************** Global variables*******************************************************************************/ extern ErrorInfoType eiErrorInfo;/****************************************************************************** Standard functions*******************************************************************************/ ReturnType Flash( CommandType cmdCommand, ParameterType *fp ); ReturnType FlashBankErase( uBlockType ublBlockNr, ReturnType *rpResults ); ReturnType FlashBankReset( udword udBankAddrOff );
ReturnType FlashBankResume( udword udBankAddrOff ); ReturnType FlashBankSuspend( udword udBankAddrOff ); ReturnType FlashBlockErase( uBlockType ublBlockNr ); ReturnType FlashBlockProtect( uBlockType ublBlockNr ); ReturnType FlashBlockUnprotect( uBlockType ublBlockNr ); ReturnType FlashCheckBlockProtection( uBlockType ublBlockNr ); ReturnType FlashCheckCompatibility( void ); ReturnType FlashChipErase( ReturnType *rpResults ); ReturnType FlashChipUnprotect( ReturnType *rpResults ); ReturnType FlashGroupProtect( uBlockType ublBlockNr ); ReturnType FlashProgram( udword udMode, udword udAddrOff, udword udNrOfElementsInArray, void *pArray ); uCPUBusType FlashRead( udword udAddrOff ); ReturnType FlashReadCfi( uword uwCFIFunc, uCPUBusType *ucpCFIValue ); ReturnType FlashReadDeviceId( uCPUBusType *ucpDeviceID); ReturnType FlashReadManufacturerCode( uCPUBusType *ucpManufacturerCode); ReturnType FlashReset( void ); ReturnType FlashResume( void ); ReturnType FlashSingleProgram( udword udAddrOff, uCPUBusType ucVal ); ReturnType FlashSuspend( void ); void FlashWrite( udword udAddrOff, uCPUBusType ucVal );/****************************************************************************** Utility functions*******************************************************************************/ #ifdef VERBOSE byte *FlashErrorStr( ReturnType rErrNum );#endif
ReturnType FlashResponseIntegrityCheck( uCPUBusType *ucpFlashResponse ); ReturnType FlashTimeOut( udword udSeconds ); /*******************************************************************************Device Constants*******************************************************************************/#define MANUFACTURER_ST (0x0020) /* ST Manufacturer Code is 0x20 */#define ANY_ADDR (0x0) /* Any address offset within the Flash Memory will do */#define ANY_VALUE (0x0) /* Any Value will do */#ifdef USE_M29KW064E /* The M29KW064E device */ #define EXPECTED_DEVICE (0x88AF) /* Device code for the M29KW064E */ #define FLASH_SIZE (0x400000) /* Total device size in Elements */ #define FLASH_WRITE_BUFFER_SIZE 1 /* Write Buffer = 1 Element */ #define FLASH_MWA 1 /* Minimum Write Access */ static const udword BlockOffset[] = { 0x000000, /* Start offset of block 0 */ 0x020000, /* Start offset of block 1 */ 0x040000, /* Start offset of block 2 */ 0x060000, /* Start offset of block 3 */ 0x080000, /* Start offset of block 4 */ 0x0A0000, /* Start offset of block 5 */ 0x0C0000, /* Start offset of block 6 */ 0x0E0000, /* Start offset of block 7 */ 0x100000, /* Start offset of block 8 */ 0x120000, /* Start offset of block 9 */ 0x140000, /* Start offset of block 10 */ 0x160000, /* Start offset of block 11 */ 0x180000, /* Start offset of block 12 */ 0x1A0000, /* Start offset of block 13 */ 0x1C0000, /* Start offset of block 14 */ 0x1E0000, /* Start offset of block 15 */ 0x200000, /* Start offset of block 16 */ 0x220000, /* Start offset of block 17 */ 0x240000, /* Start offset of block 18 */ 0x260000, /* Start offset of block 19 */ 0x280000, /* Start offset of block 20 */ 0x2A0000, /* Start offset of block 21 */ 0x2C0000, /* Start offset of block 22 */ 0x2E0000, /* Start offset of block 23 */ 0x300000, /* Start offset of block 24 */ 0x320000, /* Start offset of block 25 */ 0x340000, /* Start offset of block 26 */ 0x360000, /* Start offset of block 27 */ 0x380000, /* Start offset of block 28 */ 0x3A0000, /* Start offset of block 29 */ 0x3C0000, /* Start offset of block 30 */ 0x3E0000 /* Start offset of block 31 */ }; /* EndArray BlockOffset[] */#endif /* USE_M29KW064E */#define NUM_BLOCKS (sizeof(BlockOffset)/sizeof(BlockOffset[0]))ReturnType FlashDataToggle( void );ReturnType FlashMWProgram(udword udMode, udword udAddrOff, udword udNrOfElementsInArray, void *pArray );/******************************************************************************* 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_NoInformationAvailableDescription: The system can't give any additional information about the error.Solution: None******************************************************************************** Error Name: Flash_NoOperationToSuspendDescription: 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_SpecificErrorDescription: 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 and Return values, Explanations and Help.********************************************************************************Error Name: FlashSpec_MwpSetupFailedDescription: The Multiple Word Program algorithm has not successfully completed the Setup Phase. See the related DataSheet for more details. 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_ToggleFailedDescription: 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.********************************************************************************/#endif/******************************************************************************* End of c1667.h********************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -