- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

# ctrl_access.h File Reference

Copyright (c) 2004This file contains the interface :

- between USB <-> MEMORY OR
- between USB <- Access Memory Ctrl -> Memory.

More...

`#include "conf\conf_access.h"`
`#include "ctrl_status.h"`
`#include "lib_mem\virtual_mem\virtual_mem.h"`
`#include "lib_mem\nf_1x_2kb\nf_mem.h"`
`#include "lib_mem\nf_1x_512\nf_mem.h"`
`#include "lib_mem\df\df_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 "lib_mcu\usb\usb_drv.h"`
`#include "conf_usb.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 | ID_STREAM_ERR 0xFF
| ---- Interface for streaming interface ----------------------------------
#define | TYPE_STREAM_AUDIO DFC_ID_AUDIOPROC1
#define | TYPE_STREAM_AUDIO2 DFC_ID_AUDIOPROC2
#define | TYPE_STREAM_SIO DFC_ID_SIO
#define | TYPE_STREAM_SPI DFC_ID_SPI
#define | TYPE_STREAM_DEVNULL DFC_ID_NULL_DEV
## Functions
U8 | get_nb_lun ()
| **** Listing of commun interface ****************************************
U8 | get_cur_lun ()
| This fonction return the current logical unit.
Ctrl_status | mem_test_unit_ready (U8 lun)
| This fonction 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 fonction return the capacity of the memory.
Bool | mem_wr_protect (U8 lun)
| This fonction return is the write protected mode.
Bool | mem_removal (U8 lun)
| This fonction inform about the memory type.
U8 code * | mem_name (U8 lun)
| This fonction returns a pointer to the LUN name.
Ctrl_status | memory_2_usb (U8 lun, U32 addr, U16 nb_sector)
| **** Listing of READ/WRITE interface ************************************
Ctrl_status | usb_2_memory (U8 lun, U32 addr, U16 nb_sector)
| This fonction trabsfer a data from usb to memory.
Ctrl_status | memory_2_ram (U8 lun, const U32 _MEM_TYPE_SLOW_ *addr, U8 _MEM_TYPE_SLOW_ *ram)
| This fonction tranfer one sector data from memory to ram.
Ctrl_status | ram_2_memory (U8 lun, const U32 _MEM_TYPE_SLOW_ *addr, U8 _MEM_TYPE_SLOW_ *ram)
| This fonction trabsfer 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 fonction copy a data from memory to other memory.
U8 | stream_read_10_start (U8 TypeStream, U8 lun, U32 addr, U16 nb_sector)
U8 | stream_write_10_start (U8 TypeStream, U8 lun, U32 addr, U16 nb_sector)
U8 | stream_to_stream_start (U8 TypeStream_src, U8 TypeStream_dest, U16 nb_sector)
Ctrl_status | stream_state (U8 Id)
| Returns the state on a data transfer.
U16 | stream_stop (U8 Id)
| Stop the data transfer.

## Detailed Description

Copyright (c) 2004This file contains the interface :

- between USB <-> MEMORY OR
- between USB <- Access Memory Ctrl -> Memory.

Please read file license.txt for copyright notice.

This interface may be controled by a "Access Memory Control" for :

- include a management of write protect global or specific
- include a management of access password
- ...

Version:
  1.1 (c5131-mass-storage-virtual-1_0_4)

Todo:

Bug:

Definition in file ctrl_access.h.

## Define Documentation

#define ID_STREAM_ERR 0xFF

---- Interface for streaming interface ----------------------------------

Definition at line 103 of file ctrl_access.h.

#define TYPE_STREAM_AUDIO DFC_ID_AUDIOPROC1

Definition at line 108 of file ctrl_access.h.

#define TYPE_STREAM_AUDIO2 DFC_ID_AUDIOPROC2

Definition at line 109 of file ctrl_access.h.

#define TYPE_STREAM_SIO DFC_ID_SIO

Definition at line 110 of file ctrl_access.h.

#define TYPE_STREAM_SPI DFC_ID_SPI

Definition at line 111 of file ctrl_access.h.

#define TYPE_STREAM_DEVNULL DFC_ID_NULL_DEV

Definition at line 112 of file ctrl_access.h.

## Function Documentation

U8 get_nb_lun | ( |  | ) |

**** Listing of commun interface ****************************************

Returns:
  U8 number of logical unit in the system

Definition at line 157 of file ctrl_access.c.

References MAX_LUN.

Referenced by usb_user_read_request().

    00158 {
    00159 #if   (MEM_USB == ENABLED)
    00160    return   (MAX_LUN + Host_getlun());
    00161 #else
    00162    return   MAX_LUN;
    00163 #endif
    00164 }

U8 get_cur_lun | ( |  | ) |

This fonction return the current logical unit.

Returns:
  U8 number of logical unit in the system

Definition at line 171 of file ctrl_access.c.

Referenced by usb_mass_storage_cbw().

    00172 {
    00173    return   0; //TODO
    00174 }

Ctrl_status mem_test_unit_ready | ( | U8 | lun | ) |

This fonction 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 190 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.

Referenced by sbc_test_unit_ready().

    00191 {
    00192    switch( lun )
    00193    {
    00194 #     if (LUN_0 == ENABLE)
    00195       case LUN_ID_0:
    00196          return Lun_0_test_unit_ready();
    00197          break;
    00198 #     endif
    00199 #     if (LUN_1 == ENABLE)
    00200       case LUN_ID_1:
    00201          return Lun_1_test_unit_ready();
    00202          break;
    00203 #     endif
    00204 #     if (LUN_2 == ENABLE)
    00205       case LUN_ID_2:
    00206          return Lun_2_test_unit_ready();
    00207          break;
    00208 #     endif
    00209 #     if (LUN_3 == ENABLE)
    00210       case LUN_ID_3:
    00211          return Lun_3_test_unit_ready();
    00212          break;
    00213 #     endif
    00214 #     if (LUN_4 == ENABLE)
    00215       case LUN_ID_4:
    00216          return Lun_4_test_unit_ready();
    00217          break;
    00218 #     endif
    00219 #     if (LUN_5 == ENABLE)
    00220       case LUN_ID_5:
    00221          return Lun_5_test_unit_ready();
    00222          break;
    00223 #     endif
    00224 #     if (LUN_6 == ENABLE)
    00225       case LUN_ID_6:
    00226          return Lun_6_test_unit_ready();
    00227          break;
    00228 #     endif
    00229 #     if (LUN_7 == ENABLE)
    00230       case LUN_ID_7:
    00231          return Lun_7_test_unit_ready();
    00232          break;
    00233 #     endif
    00234 #     if (LUN_USB == ENABLE)
    00235       default:
    00236          return Lun_usb_test_unit_ready(lun - LUN_ID_USB);
    00237          break;
    00238 #     endif
    00239    }
    00240    return   CTRL_FAIL;
    00241 }

Ctrl_status mem_read_capacity | ( | U8 | lun,
|  | U32 _MEM_TYPE_SLOW_ * | u32_nb_sector |
| ) |  |  |

This fonction return the capacity of the memory.

Parameters:

  | lun | Logical unit number

Returns:
  *u16_nb_sector number of sector (sector = 512B)

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

Definition at line 252 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.

Referenced by sbc_read_capacity().

    00253 {
    00254    switch( lun )
    00255    {
    00256 #     if (LUN_0 == ENABLE)
    00257       case LUN_ID_0:
    00258          return Lun_0_read_capacity( u32_nb_sector );
    00259          break;
    00260 #     endif
    00261 #     if (LUN_1 == ENABLE)
    00262       case LUN_ID_1:
    00263          return Lun_1_read_capacity( u32_nb_sector );
    00264          break;
    00265 #     endif
    00266 #     if (LUN_2 == ENABLE)
    00267       case LUN_ID_2:
    00268          return Lun_2_read_capacity( u32_nb_sector );
    00269          break;
    00270 #     endif
    00271 #     if (LUN_3 == ENABLE)
    00272       case LUN_ID_3:
    00273          return Lun_3_read_capacity( u32_nb_sector );
    00274          break;
    00275 #     endif
    00276 #     if (LUN_4 == ENABLE)
    00277       case LUN_ID_4:
    00278          return Lun_4_read_capacity( u32_nb_sector );
    00279          break;
    00280 #     endif
    00281 #     if (LUN_5 == ENABLE)
    00282       case LUN_ID_5:
    00283          return Lun_5_read_capacity( u32_nb_sector );
    00284          break;
    00285 #     endif
    00286 #     if (LUN_6 == ENABLE)
    00287       case LUN_ID_6:
    00288          return Lun_6_read_capacity( u32_nb_sector );
    00289          break;
    00290 #     endif
    00291 #     if (LUN_7 == ENABLE)
    00292       case LUN_ID_7:
    00293          return Lun_7_read_capacity( u32_nb_sector );
    00294          break;
    00295 #     endif
    00296 #     if (LUN_USB == ENABLE)
    00297       default:
    00298          return Lun_usb_read_capacity( lun - LUN_ID_USB,u32_nb_sector );
    00299          break;
    00300 #     endif
    00301    }
    00302    return   CTRL_FAIL;
    00303 }

Bool mem_wr_protect | ( | U8 | lun | ) |

This fonction 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 314 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.

Referenced by sbc_header_mode_sense(), and sbc_write_10().

    00315 {
    00316    switch( lun )
    00317    {
    00318 #     if (LUN_0 == ENABLE)
    00319       case LUN_ID_0:
    00320          return Lun_0_wr_protect();
    00321          break;
    00322 #     endif
    00323 #     if (LUN_1 == ENABLE)
    00324       case LUN_ID_1:
    00325          return Lun_1_wr_protect();
    00326          break;
    00327 #     endif
    00328 #     if (LUN_2 == ENABLE)
    00329       case LUN_ID_2:
    00330          return Lun_2_wr_protect();
    00331          break;
    00332 #     endif
    00333 #     if (LUN_3 == ENABLE)
    00334       case LUN_ID_3:
    00335          return Lun_3_wr_protect();
    00336          break;
    00337 #     endif
    00338 #     if (LUN_4 == ENABLE)
    00339       case LUN_ID_4:
    00340          return Lun_4_wr_protect();
    00341          break;
    00342 #     endif
    00343 #     if (LUN_5 == ENABLE)
    00344       case LUN_ID_5:
    00345          return Lun_5_wr_protect();
    00346          break;
    00347 #     endif
    00348 #     if (LUN_6 == ENABLE)
    00349       case LUN_ID_6:
    00350          return Lun_6_wr_protect();
    00351          break;
    00352 #     endif
    00353 #     if (LUN_7 == ENABLE)
    00354       case LUN_ID_7:
    00355          return Lun_7_wr_protect();
    00356          break;
    00357 #     endif
    00358 #     if (LUN_USB == ENABLE)
    00359       default:
    00360          return Lun_usb_wr_protect(lun - LUN_ID_USB);
    00361          break;
    00362 #     endif
    00363    }
    00364    return   CTRL_FAIL;
    00365 }

Bool mem_removal | ( | U8 | lun | ) |

This fonction inform about the memory type.

Parameters:

  | lun | Logical unit number

Returns:
  TRUE -> The memory is removal

Definition at line 374 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.

    00375 {
    00376    switch( lun )
    00377    {
    00378 #     if (LUN_0 == ENABLE)
    00379       case LUN_ID_0:
    00380          return Lun_0_removal();
    00381          break;
    00382 #     endif
    00383 #     if (LUN_1 == ENABLE)
    00384       case LUN_ID_1:
    00385          return Lun_1_removal();
    00386          break;
    00387 #     endif
    00388 #     if (LUN_2 == ENABLE)
    00389       case LUN_ID_2:
    00390          return Lun_2_removal();
    00391          break;
    00392 #     endif
    00393 #     if (LUN_3 == ENABLE)
    00394       case LUN_ID_3:
    00395          return Lun_3_removal();
    00396          break;
    00397 #     endif
    00398 #     if (LUN_4 == ENABLE)
    00399       case LUN_ID_4:
    00400          return Lun_4_removal();
    00401          break;
    00402 #     endif
    00403 #     if (LUN_5 == ENABLE)
    00404       case LUN_ID_5:
    00405          return Lun_5_removal();
    00406          break;
    00407 #     endif
    00408 #     if (LUN_6 == ENABLE)
    00409       case LUN_ID_6:
    00410          return Lun_6_removal();
    00411          break;
    00412 #     endif
    00413 #     if (LUN_7 == ENABLE)
    00414       case LUN_ID_7:
    00415          return Lun_7_removal();
    00416          break;
    00417 #     endif
    00418 #     if (LUN_USB == ENABLE)
    00419       default:
    00420          return Lun_usb_removal();
    00421          break;
    00422 #     endif
    00423    }
    00424    return   CTRL_FAIL;
    00425 }

U8 code* mem_name | ( | U8 | lun | ) |

This fonction returns a pointer to the LUN name.

Parameters:

  | lun | Logical unit number

Returns:
  pointer to code string

Definition at line 433 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.

    00434 {
    00435    switch( lun )
    00436    {
    00437 #     if (LUN_0 == ENABLE)
    00438       case LUN_ID_0:
    00439          return (U8 code*)lun0_name;
    00440          break;
    00441 #     endif
    00442 #     if (LUN_1 == ENABLE)
    00443       case LUN_ID_1:
    00444          return (U8 code*)lun1_name;
    00445          break;
    00446 #     endif
    00447 #     if (LUN_2 == ENABLE)
    00448       case LUN_ID_2:
    00449          return (U8 code*)lun2_name;
    00450          break;
    00451 #     endif
    00452 #     if (LUN_3 == ENABLE)
    00453       case LUN_ID_3:
    00454          return (U8 code*)lun3_name;
    00455          break;
    00456 #     endif
    00457 #     if (LUN_4 == ENABLE)
    00458       case LUN_ID_4:
    00459          return (U8 code*)lun4_name;
    00460          break;
    00461 #     endif
    00462 #     if (LUN_5 == ENABLE)
    00463       case LUN_ID_5:
    00464          return (U8 code*)lun5_name;
    00465          break;
    00466 #     endif
    00467 #     if (LUN_6 == ENABLE)
    00468       case LUN_ID_6:
    00469          return (U8 code*)lun6_name;
    00470          break;
    00471 #     endif
    00472 #     if (LUN_7 == ENABLE)
    00473       case LUN_ID_7:
    00474          return (U8 code*)lun7_name;
    00475          break;
    00476 #     endif
    00477 #     if (LUN_USB == ENABLE)
    00478       default:
    00479          return (U8 code*)lunusb_name;
    00480          break;
    00481 #     endif
    00482    }
    00483    return 0;   // Remove compiler warning
    00484 }

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

**** Listing of READ/WRITE interface ************************************

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

References CTRL_GOOD, Lun_0_read_10, Lun_0_usb_read, Lun_1_read_10, Lun_1_usb_read, Lun_2_read_10, Lun_2_usb_read, Lun_3_read_10, Lun_3_usb_read, 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.

Referenced by sbc_read_10().

    00503 {
    00504    Ctrl_status status;
    00505
    00506    switch( lun )
    00507    {
    00508 #     if (LUN_0 == ENABLE)
    00509       case LUN_ID_0:
    00510          status = Lun_0_read_10(addr , nb_sector);
    00511          if (CTRL_GOOD == status)
    00512          {
    00513             status = Lun_0_usb_read();
    00514          }
    00515          break;
    00516 #     endif
    00517 #     if (LUN_1 == ENABLE)
    00518       case LUN_ID_1:
    00519          status = Lun_1_read_10(addr , nb_sector);
    00520          if (CTRL_GOOD == status)
    00521          {
    00522             status = Lun_1_usb_read();
    00523          }
    00524          break;
    00525 #     endif
    00526 #     if (LUN_2 == ENABLE)
    00527       case LUN_ID_2:
    00528          status = Lun_2_read_10(addr , nb_sector);
    00529          if (CTRL_GOOD == status)
    00530          {
    00531             status = Lun_2_usb_read();
    00532          }
    00533          break;
    00534 #     endif
    00535 #     if (LUN_3 == ENABLE)
    00536       case LUN_ID_3:
    00537          status = Lun_3_read_10(addr , nb_sector);
    00538          if (CTRL_GOOD == status)
    00539          {
    00540             status = Lun_3_usb_read();
    00541          }
    00542          break;
    00543 #     endif
    00544 #     if (LUN_4 == ENABLE)
    00545       case LUN_ID_4:
    00546          status = Lun_4_read_10(addr , nb_sector);
    00547          if (CTRL_GOOD == status)
    00548          {
    00549             status = Lun_4_usb_read();
    00550          }
    00551          break;
    00552 #     endif
    00553 #     if (LUN_5 == ENABLE)
    00554       case LUN_ID_5:
    00555          status = Lun_5_read_10(addr , nb_sector);
    00556          if (CTRL_GOOD == status)
    00557          {
    00558             status = Lun_5_usb_read();
    00559          }
    00560          break;
    00561 #     endif
    00562 #     if (LUN_6 == ENABLE)
    00563       case LUN_ID_6:
    00564          status = Lun_6_read_10(addr , nb_sector);
    00565          if (CTRL_GOOD == status)
    00566          {
    00567             status = Lun_6_usb_read();
    00568          }
    00569          break;
    00570 #     endif
    00571 #     if (LUN_7 == ENABLE)
    00572       case LUN_ID_7:
    00573          status = Lun_7_read_10(addr , nb_sector);
    00574          if (CTRL_GOOD == status)
    00575          {
    00576             status = Lun_7_usb_read();
    00577          }
    00578          break;
    00579 #     endif
    00580    }
    00581    return   status;
    00582 }

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

This fonction trabsfer 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 595 of file ctrl_access.c.

References CTRL_GOOD, Lun_0_usb_write, Lun_0_write_10, Lun_1_usb_write, Lun_1_write_10, Lun_2_usb_write, Lun_2_write_10, Lun_3_usb_write, 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.

Referenced by sbc_write_10().

    00596 {
    00597    Ctrl_status status;
    00598
    00599    switch( lun )
    00600    {
    00601 #     if (LUN_0 == ENABLE)
    00602       case LUN_ID_0:
    00603          status = Lun_0_write_10(addr , nb_sector);
    00604          if (CTRL_GOOD == status)
    00605          {
    00606             status = Lun_0_usb_write();
    00607          }
    00608          break;
    00609 #     endif
    00610 #     if (LUN_1 == ENABLE)
    00611       case LUN_ID_1:
    00612          status = Lun_1_write_10(addr , nb_sector);
    00613          if (CTRL_GOOD == status)
    00614          {
    00615             status = Lun_1_usb_write();
    00616          }
    00617          break;
    00618 #     endif
    00619 #     if (LUN_2 == ENABLE)
    00620       case LUN_ID_2:
    00621          status = Lun_2_write_10(addr , nb_sector);
    00622          if (CTRL_GOOD == status)
    00623          {
    00624             status = Lun_2_usb_write();
    00625          }
    00626          break;
    00627 #     endif
    00628 #     if (LUN_3 == ENABLE)
    00629       case LUN_ID_3:
    00630          status = Lun_3_write_10(addr , nb_sector);
    00631          if (CTRL_GOOD == status)
    00632          {
    00633             status = Lun_3_usb_write();
    00634          }
    00635          break;
    00636 #     endif
    00637 #     if (LUN_4 == ENABLE)
    00638       case LUN_ID_4:
    00639          status = Lun_4_write_10(addr , nb_sector);
    00640          if (CTRL_GOOD == status)
    00641          {
    00642             status = Lun_4_usb_write();
    00643          }
    00644          break;
    00645 #     endif
    00646 #     if (LUN_5 == ENABLE)
    00647       case LUN_ID_5:
    00648          status = Lun_5_write_10(addr , nb_sector);
    00649          if (CTRL_GOOD == status)
    00650          {
    00651             status = Lun_5_usb_write();
    00652          }
    00653          break;
    00654 #     endif
    00655 #     if (LUN_6 == ENABLE)
    00656       case LUN_ID_6:
    00657          status = Lun_6_write_10(addr , nb_sector);
    00658          if (CTRL_GOOD == status)
    00659          {
    00660             status = Lun_6_usb_write();
    00661          }
    00662          break;
    00663 #     endif
    00664 #     if (LUN_7 == ENABLE)
    00665       case LUN_ID_7:
    00666          status = Lun_7_write_10(addr , nb_sector);
    00667          if (CTRL_GOOD == status)
    00668          {
    00669             status = Lun_7_usb_write();
    00670          }
    00671          break;
    00672 #     endif
    00673    }
    00674    return   status;
    00675 }

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

This fonction 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:
  TRUE -> The memory is removal

Definition at line 689 of file ctrl_access.c.

References CTRL_GOOD, Lun_0_mem_2_ram, Lun_0_mem_2_ram_read, Lun_1_mem_2_ram, Lun_1_mem_2_ram_read, Lun_2_mem_2_ram, Lun_2_mem_2_ram_read, Lun_3_mem_2_ram, Lun_3_mem_2_ram_read, 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_mem_2_ram.

Referenced by stream_mem_to_mem().

    00690 {
    00691
    00692    Ctrl_status status;
    00693
    00694    switch( lun )
    00695    {
    00696 #     if (LUN_0 == ENABLE)
    00697       case LUN_ID_0:
    00698          status = Lun_0_mem_2_ram(*addr , ram);
    00699          if (CTRL_GOOD == status)
    00700          {
    00701             status = Lun_0_mem_2_ram_read();
    00702          }
    00703          break;
    00704 #     endif
    00705 #     if (LUN_1 == ENABLE)
    00706       case LUN_ID_1:
    00707          status = Lun_1_mem_2_ram(*addr , ram);
    00708          if (CTRL_GOOD == status)
    00709          {
    00710             status = Lun_1_mem_2_ram_read();
    00711          }
    00712          break;
    00713 #     endif
    00714 #     if (LUN_2 == ENABLE)
    00715       case LUN_ID_2:
    00716          status = Lun_2_mem_2_ram(*addr , ram);
    00717          if (CTRL_GOOD == status)
    00718          {
    00719             status = Lun_2_mem_2_ram_read();
    00720          }
    00721          break;
    00722 #     endif
    00723 #     if (LUN_3 == ENABLE)
    00724       case LUN_ID_3:
    00725          status = Lun_3_mem_2_ram(*addr , ram);
    00726          if (CTRL_GOOD == status)
    00727          {
    00728             status = Lun_3_mem_2_ram_read();
    00729          }
    00730          break;
    00731 #     endif
    00732 #     if (LUN_4 == ENABLE)
    00733       case LUN_ID_4:
    00734          status = Lun_4_mem_2_ram(*addr , ram);
    00735          if (CTRL_GOOD == status)
    00736          {
    00737             status = Lun_4_mem_2_ram_read();
    00738          }
    00739          break;
    00740 #     endif
    00741 #     if (LUN_5 == ENABLE)
    00742       case LUN_ID_5:
    00743          status = Lun_5_mem_2_ram(*addr , ram);
    00744          if (CTRL_GOOD == status)
    00745          {
    00746             status = Lun_5_mem_2_ram_read();
    00747          }
    00748          break;
    00749 #     endif
    00750 #     if (LUN_6 == ENABLE)
    00751       case LUN_ID_6:
    00752          status = Lun_6_mem_2_ram(*addr , ram);
    00753          if (CTRL_GOOD == status)
    00754          {
    00755             status = Lun_6_mem_2_ram_read();
    00756          }
    00757          break;
    00758 #     endif
    00759 #     if (LUN_7 == ENABLE)
    00760       case LUN_ID_7:
    00761          status = Lun_7_mem_2_ram(*addr , ram);
    00762          if (CTRL_GOOD == status)
    00763          {
    00764             status = Lun_7_mem_2_ram_read();
    00765          }
    00766          break;
    00767 #     endif
    00768 #     if (LUN_USB == ENABLE)
    00769       default:
    00770          return  Lun_usb_mem_2_ram(*addr , ram);
    00771 #     endif
    00772    }
    00773    return   status;
    00774 }

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

This fonction trabsfer 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:
  TRUE -> The memory is removal

Definition at line 790 of file ctrl_access.c.

References CTRL_GOOD, Lun_0_ram_2_mem, Lun_0_ram_2_mem_write, Lun_1_ram_2_mem, Lun_1_ram_2_mem_write, Lun_2_ram_2_mem, Lun_2_ram_2_mem_write, Lun_3_ram_2_mem, Lun_3_ram_2_mem_write, 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_ram_2_mem.

Referenced by stream_mem_to_mem().

    00791 {
    00792    Ctrl_status status;
    00793
    00794    switch( lun )
    00795    {
    00796 #     if (LUN_0 == ENABLE)
    00797       case LUN_ID_0:
    00798          status = Lun_0_ram_2_mem(*addr , ram);
    00799          if (CTRL_GOOD == status)
    00800          {
    00801             status = Lun_0_ram_2_mem_write();
    00802          }
    00803          break;
    00804 #     endif
    00805 #     if (LUN_1 == ENABLE)
    00806       case LUN_ID_1:
    00807          status = Lun_1_ram_2_mem(*addr , ram);
    00808          if (CTRL_GOOD == status)
    00809          {
    00810             status = Lun_1_ram_2_mem_write();
    00811          }
    00812          break;
    00813 #     endif
    00814 #     if (LUN_2 == ENABLE)
    00815       case LUN_ID_2:
    00816          status = Lun_2_ram_2_mem(*addr , ram);
    00817          if (CTRL_GOOD == status)
    00818          {
    00819             status = Lun_2_ram_2_mem_write();
    00820          }
    00821          break;
    00822 #     endif
    00823 #     if (LUN_3 == ENABLE)
    00824       case LUN_ID_3:
    00825          status = Lun_3_ram_2_mem(*addr , ram);
    00826          if (CTRL_GOOD == status)
    00827          {
    00828             status = Lun_3_ram_2_mem_write();
    00829          }
    00830          break;
    00831 #     endif
    00832 #     if (LUN_4 == ENABLE)
    00833       case LUN_ID_4:
    00834          status = Lun_4_ram_2_mem(*addr , ram);
    00835          if (CTRL_GOOD == status)
    00836          {
    00837             status = Lun_4_ram_2_mem_write();
    00838          }
    00839          break;
    00840 #     endif
    00841 #     if (LUN_5 == ENABLE)
    00842       case LUN_ID_5:
    00843          status = Lun_5_ram_2_mem(*addr , ram);
    00844          if (CTRL_GOOD == status)
    00845          {
    00846             status = Lun_5_ram_2_mem_write();
    00847          }
    00848          break;
    00849 #     endif
    00850 #     if (LUN_6 == ENABLE)
    00851       case LUN_ID_6:
    00852          status = Lun_6_ram_2_mem(*addr , ram);
    00853          if (CTRL_GOOD == status)
    00854          {
    00855             status = Lun_6_ram_2_mem_write();
    00856          }
    00857          break;
    00858 #     endif
    00859  #     if (LUN_7 == ENABLE)
    00860       case LUN_ID_7:
    00861          status = Lun_7_ram_2_mem(*addr , ram);
    00862          if (CTRL_GOOD == status)
    00863          {
    00864             status = Lun_7_ram_2_mem_write();
    00865          }
    00866          break;
    00867 #     endif
    00868 #     if (LUN_USB == ENABLE)
    00869       default:
    00870          return  Lun_usb_ram_2_mem(*addr , ram);
    00871          break;
    00872 #     endif
    00873    }
    00874    return   status;
    00875 }

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

This fonction 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 892 of file ctrl_access.c.

References buf_sector, CTRL_GOOD, memory_2_ram(), and ram_2_memory().

    00893 {
    00894    while(nb_sector)
    00895    {
    00896       memory_2_ram( src_lun , &src_addr , buf_sector );
    00897       ram_2_memory( dest_lun , &dest_addr , buf_sector );
    00898       src_addr++;
    00899       dest_addr++;
    00900       nb_sector--;
    00901    }
    00902    return CTRL_GOOD;
    00903 }

Here is the call graph for this function:

U8 stream_read_10_start | ( | U8 | TypeStream,
|  | U8 | lun,
|  | U32 | addr,
|  | U16 | nb_sector |
| ) |  |  |

U8 stream_write_10_start | ( | U8 | TypeStream,
|  | U8 | lun,
|  | U32 | addr,
|  | U16 | nb_sector |
| ) |  |  |

U8 stream_to_stream_start | ( | U8 | TypeStream_src,
|  | U8 | TypeStream_dest,
|  | U16 | nb_sector |
| ) |  |  |

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

References CTRL_GOOD.

    00919 {
    00920
    00921    return CTRL_GOOD;
    00922 }

U16 stream_stop | ( | U8 | Id | ) |

Stop the data transfer.

Parameters:

  | id | Transfer id

Returns:
  the number of sector remainder

Definition at line 930 of file ctrl_access.c.

    00931 {
    00932    return 0;
    00933 }