📄 c1667.h
字号:
/***************** Header File for Flash Memory ******************************* Filename: c1667.h Description: Header file for c1667.c. Consult also the C file for more details. Version: V1.1 Date: 21/03/2003 Author: Sylvia Goettl, STMicroelectronics, Agrate Brianza (Italy) Francesco Petruzziello, STMicroelectronics, Arzano (Italy) Copyright (c) 2003 STMicroelectronics. THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY AND FILES FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.************************************************************************************************************************************************************** Version History. Ver. Date Comments 1.1 21/03/2003 Initial Release of the software.******************************************************************************//*************** User Change Area ******************************************** This section is meant to give all the opportunities to customize the SW Drivers according to the requirements of hardware and flash configuration. It is possible to choose flash start address, CPU Bitdepth, number of flash chips, hardware configuration and performance data (TimeOut Info). The options are listed and explained below: ********* Data Types ********* The source code defines hardware independent datatypes assuming the compiler implements the numerical types as unsigned char 8 bits (defined as ubyte) char 8 bits (defined as byte) unsigned short 16 bits (defined as uword) short 16 bits (defined as word) unsigned int 32 bits (defined as udword) int 32 bits (defined as dword) In case the compiler does not support the currently used numerical types, they can be easily changed just once here in the user area of the headerfile. The data types are consequently referenced in the source code as (u)byte, (u)word and (u)dword. No other data types like 'CHAR','SHORT','INT','LONG' directly used in the code. ********* Flash Type ********* This driver supports the following Flash Types M29KW064E 16bit, 64Mbit Flash #define USE_M29KW064E ********* Base Address ********* The start address where the flash memory chips are "visible" within the memory of the CPU is called the BASE_ADDR. This address must be set according to the current system. This value is used by FlashRead() FlashWrite(). Some applications which require a more complicated FlashRead() or FlashWrite() may not use BASE_ADDR. ********* Flash and Board Configuration ********* The driver supports also different configurations of the flash chips on the board. In each configuration a new data Type called 'uCPUBusType' is defined to match the current CPU data bus width. This data type is then used for all accesses to the memory. The different options (defines) are explained below: - USE_16BIT_CPU_ACCESSING_1_16BIT_FLASH Using this define enables a configuration consisting of an environment containing a CPU with 16bit databus and 1 16bit flash chip connected to it. Standard Configuration. - USE_32BIT_CPU_ACCESSING_2_16BIT_FLASH Using this define enables a configuration consisting of an environment containing a CPU with 32bit databus and two flash chips connected to it. With every write access on the databus the first 16bit reaches, therefore, flash 1 and the second 16 bit reaches thus flash 2. The address pins are connected in parallel. ********* TimeOut ********* There are timeouts implemented in the loops of the code, in order to enable a timeout for operations that would otherwise never terminate. There are two possibilities: 1) The ANSI Library functions declared in 'time.h' exist If the current compiler supports 'time.h' the define statement TIME_H_EXISTS should be activated. This makes sure that the performance of the current evaluation HW does not change the timeout settings. 2) or they are not available (COUNT_FOR_A_SECOND) If the current compiler does not support 'time.h', the define statement can not be used. To overcome this constraint the value COUNT_FOR_A_SECOND has to be defined in order to create a one second delay. For example, if 100000 repetitions of a loop are needed, to give a time delay of one second, then COUNT_FOR_A_SECOND should have the value 100000. Note: This delay is HW (Performance) dependent and needs, therefore, updated with every new HW. This driver has been tested with a certain configuration and other target platforms may have other performance data, therefore, the value may have to be changed. It is up to the user to implement this value to avoid the code timing out too early instead of completing correctly. ********* Additional Routines ********* The drivers provides also a subroutine which displays the full error message instead of just an error number. The define statement VERBOSE activates additional Routines. Currently it activates the function FlashErrorStr() No further changes should be necessary. *****************************************************************************/#ifndef __C1667__H__#define __C1667__H__typedef unsigned char ubyte; /* All HW dependent Basic Data Types */ typedef char byte; typedef unsigned short uword; typedef short word; typedef unsigned int udword; typedef int dword; #define USE_M29KW064E /* Possible Values: USE_M29KW064E */#define BASE_ADDR ((volatile uCPUBusType*)0x00000000)/* BASE_ADDR is the base or start address of the flash, see the functions FlashRead and FlashWrite(). Some applications which require a more complicated FlashRead() or FlashWrite() may not use BASE_ADDR */#define USE_32BIT_CPU_ACCESSING_2_16BIT_FLASH /* Current PCB Info *//* Possible Values: USE_16BIT_CPU_ACCESSING_1_16BIT_FLASH USE_32BIT_CPU_ACCESSING_2_16BIT_FLASH */ #define TIME_H_EXISTS /* set this macro if C-library "time.h" is supported *//* Possible Values: TIME_H_EXISTS - no define - TIME_H_EXISTS */ #ifndef TIME_H_EXISTS #define COUNT_FOR_A_SECOND 100000 /* Timer Usage */#endif #define VERBOSE /* Activates additional Routines *//* Currently the Error String Definition *//********************** End of User Change Area *****************************//*****************************************************************************HW Structure Info, Usage of the Flash Memory (Circuitry)*****************************************************************************/#ifdef USE_16BIT_CPU_ACCESSING_1_16BIT_FLASH typedef uword uCPUBusType; typedef word CPUBusType; #define FLASH_BIT_DEPTH 16 #define HEX "04Xh" #define CMD(A) (A) #define CONFIGURATION_DEFINED#endif #ifdef USE_32BIT_CPU_ACCESSING_2_16BIT_FLASH typedef udword uCPUBusType; typedef dword CPUBusType; #define FLASH_BIT_DEPTH 16 #define HEX "08Xh" #define CMD(A) (A+(A<<16)) #define CONFIGURATION_DEFINED#endif /*******************************************************************************Device Specific Return Codes*******************************************************************************/typedef enum { FlashSpec_MwpSetupFailed, FlashSpec_ToggleFailed } SpecificReturnType;/******************************************************************************* CONFIGURATION CHECK*******************************************************************************/ #ifndef CONFIGURATION_DEFINED #error User Change Area Error: PCB Info uncorrect Check the USE_xxBIT_CPU_ACCESSING_n_yyBIT_FLASH Value#endif/******************************************************************************* 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -