?? nf_drv.h
字號:
/*H**************************************************************************
* NAME: nf_drv.h
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE: snd1c-refd-nf-4_0_3
* REVISION: 1.6
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the 2x NF 2kb driver definitions
*****************************************************************************/
#ifndef _NF_DRV_H_
#define _NF_DRV_H_
/*_____ I N C L U D E S ____________________________________________________*/
#include "board.h" /* board definition */
/*_____ M A C R O S ________________________________________________________*/
/************************** Read Command ************************************/
#define NF_READ_CMD 0x00
#define NF_READ_CMD2 0x30
#define NF_RANDOM_READ_CMD_C1 0x05
#define NF_RANDOM_READ_CMD_C2 0xE0
/************************** Read ID Command *********************************/
#define NF_READ_ID_CMD 0x90
#define NF_RESET_CMD 0xff
/************************** Program / Copy Back command *********************/
#define NF_SEQUENTIAL_DATA_INPUT_CMD 0x80
#define NF_RANDOM_DATA_INPUT_CMD 0x85
#define NF_COPY_BACK_CMD 0x35
#define NF_PAGE_PROGRAM_CMD 0x10
#define NF_CACHE_PROGRAM_CMD 0x15
/************************** Erase command ***********************************/
#define NF_BLOCK_ERASE_CMD 0x60
#define NF_BLOCK_ERASE_CONFIRM_CMD 0xD0
/************************** Read Status command *****************************/
#define NF_READ_STATUS_CMD 0x70
#define NF_BUFFER_SIZE (Byte)(40)
#define Nf_wait_busy() { while (!NF_RD_BUSY); }
/* Nand Flash Driver */
#define NF_1X_512B 0
#define NF_2X_512B 1
#define NF_1X_2KB 2
#define NF_2X_2KB 3
/* Page address */
#define NF_PAGE_0 0x00
#define NF_PAGE_1 0x02
#define NF_PAGE_2 0x04
#define NF_PAGE_3 0x06
#define NF_SPARE_PAGE 0x08
/* block address <-> sector address conversion */
/* 64 sectors in one block -> 6 bits shift */
#define NF_SHIFT_SECTOR_BLOCK 6
/* block address <-> zone address conversion */
/* 1024 block in one zone -> 10 bits shift */
#define NF_SHIFT_BLOCK_ZONE 10
/* sector address <-> zone address conversion */
/* 65536 sectors in one zone -> 16 bits shift */
#define NF_SHIFT_SECTOR_ZONE 16
/*_____ D E F I N I T I O N ________________________________________________*/
/* Structure to store the correspondance between logical and physical block */
typedef struct
{
Byte zone;
Uint16 logical_block;
Uint16 physical_block_odd;
Uint16 physical_block_even;
} t_reassign_block;
typedef struct
{
Uint16 even;
Uint16 odd;
} t_free_blocks;
typedef struct
{
Union16 even;
Union16 odd;
} t_lut;
/* Nand Flash CARD DEFINITION */
/* This value are only 128Mb and 256Mbytes Nand Flash with 2048 bytes page size */
#define NF_PAGE_PER_BLOCK (64) /* pages_block value: pages in a block */
#define NF_DATA_SIZE (2048) /* data_size value: data_size in bytes */
#define NF_SPARE_SIZE (64) /* spare_size value: spare_size in bytes*/
#define NF_BLOCK_PER_ZONE (1024) /* 1024 block per size */
#if (NF_CAPACITY_AUTO_DETECT == TRUE)
#define NF_ZONE_MAX (Byte)(2)
#define NF_5_CYCLE_ADDRESS_BIT nf_5_cycle_address
#define NF_TYPE nf_device_type
#define NF_ZONE_MAX_CPT nf_zone_max
#define NF_SECTOR_SIZE (Uint32)(nf_mem_size)
#define NF_SIZE_256MB (Byte)(0)
#define NF_SIZE_512MB (Byte)(1)
#define NF_SECTOR_SIZE_256MB (Uint32)(127999)
#define NF_SECTOR_SIZE_512MB (Uint32)(255999)
#define NF_K9F1G08U0M 0xF1
#define NF_K9F1K08Q0M 0xA1
#define NF_K9K2G08Q0M 0xAA
#define NF_K9K2G08U0M 0xDA
#else
#ifdef NF_256
#define NF_TYPE (Byte)(0)
#define NF_SIZE (Byte)(256)
#define NF_ZONE_MAX (Byte)(1)
#define NF_SECTOR_SIZE (Uint32)(127999)
#define NF_5_CYCLE_ADDRESS (0)
#endif
#ifdef NF_512
#define NF_TYPE (Byte)(1)
#define NF_SIZE (Byte)(512)
#define NF_ZONE_MAX (Byte)(2)
#define NF_SECTOR_SIZE (Uint32)(255999)
#define NF_5_CYCLE_ADDRESS (1)
#endif
#ifndef NF_TYPE
#error NF capacity must be defined in board.h
#endif
#define NF_ZONE_MAX_CPT NF_ZONE_MAX
#define NF_5_CYCLE_ADDRESS_BIT NF_5_CYCLE_ADDRESS
#endif
/* SCSI DEFINITION FOR SMARTMEDIA */
#define NF_BLOCK_SIZE ((Uint32)(2048))
#define NF_DISK_SIZE ((Uint32)(NF_SECTOR_SIZE))
/* Low Level routine */
#define Nf_rd_byte_odd() (nf_data_odd)
#define Nf_wr_byte_odd(b) (nf_data_odd = b)
#define Nf_send_command_odd(command) (nf_send_cmd_odd = command)
#define Nf_send_address_odd(address) (nf_send_add_odd = address)
#define Nf_rd_byte_even() (nf_data_even)
#define Nf_wr_byte_even(b) (nf_data_even = b)
#define Nf_send_command_even(command) (nf_send_cmd_even = command)
#define Nf_send_address_even(address) (nf_send_add_even = address)
#define Nf_wait_busy_odd() while (!NF_BSY_ODD)
#define Nf_wait_busy_even() while (!NF_BSY_EVEN)
#if NF_CAPACITY_AUTO_DETECT == TRUE
#define Nf_write_open_odd(address_sector) \
Nf_send_command_odd (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address_odd ( 0x00 ); \
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -