ctrl_access.h File Reference

#include "conf/conf_access.h"
#include "ctrl_status.h"
#include "lib_mem\virtual_mem\virtual_mem.h"
#include "lib_mem\nf\nf_mngt.h"
#include "lib_mem\df\df_mem.h"
#include "lib_mem\mmc_sd\mmc_sd_mem.h"
#include <LUN_4_INCLUDE>
#include <LUN_5_INCLUDE>
#include <LUN_6_INCLUDE>
#include <LUN_7_INCLUDE>
#include "lib_mem\host_mem\host_mem.h"

Include dependency graph for ctrl_access.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ACCESS_MEM_TO_RAM   DISABLE
#define LUN_0   DISABLE
#define LUN_1   DISABLE
#define LUN_2   DISABLE
#define LUN_3   DISABLE
#define LUN_4   DISABLE
#define LUN_5   DISABLE
#define LUN_6   DISABLE
#define LUN_7   DISABLE
#define LUN_USB   DISABLE
#define LUN_ID_VIRTUAL   LUN_ID_0
#define LUN_0_INCLUDE   "lib_mem\virtual_mem\virtual_mem.h"
#define Lun_0_test_unit_ready()   virtual_test_unit_ready()
#define Lun_0_read_capacity(nb_sect)   virtual_read_capacity(nb_sect)
#define Lun_0_wr_protect()   virtual_wr_protect()
#define Lun_0_removal()   virtual_removal()
#define Lun_0_read_10(ad, sec)   virtual_read_10(ad, sec)
#define Lun_0_write_10(ad, sec)   virtual_write_10(ad, sec)
#define Lun_0_ram_2_mem(addr, ram)   virtual_ram_2_mem(addr, ram)
#define Lun_0_mem_2_ram(addr, ram)   virtual_mem_2_ram(addr, ram)
#define LUN_0_NAME   "VIRTUAL_MEM_ON_CHIP"
#define LUN_ID_NF   LUN_ID_1
#define LUN_1_INCLUDE   "lib_mem\nf\nf_mngt.h"
#define Lun_1_test_unit_ready()   nf_test_unit_ready()
#define Lun_1_read_capacity(nb_sect)   nf_read_capacity(nb_sect)
#define Lun_1_wr_protect()   nf_wr_protect()
#define Lun_1_removal()   nf_removal()
#define Lun_1_read_10(ad, sec)   nf_read_10(ad, sec)
#define Lun_1_write_10(ad, sec)   nf_write_10(ad, sec)
#define Lun_1_ram_2_mem(addr, ram)   nf_ram_2_nf(addr, ram)
#define Lun_1_mem_2_ram(addr, ram)   nf_nf_2_ram(addr, ram)
#define LUN_1_NAME   "\"NAND Flash\""
#define LUN_ID_DF   LUN_ID_2
#define LUN_2_INCLUDE   "lib_mem\df\df_mem.h"
#define Lun_2_test_unit_ready()   df_test_unit_ready()
#define Lun_2_read_capacity(nb_sect)   df_read_capacity(nb_sect)
#define Lun_2_wr_protect()   df_wr_protect()
#define Lun_2_removal()   df_removal()
#define Lun_2_read_10(ad, sec)   df_read_10(ad, sec)
#define Lun_2_write_10(ad, sec)   df_write_10(ad, sec)
#define Lun_2_ram_2_mem(addr, ram)   df_ram_2_df(addr, ram)
#define Lun_2_mem_2_ram(addr, ram)   df_df_2_ram(addr, ram)
#define LUN_2_NAME   "\"On board data flash\""
#define LUN_ID_MMC_SD   LUN_ID_3
#define LUN_3_INCLUDE   "lib_mem\mmc_sd\mmc_sd_mem.h"
#define Lun_3_test_unit_ready()   mmc_sd_test_unit_ready()
#define Lun_3_read_capacity(nb_sect)   mmc_sd_read_capacity(nb_sect)
#define Lun_3_wr_protect()   mmc_sd_wr_protect()
#define Lun_3_removal()   mmc_sd_removal()
#define Lun_3_read_10(ad, sec)   mmc_sd_read_10(ad, sec)
#define Lun_3_write_10(ad, sec)   mmc_sd_write_10(ad, sec)
#define Lun_3_ram_2_mem(addr, ram)   mmc_ram_2_mmc(addr, ram)
#define Lun_3_mem_2_ram(addr, ram)   mmc_mmc_2_ram(addr, ram)
#define LUN_3_NAME   "\"MMC\""
#define LUN_USB_INCLUDE   "lib_mem\host_mem\host_mem.h"
#define Lun_usb_test_unit_ready(lun)   host_test_unit_ready(lun)
#define Lun_usb_read_capacity(lun, nb_sect)   host_read_capacity(lun,nb_sect)
#define Lun_usb_wr_protect(lun)   host_wr_protect(lun)
#define Lun_usb_removal()   host_removal()
#define Lun_usb_ram_2_mem(lun, addr, ram)   host_write_10_ram(lun,addr, ram)
#define Lun_usb_mem_2_ram(lun, addr, ram)   host_read_10_ram(lun,addr, ram)
#define LUN_USB_NAME   "\"USB Remote memory\""
#define ID_STREAM_ERR   0xFF

