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

📄 lh79524_lpd_cf_driver.h

📁 SHARP_ARM720T_LH79524/5软件开发包_支持TFT_LCD_NAND_FLASH_ETH_USB
💻 H
字号:
/**********************************************************************
 * $Workfile:   lh79524_lpd_cf_driver.h  $
 * $Revision:   1.0  $
 * $Author:   ZhangJ  $
 * $Date:   Oct 20 2004 09:37:02  $
 *
 * Project: CF card memory mode interface driver
 *
 * Description:
 *  This package contains a set of standard functions used to retrieve
 *  and stored data (in sectors) on the Compact Flash (CF) card.
 *  Functions included are:
 *          cfmem_init - Initialize CF interface driver
 *          cfmem_shutdown - Shutdown CF interface driver
 *          cfmem_is_card_inserted - Is the card inserted
 *          cfmem_is_card_ready - Is the card ready for commands
 *          cfmem_is_card_busy - Is the card busy (processing a command)
 *          cfmem_set_sector - Set the cylinder, head, and sector (with
 *                            just a sector number)
 *          cfmem_start_sector_read - Starts the read of a single or 
 *                                   block of sectors
 *          cfmem_start_sector_write - Writes a block of data to a 
 *                                    single or block of sectors
 *          cfmem_read_data  - Read a block of data from the CF card
 *          cfmem_write_data - Write a block of data to the CF card
 *          
 *
 * Notes:
 *  These functions are intended to be binded with a higher level
 *  driver for interfacing and controlling the structures on the
 *  card.
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh79524/bsps/sdk79524/include/lh79524_lpd_cf_driver.h-arc  $
 * 
 *    Rev 1.0   Oct 20 2004 09:37:02   ZhangJ
 * Initial revision.
 * 
 * 
 * SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 * OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 * AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 * SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 * FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 * SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 * FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 * COPYRIGHT (C) 2003 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *     CAMAS, WA
 *********************************************************************/
#ifndef _LH79524_LPD_CF_DRIVER_H
#define _LH79524_LPD_CF_DRIVER_H

#ifdef __cplusplus
#if __cplusplus
extern "C"
{
#endif // __cplusplus
#endif // __cplusplus

#include "abl_types.h"

// Memory mapped structure of CF card registers
typedef struct
{
    volatile UNS_16      data_NN;			//offset 0	--
    volatile UNS_16		 reserved0;
    volatile UNS_16      sector_count;		//offset 4	 --
    volatile UNS_16      sector_no;			//offset 6
    volatile UNS_16      cyl_low;			//offset 8	 --
    volatile UNS_16      cyl_hi;			//offset 0xa
    volatile UNS_16      sel_card;			//offset 0xc --
    volatile UNS_16      status_command;	//offset 0xe
    volatile UNS_16      data_EO;			//offset 0x10
    
} CFMEM_REGS_TYPE;

#define CF_BASE_ADDRESS     (0x48102000) 

#define CFMEM_STAT          ((CFMEM_REGS_TYPE *)(CF_BASE_ADDRESS))


#define CF_BUSY    _BIT(7)      // Status register: busy
#define CF_RDY     _BIT(6)      // Status register: Command ready
#define CF_DWF     _BIT(5)      // Status register: Write fault
#define CF_DSC     _BIT(4)      // Status register: CF card ready
#define CF_DRQ     _BIT(3)      // Status register: data request
#define CF_CORR    _BIT(2)      // Status register: Correctable error
#define CF_IDX     _BIT(1)      // Status register: reserved, always 0
#define CF_ERR     _BIT(0)      // Status register: error

#define CF_BBK     _BIT(7)      // Error register: Bad block
#define CF_UNC     _BIT(6)      // Error register: Uncorrectable error
#define CF_IDNF    _BIT(4)      // Error register: sector not found
#define CF_ABORT   _BIT(2)      // Error register: Abort error
#define CF_AMNF    _BIT(1)      // Error register: General error

#define CF_LBA     _BIT(4)      // Head register: LBA mode select
#define CF_RST     _BIT(2)      // Device control register: reset
#define CF_IEN     _BIT(1)      // Interrupt enable

// Status word check mask used in detection scheme
#define CF_DETECT_MASK (CF_BUSY | CF_RDY | CF_DSC | CF_IDX)

// Expected value from masked status in CF detection scheme
#define CF_DETECT_VALUE (CF_RDY | CF_DSC)

// CF-ATA commands used in this implementation
#define CFC_IDENT  0xEC         // Identify drive command
#define CFC_R_SECT 0x20         // Read sector command
#define CFC_W_SECT 0x30         // Write sector command
#define CFC_E_SECT 0xC0         // Erase sector command



//**********************************************************************
// Card functions
//**********************************************************************

INT_32 cfmem_init (void);
void   cfmem_shutdown (void);
INT_32 cfmem_is_card_inserted (void);
INT_32 cfmem_is_card_ready (void);
INT_32 cfmem_is_card_busy (void);
void   cfmem_set_sector (UNS_32 sectorno);
void   cfmem_send_command (UNS_32 command);
void cfmem_start_sector_read (void);
void cfmem_start_sector_write (void);
INT_32 cfmem_read_data (void *data, INT_32 bytes);
INT_32 cfmem_write_data (void *data, INT_32 bytes);
INT_32 cfmem_erase_sector (INT_32 sectorno);

#ifdef __cplusplus
}
#endif
#endif // LH79520_FCMEM_DRIVER_H

⌨️ 快捷键说明

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