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

📄 flash.h

📁 56f8300E系列dsp的BOOTloader
💻 H
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element:  $ 
* $Author:  $ 
* $Revision:  $ 
* $VOB:  $ 
* $OS:  $ 
*
* Description:       Flash driver for DSP5680x
*
* Notes:  
*
******************************************************************************/
#ifndef __FLASH_H
#define __FLASH_H


#include "port.h"
#include "bsp.h"
#include "io.h"

#ifdef __cplusplus
extern "C" {
#endif


/******************************************************************************
*
*                      General Interface Description
*
*  The DSP5683x processor has three Flash Memory blocks:
*     Data Flash are located in X memory space ;
*     Program Flash are located in P memory space 
*     Boot Flash are located in P memory 
* 
*  In SDK each Flash memory block is represented as separate device so the application 
*  has to use the driver oriented API to work with Flash devices.
* 
*  The NonBlocking mode is not supported by this driver;  only the Blocking mode
*  is supported, so all calls are synchronous.  API calls return control to the 
*  application only when the required operation is fully completed. 
*
*  All Flash Driver API calls are not reentrant. 
*
*  The Flash Driver uses an internal start address for "read" and "write" calls. 
*  This address saves the position within the Flash address space for "read" and "write" 
*  operations. The address is incremented by the 'size' value after "read" and "write" 
*  calls. User can update the current address value via "ioctl" call.
*
*  Before using any Flash device, the application has to open device via "open" call 
*  and save the device descriptor. 
*
*  There are two ways to read data from Flash:
*
*  1. Flash is located in standard processor address space, so application
*  can directly read data from flash address range. The following SDK functions 
*  will be useful in such case:
*     memcpy()        - copy data from X memory to X memory;
*     memCopyXtoP()   - copy data from X to P memory;
*     memCopyPtoX()   - copy data from P to X memory;
*     memCopyPtoP()   - copy data from P to P memory.
*
*  2. Application can regard Flash as a device and use "read" call to read data 
*  from Flash. "read" can place data in both X memory and P memory; for details 
*  see "ioctl" call.
*
*  To write data into Flash, the application should use a "write" call.
*  
*  After all Flash operations are completed, the Flash device has to be closed via
*  a "close" call.
* 
*  For more reference see this file and io.h file.
*
******************************************************************************/


/*****************************************************************************
* 
*    OPEN
*
*  int open(const char *pName, int OFlags, ...);
*
* Semantics:
*     Open the particular Flash device for operations. Argument pName is the 
*     particular Flash device name. The Flash device is always opened for read
*     and for write.
*
* Parameters:
*     pName    - device name. Use   BSP_DEVICE_NAME_FLASH_X for Data Flash,
*                                   BSP_DEVICE_NAME_FLASH_P for Program Flash,
*                                   BSP_DEVICE_NAME_FLASH_B for Boot Flash.
*     OFlags   - open mode flags. Ignored. 
* 
* Return Value: 
*     Flash device descriptor if open is successful.
*     -1 value if open failed.
*     
* Example:
*
*     int FlashFD; 
* 
*     FlashFD = open(BSP_DEVICE_NAME_FLASH_X, 0, NULL);
*
*****************************************************************************/

/*****************************************************************************
*
* IOCTL
*
*     UWord16 ioctl(int FileDesc, UWord16 Cmd, unsigned long Params); 
*
* Semantics:
*     Change Flash device modes. Flash driver supports the following commands:
*
*  FLASH_RESET                   Reset internal flash address to initial state.
*                                No parameter.
*  FLASH_SET_VERIFY_ON           Set verification mode on. No parameter.
*  FLASH_SET_VERIFY_OFF          Set verification mode on. No parameter.
*  FLASH_CMD_SEEK                Change internal address. 
*                                (Parameter is UWord16 * pParams)
*                                Address is real offset in 16-bit words from 
*                                the beginning of flash 
*                                address space. If set address to zero value 
*                                the following API call will be referenced to 
*                                the first flash word. 
*
*  If Params is not used then NULL should be passed into function.
*
* Parameters:
*     FileDesc    - Flash Device descriptor returned by "open" call.
*     Cmd         - command for driver 
*     Params      - commands` parameter
*
* Return Value: 
*     Zero 
*
* Example:
*
*     UWord16 Address = 0x0010;
*     
*     // set address in flash
*     ioctl(FlashFD, FLASH_CMD_SEEK, Address); 
*
*     // set user buffer location to Program memory
*     ioctl(FlashFD, FLASH_SET_USER_P_DATA, NULL); 
*
*     // set Verification mode on 
*     ioctl(FlashFD, FLASH_SET_VERIFY_ON, NULL); 
*
*****************************************************************************/
/*****************************************************************************
*
* WRITE
*
*     ssize_t write(int FileDesc, const void * pBuffer, size_t Size);
*
* Semantics:
*     Write user buffer into flash.     
*
* Parameters:
*     FileDesc    - Flash Device descriptor returned by "open" call.
*     pBuffer     - pointer to user buffer. Buffer location in X Data or 
*                   or in P memory is determined via "ioctl" call.
*     Size        - number of words to be written into flash. 
*
* Return Value: 
*     - Actual number of written words.
*     - Zero if verification mode is on and verification failed.
*
*****************************************************************************/

/*****************************************************************************
*
* READ
*
*     ssize_t read(int FileDesc, void * pBuffer, size_t Size);
*
* Semantics:
*     Read data from flash to user buffer or verify data from flash against 
*     users` buffer.
*
* Parameters:
*     FileDesc    - Flash Device descriptor returned by "open" call.
*     pBuffer     - pointer to user buffer. Buffer location in X Data or 
*                   or in Program memory is determined via "ioctl" call.
*     Size        - number of words to be read from flash. 
*
* Return Value: 
*     - Actual number of read or verified words.
*     - Zero if verification mode is on and verification failed.
*
*****************************************************************************/

/*****************************************************************************
*
* CLOSE
*
*     int close(int FileDesc);  
*
* Semantics:
*     Close flash device.
*
* Parameters:
*     FileDesc    - Flash Device descriptor returned by "open" call.
*
* Return Value: 
*     Zero
*
*****************************************************************************/


/* ioctl commands */

enum io_flash 
{
    FLASH_RESET  =          IO_OFFSET(io_sInterface, pIoctl[0] ),
    FLASH_MODE_VERIFY  =   IO_OFFSET(io_sInterface, pIoctl[1] ),
    FLASH_CMD_SEEK  =   IO_OFFSET(io_sInterface, pIoctl[2] )
};


/* flags & open modes */
#define O_READ_COMPARE  0x0010
#define O_WRITE_VERIFY  0x0020
#define O_ERASE_MODE  0x0040



#ifdef __cplusplus
}
#endif


										
#endif

⌨️ 快捷键说明

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