?? c2312.c
字號:
FlashReset();
return rRetVal;
} /* EndFunction FlashQuadProgram */
#if defined(USE_M29DW640F_8) /* In 8 bit Mode */
/*******************************************************************************
Function: ReturnType FlashOctProgram( udword udAddrOff, uCPUBusType *pArray )
Arguments: udAddrOff is the address to program.
pArray is the pointer to the content to be programmed
Return Value: The function returns the following conditions:
Flash_Success
Flash_ProgramFailed
Note:
1) This procedure is available only in 8-bit mode. For the 16-bit mode, see the
FlashDoubleProgram/FlashQuadProgram procedure
2) This procedure automatically put the two least significati bits of udAddrOff
to zero, to align the address with an oct-bytes boundary.
Description: This function programs eight consecutive byte, starting from the
oct-byte boundary.
Pseudo Code:
Step 1: Align address to oct-bytes boundary
Step 2: Program
Step 3: Wait until the Program/Erase Controller has completed
Step 4: Return to read Array mode
********************************************************************************/
ReturnType FlashOctProgram( udword udAddrOff, uCPUBusType *pArray )
{
ReturnType rRetVal = Flash_Success; /* Return value */
/* Step 1: Align address to oct-BYTE boundary */
udAddrOff = udAddrOff & (0xFFFFFFF8);
/* Step 2: Program */
/* Note: the command is expressed without ConvAddr, because it is possible
only in 8bit mode*/
FlashWrite( 0x0AAA, CMD(0x008B) ); /* Oct Byte Command */
FlashWrite( udAddrOff, *pArray++);
FlashWrite( udAddrOff+1, *pArray++);
FlashWrite( udAddrOff+2, *pArray++);
FlashWrite( udAddrOff+3, *pArray++);
FlashWrite( udAddrOff+4, *pArray++);
FlashWrite( udAddrOff+5, *pArray++);
FlashWrite( udAddrOff+6, *pArray++);
FlashWrite( udAddrOff+7, *pArray++);
/* Step 3: Wait until Program/Erase Controller has completed */
if (FlashDataToggle(udAddrOff) != Flash_Success)
rRetVal = Flash_ProgramFailed;
/* Step 4: Return to read Array mode */
FlashReset();
return rRetVal;
}/* End of FlashOctProgram*/
#endif /*defined(USE_M29DW640F_8) */
/*******************************************************************************
Function: uCPUBusType FlashRead( udword udAddrOff )
Arguments: udAddrOff is the offset into the flash to read from.
Return Value: The uCPUBusType content at the address offset.
Description: This function is used to read a uCPUBusType from the flash.
On many microprocessor systems a macro can be used instead, increasing the
speed of the flash routines. For example:
#define FlashRead( udAddrOff ) ( BASE_ADDR[udAddrOff] )
A function is used here instead to allow the user to expand it if necessary.
Pseudo Code:
Step 1: Return the value at double-word offset udAddrOff
*******************************************************************************/
uCPUBusType FlashRead( udword udAddrOff ) {
/* Step 1 Return the value at double-word offset udAddrOff */
return BASE_ADDR[udAddrOff];
} /* EndFunction FlashRead */
/*******************************************************************************
Function: ReturnType FlashReadCfi( uword uwCfiFunc, uCPUBusType *ucpCfiValue )
Arguments: uwCfiFunc is set to the offset of the CFI parameter to be read.
The CFI value read from offset uwCfiFunc is passed back to the calling
function by *ucpCfiValue.
Return Value: The function returns the following conditions:
Flash_Success
Flash_CfiFailed
Description: This function checks whether the flash CFI is present and operable,
then reads the CFI value at the specified offset. The CFI value requested is
then passed back to the calling function.
Pseudo Code:
Step 1: Send the Read CFI Instruction
Step 2: Check that the CFI interface is operable
Step 3: If CFI is operable read the required CFI value
Step 4: Return the flash to Read Array mode
*******************************************************************************/
ReturnType FlashReadCfi( uword uwCfiFunc, uCPUBusType *ucpCfiValue ) {
ReturnType rRetVal = Flash_Success; /* Holds the return value */
udword udCfiAddr; /* Holds CFI address */
/* Step 1: Send the Read CFI Instruction */
FlashWrite( ConvAddr(0x55), (uCPUBusType)CMD(0x0098) );
/* Step 2: Check that the CFI interface is operable */
if( ((FlashRead( ShAddr(0x00000010) ) & CMD(0x00FF) ) != CMD(0x0051)) ||
((FlashRead( ShAddr(0x00000011) ) & CMD(0x00FF) ) != CMD(0x0052)) ||
((FlashRead( ShAddr(0x00000012) ) & CMD(0x00FF) ) != CMD(0x0059)) )
rRetVal = Flash_CfiFailed;
else {
/* Step 3: Read the required CFI Info */
udCfiAddr = (udword)uwCfiFunc;
*ucpCfiValue = FlashRead( ShAddr((udCfiAddr & 0x000000FF)) );
} /* EndIf */
FlashReset(); /* Step 4: Return to Read Array mode */
return rRetVal;
} /* EndFunction FlashReadCfi */
/*******************************************************************************
Function: ReturnType FlashReadDeviceId( uCPUBusType *ucpDeviceId )
Arguments: - *ucpDeviceId = <return value> The function returns the Device Code.
The device code for the part is:
M29DW640F 0x227E
Note: In case a common response of more flash chips is not identical the real
read value will be given (Flash_ResponseUnclear)
Return Value: The function returns the following conditions:
Flash_Success
Flash_ResponseUnclear
Description: This function can be used to read the device code of the flash.
Pseudo Code:
Step 1: Send the Auto Select instruction
Step 2: Read the DeviceId
Step 3: Return the device to Read Array mode
Step 4: Check flash response (more flashes could give different results)
*******************************************************************************/
ReturnType FlashReadDeviceId( uCPUBusType *ucpDeviceId ) {
/* Step 1: Send the AutoSelect command */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x00AA) ); /* 1st Cycle */
FlashWrite( ConvAddr(0x002AA), (uCPUBusType)CMD(0x0055) ); /* 2nd Cycle */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x0090) ); /* 3rd Cycle */
/* Step 2: Read the DeviceId */
*ucpDeviceId = FlashRead(ShAddr(0x1)); /* A0 = 1, A1 = 0 */
/* Step 3: Return to Read Array Mode */
FlashReset();
/* Step 4: Check flash response (more flashes could give different results) */
return FlashResponseIntegrityCheck( ucpDeviceId );
} /* EndFunction FlashReadDeviceId */
/*******************************************************************************
Function: ReturnType FlashReadExtendedBlockVerifyCode( uCPUBusType *ucpVerifyCode )
Arguments: - *ucpVerifyCode = <return value>
The function returns the Extended Memory Block Verify Code.
The Extended Memory Block Verify Code for the part are:
M29DW640F
0x80 (factory locked)
0x00 (not factory locked)
Note: In case a common response of more flash chips is not identical the real
read value will be given (Flash_ResponseUnclear)
Return Value: The function returns the following conditions:
Flash_Success
Flash_ResponseUnclear
Description: This function can be used to read the Extended Memory Block Verify Code.
The verify code is used to specify if the Extended Memory Block was locked/not locked
by the manufacturer.
Pseudo Code:
Step 1: Send the Auto Select instruction
Step 2: Read the Extended Memory Block Verify Code
Step 3: Return the device to Read Array mode
Step 4: Check flash response (more flashes could give different results)
*******************************************************************************/
ReturnType FlashReadExtendedBlockVerifyCode( uCPUBusType *ucpVerifyCode ) {
/* Step 1: Send the AutoSelect command */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x00AA) ); /* 1st Cycle */
FlashWrite( ConvAddr(0x002AA), (uCPUBusType)CMD(0x0055) ); /* 2nd Cycle */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x0090) ); /* 3rd Cycle */
/* Step 2: Read the Extended Memory Block Verify Code */
*ucpVerifyCode = FlashRead(ShAddr(0x3)); /* A0 = 1, A1 = 1 */
/* Step 3: Return to Read Array Mode */
FlashReset();
/* Step 4: Check flash response (more flashes could give different results) */
return FlashResponseIntegrityCheck( ucpVerifyCode );
} /* EndFunction FlashReadExtendedBlockVerifyCode */
/*******************************************************************************
Function: ReturnType FlashReadManufacturerCode( uCPUBusType *ucpManufacturerCode )
Arguments: - *ucpManufacturerCode = <return value> The function returns
the manufacture code (for ST = 0x0020).
In case a common response of more flash chips is not identical the real
read value will be given (Flash_ResponseUnclear)
Return Value: The function returns the following conditions:
Flash_Success
Flash_ResponseUnclear
Description: This function can be used to read the manufacture code of the flash.
Pseudo Code:
Step 1: Send the Auto Select instruction
Step 2: Read the Manufacturer Code
Step 3: Return the device to Read Array mode
Step 4: Check flash response (more flashes could give different results)
*******************************************************************************/
ReturnType FlashReadManufacturerCode( uCPUBusType *ucpManufacturerCode ) {
/* Step 1: Send the AutoSelect command */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x00AA) ); /* 1st Cycle */
FlashWrite( ConvAddr(0x002AA), (uCPUBusType)CMD(0x0055) ); /* 2nd Cycle */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x0090) ); /* 3rd Cycle */
/* Step 2: Read the DeviceId */
*ucpManufacturerCode = FlashRead( ShAddr(0x0) ); /* A0 = 0, A1 = 0 */
/* Step 3: Return to Read Array Mode */
FlashReset();
/* Step 4: Check flash response (more flashes could give different results) */
return FlashResponseIntegrityCheck( ucpManufacturerCode );
} /* EndFunction FlashReadManufacturerCode */
/*******************************************************************************
Function: void FlashReset( void )
Arguments: none
Return Value: Flash_Success
Description: This function places the flash in the Read Array mode described
in the Data Sheet. In this mode the flash can be read as normal memory.
All of the other functions leave the flash in the Read Array mode so this is
not strictly necessary. It is provided for completeness and in case of
problems.
Pseudo Code:
Step 1: write command sequence (see Instructions Table of the Data Sheet)
*******************************************************************************/
ReturnType FlashReset( void ) {
/* Step 1: write command sequence */
FlashWrite( ConvAddr(0x00555), (uCPUBusType)CMD(0x00AA) ); /* 1st Cycle */
FlashWrite( ConvAddr(0x002AA), (uCPUBusType)CMD(0x0055) ); /* 2nd Cycle */
FlashWrite( ANY_ADDR, (uCPUBusType)CMD(0x00F0) ); /* 3rd Cycle: write 0x00F0 to ANY address */
return Flash_Success;
} /* EndFunction FlashReset */
/*******************************************************************************
Function: ReturnType FlashResponseIntegrityCheck(uCPUBusType *ucpFlashResponse)
Arguments: - ucpFlashResponse <parameter> + <return value>
The function returns a unique value in case one flash or an
array of flashes return all the same value (Consistent Response = Flash_Success).
In case an array of flashes returns different values the function returns the
received response without any changes (Inconsistent Response = Flash_ResponseUnclear).
Return Value: The function returns the following conditions:
Flash_Success
Flash_ResponseUnclear
Description: This function is used to create one response in multi flash
environments, instead of giving multiple answers of the single flash
devices.
For example: Using a 32bit CPU and two 16bit Flash devices, the device Id
would be directly read: 00170017h, because each device gives an answer
within the range of the databus. In order to give a simple response
like 00000017h in all possible c
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -