📄 nf_drv.h
字号:
#define NF_SIZE (Uint16)(2048)
#define NF_ZONE_MAX (Byte)(4)
#define NF_SECTOR_SIZE (Uint32)(1023999)
#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() (nf_data)
#define Nf_wr_byte(b) (nf_data = b)
#define Nf_send_command(command) (nf_send_cmd = command)
#define Nf_send_address(address) (nf_send_add = address)
#if NF_CAPACITY_AUTO_DETECT
#define Nf_write_open(address_sector) \
Nf_send_command (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
if (NF_5_CYCLE_ADDRESS_BIT) \
Nf_send_address ( ((Byte*)&address_sector)[1] )
#define Nf_read_open(address_sector) \
Nf_send_command (NF_READ_CMD); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
if (NF_5_CYCLE_ADDRESS_BIT) \
Nf_send_address ( ((Byte*)&address_sector)[1] ); \
Nf_send_command (NF_READ_CMD2); \
Nf_wait_busy()
#define Nf_read_open_spare_area(address_sector, nb_byte) \
Nf_send_command (NF_READ_CMD); \
Nf_send_address ( nb_byte ); \
Nf_send_address ( NF_SPARE_PAGE ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
if (NF_5_CYCLE_ADDRESS_BIT) \
Nf_send_address ( ((Byte*)&address_sector)[1] ); \
Nf_send_command (NF_READ_CMD2); \
Nf_wait_busy()
#define Nf_write_open_spare_area(address_sector, nb_byte) \
Nf_send_command (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address ( nb_byte ); \
Nf_send_address ( NF_SPARE_PAGE ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
if (NF_5_CYCLE_ADDRESS_BIT) \
Nf_send_address ( ((Byte*)&address_sector)[1] )
#else
#if NF_5_CYCLE_ADDRESS == 0
#define Nf_write_open(address_sector) \
Nf_send_command (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] )
#define Nf_read_open(address_sector) \
Nf_send_command (NF_READ_CMD); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
Nf_send_command (NF_READ_CMD2); \
Nf_wait_busy()
#define Nf_read_open_spare_area(address_sector, nb_byte) \
Nf_send_command (NF_READ_CMD); \
Nf_send_address ( nb_byte ); \
Nf_send_address ( NF_SPARE_PAGE ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
Nf_send_command (NF_READ_CMD2); \
Nf_wait_busy()
#define Nf_write_open_spare_area(address_sector, nb_byte) \
Nf_send_command (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address ( nb_byte ); \
Nf_send_address ( NF_SPARE_PAGE ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] )
#else
#define Nf_write_open(address_sector) \
Nf_send_command (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
Nf_send_address ( ((Byte*)&address_sector)[1] )
#define Nf_read_open(address_sector) \
Nf_send_command (NF_READ_CMD); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( 0x00 ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
Nf_send_address ( ((Byte*)&address_sector)[1] ); \
Nf_send_command (NF_READ_CMD2); \
Nf_wait_busy()
#define Nf_read_open_spare_area(address_sector, nb_byte) \
Nf_send_command (NF_READ_CMD); \
Nf_send_address ( nb_byte ); \
Nf_send_address ( NF_SPARE_PAGE ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
Nf_send_address ( ((Byte*)&address_sector)[1] ); \
Nf_send_command (NF_READ_CMD2); \
Nf_wait_busy()
#define Nf_write_open_spare_area(address_sector, nb_byte) \
Nf_send_command (NF_SEQUENTIAL_DATA_INPUT_CMD); \
Nf_send_address ( nb_byte ); \
Nf_send_address ( NF_SPARE_PAGE ); \
Nf_send_address ( ((Byte*)&address_sector)[3] ); \
Nf_send_address ( ((Byte*)&address_sector)[2] ); \
Nf_send_address ( ((Byte*)&address_sector)[1] )
#endif
#endif
/*_____ D E C L A R A T I O N ______________________________________________*/
extern void nf_init_buffer(void); /* Initialize the buffer gl_buffer with 0xFF */
extern void nf_download_buffer(void); /* Copy the content of gl_buffer on the card */
extern void nf_upload_buffer(void); /* Load the content of the card on gl_buffer */
void nf_copy_block_head(void); /* Copy the first sectors of a block */
void nf_copy_block_tail(void); /* Copy the last sectors of a block */
void nf_reassign_block(void); /* reassign the physical block on the look up table */
bit nf_block_erase (Uint32); /* Erase one block */
bit nf_erase_all_block(void); /* Erase all block */
void nf_init_spare(void); /* Init the first redundant data of a block */
void nf_calc_logical_block(); /* Calulate the value of logical block in spare area */
void nf_update_spare_data(void); /* Write only the redundant information */
bit nf_read_spare_byte(void); /* LUT generation */
#endif /* _NF_DRV_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -