📄 template.c
字号:
query->ExtTablePtr = (UINT16)( query->ExtTablePtr | item );
offset++;
}
/* read alternate vendor id */
query->AltVendorId = 0;
for ( i=0; i < 2; i++ )
{
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
item = item << (8*(1-i) );
#else
item &= 0xff;
item = item << (8*i);
#endif
query->AltVendorId = (UINT16)( query->AltVendorId | item );
offset++;
}
/* read secondary extended table ptr */
query->SecExtTablePtr = 0;
for ( i=0; i < 2; i++ )
{
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
item = item << (8*(1-i) );
#else
item &= 0xff;
item = item << (8*i);
#endif
query->SecExtTablePtr = (UINT16)
( query->SecExtTablePtr | item );
offset++;
}
/* read minimum voltage */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->VccMin = (UINT8)item;
offset++;
/* read maximum voltage */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->VccMax = (UINT8)item;
offset++;
/* read supply voltage */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->VppMin = (UINT8)item;
offset++;
/* read supply max voltage */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->VppMax = (UINT8)item;
offset++;
/* read typical program timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->TypicalProgTimeout = (UINT8)item;
offset++;
/* read typical buffer timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->TypicalBufferTimeout = (UINT8)item;
offset++;
/* read block erase timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->BlockEraseTimeout = (UINT8)item;
offset++;
/* read chip erase timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->ChipEraseTimeout = (UINT8)item;
offset++;
/* read max single timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->MaxSingleTimeout = (UINT8)item;
offset++;
/* read max buffer timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->MaxBufferTimeout = (UINT8)item;
offset++;
/* read max block erase timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->MaxBlockEraseTimeout = (UINT8)item;
offset++;
/* read max chip erase timeout */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->MaxChipEraseTimeout = (UINT8)item;
offset++;
/* read device size */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->DeviceSize = (UINT8)item;
offset++;
/* read device interface */
query->DeviceInterface = 0;
for ( i=0; i < 2; i++ )
{
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
item = item << (8*(1-i) );
#else
item &= 0xff;
item = item << (8*i);
#endif
query->DeviceInterface = (UINT16)
( query->DeviceInterface | item );
offset++;
}
/* read max write buffer bytes */
query->MaxWriteBufferBytes = 0;
for ( i=0; i < 2; i++ )
{
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
item = item << (8*(1-i) );
#else
item &= 0xff;
item = item << (8*i);
#endif
query->MaxWriteBufferBytes = (UINT16)
( query->MaxWriteBufferBytes | item );
offset++;
}
/* read num erase blocks */
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
#else
item &= 0xff;
#endif
query->NumEraseBlocks = (UINT8)item;
offset++;
/* read erase block information */
query->EraseBlockInformation = 0;
for ( i=0; i < 4; i++ )
{
stat = TMPL_GetQueryAddress(offset, &add);
if ( stat.Result != StatCompleted )
{
return( stat );
}
TMPL_ReadF( add, &item );
#if BIG_ENDIAN_ARCHITECTURE
item &= 0x00ff;
longitem = (UINT32)((UINT32)item << (8*(3-i) ));
#else
item &= 0xff;
longitem = (UINT32)((UINT32)item << (8*i));
#endif
query->EraseBlockInformation = (UINT32)
( query->EraseBlockInformation | longitem );
offset++;
}
stat.Result = StatCompleted;
TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_ARRAY );
return( stat );
}
#endif /* X_16 */
#endif /* !DEVICE_QUERY */
#if !DEVICE_READ_BLOCK_STATUS /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_ReadBlockStatus
*
* Description:
*
* This procedure is called to read the status for the specified block
* from the flash device. See the flash device datasheet for specific
* details on this command.
*
* Parameters:
*
* IN blocknum - the block number on the device.
*
* OUT blockstat- the status of the block as: unlocked, locked,
* or locked down.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_ReadBlockStatus ( UINT16 blocknum,
TMPL_FDATA_PTR blockstat );
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_READ_BLOCK_STATUS */
#if !DEVICE_READ_DEVICE_ID /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_ReadDeviceID
*
* Description:
*
* This procedure is called to read the status for the specified block
* from the flash device. See the flash device datasheet for specific
* details on this command.
*
* Parameters:
*
* OUT mcode - the manufacturer code.
*
* OUT deviceid - the device id.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_ReadDeviceID ( UINT16_PTR mcode,
UINT16_PTR deviceid )
{
TMPL_Status stat;
UINT32 idaddress;
#if X_8
idaddress = ( TMPL_BASE_FLASH_ADDRESS + 2 ); //TMPL_BASE_FLASH_ADDRESS=0x0
#endif
#if X_16
idaddress = ( TMPL_BASE_FLASH_ADDRESS + sizeof( TMPL_FDATA ) );
#endif
TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_ID_CODES);
TMPL_ReadF( TMPL_BASE_FLASH_ADDRESS, mcode);
TMPL_ReadF( idaddress, deviceid);
/* return device to read array mode */
TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_ARRAY );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -