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

📄 template.c

📁 此源码包为intel J3系列NorFlash的驱动程序,支持8位,16位总线宽度
💻 C
📖 第 1 页 / 共 4 页
字号:

   stat.Result = StatCompleted;

   return( stat );

}
#endif /* !DEVICE_READ_DEVICE_ID */


#if !DEVICE_READF /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_ReadF
 *
 * Description:   
 *
 *    This procedure is called to read a single data item directly from the 
 *    specified device address.  This function is used internally by the
 *    flash template api.  Clients that need to read data from the flash
 *    device should use the TMPL_ReadFlash command.  See the flash device 
 *    datasheet for specific details on reading flash data.
 *
 * Parameters:
 *
 *    IN      address  - the flash address to be read from.
 *
 *    OUT     value    - the flash data read from the device.
 *
 * Returns:   
 *
 *    NONE
 *
 * Assumptions:
 *
 *    The flash device is in the READ_ARRAY mode when this function is
 *    called.
 *
 ***************************************************************************/
void TMPL_ReadF ( UINT32         address, 
                  TMPL_FDATA_PTR value )
{

   TMPL_FDATA_PTR  fptr;

   fptr = TMPL_GetFptr(address);

   *value = *fptr; 

}
#endif /* !DEVICE_READF */


#if !DEVICE_READ_FLASH /* if there is no device.c implementation */
#if X_16
/****************************************************************************
 *
 * TMPL_ReadFlash
 *
 * Description:   
 *
 *    This procedure is called to read one or more data items from 
 *    the flash device at the specified starting address.  See the flash 
 *    device datasheet for specific details on reading flash data.
 *
 * Parameters:
 *
 *    IN      address  - the starting device address.
 *
 *    OUT     buffer   - the buffer to contain the data items read.
 *
 *    IN      numitems - the number of data items to read.
 *
 *    IN      returnSR - flag to indicate whether the device status register
 *                       value should be returned by this function.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *                  TMPL_CommandStat and optionally the flash device
 *                  status register value.
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_ReadFlash ( UINT32    address, 
                             UINT8_PTR buffer, 
                             UINT32    numbytes,
                             UINT8     returnSR )
{
   TMPL_Status stat;
   TMPL_FDATA readdata;
   TMPL_FDATA readdatatemp;

   TMPL_FDATA_PTR fptr;

   if ( ( address + numbytes ) > TMPL_TOTAL_SIZE )
   {
      stat.Result = StatBadAddress;

      return( stat );
   }

   if ( returnSR )
   {
      TMPL_ClearStatus();
   }

   TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_ARRAY );

   if ( ( address & 0x1 ) != 0 ) 
   {
      address--;

      fptr = TMPL_GetFptr(address);

	  readdata = *fptr;

	  *buffer++ = mGetHighMemoryByte(readdata);

      numbytes--;

      address += sizeof(TMPL_FDATA);
   }

   while ( numbytes > 1 )
   {

      fptr = TMPL_GetFptr(address);

      readdata = *fptr;

	  *buffer++ = mGetLowMemoryByte(readdata);
      *buffer++ = mGetHighMemoryByte(readdata);

      address += sizeof(TMPL_FDATA);
	  numbytes -= sizeof(TMPL_FDATA);
   }	

   if ( numbytes > 0 ) /* 1 more byte left */
   {
      fptr = TMPL_GetFptr(address);

	  readdata = *fptr;

	  *buffer = mGetLowMemoryByte(readdata);

   }

   stat.Result = StatCompleted;

   if ( returnSR )
   {
      stat.SR = TMPL_ReadStatus(); 
   }

   return( stat );

}
#endif /* X_16 */
#endif /* !DEVICE_READ_FLASH */


#if !DEVICE_READ_PROTECTION /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_ReadProtection
 *
 * Description:   
 *
 *    This procedure is called to read the protection register value on
 *    the flash device from the specified location.  See the flash device 
 *    datasheet for specific details on this command.
 *
 * Parameters:
 *
 *    IN      location - the protection register location on the flash
 *                       device to be read from. 
 *
 *    OUT     value    - the data item read from the register.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *                  TMPL_CommandStat.
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_ReadProtection ( UINT32         location, 
                                  TMPL_FDATA_PTR value )
{

   STATUS stat;

   stat.Result = StatUnsupported;

   return( stat );
}
#endif /* !DEVICE_READ_PROTECTION */


#if !DEVICE_READ_STATUS /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_ReadStatus
 *
 * Description:   
 *
 *    This procedure is called to read the status register value from
 *    the flash device.  See the flash device datasheet for specific details
 *    on this command.
 *
 * Parameters:
 *
 *    NONE
 *
 * Returns:   
 *
 *    TMPL_FDATA - the status register value read from the device.
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_FDATA TMPL_ReadStatus ( void )
{
    TMPL_FDATA status;

	TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_STATUS_REGISTER );

	TMPL_ReadF(TMPL_BASE_FLASH_ADDRESS, &status );

    return( status );

}
#endif /* !DEVICE_READ_STATUS */


