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

📄 template.h

📁 嵌入式单片机下可做对Intel flash编程的代码
💻 H
📖 第 1 页 / 共 3 页
字号:
/* ILx32 flash command definitions */
#if ILX_32

   #define TMPL_PROGRAM_SETUP         0x00400040
   #define TMPL_BASE_FLASH_ADDRESS    0x00000000
   #define TMPL_READ_STATUS_REGISTER  0x00700070
   #define TMPL_CLEAR_STATUS_REGISTER 0x00500050
   #define TMPL_READ_ID_CODES         0x00900090
   #define TMPL_READ_QUERY            0x00980098
   #define TMPL_BLOCK_ERASE           0x00200020
   #define TMPL_CONFIRM               0x00D000D0
   #define TMPL_READ_ARRAY            0x00ff00ff
   #define TMPL_CONFIG_SETUP          0x00600060

   /* Status Register Values */
   #define TMPL_BLOCK_LOCKED         0x00020002
   #define TMPL_PROGRAM_SUSPENDED    0x00040004
   #define TMPL_VPP_LOW              0x00080008
   #define TMPL_PROGRAM_ERROR        0x00100010
   #define TMPL_ERASE_ERROR          0x00200020
   #define TMPL_ERASE_SUSPENDED      0x00400040
   #define TMPL_STATUS_READY         0x00800080

   typedef UINT32 TMPL_FDATA; /* flash data item */

#endif /* ILX_32 */

typedef TMPL_FDATA * volatile TMPL_FDATA_PTR; 

/* status structure */
typedef struct TMPL_stat {
   enum TMPL_CommandStat Result;  /* subroutine status */
   volatile TMPL_FDATA   SR;      /* Flash status register value */
}TMPL_Status;

/* Page Break  */

/*
 *  Flash template function declarations
 */

/****************************************************************************
 *
 * TMPL_ClearStatus
 *
 * Description:   
 *    This procedure is called to clear the status register on the flash
 *    device.  See the flash device datasheet for specific details on 
 *    this command.
 *
 * Parameters:
 *    NONE
 *
 * Returns:   
 *    NONE
 *
 * Assumptions:
 *    NONE
 *
 ***************************************************************************/
void TMPL_ClearStatus ( void );


/****************************************************************************
 *
 * TMPL_EraseBlock
 *
 * Description:   
 *
 *    This procedure is called to erase a data block on the flash 
 *    device.  See the flash device datasheet for specific details on
 *    this command.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number on the device.
 *
 *    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_EraseBlock ( UINT16 blocknum, 
                              UINT8 returnSR );


/****************************************************************************
 *
 * TMPL_EraseAllBlocks
 *
 * Description:   
 *
 *    This procedure is called to erase all data blocks on the flash 
 *    device.  See the flash device datasheet for specific details on
 *    the block erase 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:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_EraseAllBlocks ( UINT8 returnSR );


/****************************************************************************
 *
 * TMPL_EraseSuspend
 *
 * Description:   
 *
 *    This procedure is called to issue the erase suspend command to
 *    the flash device.  See the flash device datasheet for specific details 
 *    on this command.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number on the device.
 *
 *    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:
 *
 *    When this function is called the device is currently in the erase 
 *    mode for the block identified.
 *
 ***************************************************************************/
TMPL_Status TMPL_EraseSuspend ( UINT16 blocknum,
                                UINT8 returnSR );


/****************************************************************************
 *
 * TMPL_ExtendedQuery
 *
 * Description:   
 *
 *    This procedure is called to retrieve the extended query
 *    data from the flash device.  See the flash device datasheet for
 *    specific details on this command.
 *
 * Parameters:
 *
 *    OUT      *extquery - pointer to extended query structure
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum 
 *                  TMPL_CommandStat.
 *
 * Assumptions:
 *
 *    NONE
 ***************************************************************************/
TMPL_Status TMPL_ExtendedQuery( struct TMPL_ExtQueryData *extquery );


/****************************************************************************
 *
 * TMPL_GetBlockAddress
 *
 * Description:   
 *
 *    This procedure is called to get the flash starting address for the
 *    specified block number.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number on the device.
 *
 *    OUT     address  - the starting flash address for the specified
 *                       block.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *    TMPL_CommandStat.
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_GetBlockAddress ( UINT16     blocknum, 
                                   UINT32_PTR address );


/****************************************************************************
 *
 * TMPL_GetFptr
 *
 * Description:   
 *
 *    This procedure is called to return a flash ptr given a 
 *    specified device address.  This routine will likely need to be
 *    provided externally by the template client in order to properly
 *    deal with addressing details that are specific to the HW platform.
 *
 * Parameters:
 *
 *    IN      address  - the flash address 
 *
 * Returns:   
 *
 *    TMPL_FDATA_PTR  - address returned in ptr form
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_FDATA_PTR TMPL_GetFptr( UINT32 address );


/****************************************************************************
 *
 * TMPL_GetQueryAddress
 *
 * Description:   
 *
 *    This procedure is called to get the flash address for a given
 *    query offset.
 *
 *   Parameters:
 *
 *    IN      offset   - query offset location
 *
 *    OUT     address  - the flash address for the specified query
 *                       offset.
 *
 * Returns:   
 *
 *    TMPL_Status - includes function return status defined by enum
 *    TMPL_CommandStat.
 *
 * Assumptions:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_GetQueryAddress ( UINT32 offset, UINT32_PTR address );


/****************************************************************************
 *
 * TMPL_LockBlock
 *
 * Description:   
 *
 *    This procedure is called to lock the specified block on the flash
 *    device.  See the flash device datasheet for specific details on this 
 *    command.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number on the device.
 *
 *    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_LockBlock ( UINT16 blocknum,
                             UINT8 returnSR );


/****************************************************************************
 *
 * TMPL_LockDownBlock
 *
 * Description:   
 *
 *    This procedure is called to lockdown the specified block on the flash
 *    device.  See the flash device datasheet for specific details on this 
 *    command.
 *
 * Parameters:
 *
 *    IN      blocknum - the block number on the device.
 *
 *    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_LockDownBlock ( UINT16 blocknum,
                                 UINT8 returnSR );


/****************************************************************************
 *
 * TMPL_LockProtection
 *
 * Description:   
 *
 *    This procedure is called to program the protection register user lock
 *    bit 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:
 *
 *    NONE
 *
 ***************************************************************************/
TMPL_Status TMPL_LockProtection ( UINT8 returnSR );


/****************************************************************************
 *
 * TMPL_ProgramFlash
 *
 * Description:   
 *
 *    This procedure is called to program the flash device at the specified 
 *    address with the single specified data value.  See the flash device 
 *    datasheet for specific details on this command.
 *
 * Parameters:
 *
 *    IN      address  - the flash address to be programmed.
 *
 *    IN      item     - the data value to be programmed.
 *
 *    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_ProgramFlash ( UINT32 address, 
                                UINT8  item,
                                UINT8  returnSR );


/****************************************************************************
 *
 * TMPL_ProgramFlashBuffered
 *
 * Description:   
 *
 *    This procedure is called to program the flash device at the specified 
 *    starting address contiguously with the specified buffer data.  See
 *    the flash device datasheet for specific details on the program
 *    command.
 *
 * Parameters:
 *
 *    IN      address  - the flash address to be programmed.
 *
 *    IN      buffer   - the buffer containing data to be programmed.
 *
 *    IN      numitems - the number of data items contained in the buffer.
 *
 *    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_ProgramFlashBuffered ( UINT32    address, 
                                        UINT8_PTR buffer, 
                                        UINT32    numbytes,
                                        UINT8     returnSR );


/****************************************************************************
 *
 * TMPL_ProgramProtection

⌨️ 快捷键说明

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