Functions

U8 get_nb_lun ()
 This function return the number of logical unit.
U8 get_cur_lun ()
 This function return the current logical unit.
Ctrl_status mem_test_unit_ready (U8 lun)
 This function test the state of memory, and start the initialisation of the memory.
Ctrl_status mem_read_capacity (U8 lun, U32 _MEM_TYPE_SLOW_ *u32_nb_sector)
 This function return the capacity of the memory.
U8 mem_sector_size (U8 lun)
 This function return the sector size of the memory.
Bool mem_wr_protect (U8 lun)
 This function return is the write protected mode.
Bool mem_removal (U8 lun)
 This function inform about the memory type.
U8 code * mem_name (U8 lun)
 This function returns a pointer to the LUN name.
Ctrl_status memory_2_usb (U8 lun, U32 addr, U16 nb_sector)
 This function tranfer a data from memory to usb.
Ctrl_status usb_2_memory (U8 lun, U32 addr, U16 nb_sector)
 This function transfer a data from usb to memory.
Ctrl_status memory_2_ram (U8 lun, const U32 _MEM_TYPE_SLOW_ addr, U8 _MEM_TYPE_SLOW_ *ram)
 Interface for RAM.
Ctrl_status ram_2_memory (U8 lun, const U32 _MEM_TYPE_SLOW_ addr, U8 _MEM_TYPE_SLOW_ *ram)
 This function transfer a data from ram to memory.
U8 stream_mem_to_mem (U8 src_lun, U32 src_addr, U8 dest_lun, U32 dest_addr, U16 nb_sector)
 This function copy a data from memory to other memory.
Ctrl_status stream_state (U8 Id)
 Returns the state on a data transfer.
U16 stream_stop (U8 Id)
 Stop the data transfer.


Detailed Description

This file contains the interface :

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file ctrl_access.h.


Define Documentation

#define ACCESS_MEM_TO_RAM   DISABLE

Definition at line 52 of file ctrl_access.h.

#define LUN_0   DISABLE

Definition at line 57 of file ctrl_access.h.

#define LUN_1   DISABLE

Definition at line 60 of file ctrl_access.h.

#define LUN_2   DISABLE

Definition at line 63 of file ctrl_access.h.

#define LUN_3   DISABLE

Definition at line 66 of file ctrl_access.h.

#define LUN_4   DISABLE

Definition at line 69 of file ctrl_access.h.

#define LUN_5   DISABLE

Definition at line 72 of file ctrl_access.h.

#define LUN_6   DISABLE

Definition at line 75 of file ctrl_access.h.

#define LUN_7   DISABLE

Definition at line 78 of file ctrl_access.h.

#define LUN_USB   DISABLE

Definition at line 81 of file ctrl_access.h.

#define LUN_ID_VIRTUAL   LUN_ID_0

Definition at line 85 of file ctrl_access.h.

#define LUN_0_INCLUDE   "lib_mem\virtual_mem\virtual_mem.h"

Definition at line 86 of file ctrl_access.h.

 
#define Lun_0_test_unit_ready (  )     virtual_test_unit_ready()

Definition at line 87 of file ctrl_access.h.

Referenced by mem_test_unit_ready().

#define Lun_0_read_capacity ( nb_sect   )     virtual_read_capacity(nb_sect)

Definition at line 88 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_0_wr_protect (  )     virtual_wr_protect()

Definition at line 89 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_0_removal (  )     virtual_removal()

Definition at line 90 of file ctrl_access.h.

Referenced by mem_removal().

#define Lun_0_read_10 ( ad,
sec   )     virtual_read_10(ad, sec)

Definition at line 91 of file ctrl_access.h.

Referenced by memory_2_usb().

#define Lun_0_write_10 ( ad,
sec   )     virtual_write_10(ad, sec)

Definition at line 92 of file ctrl_access.h.

Referenced by usb_2_memory().

#define Lun_0_ram_2_mem ( addr,
ram   )     virtual_ram_2_mem(addr, ram)

Definition at line 93 of file ctrl_access.h.

Referenced by ram_2_memory().

#define Lun_0_mem_2_ram ( addr,
ram   )     virtual_mem_2_ram(addr, ram)

Definition at line 94 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_0_NAME   "VIRTUAL_MEM_ON_CHIP"

Definition at line 95 of file ctrl_access.h.

#define LUN_ID_NF   LUN_ID_1

Definition at line 98 of file ctrl_access.h.

#define LUN_1_INCLUDE   "lib_mem\nf\nf_mngt.h"

Definition at line 99 of file ctrl_access.h.

 
#define Lun_1_test_unit_ready (  )     nf_test_unit_ready()

Definition at line 100 of file ctrl_access.h.

Referenced by mem_test_unit_ready().

#define Lun_1_read_capacity ( nb_sect   )     nf_read_capacity(nb_sect)

Definition at line 101 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_1_wr_protect (  )     nf_wr_protect()

Definition at line 102 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_1_removal (  )     nf_removal()

Definition at line 103 of file ctrl_access.h.

Referenced by mem_removal().

#define Lun_1_read_10 ( ad,
sec   )     nf_read_10(ad, sec)

Definition at line 104 of file ctrl_access.h.

Referenced by memory_2_usb().

#define Lun_1_write_10 ( ad,
sec   )     nf_write_10(ad, sec)

Definition at line 105 of file ctrl_access.h.

Referenced by usb_2_memory().

#define Lun_1_ram_2_mem ( addr,
ram   )     nf_ram_2_nf(addr, ram)

Definition at line 106 of file ctrl_access.h.

Referenced by ram_2_memory().

#define Lun_1_mem_2_ram ( addr,
ram   )     nf_nf_2_ram(addr, ram)

Definition at line 107 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_1_NAME   "\"NAND Flash\""

Definition at line 108 of file ctrl_access.h.

#define LUN_ID_DF   LUN_ID_2

Definition at line 111 of file ctrl_access.h.

#define LUN_2_INCLUDE   "lib_mem\df\df_mem.h"

Definition at line 112 of file ctrl_access.h.

 
#define Lun_2_test_unit_ready (  )     df_test_unit_ready()

Definition at line 113 of file ctrl_access.h.

Referenced by mem_test_unit_ready().

#define Lun_2_read_capacity ( nb_sect   )     df_read_capacity(nb_sect)

Definition at line 114 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_2_wr_protect (  )     df_wr_protect()

Definition at line 115 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_2_removal (  )     df_removal()

Definition at line 116 of file ctrl_access.h.

Referenced by mem_removal().

#define Lun_2_read_10 ( ad,
sec   )     df_read_10(ad, sec)

Definition at line 117 of file ctrl_access.h.

Referenced by memory_2_usb().

#define Lun_2_write_10 ( ad,
sec   )     df_write_10(ad, sec)

Definition at line 118 of file ctrl_access.h.

Referenced by usb_2_memory().

#define Lun_2_ram_2_mem ( addr,
ram   )     df_ram_2_df(addr, ram)

Definition at line 119 of file ctrl_access.h.

Referenced by ram_2_memory().

#define Lun_2_mem_2_ram ( addr,
ram   )     df_df_2_ram(addr, ram)

Definition at line 120 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_2_NAME   "\"On board data flash\""

Definition at line 121 of file ctrl_access.h.

#define LUN_ID_MMC_SD   LUN_ID_3

Definition at line 124 of file ctrl_access.h.

#define LUN_3_INCLUDE   "lib_mem\mmc_sd\mmc_sd_mem.h"

Definition at line 125 of file ctrl_access.h.

 
#define Lun_3_test_unit_ready (  )     mmc_sd_test_unit_ready()

Definition at line 126 of file ctrl_access.h.

Referenced by mem_test_unit_ready().

#define Lun_3_read_capacity ( nb_sect   )     mmc_sd_read_capacity(nb_sect)

Definition at line 127 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_3_wr_protect (  )     mmc_sd_wr_protect()

Definition at line 128 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_3_removal (  )     mmc_sd_removal()

Definition at line 129 of file ctrl_access.h.

Referenced by mem_removal().

#define Lun_3_read_10 ( ad,
sec   )     mmc_sd_read_10(ad, sec)

Definition at line 130 of file ctrl_access.h.

Referenced by memory_2_usb().

#define Lun_3_write_10 ( ad,
sec   )     mmc_sd_write_10(ad, sec)

Definition at line 131 of file ctrl_access.h.

Referenced by usb_2_memory().

#define Lun_3_ram_2_mem ( addr,
ram   )     mmc_ram_2_mmc(addr, ram)

Definition at line 132 of file ctrl_access.h.

Referenced by ram_2_memory().

#define Lun_3_mem_2_ram ( addr,
ram   )     mmc_mmc_2_ram(addr, ram)

Definition at line 133 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_3_NAME   "\"MMC\""

Definition at line 134 of file ctrl_access.h.

#define LUN_USB_INCLUDE   "lib_mem\host_mem\host_mem.h"

Definition at line 137 of file ctrl_access.h.

#define Lun_usb_test_unit_ready ( lun   )     host_test_unit_ready(lun)

Definition at line 138 of file ctrl_access.h.

Referenced by mem_test_unit_ready().

#define Lun_usb_read_capacity ( lun,
nb_sect   )     host_read_capacity(lun,nb_sect)

Definition at line 139 of file ctrl_access.h.

Referenced by mem_read_capacity().

#define Lun_usb_wr_protect ( lun   )     host_wr_protect(lun)

Definition at line 140 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_usb_removal (  )     host_removal()

Definition at line 141 of file ctrl_access.h.

Referenced by mem_removal().

#define Lun_usb_ram_2_mem ( lun,
addr,
ram   )     host_write_10_ram(lun,addr, ram)

Definition at line 142 of file ctrl_access.h.

Referenced by ram_2_memory().

#define Lun_usb_mem_2_ram ( lun,
addr,
ram   )     host_read_10_ram(lun,addr, ram)

Definition at line 143 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_USB_NAME   "\"USB Remote memory\""

Definition at line 144 of file ctrl_access.h.

#define ID_STREAM_ERR   0xFF

Definition at line 202 of file ctrl_access.h.

Referenced by stream_mem_to_mem().


Function Documentation

U8 get_nb_lun (  ) 

This function return the number of logical unit.

Returns:
U8 number of logical unit in the system

Definition at line 172 of file ctrl_access.c.

References MAX_LUN.

00173 {
00174 #if   (LUN_USB == ENABLED)
00175    host_ms_max_lun=0;
00176    for(dms_selected=0;dms_selected<dms_connected;dms_selected++)
00177    {
00178       host_ms_max_lun += Host_getlun();
00179    }
00180    return   (MAX_LUN + host_ms_max_lun);
00181 #else
00182    return   MAX_LUN;
00183 #endif
00184 }

U8 get_cur_lun (  ) 

This function return the current logical unit.

Returns:
U8 number of logical unit in the system

Definition at line 191 of file ctrl_access.c.

00192 {
00193    return   0; //TODO a specific management
00194 }

Ctrl_status mem_test_unit_ready ( U8  lun  ) 

This function test the state of memory, and start the initialisation of the memory.

MORE (see SPC-3 §5.2.4) : The TEST UNIT READY command allows an application client to poll a logical unit until it is ready without the need to allocate space for returned data. The TEST UNIT READY command may be used to check the media status of logical units with removable media.

Parameters:
lun Logical unit number
Returns:
Ctrl_status It is ready -> CTRL_GOOD Memory unplug -> CTRL_NO_PRESENT Not initialize -> CTRL_BUSY

Definition at line 210 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_test_unit_ready, Lun_1_test_unit_ready, Lun_2_test_unit_ready, Lun_3_test_unit_ready, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, LUN_ID_USB, and Lun_usb_test_unit_ready.

00211 {
00212    switch( lun )
00213    {
00214 #     if (LUN_0 == ENABLE)
00215       case LUN_ID_0:
00216       return Lun_0_test_unit_ready();
00217       break;
00218 #     endif
00219 #     if (LUN_1 == ENABLE)
00220       case LUN_ID_1:
00221       return Lun_1_test_unit_ready();
00222       break;
00223 #     endif
00224 #     if (LUN_2 == ENABLE)
00225       case LUN_ID_2:
00226       return Lun_2_test_unit_ready();
00227       break;
00228 #     endif
00229 #     if (LUN_3 == ENABLE)
00230       case LUN_ID_3:
00231       return Lun_3_test_unit_ready();
00232       break;
00233 #     endif
00234 #     if (LUN_4 == ENABLE)
00235       case LUN_ID_4:
00236       return Lun_4_test_unit_ready();
00237       break;
00238 #     endif
00239 #     if (LUN_5 == ENABLE)
00240       case LUN_ID_5:
00241       return Lun_5_test_unit_ready();
00242       break;
00243 #     endif
00244 #     if (LUN_6 == ENABLE)
00245       case LUN_ID_6:
00246       return Lun_6_test_unit_ready();
00247       break;
00248 #     endif
00249 #     if (LUN_7 == ENABLE)
00250       case LUN_ID_7:
00251       return Lun_7_test_unit_ready();
00252       break;
00253 #     endif
00254 #     if (LUN_USB == ENABLE)
00255       default:
00256       return Lun_usb_test_unit_ready(lun - LUN_ID_USB);
00257       break;
00258 #     endif
00259    }
00260    return   CTRL_FAIL;
00261 }

Ctrl_status mem_read_capacity ( U8  lun,
U32 _MEM_TYPE_SLOW_ *  u32_last_sector 
)

This function return the capacity of the memory.

Parameters:
lun Logical unit number
Returns:
*u32_last_sector the last address sector

Ctrl_status It is ready -> CTRL_GOOD Memory unplug -> CTRL_NO_PRESENT

Definition at line 273 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_read_capacity, Lun_1_read_capacity, Lun_2_read_capacity, Lun_3_read_capacity, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, LUN_ID_USB, and Lun_usb_read_capacity.

00274 {
00275    switch( lun )
00276    {
00277 #     if (LUN_0 == ENABLE)
00278       case LUN_ID_0:
00279       return Lun_0_read_capacity( u32_last_sector );
00280       break;
00281 #     endif
00282 #     if (LUN_1 == ENABLE)
00283       case LUN_ID_1:
00284       return Lun_1_read_capacity( u32_last_sector );
00285       break;
00286 #     endif
00287 #     if (LUN_2 == ENABLE)
00288       case LUN_ID_2:
00289       return Lun_2_read_capacity( u32_last_sector );
00290       break;
00291 #     endif
00292 #     if (LUN_3 == ENABLE)
00293       case LUN_ID_3:
00294       return Lun_3_read_capacity( u32_last_sector );
00295       break;
00296 #     endif
00297 #     if (LUN_4 == ENABLE)
00298       case LUN_ID_4:
00299       return Lun_4_read_capacity( u32_last_sector );
00300       break;
00301 #     endif
00302 #     if (LUN_5 == ENABLE)
00303       case LUN_ID_5:
00304       return Lun_5_read_capacity( u32_last_sector );
00305       break;
00306 #     endif
00307 #     if (LUN_6 == ENABLE)
00308       case LUN_ID_6:
00309       return Lun_6_read_capacity( u32_last_sector );
00310       break;
00311 #     endif
00312 #     if (LUN_7 == ENABLE)
00313       case LUN_ID_7:
00314       return Lun_7_read_capacity( u32_last_sector );
00315       break;
00316 #     endif
00317 #     if (LUN_USB == ENABLE)
00318       default:
00319       return Lun_usb_read_capacity( lun - LUN_ID_USB, u32_last_sector );
00320       break;
00321 #     endif
00322    }
00323    return   CTRL_FAIL;
00324 }

U8 mem_sector_size ( U8  lun  ) 

This function return the sector size of the memory.

Parameters:
lun Logical unit number
Returns:
size of sector (unit 512B)

Definition at line 333 of file ctrl_access.c.

References LUN_ID_USB.

00334 {
00335 # if (LUN_USB == ENABLE)
00336   return (lun < LUN_ID_USB) ? 1 : 1; // TODO , add new USB mass-storage driver to manage specific disk capacity
00337 #else
00338   return 1;
00339 #endif
00340 }

Bool mem_wr_protect ( U8  lun  ) 

This function return is the write protected mode.

Parameters:
lun Logical unit number
Only used by memory removal with a HARDWARE SPECIFIC write protected detection !!! The customer must be unplug the card for change this write protected mode.

Returns:
TRUE -> the memory is protected

Definition at line 352 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_wr_protect, Lun_1_wr_protect, Lun_2_wr_protect, Lun_3_wr_protect, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, LUN_ID_USB, and Lun_usb_wr_protect.

00353 {
00354    switch( lun )
00355    {
00356 #     if (LUN_0 == ENABLE)
00357       case LUN_ID_0:
00358       return Lun_0_wr_protect();
00359       break;
00360 #     endif
00361 #     if (LUN_1 == ENABLE)
00362       case LUN_ID_1:
00363       return Lun_1_wr_protect();
00364       break;
00365 #     endif
00366 #     if (LUN_2 == ENABLE)
00367       case LUN_ID_2:
00368       return Lun_2_wr_protect();
00369       break;
00370 #     endif
00371 #     if (LUN_3 == ENABLE)
00372       case LUN_ID_3:
00373       return Lun_3_wr_protect();
00374       break;
00375 #     endif
00376 #     if (LUN_4 == ENABLE)
00377       case LUN_ID_4:
00378       return Lun_4_wr_protect();
00379       break;
00380 #     endif
00381 #     if (LUN_5 == ENABLE)
00382       case LUN_ID_5:
00383       return Lun_5_wr_protect();
00384       break;
00385 #     endif
00386 #     if (LUN_6 == ENABLE)
00387       case LUN_ID_6:
00388       return Lun_6_wr_protect();
00389       break;
00390 #     endif
00391 #     if (LUN_7 == ENABLE)
00392       case LUN_ID_7:
00393       return Lun_7_wr_protect();
00394       break;
00395 #     endif
00396 #     if (LUN_USB == ENABLE)
00397       default:
00398       return Lun_usb_wr_protect(lun - LUN_ID_USB);
00399       break;
00400 #     endif
00401    }
00402    return   CTRL_FAIL;
00403 }

Bool mem_removal ( U8  lun  ) 

This function inform about the memory type.

Parameters:
lun Logical unit number
Returns:
TRUE -> The memory is removal

Definition at line 412 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_removal, Lun_1_removal, Lun_2_removal, Lun_3_removal, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, and Lun_usb_removal.

00413 {
00414    switch( lun )
00415    {
00416 #     if (LUN_0 == ENABLE)
00417       case LUN_ID_0:
00418       return Lun_0_removal();
00419       break;
00420 #     endif
00421 #     if (LUN_1 == ENABLE)
00422       case LUN_ID_1:
00423       return Lun_1_removal();
00424       break;
00425 #     endif
00426 #     if (LUN_2 == ENABLE)
00427       case LUN_ID_2:
00428       return Lun_2_removal();
00429       break;
00430 #     endif
00431 #     if (LUN_3 == ENABLE)
00432       case LUN_ID_3:
00433       return Lun_3_removal();
00434       break;
00435 #     endif
00436 #     if (LUN_4 == ENABLE)
00437       case LUN_ID_4:
00438       return Lun_4_removal();
00439       break;
00440 #     endif
00441 #     if (LUN_5 == ENABLE)
00442       case LUN_ID_5:
00443       return Lun_5_removal();
00444       break;
00445 #     endif
00446 #     if (LUN_6 == ENABLE)
00447       case LUN_ID_6:
00448       return Lun_6_removal();
00449       break;
00450 #     endif
00451 #     if (LUN_7 == ENABLE)
00452       case LUN_ID_7:
00453       return Lun_7_removal();
00454       break;
00455 #     endif
00456 #     if (LUN_USB == ENABLE)
00457       default:
00458       return Lun_usb_removal();
00459       break;
00460 #     endif
00461    }
00462    return   CTRL_FAIL;
00463 }

U8 code* mem_name ( U8  lun  ) 

This function returns a pointer to the LUN name.

Parameters:
lun Logical unit number
Returns:
pointer to code string

Definition at line 475 of file ctrl_access.c.

References lun0_name, lun1_name, lun2_name, lun3_name, lun4_name, lun5_name, lun6_name, lun7_name, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, and lunusb_name.

00477 {
00478    switch( lun )
00479    {
00480 #     if (LUN_0 == ENABLE)
00481       case LUN_ID_0:
00482       return (U8 code*)lun0_name;
00483       break;
00484 #     endif
00485 #     if (LUN_1 == ENABLE)
00486       case LUN_ID_1:
00487       return (U8 code*)lun1_name;
00488       break;
00489 #     endif
00490 #     if (LUN_2 == ENABLE)
00491       case LUN_ID_2:
00492       return (U8 code*)lun2_name;
00493       break;
00494 #     endif
00495 #     if (LUN_3 == ENABLE)
00496       case LUN_ID_3:
00497       return (U8 code*)lun3_name;
00498       break;
00499 #     endif
00500 #     if (LUN_4 == ENABLE)
00501       case LUN_ID_4:
00502       return (U8 code*)lun4_name;
00503       break;
00504 #     endif
00505 #     if (LUN_5 == ENABLE)
00506       case LUN_ID_5:
00507       return (U8 code*)lun5_name;
00508       break;
00509 #     endif
00510 #     if (LUN_6 == ENABLE)
00511       case LUN_ID_6:
00512       return (U8 code*)lun6_name;
00513       break;
00514 #     endif
00515 #     if (LUN_7 == ENABLE)
00516       case LUN_ID_7:
00517       return (U8 code*)lun7_name;
00518       break;
00519 #     endif
00520 #     if (LUN_USB == ENABLE)
00521       default:
00522       return (U8 code*)lunusb_name;
00523       break;
00524 #     endif
00525    }
00526    return 0;   // Remove compiler warning
00527 }

Ctrl_status memory_2_usb ( U8  lun,
U32  addr,
U16  nb_sector 
)

This function tranfer a data from memory to usb.

Parameters:
lun Logical unit number
addr Sector address to start read (sector = 512B)
nb_sector Number of sectors to transfer
Returns:
Ctrl_status It is ready -> CTRL_GOOD A error occur -> CTRL_FAIL Memory unplug -> CTRL_NO_PRESENT

Definition at line 547 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_read_10, Lun_1_read_10, Lun_2_read_10, Lun_3_read_10, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, and LUN_ID_7.

00548 {
00549    Ctrl_status status=CTRL_FAIL;
00550 
00551    switch( lun )
00552    {
00553 #     if (LUN_0 == ENABLE)
00554       case LUN_ID_0:
00555       status = Lun_0_read_10(addr , nb_sector);
00556       break;
00557 #     endif
00558 #     if (LUN_1 == ENABLE)
00559       case LUN_ID_1:
00560       status = Lun_1_read_10(addr , nb_sector);
00561       break;
00562 #     endif
00563 #     if (LUN_2 == ENABLE)
00564       case LUN_ID_2:
00565       status = Lun_2_read_10(addr , nb_sector);
00566       break;
00567 #     endif
00568 #     if (LUN_3 == ENABLE)
00569       case LUN_ID_3:
00570       status = Lun_3_read_10(addr , nb_sector);
00571       break;
00572 #     endif
00573 #     if (LUN_4 == ENABLE)
00574       case LUN_ID_4:
00575       status = Lun_4_read_10(addr , nb_sector);
00576       break;
00577 #     endif
00578 #     if (LUN_5 == ENABLE)
00579       case LUN_ID_5:
00580       status = Lun_5_read_10(addr , nb_sector);
00581       break;
00582 #     endif
00583 #     if (LUN_6 == ENABLE)
00584       case LUN_ID_6:
00585       status = Lun_6_read_10(addr , nb_sector);
00586       break;
00587 #     endif
00588 #     if (LUN_7 == ENABLE)
00589       case LUN_ID_7:
00590       status = Lun_7_read_10(addr , nb_sector);
00591       break;
00592 #     endif
00593    }
00594    return   status;
00595 }

Ctrl_status usb_2_memory ( U8  lun,
U32  addr,
U16  nb_sector 
)

This function transfer a data from usb to memory.

Parameters:
lun Logical unit number
addr Sector address to start write (sector = 512B)
nb_sector Number of sectors to transfer
Returns:
Ctrl_status It is ready -> CTRL_GOOD A error occur -> CTRL_FAIL Memory unplug -> CTRL_NO_PRESENT

Definition at line 608 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_write_10, Lun_1_write_10, Lun_2_write_10, Lun_3_write_10, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, and LUN_ID_7.

00609 {
00610    Ctrl_status status=CTRL_FAIL;
00611 
00612    switch( lun )
00613    {
00614 #     if (LUN_0 == ENABLE)
00615       case LUN_ID_0:
00616       status = Lun_0_write_10(addr , nb_sector);
00617       break;
00618 #     endif
00619 #     if (LUN_1 == ENABLE)
00620       case LUN_ID_1:
00621       status = Lun_1_write_10(addr , nb_sector);
00622       break;
00623 #     endif
00624 #     if (LUN_2 == ENABLE)
00625       case LUN_ID_2:
00626       status = Lun_2_write_10(addr , nb_sector);
00627       break;
00628 #     endif
00629 #     if (LUN_3 == ENABLE)
00630       case LUN_ID_3:
00631       status = Lun_3_write_10(addr , nb_sector);
00632       break;
00633 #     endif
00634 #     if (LUN_4 == ENABLE)
00635       case LUN_ID_4:
00636       status = Lun_4_write_10(addr , nb_sector);
00637       break;
00638 #     endif
00639 #     if (LUN_5 == ENABLE)
00640       case LUN_ID_5:
00641       status = Lun_5_write_10(addr , nb_sector);
00642       break;
00643 #     endif
00644 #     if (LUN_6 == ENABLE)
00645       case LUN_ID_6:
00646       status = Lun_6_write_10(addr , nb_sector);
00647       break;
00648 #     endif
00649 #     if (LUN_7 == ENABLE)
00650       case LUN_ID_7:
00651       status = Lun_7_write_10(addr , nb_sector);
00652       break;
00653 #     endif
00654    }
00655    return   status;
00656 }

Ctrl_status memory_2_ram ( U8  lun,
const U32 _MEM_TYPE_SLOW_  addr,
U8 _MEM_TYPE_SLOW_ *  ram 
)

Interface for RAM.

This function tranfer one sector data from memory to ram

Parameters:
lun Logical unit number
addr Sector address to start read (sector = 512B)
nb_sector Number of sectors to transfer
ram Adresse of ram buffer (only xdata)
Returns:
Ctrl_status It is ready -> CTRL_GOOD A error occur -> CTRL_FAIL Memory unplug -> CTRL_NO_PRESENT

Definition at line 673 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_mem_2_ram, Lun_1_mem_2_ram, Lun_2_mem_2_ram, Lun_3_mem_2_ram, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, LUN_ID_USB, and Lun_usb_mem_2_ram.

00674 {
00675 
00676    Ctrl_status status=CTRL_FAIL;
00677 
00678    switch( lun )
00679    {
00680 #     if (LUN_0 == ENABLE)
00681       case LUN_ID_0:
00682       status = Lun_0_mem_2_ram(addr , ram);
00683       break;
00684 #     endif
00685 #     if (LUN_1 == ENABLE)
00686       case LUN_ID_1:
00687       status = Lun_1_mem_2_ram(addr , ram);
00688       break;
00689 #     endif
00690 #     if (LUN_2 == ENABLE)
00691       case LUN_ID_2:
00692       status = Lun_2_mem_2_ram(addr , ram);
00693       break;
00694 #     endif
00695 #     if (LUN_3 == ENABLE)
00696       case LUN_ID_3:
00697       status = Lun_3_mem_2_ram(addr , ram);
00698       break;
00699 #     endif
00700 #     if (LUN_4 == ENABLE)
00701       case LUN_ID_4:
00702       status = Lun_4_mem_2_ram(addr , ram);
00703       break;
00704 #     endif
00705 #     if (LUN_5 == ENABLE)
00706       case LUN_ID_5:
00707       status = Lun_5_mem_2_ram(addr , ram);
00708       break;
00709 #     endif
00710 #     if (LUN_6 == ENABLE)
00711       case LUN_ID_6:
00712       status = Lun_6_mem_2_ram(addr , ram);
00713       break;
00714 #     endif
00715 #     if (LUN_7 == ENABLE)
00716       case LUN_ID_7:
00717       status = Lun_7_mem_2_ram(addr , ram);
00718       break;
00719 #     endif
00720 #     if (LUN_USB == ENABLE)
00721       default:
00722       return  Lun_usb_mem_2_ram(lun - LUN_ID_USB,addr , ram);
00723 #     endif
00724    }
00725    return   status;
00726 }