#if !DEVICE_RESUME /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_Resume
 *
 * Description:   
 *
 *    This procedure is called to issue the resume command to the flash
 *    device for the specified block. See the flash device datasheet for
 *    specific details on this command.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number to resume.
 *
 *    IN      returnSR - flag to indicate whether the device status register
 *                       value should be returned by this function.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *                  TMPL_CommandStat and optionally the flash device
 *                  status register value.
 *
 * Assumptions:
 *
 *    The block indicated was previously program suspended or erase 
 *    suspended.
 *
 ***************************************************************************/
TMPL_Status TMPL_Resume ( UINT16 blocknum,
                          UINT8  returnSR )
{

   TMPL_Status stat;

   stat.Result = StatUnsupported;

   return( stat );
}
#endif /* !DEVICE_RESUME */


#if !DEVICE_SEC_EXTENDED_QUERY /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_SecExtendedQuery
 *
 * Description:   
 *
 *    This procedure is called to retrieve the secondary extended query
 *    data from the flash device.  See the flash device datasheet for
 *    specific details on this command.
 *
 * Parameters:
 *
 *    OUT      *secextquery - pointer to secondary extended query structure
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *                  TMPL_CommandStat.
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_SecExtendedQuery ( struct TMPL_SecExtQueryData *secextquery )
{
   TMPL_Status stat;

   stat.Result = StatUnsupported;

   return( stat );
}
#endif /* !DEVICE_SEC_EXTENDED_QUERY */


#if !DEVICE_UNLOCK_ALL_BLOCKS /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_UnlockAllBlocks
 *
 * Description:   
 *
 *    This procedure is called to unlock all blocks on the flash
 *    device.  See the flash device datasheet for specific details on this 
 *    command.
 *
 * Parameters:
 *
 *    IN      returnSR - flag to indicate whether the device status register
 *                       value should be returned by this function.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum 
 *                  TMPL_CommandStat and optionally the flash device 
 *                  status register value.
 *
 * Assumptions:
 *
 *    The blocks were previously locked.
 *
 ***************************************************************************/
TMPL_Status TMPL_UnlockAllBlocks ( UINT8  returnSR )
{

   TMPL_Status stat;

   stat.Result = StatUnsupported;

   return( stat );
}
#endif /* !DEVICE_UNLOCK_ALL_BLOCKS */


#if !DEVICE_UNLOCK_BLOCK /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_UnlockBlock
 *
 * Description:   
 *
 *    This procedure is called to unlock the specified block on the flash
 *    device.  See the flash device datasheet for specific details on this 
 *    command.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number to unlock.
 *
 *    IN      returnSR - flag to indicate whether the device status register
 *                       value should be returned by this function.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *                  TMPL_CommandStat and optionally the flash device
 *                  status register value.
 *
 * Assumptions:
 *
 *    The block indicated was previously locked.
 *
 ***************************************************************************/
TMPL_Status TMPL_UnlockBlock ( UINT16 blocknum,
                               UINT8  returnSR )
{

   TMPL_Status stat;

   stat.Result = StatUnsupported;

   return( stat );
}
#endif /* !DEVICE_UNLOCK_BLOCK */


#if !DEVICE_WAIT_UNTIL_READY /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_WaitUntilReady
 *
 * Description:   
 *
 *    This procedure is called to wait until the flash device status 
 *    indicates a ready state or times out.  See the flash device datasheet
 *    for specific details on reading status data.
 *
 * Parameters:
 *
 *    IN      timeout  - timeout value specified as number of times
 *                       to read the status register before giving up.
 *
 * Returns:   
 *
 *    UINT8          - boolean flag indicating whether the ready state was
 *                     reached before the timeout number of reads 
 *                     occured.
 *
 * Assumptions:
 *
 *    NONE.
 *
 ***************************************************************************/
UINT8 TMPL_WaitUntilReady ( UINT32 timeout )
{

   while( timeout )
   {

      if ( mIsStatusReady( TMPL_ReadStatus() ) )
	  {
	     return( TRUE );
	  }

      timeout--;
   }

   return( FALSE );

}
#endif /* !DEVICE_WAIT_UNTIL_READY */


#if !DEVICE_WRITEF /* if there is no device.c implementation */
/****************************************************************************
 *
 * TMPL_WriteF
 *
 * Description:   
 *
 *    This procedure is called to write a single data item directly to the 
 *    specified device address.  This function is used internally by the
 *    flash template api.  Clients that need to write data to the flash
 *    device should use the TMPL_ProgramFlash or TMPL_ProgramFlashBuffered
 *    command.  See the flash device datasheet for specific details on
 *    writing flash data.
 *
 * Parameters:
 *
 *    IN      address  - the flash address to be written to.
 *
 *    IN      value    - the flash data to write to the device.
 *
 * Returns:   
 *
 *    NONE
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
void TMPL_WriteF ( UINT32     address, 
                   TMPL_FDATA value )
{

   TMPL_FDATA_PTR  fptr;

   fptr = TMPL_GetFptr(address);

   *fptr = value; 

}
#endif /* !DEVICE_WRITEF */




⌨️ 快捷键说明

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