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