00001
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _DF_H_
00042 #define _DF_H_
00043
00044
00045
00046 #include "config.h"
00047
00048
00049
00050
00051 #define MEM_BSY 0
00052 #define MEM_OK 1
00053 #define MEM_KO 2
00054
00055
00056 #define DF_MSK_DENSITY ((Byte)0x3C) // status density mask
00057 #define DF_MSK_BIT_BUSY ((Byte)0x80)
00058 #define DF_MEM_BUSY ((Byte)0x00)
00059
00060 #define DF_RD_STATUS ((Byte)0xD7) // read status cmd
00061 #define DF_PG_ERASE ((Byte)0x81) // page erase cmd
00062 #define DF_BK_ERASE ((Byte)0x50) // block erase cmd
00063
00064 #define DF_WR_BUF_1 ((Byte)0x84) // write buffer 1 cmd
00065 #define DF_WR_BUF_2 ((Byte)0x87) // write buffer 2 cmd
00066 #define DF_B1_MAIN ((Byte)0x83) // buffer 1 to main program with erase cmd
00067 #define DF_B2_MAIN ((Byte)0x86) // buffer 2 to main program with erase cmd
00068
00069 #define DF_RD_MAIN ((Byte)0xD2) // main memory page read cmd
00070 #define DF_TF_BUF_1 ((Byte)0x53) // main memory page to buffer 1 transfer cmd
00071 #define DF_TF_BUF_2 ((Byte)0x55) // main memory page to buffer 2 transfer cmd
00072 #define DF_RD_BUF_1 ((Byte)0xD4) // buffer 1 read cmd
00073 #define DF_RD_BUF_2 ((Byte)0xD6) // buffer 2 read cmd
00074
00075
00076 #define DF_4MB ((Byte)0)
00077 #define DF_8MB ((Byte)1)
00078 #define DF_16MB ((Byte)2)
00079 #define DF_32MB ((Byte)3)
00080 #define DF_64MB ((Byte)4)
00081
00082
00083
00084
00085
00086 #define df_set_busy(i) (df_mem_busy |= (1<<i))
00087 #define df_release_busy(i) (df_mem_busy &= ~(1<<i))
00088 #define is_df_busy(i) (((df_mem_busy&(1<<i)) != 0) ? TRUE : FALSE)
00089
00090
00091
00092
00093 #ifdef DF_4_MB // AT45DB321 memories
00094 #define DF_SHFT_DFIDX (22) // RShift to apply to an absolute
00095
00096 #define DF_DENSITY ((Byte)0x34)
00097 #define DF_PG_BUF_1 ((Byte)0x82) // main memory program through buf1
00098 #define DF_PG_BUF_2 ((Byte)0x85) // main memory program through buf2
00099 #define DF_PAGE_SIZE (512) // page length
00100 #define DF_PAGE_MASK ((Byte)0x01) // mask MSB page bits
00101 #define DF_SHFT_B1 (1)
00102 #define DF_SHFT_B2 (7)
00103 #endif
00104
00105 #ifdef DF_8_MB // AT45DB642 memories
00106 #define DF_SHFT_DFIDX (23) // RShift to apply to an absolute
00107
00108 #define DF_DENSITY ((Byte)0x3C)
00109 #define DF_PG_BUF_1 ((Byte)0x82) // fast main memory program through buf1
00110 #define DF_PG_BUF_2 ((Byte)0x85) // fast main memory program through buf2
00111 #define DF_PAGE_SIZE (1024) // page length
00112 #define DF_PAGE_MASK ((Byte)0x03) // mask MSB page bits
00113 #define DF_SHFT_B1 (1)
00114 #define DF_SHFT_B2 (7)
00115 #endif
00116
00117
00118
00119
00120 void df_init (void);
00121 Bool df_mem_check (void);
00122 Bool df_read_open (Uint32);
00123 void df_read_close (void);
00124 Bool df_write_open (Uint32);
00125 void df_write_close (void);
00126
00128 Bool df_write_sector (Uint16);
00129 Bool df_read_sector (Uint16);
00131 bit df_host_write_sector (Uint16);
00132 bit df_host_read_sector (Uint16);
00133
00135 Bool df_read_sector_2_ram (U8 *ram);
00136 Bool df_write_sector_from_ram (U8 *ram);
00137
00138 #endif // _DF_H_
00139
00140