📄 nf_drv.h
字号:
/*H**************************************************************************
* NAME: nf_drv.h
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE: snd1c-refd-nf-4_0_3
* REVISION: 1.5
*----------------------------------------------------------------------------
* PURPOSE: This file contains the NF driver definitions for 2 NF slots
*
*****************************************************************************/
#ifndef _NF_DRV_H_
#define _NF_DRV_H_
/*_____ I N C L U D E S ____________________________________________________*/
/*_____ M A C R O S ________________________________________________________*/
/************************** Read Command ************************************/
#define NF_READ_A_AREA_CMD 0x00
#define NF_READ_B_AREA_CMD 0x01
#define NF_READ_C_AREA_CMD 0x50
/************************** Read ID Command *********************************/
#define NF_READ_ID_CMD 0x90
#define NF_RESET_CMD 0xFF
/************************** Program command *********************************/
#define NF_SEQUENTIAL_DATA_INPUT_CMD 0x80
#define NF_PAGE_PROGRAM_CMD 0x10
#define NF_COPY_BACK_FROM_PAGE 0x00
#define NF_COPY_BACK_TO_PAGE 0x8A
/************************** 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)
/* Nand Flash Driver */
#define NF_1X_512B 0
#define NF_2X_512B 1
#define NF_1X_2KB 2
#define NF_2X_2KB 3
#define M_SAMSUNG 0xEC
#define M_TOSHIBA 0x98
/*_____ 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 DEFINITION */
#define SAMSUNG_NF
/* This value are only for 16Mbytes and upper Nand Flash slot capacities */
#define NF_PAGE_PER_BLOCK (32) /* pages_block value: pages in a block */
#define NF_DATA_SIZE (512) /* data_size value: data_size in bytes */
#define NF_SPARE_SIZE (16) /* 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)(8)
#define NF_4_CYCLE_ADDRESS_BIT nf_4_cycle_address
#define NF_TYPE nf_device_type
#define NF_ZONE_MAX_CPT nf_zone_max
#define NF_COPY_BACK_BIT (nf_copy_back)
#define NF_SECTOR_SIZE (Uint32)(nf_mem_size)
#define NF_SIZE_32MB (Byte)(0)
#define NF_SIZE_64MB (Byte)(1)
#define NF_SIZE_128MB (Byte)(2)
#define NF_SIZE_256MB (Byte)(3)
#define NF_SECTOR_SIZE_32MB (Uint32)(63999)
#define NF_SECTOR_SIZE_64MB (Uint32)(127999)
#define NF_SECTOR_SIZE_128MB (Uint32)(255999)
#define NF_SECTOR_SIZE_256MB (Uint32)(511999)
#else
#ifdef NF_32
#define NF_TYPE (Byte)(0)
#define NF_SIZE (Byte)(32)
#define NF_ZONE_MAX (Byte)(1)
#define NF_SECTOR_SIZE (Uint32)(63999)
#define NF_4_CYCLE_ADDRESS (0)
#define NF_COPY_BACK (0)
#endif
#ifdef NF_64
#define NF_TYPE (Byte)(1)
#define NF_SIZE (Byte)(64)
#define NF_ZONE_MAX (Byte)(2)
#define NF_SECTOR_SIZE (Uint32)(127999)
#define NF_4_CYCLE_ADDRESS (0)
#if (NF_MANUFACTURER == NF_MAN_SAMSUNG)
#define NF_COPY_BACK (1)
#else
#define NF_COPY_BACK (0)
#endif
#endif
#ifdef NF_128
#define NF_TYPE (Byte)(2)
#define NF_SIZE (Byte)(128)
#define NF_ZONE_MAX (Byte)(4)
#define NF_SECTOR_SIZE (Uint32)(255999)
#define NF_4_CYCLE_ADDRESS (1)
#if (NF_MANUFACTURER == NF_MAN_SAMSUNG)
#define NF_COPY_BACK (1)
#else
#define NF_COPY_BACK (0)
#endif
#endif
#ifdef NF_256
#define NF_TYPE (Byte)(3)
#define NF_SIZE (Byte)(128)
#define NF_ZONE_MAX (Byte)(8)
#define NF_SECTOR_SIZE (Uint32)(511999)
#define NF_4_CYCLE_ADDRESS (1)
#if (NF_MANUFACTURER == NF_MAN_SAMSUNG)
#define NF_COPY_BACK (1)
#else
#define NF_COPY_BACK (0)
#endif
#endif
#ifndef NF_TYPE
#error NF capacity must be defined in board.h
#endif
#define NF_ZONE_MAX_CPT NF_ZONE_MAX
#define NF_4_CYCLE_ADDRESS_BIT NF_4_CYCLE_ADDRESS
#define NF_COPY_BACK_BIT NF_COPY_BACK
#endif
/* SCSI DEFINITION FOR SMARTMEDIA */
#define NF_BLOCK_SIZE ((Uint32)(NF_DATA_SIZE))
#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_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 = (Byte)command)
#define Nf_send_address_even(address) (nf_send_add_even = (Byte)address)
#define Nf_send_command_odd(command) (nf_send_cmd_odd = (Byte)command)
#define Nf_send_address_odd(address) (nf_send_add_odd = (Byte)address)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -