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 55 of file ctrl_access.h.

#define LUN_0   DISABLE

Definition at line 60 of file ctrl_access.h.

#define LUN_1   DISABLE

Definition at line 63 of file ctrl_access.h.

#define LUN_2   DISABLE

Definition at line 66 of file ctrl_access.h.

#define LUN_3   DISABLE

Definition at line 69 of file ctrl_access.h.

#define LUN_4   DISABLE

Definition at line 72 of file ctrl_access.h.

#define LUN_5   DISABLE

Definition at line 75 of file ctrl_access.h.

#define LUN_6   DISABLE

Definition at line 78 of file ctrl_access.h.

#define LUN_7   DISABLE

Definition at line 81 of file ctrl_access.h.

#define LUN_USB   DISABLE

Definition at line 84 of file ctrl_access.h.

#define LUN_ID_VIRTUAL   LUN_ID_0

Definition at line 88 of file ctrl_access.h.

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

Definition at line 89 of file ctrl_access.h.

 
#define Lun_0_test_unit_ready (  )     virtual_test_unit_ready()

Definition at line 90 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 91 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_0_wr_protect (  )     virtual_wr_protect()

Definition at line 92 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_0_removal (  )     virtual_removal()

Definition at line 93 of file ctrl_access.h.

Referenced by mem_removal().

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

Definition at line 94 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 95 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 96 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 97 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_0_NAME   "VIRTUAL_MEM_ON_CHIP"

Definition at line 98 of file ctrl_access.h.

#define LUN_ID_NF   LUN_ID_1

Definition at line 101 of file ctrl_access.h.

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

Definition at line 102 of file ctrl_access.h.

 
#define Lun_1_test_unit_ready (  )     nf_test_unit_ready()

Definition at line 103 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 104 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_1_wr_protect (  )     nf_wr_protect()

Definition at line 105 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_1_removal (  )     nf_removal()

Definition at line 106 of file ctrl_access.h.

Referenced by mem_removal().

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

Definition at line 107 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 108 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 109 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 110 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_1_NAME   "\"NAND Flash\""

Definition at line 111 of file ctrl_access.h.

#define LUN_ID_DF   LUN_ID_2

Definition at line 114 of file ctrl_access.h.

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

Definition at line 115 of file ctrl_access.h.

 
#define Lun_2_test_unit_ready (  )     df_test_unit_ready()

Definition at line 116 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 117 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_2_wr_protect (  )     df_wr_protect()

Definition at line 118 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_2_removal (  )     df_removal()

Definition at line 119 of file ctrl_access.h.

Referenced by mem_removal().

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

Definition at line 120 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 121 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 122 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 123 of file ctrl_access.h.

Referenced by memory_2_ram().

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

Definition at line 124 of file ctrl_access.h.

#define LUN_ID_MMC_SD   LUN_ID_3

Definition at line 127 of file ctrl_access.h.

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

Definition at line 128 of file ctrl_access.h.

 
#define Lun_3_test_unit_ready (  )     mmc_sd_test_unit_ready()

Definition at line 129 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 130 of file ctrl_access.h.

Referenced by mem_read_capacity().

 
#define Lun_3_wr_protect (  )     mmc_sd_wr_protect()

Definition at line 131 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_3_removal (  )     mmc_sd_removal()

Definition at line 132 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 133 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 134 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 135 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 136 of file ctrl_access.h.

Referenced by memory_2_ram().

#define LUN_3_NAME   "\"MMC\""

Definition at line 137 of file ctrl_access.h.

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

Definition at line 140 of file ctrl_access.h.

#define Lun_usb_test_unit_ready ( lun   )     host_test_unit_ready(lun)

Definition at line 141 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 142 of file ctrl_access.h.

Referenced by mem_read_capacity().

#define Lun_usb_wr_protect ( lun   )     host_wr_protect(lun)

Definition at line 143 of file ctrl_access.h.

Referenced by mem_wr_protect().

 
#define Lun_usb_removal (  )     host_removal()

Definition at line 144 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 145 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 146 of file ctrl_access.h.

Referenced by memory_2_ram().

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

Definition at line 147 of file ctrl_access.h.

#define ID_STREAM_ERR   0xFF

Definition at line 205 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 175 of file ctrl_access.c.

References MAX_LUN.

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

U8 get_cur_lun (  ) 

This function return the current logical unit.

Returns:
U8 number of logical unit in the system

Definition at line 194 of file ctrl_access.c.

00195 {
00196    return   0; //TODO a specific management
00197 }

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 213 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.

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

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 276 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.

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

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 336 of file ctrl_access.c.

References LUN_ID_USB.

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

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 355 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.

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

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 415 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.

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

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 478 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.

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

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 550 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.

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

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 611 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.

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

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 676 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.

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

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 748 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.

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

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 809 of file ctrl_access.c.

References CTRL_FAIL, CTRL_GOOD, ID_STREAM_ERR, memory_2_ram(), and ram_2_memory().

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

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 839 of file ctrl_access.c.

References CTRL_GOOD.

00840 {
00841    return CTRL_GOOD;
00842 }

U16 stream_stop ( U8  Id  ) 

Stop the data transfer.

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

Definition at line 850 of file ctrl_access.c.

00851 {
00852    return 0;
00853 }


Generated on Fri Sep 11 14:39:51 2009 for ATMEL by  doxygen 1.5.3