SAMV71 Xplained Ultra Software Package 1.4

Memory Control Access

Defines

#define SECTOR_SIZE   512

Enumerations

enum  Ctrl_status { CTRL_GOOD = PASS, CTRL_FAIL = FAIL, CTRL_NO_PRESENT = FAIL + 1, CTRL_BUSY = FAIL + 2 }
 

Status returned by CTRL_ACCESS interfaces.

More...

Variables

bool g_wr_protect
 Write protect.

Control Interface



uint8_t get_nb_lun (void)
 Returns the number of LUNs.
uint8_t get_cur_lun (void)
 Returns the current LUN.
Ctrl_status mem_test_unit_ready (uint8_t lun)
 Tests the memory state and initializes the memory if required.
Ctrl_status mem_read_capacity (uint8_t lun, uint32_t *u32_nb_sector)
 Returns the address of the last valid sector (512 bytes) in the memory.
uint8_t mem_sector_size (uint8_t lun)
 Returns the size of the physical sector.
bool mem_unload (uint8_t lun, bool unload)
 Unload/load the medium.
bool mem_wr_protect (uint8_t lun)
 Returns the write-protection state of the memory.
bool mem_removal (uint8_t lun)
 Tells whether the memory is removable.
const char * mem_name (uint8_t lun)
 Returns a pointer to the LUN name.

MEM <-> USB Interface



Ctrl_status memory_2_usb (uint8_t lun, uint32_t addr, U16 nb_sector)
 Transfers data from the memory to USB.
Ctrl_status usb_2_memory (uint8_t lun, uint32_t addr, U16 nb_sector)
 Transfers data from USB to the memory.

MEM <-> RAM Interface



Ctrl_status memory_2_ram (uint8_t lun, uint32_t addr, void *ram)
 Copies 1 data sector from the memory to RAM.
Ctrl_status ram_2_memory (uint8_t lun, uint32_t addr, const void *ram)
 Copies 1 data sector from RAM to the memory.

Streaming MEM <-> MEM Interface



Ctrl_status stream_mem_to_mem (uint8_t src_lun, uint32_t src_addr, uint8_t dest_lun, uint32_t dest_addr, U16 nb_sector)
 Copies data from one memory to another.
Ctrl_status stream_state (uint8_t id)
 Returns the state of a streaming data transfer.
U16 stream_stop (uint8_t id)
 Stops a streaming data transfer.
#define ID_STREAM_ERR   0xFF
 Erroneous streaming data transfer ID.

LUN IDs



#define LUN_ID_0   (0)
 First static LUN.
#define LUN_ID_1   (LUN_ID_0 + LUN_0)
#define LUN_ID_2   (LUN_ID_1 + LUN_1)
#define LUN_ID_3   (LUN_ID_2 + LUN_2)
#define LUN_ID_4   (LUN_ID_3 + LUN_3)
#define LUN_ID_5   (LUN_ID_4 + LUN_4)
#define LUN_ID_6   (LUN_ID_5 + LUN_5)
#define LUN_ID_7   (LUN_ID_6 + LUN_6)
#define MAX_LUN   (LUN_ID_7 + LUN_7)
 Number of static LUNs.
#define LUN_ID_USB   (MAX_LUN)

Detailed Description

Common abstraction layer for memory interfaces. It provides interfaces between: Memory and USB, Memory and RAM, Memory and Memory. Common API for XMEGA and UC3.


Define Documentation

#define LUN_ID_USB   (MAX_LUN)

First dynamic LUN (USB host mass storage).

Definition at line 136 of file ctrl_access.h.


Enumeration Type Documentation

Status returned by CTRL_ACCESS interfaces.

Enumerator:
CTRL_GOOD 

Success, memory ready.

CTRL_FAIL 

An error occurred.

CTRL_NO_PRESENT 

Memory unplugged.

CTRL_BUSY 

Memory not initialized or changed.

Definition at line 84 of file ctrl_access.h.


Function Documentation

uint8_t get_cur_lun ( void   ) 

Returns the current LUN.

Returns:
Current LUN.

Definition at line 310 of file ctrl_access.c.

uint8_t get_nb_lun ( void   ) 

Returns the number of LUNs.

Returns:
Number of LUNs in the system.

Definition at line 289 of file ctrl_access.c.

const char* mem_name ( uint8_t  lun  ) 

Returns a pointer to the LUN name.

