00001
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _CTRL_ACCESS_H_
00058 #define _CTRL_ACCESS_H_
00059
00060 #include "compiler.h"
00061 #include "conf_access.h"
00062
00063
00065 typedef enum
00066 {
00067 CTRL_GOOD = PASS,
00068 CTRL_FAIL = FAIL,
00069 CTRL_NO_PRESENT = FAIL + 1,
00070 CTRL_BUSY = FAIL + 2
00071 } Ctrl_status;
00072
00073
00074
00075
00076
00077 #ifndef LUN_0
00078 #error LUN_0 must be defined as ENABLE or DISABLE in conf_access.h
00079 #endif
00080 #ifndef LUN_1
00081 #error LUN_1 must be defined as ENABLE or DISABLE in conf_access.h
00082 #endif
00083 #ifndef LUN_2
00084 #error LUN_2 must be defined as ENABLE or DISABLE in conf_access.h
00085 #endif
00086 #ifndef LUN_3
00087 #error LUN_3 must be defined as ENABLE or DISABLE in conf_access.h
00088 #endif
00089 #ifndef LUN_4
00090 #error LUN_4 must be defined as ENABLE or DISABLE in conf_access.h
00091 #endif
00092 #ifndef LUN_5
00093 #error LUN_5 must be defined as ENABLE or DISABLE in conf_access.h
00094 #endif
00095 #ifndef LUN_6
00096 #error LUN_6 must be defined as ENABLE or DISABLE in conf_access.h
00097 #endif
00098 #ifndef LUN_7
00099 #error LUN_7 must be defined as ENABLE or DISABLE in conf_access.h
00100 #endif
00101 #ifndef LUN_USB
00102 #error LUN_USB must be defined as ENABLE or DISABLE in conf_access.h
00103 #endif
00104
00107
00108 #define LUN_ID_0 (0)
00109 #define LUN_ID_1 (LUN_ID_0 + LUN_0)
00110 #define LUN_ID_2 (LUN_ID_1 + LUN_1)
00111 #define LUN_ID_3 (LUN_ID_2 + LUN_2)
00112 #define LUN_ID_4 (LUN_ID_3 + LUN_3)
00113 #define LUN_ID_5 (LUN_ID_4 + LUN_4)
00114 #define LUN_ID_6 (LUN_ID_5 + LUN_5)
00115 #define LUN_ID_7 (LUN_ID_6 + LUN_6)
00116 #define MAX_LUN (LUN_ID_7 + LUN_7)
00117 #define LUN_ID_USB (MAX_LUN)
00118
00119
00120
00121
00122 #if LUN_0 == ENABLE
00123 #include LUN_0_INCLUDE
00124 #endif
00125 #if LUN_1 == ENABLE
00126 #include LUN_1_INCLUDE
00127 #endif
00128 #if LUN_2 == ENABLE
00129 #include LUN_2_INCLUDE
00130 #endif
00131 #if LUN_3 == ENABLE
00132 #include LUN_3_INCLUDE
00133 #endif
00134 #if LUN_4 == ENABLE
00135 #include LUN_4_INCLUDE
00136 #endif
00137 #if LUN_5 == ENABLE
00138 #include LUN_5_INCLUDE
00139 #endif
00140 #if LUN_6 == ENABLE
00141 #include LUN_6_INCLUDE
00142 #endif
00143 #if LUN_7 == ENABLE
00144 #include LUN_7_INCLUDE
00145 #endif
00146 #if LUN_USB == ENABLE
00147 #include LUN_USB_INCLUDE
00148 #endif
00149
00150
00151
00152 #ifndef GLOBAL_WR_PROTECT
00153 #error GLOBAL_WR_PROTECT must be defined as ENABLED or DISABLED in conf_access.h
00154 #endif
00155
00156
00157 #if GLOBAL_WR_PROTECT == ENABLED
00158
00160 extern Bool g_wr_protect;
00161
00162 #endif
00163
00164
00167
00168
00169 #ifdef FREERTOS_USED
00170
00175 extern Bool ctrl_access_init(void);
00176
00177 #endif // FREERTOS_USED
00178
00183 extern U8 get_nb_lun(void);
00184
00191 extern U8 get_cur_lun(void);
00192
00205 extern Ctrl_status mem_test_unit_ready(U8 lun);
00206
00215 extern Ctrl_status mem_read_capacity(U8 lun, U32 *u32_nb_sector);
00216
00223 extern U8 mem_sector_size(U8 lun);
00224
00234 extern Bool mem_wr_protect(U8 lun);
00235
00242 extern Bool mem_removal(U8 lun);
00243
00250 extern const char *mem_name(U8 lun);
00251
00253
00254
00255 #if ACCESS_USB == ENABLED
00256
00259
00260
00269 extern Ctrl_status memory_2_usb(U8 lun, U32 addr, U16 nb_sector);
00270
00279 extern Ctrl_status usb_2_memory(U8 lun, U32 addr, U16 nb_sector);
00280
00282
00283 #endif // ACCESS_USB == ENABLED
00284
00285
00286 #if ACCESS_MEM_TO_RAM == ENABLED
00287
00290
00291
00300 extern Ctrl_status memory_2_ram(U8 lun, U32 addr, void *ram);
00301
00310 extern Ctrl_status ram_2_memory(U8 lun, U32 addr, const void *ram);
00311
00313
00314 #endif // ACCESS_MEM_TO_RAM == ENABLED
00315
00316
00317 #if ACCESS_STREAM == ENABLED
00318
00321
00322
00324 #define ID_STREAM_ERR 0xFF
00325
00326 #if ACCESS_MEM_TO_MEM == ENABLED
00327
00338 extern Ctrl_status stream_mem_to_mem(U8 src_lun, U32 src_addr, U8 dest_lun, U32 dest_addr, U16 nb_sector);
00339
00340 #endif // ACCESS_MEM_TO_MEM == ENABLED
00341
00350 extern Ctrl_status stream_state(U8 id);
00351
00360 extern U16 stream_stop(U8 id);
00361
00363
00364 #endif // ACCESS_STREAM == ENABLED
00365
00366
00367 #endif // _CTRL_ACCESS_H_