Ctrl_status ram_2_memory ( U8  lun,
const U32 _MEM_TYPE_SLOW_  addr,
U8 _MEM_TYPE_SLOW_ *  ram 
)

This function transfer a data from ram to memory.

Parameters:
lun Logical unit number
addr Sector address to start write (sector = 512B)
nb_sector Number of sectors to transfer
ram Adresse of ram buffer (only xdata)
Returns:
Ctrl_status It is ready -> CTRL_GOOD A error occur -> CTRL_FAIL Memory unplug -> CTRL_NO_PRESENT

Definition at line 745 of file ctrl_access.c.

References CTRL_FAIL, Lun_0_ram_2_mem, Lun_1_ram_2_mem, Lun_2_ram_2_mem, Lun_3_ram_2_mem, LUN_ID_0, LUN_ID_1, LUN_ID_2, LUN_ID_3, LUN_ID_4, LUN_ID_5, LUN_ID_6, LUN_ID_7, LUN_ID_USB, and Lun_usb_ram_2_mem.

00746 {
00747    Ctrl_status status=CTRL_FAIL;
00748 
00749    switch( lun )
00750    {
00751 #     if (LUN_0 == ENABLE)
00752       case LUN_ID_0:
00753       status = Lun_0_ram_2_mem(addr , ram);
00754       break;
00755 #     endif
00756 #     if (LUN_1 == ENABLE)
00757       case LUN_ID_1:
00758       status = Lun_1_ram_2_mem(addr , ram);
00759       break;
00760 #     endif
00761 #     if (LUN_2 == ENABLE)
00762       case LUN_ID_2:
00763       status = Lun_2_ram_2_mem(addr , ram);
00764       break;
00765 #     endif
00766 #     if (LUN_3 == ENABLE)
00767       case LUN_ID_3:
00768       status = Lun_3_ram_2_mem(addr , ram);
00769       break;
00770 #     endif
00771 #     if (LUN_4 == ENABLE)
00772       case LUN_ID_4:
00773       status = Lun_4_ram_2_mem(addr , ram);
00774       break;
00775 #     endif
00776 #     if (LUN_5 == ENABLE)
00777       case LUN_ID_5:
00778       status = Lun_5_ram_2_mem(addr , ram);
00779       break;
00780 #     endif
00781 #     if (LUN_6 == ENABLE)
00782       case LUN_ID_6:
00783       status = Lun_6_ram_2_mem(addr , ram);
00784       break;
00785 #     endif
00786 #     if (LUN_7 == ENABLE)
00787       case LUN_ID_7:
00788       status = Lun_7_ram_2_mem(addr , ram);
00789       break;
00790 #     endif
00791 #     if (LUN_USB == ENABLE)
00792       default:
00793       return  Lun_usb_ram_2_mem(lun - LUN_ID_USB,addr , ram);
00794       break;
00795 #     endif
00796    }
00797    return   status;
00798 }

U8 stream_mem_to_mem ( U8  src_lun,
U32  src_addr,
U8  dest_lun,
U32  dest_addr,
U16  nb_sector 
)

This function copy a data from memory to other memory.

Parameters:
addr Sector address to start write
nb_sector Number of sectors to transfer

Definition at line 806 of file ctrl_access.c.

References CTRL_FAIL, CTRL_GOOD, fat_cache_flush(), fat_cache_reset(), fs_g_sector, ID_STREAM_ERR, memory_2_ram(), and ram_2_memory().

00807 {
00808    Ctrl_status status=CTRL_FAIL;
00809    fat_cache_flush();
00810    while(nb_sector)
00811    {
00812       status = memory_2_ram( src_lun , src_addr , fs_g_sector );
00813       if( status != CTRL_GOOD )
00814          break;
00815       status = ram_2_memory( dest_lun , dest_addr , fs_g_sector );
00816       if( status != CTRL_GOOD )
00817          break;
00818       src_addr++;
00819       dest_addr++;
00820       nb_sector--;
00821    }
00822    fat_cache_reset();
00823    return (status != CTRL_GOOD)? ID_STREAM_ERR:0;
00824 }

Here is the call graph for this function:

Ctrl_status stream_state ( U8  Id  ) 

Returns the state on a data transfer.

Parameters:
id transfer id
Returns:
the state of the transfer CTRL_GOOD It is finish CTRL_BUSY It is running CTRL_FAIL It is fail

Definition at line 836 of file ctrl_access.c.

References CTRL_GOOD.

00837 {
00838    return CTRL_GOOD;
00839 }

U16 stream_stop ( U8  Id  ) 

Stop the data transfer.

Parameters:
id Transfer id
Returns:
the number of sector remainder

Definition at line 847 of file ctrl_access.c.

00848 {
00849    return 0;
00850 }


Generated on Fri Oct 31 14:31:26 2008 for ATMEL by  doxygen 1.5.3