Parameters:
lun Logical Unit Number.
Returns:
Pointer to the LUN name string.

Definition at line 459 of file ctrl_access.c.

Ctrl_status mem_read_capacity ( uint8_t  lun,
uint32_t *  u32_nb_sector 
)

Returns the address of the last valid sector (512 bytes) in the memory.

Parameters:
lun Logical Unit Number.
u32_nb_sector Pointer to the address of the last valid sector.
Returns:
Status.

Definition at line 338 of file ctrl_access.c.

bool mem_removal ( uint8_t  lun  ) 

Tells whether the memory is removable.

Parameters:
lun Logical Unit Number.
Returns:
true if the memory is removable, else false.

Definition at line 434 of file ctrl_access.c.

uint8_t mem_sector_size ( uint8_t  lun  ) 

Returns the size of the physical sector.

Parameters:
lun Logical Unit Number.
Returns:
Sector size (unit: 512 bytes).

Definition at line 360 of file ctrl_access.c.

Ctrl_status mem_test_unit_ready ( uint8_t  lun  ) 

Tests the memory state and initializes the memory if required.

The TEST UNIT READY SCSI primary command allows an application client to poll a LUN until it is ready without having to allocate memory for returned data.

This command may be used to check the media status of LUNs with removable media.

Parameters:
lun Logical Unit Number.
Returns:
Status.

Definition at line 316 of file ctrl_access.c.

bool mem_unload ( uint8_t  lun,
bool  unload 
)

Unload/load the medium.

Parameters:
lun Logical Unit Number.
unload true to unload the medium, false to load the medium.
Returns:
true if unload/load success, else false.

Definition at line 382 of file ctrl_access.c.

bool mem_wr_protect ( uint8_t  lun  ) 

Returns the write-protection state of the memory.

Parameters:
lun Logical Unit Number.
Returns:
true if the memory is write-protected, else false.
Note:
Only used by removable memories with hardware-specific write protection.

Definition at line 412 of file ctrl_access.c.

Ctrl_status memory_2_ram ( uint8_t  lun,
uint32_t  addr,
void *  ram 
)

Copies 1 data sector from the memory to RAM.

Parameters:
lun Logical Unit Number.
addr Address of first memory sector to read.
ram Pointer to RAM buffer to write.
Returns:
Status.

Definition at line 538 of file ctrl_access.c.

Ctrl_status memory_2_usb ( uint8_t  lun,
uint32_t  addr,
U16  nb_sector 
)

Transfers data from the memory to USB.

Parameters:
lun Logical Unit Number.
addr Address of first memory sector to read.
nb_sector Number of sectors to transfer.
Returns:
Status.

Definition at line 486 of file ctrl_access.c.

Ctrl_status ram_2_memory ( uint8_t  lun,
uint32_t  addr,
const void *  ram 
)

Copies 1 data sector from RAM to the memory.

Parameters:
lun Logical Unit Number.
addr Address of first memory sector to write.
ram Pointer to RAM buffer to read.
Returns:
Status.

Definition at line 565 of file ctrl_access.c.

Ctrl_status stream_mem_to_mem ( uint8_t  src_lun,
uint32_t  src_addr,
uint8_t  dest_lun,
uint32_t  dest_addr,
U16  nb_sector 
)

Copies data from one memory to another.

Parameters:
src_lun Source Logical Unit Number.
src_addr Source address of first memory sector to read.
dest_lun Destination Logical Unit Number.
dest_addr Destination address of first memory sector to write.
nb_sector Number of sectors to copy.
Returns:
Status.

Definition at line 608 of file ctrl_access.c.

Here is the call graph for this function:

Ctrl_status stream_state ( uint8_t  id  ) 

Returns the state of a streaming data transfer.

Parameters:
id Transfer ID.
Returns:
Status.

Definition at line 626 of file ctrl_access.c.

U16 stream_stop ( uint8_t  id  ) 

Stops a streaming data transfer.

Parameters:
id Transfer ID.
Returns:
Number of remaining sectors.

Definition at line 633 of file ctrl_access.c.

Ctrl_status usb_2_memory ( uint8_t  lun,
uint32_t  addr,
U16  nb_sector 
)

Transfers data from USB to the memory.

Parameters:
lun Logical Unit Number.
addr Address of first memory sector to write.
nb_sector Number of sectors to transfer.
Returns:
Status.

Definition at line 506 of file ctrl_access.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines