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

📄 template.c

📁 intel strata flash TE28Fxx系列的源代码 nor flash
💻 C
📖 第 1 页 / 共 4 页
字号:
   TMPL_Status stat;
   UINT32 add;
   UINT32 offset;
   TMPL_FDATA item;
   UINT32 longitem;
   UINT32 i;

   TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_QUERY );
 
   offset = TMPL_QUERY_START_OFFSET;

   /* read query string */ 
   for ( i=0; i < 3; i++ )
   {
      stat = TMPL_GetQueryAddress(offset, &add);

      if ( stat.Result != StatCompleted )
      {
         return( stat );
      }

      TMPL_ReadF( add, &item );
      item &= 0xff;
      query->QueryStr[i] = (char)item;
	  offset++;
   }
   query->QueryStr[3] = '\0'; /* null terminate string */

   /* read vendor id */
   query->VendorId = 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->VendorId = (UINT16)( query->VendorId | item ); 
      offset++;
   }

   /* read extended table ptr */
   query->ExtTablePtr = 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->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:   

⌨️ 快捷键说明

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