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

📄 c2312.h

📁 flash programer driver
💻 H
📖 第 1 页 / 共 4 页
字号:
     DERIVED DATATYPES*******************************************************************************/ /******** CommandsType ********/ typedef enum {    BankErase,   BankReset,   BankResume,   BankSuspend,   BlockErase,   BlockProtect,    BlockUnprotect,    CheckBlockProtection,    CheckCompatibility,    ChipErase,    ChipUnprotect,    GroupProtect,   Program,    Read,    ReadCfi,    ReadDeviceId,    ReadManufacturerCode,    Reset,    Resume,    SingleProgram,    Suspend,    Write  } CommandType; /******** ReturnType ********/ typedef enum {    Flash_AddressInvalid,    Flash_BankEraseFailed,   Flash_BlockEraseFailed,    Flash_BlockNrInvalid,    Flash_BlockProtected,    Flash_BlockProtectFailed,    Flash_BlockProtectionUnclear,    Flash_BlockUnprotected,    Flash_BlockUnprotectFailed,    Flash_CfiFailed,    Flash_ChipEraseFailed,    Flash_ChipUnprotectFailed,    Flash_FunctionNotSupported,   Flash_GroupProtectFailed,    Flash_NoInformationAvailable,   Flash_NoOperationToSuspend,   Flash_OperationOngoing,    Flash_OperationTimeOut,    Flash_ProgramFailed,    Flash_ResponseUnclear,    Flash_SpecificError,   Flash_Success,    Flash_VppInvalid,    Flash_WrongType} ReturnType;   /******** BlockType ********/ typedef uword uBlockType;  /******** ParameterType ********/  typedef union {     /**** BankErase Parameters ****/     struct {       uBlockType ublBlockNr;      ReturnType *rpResults;     } BankErase;          /**** BankReset Parameters ****/     struct {       udword udBankAddrOff;     } BankReset;    /**** BankResume Parameters ****/     struct {       udword udAddrOff;     } BankResume;         /**** BankSuspend Parameters ****/     struct {       udword udAddrOff;     } BankSuspend;    /**** BlockErase Parameters ****/     struct {       uBlockType ublBlockNr;     } BlockErase;     /**** BlockProtect Parameters ****/     struct {       uBlockType ublBlockNr;     } BlockProtect;      /**** BlockUnprotect Parameters ****/     struct {       uBlockType ublBlockNr;     } BlockUnprotect;      /**** CheckBlockProtection Parameters ****/     struct {       uBlockType ublBlockNr;     } CheckBlockProtection;      /**** CheckCompatibility has no parameters ****/      /**** ChipErase Parameters ****/     struct {       ReturnType *rpResults;     } ChipErase;           /**** ChipUnprotect Parameters ****/     struct {       ReturnType *rpResults;     } ChipUnprotect;      /**** GroupProtect Parameters ****/     struct {       uBlockType ublBlockNr;     } GroupProtect;      /**** Program Parameters ****/     struct {       udword udAddrOff;       udword udNrOfElementsInArray;                 void *pArray;       udword udMode;            } Program;     /**** Read Parameters ****/     struct {       udword  udAddrOff;       uCPUBusType ucValue;      } Read;      /**** ReadCfi Parameters ****/     struct {       uword  uwCfiFunc;       uCPUBusType ucCfiValue;            } 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 ANY_ADDR (0x0)            /* Any address offset within the Flash Memory will do */#ifdef USE_M29DW640F_8 /* The M29DW640F device 8 bit */   #define MANUFACTURER_ST (0x20)  /* ST Manufacturer Code is 0x20 */   #define EXPECTED_DEVICE (0x7E)  /* Device code for the M29DW640F */   #define FLASH_SIZE (0x800000)       /* Total device size in Bytes */   #define FLASH_WRITE_BUFFER_SIZE 1   /* Write Buffer = 1 Byte */   #define FLASH_MWA 1  /* Minimum Write Access */   #define ShAddr(A) (A<<1)            /* Exclude A-1 address bit in ReadCFi                                          and Protect/Unprotect commands */   #define ConvAddr(A) (2*A+!(A&0x1))  /* Convert a word mode command to byte mode command :                                           Word Mode Command    Byte Mode Command                                                0x555      ->     0xAAA                                                0x2AA      ->     0x555                                                0x55       ->     0xAA            */   static const ubyte BlockGroupOffset[] = {      1,1,1,1,1,1,1,1,3,      4,4,4,4,4,4,4,4,4,4,      4,4,4,4,4,4,4,4,4,4,      4,4,4,4,4,4,4,4,4,4,      3,1,1,1,1,1,1,1,1   };      static const udword BlockOffset[] = {      0x000000,  /* Start offset of block 0  */      0x002000,  /* Start offset of block 1  */      0x004000,  /* Start offset of block 2  */      0x006000,  /* Start offset of block 3  */      0x008000,  /* Start offset of block 4  */      0x00A000,  /* Start offset of block 5  */      0x00C000,  /* Start offset of block 6  */      0x00E000,  /* Start offset of block 7  */      0x010000,  /* Start offset of block 8  */      0x020000,  /* Start offset of block 9  */      0x030000,  /* Start offset of block 10  */      0x040000,  /* Start offset of block 11  */      0x050000,  /* Start offset of block 12  */      0x060000,  /* Start offset of block 13  */      0x070000,  /* Start offset of block 14  */      0x080000,  /* Start offset of block 15  */      0x090000,  /* Start offset of block 16  */      0x0A0000,  /* Start offset of block 17  */

⌨️ 快捷键说明

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