Macros | Enumerations | Variables
Memory Control Access

Macros

#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. More...
 

LUN IDs

#define LUN_ID_0   (0)
 First static LUN. More...
 
#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. More...
 
#define LUN_ID_USB   (MAX_LUN)
 

Control Interface

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

MEM <-> USB Interface

Ctrl_status memory_2_usb (U8 lun, U32 addr, U16 nb_sector)
 Transfers data from the memory to USB. More...
 
Ctrl_status usb_2_memory (U8 lun, U32 addr, U16 nb_sector)
 Transfers data from USB to the memory. More...
 

MEM <-> RAM Interface

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

Streaming MEM <-> MEM Interface

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

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.

Macro Definition Documentation

◆ ID_STREAM_ERR

#define ID_STREAM_ERR   0xFF

Erroneous streaming data transfer ID.

Definition at line 342 of file ctrl_access.h.

◆ LUN_ID_0

#define LUN_ID_0   (0)

First static LUN.

Definition at line 117 of file ctrl_access.h.

◆ LUN_ID_1

#define LUN_ID_1   (LUN_ID_0 + LUN_0)

Definition at line 118 of file ctrl_access.h.

◆ LUN_ID_2

#define LUN_ID_2   (LUN_ID_1 + LUN_1)

Definition at line 119 of file ctrl_access.h.

◆ LUN_ID_3

#define LUN_ID_3   (LUN_ID_2 + LUN_2)

Definition at line 120 of file ctrl_access.h.

◆ LUN_ID_4

#define LUN_ID_4   (LUN_ID_3 + LUN_3)

Definition at line 121 of file ctrl_access.h.

◆ LUN_ID_5

#define LUN_ID_5   (LUN_ID_4 + LUN_4)

Definition at line 122 of file ctrl_access.h.

◆ LUN_ID_6

#define LUN_ID_6   (LUN_ID_5 + LUN_5)

Definition at line 123 of file ctrl_access.h.

◆ LUN_ID_7

#define LUN_ID_7   (LUN_ID_6 + LUN_6)

Definition at line 124 of file ctrl_access.h.

◆ LUN_ID_USB

#define LUN_ID_USB   (MAX_LUN)

First dynamic LUN (USB host mass storage).

Definition at line 126 of file ctrl_access.h.

◆ MAX_LUN

#define MAX_LUN   (LUN_ID_7 + LUN_7)

Number of static LUNs.

Definition at line 125 of file ctrl_access.h.

◆ SECTOR_SIZE

#define SECTOR_SIZE   512

Definition at line 70 of file ctrl_access.h.

Enumeration Type Documentation

◆ Ctrl_status

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

Function Documentation

◆ get_cur_lun()

U8 get_cur_lun ( void  )

Returns the current LUN.

Returns
Current LUN.
Todo:
Implement.

Definition at line 302 of file ctrl_access.c.

◆ get_nb_lun()

U8 get_nb_lun ( void  )

Returns the number of LUNs.

Returns
Number of LUNs in the system.

Definition at line 281 of file ctrl_access.c.

◆ mem_name()

const char* mem_name ( U8  lun)

Returns a pointer to the LUN name.

Parameters
lunLogical Unit Number.
Returns
Pointer to the LUN name string.

Definition at line 451 of file ctrl_access.c.

◆ mem_read_capacity()

Ctrl_status mem_read_capacity ( U8  lun,
U32 u32_nb_sector 
)

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

Parameters
lunLogical Unit Number.
u32_nb_sectorPointer to the address of the last valid sector.
Returns
Status.

Definition at line 330 of file ctrl_access.c.

◆ mem_removal()

bool mem_removal ( U8  lun)

Tells whether the memory is removable.

Parameters
lunLogical Unit Number.
Returns
true if the memory is removable, else false.

Definition at line 426 of file ctrl_access.c.

◆ mem_sector_size()

U8 mem_sector_size ( U8  lun)

Returns the size of the physical sector.

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

Definition at line 352 of file ctrl_access.c.

◆ mem_test_unit_ready()

Ctrl_status mem_test_unit_ready ( U8  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
lunLogical Unit Number.
Returns
Status.

Definition at line 308 of file ctrl_access.c.

◆ mem_unload()

bool mem_unload ( U8  lun,
bool  unload 
)

Unload/load the medium.

Parameters
lunLogical Unit Number.
unloadtrue to unload the medium, false to load the medium.
Returns
true if unload/load success, else false.

Definition at line 374 of file ctrl_access.c.

◆ mem_wr_protect()

bool mem_wr_protect ( U8  lun)

Returns the write-protection state of the memory.

Parameters
lunLogical 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 404 of file ctrl_access.c.

◆ memory_2_ram()

Ctrl_status memory_2_ram ( U8  lun,
U32  addr,
void *  ram 
)

Copies 1 data sector from the memory to RAM.

Parameters
lunLogical Unit Number.
addrAddress of first memory sector to read.
ramPointer to RAM buffer to write.
Returns
Status.

Definition at line 530 of file ctrl_access.c.

◆ memory_2_usb()

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

Transfers data from the memory to USB.

Parameters
lunLogical Unit Number.
addrAddress of first memory sector to read.
nb_sectorNumber of sectors to transfer.
Returns
Status.

Definition at line 478 of file ctrl_access.c.

◆ ram_2_memory()

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

Copies 1 data sector from RAM to the memory.

Parameters
lunLogical Unit Number.
addrAddress of first memory sector to write.
ramPointer to RAM buffer to read.
Returns
Status.

Definition at line 557 of file ctrl_access.c.

◆ stream_mem_to_mem()

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

Copies data from one memory to another.

Parameters
src_lunSource Logical Unit Number.
src_addrSource address of first memory sector to read.
dest_lunDestination Logical Unit Number.
dest_addrDestination address of first memory sector to write.
nb_sectorNumber of sectors to copy.
Returns
Status.

Definition at line 600 of file ctrl_access.c.

◆ stream_state()

Returns the state of a streaming data transfer.

Parameters
idTransfer ID.
Returns
Status.
Todo:
Implement.

Definition at line 618 of file ctrl_access.c.

◆ stream_stop()

U16 stream_stop ( U8  id)

Stops a streaming data transfer.

Parameters
idTransfer ID.
Returns
Number of remaining sectors.
Todo:
Implement.

Definition at line 625 of file ctrl_access.c.

◆ usb_2_memory()

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

Transfers data from USB to the memory.

Parameters
lunLogical Unit Number.
addrAddress of first memory sector to write.
nb_sectorNumber of sectors to transfer.
Returns
Status.

Definition at line 498 of file ctrl_access.c.

Variable Documentation

◆ g_wr_protect

bool g_wr_protect

Write protect.

Definition at line 236 of file ctrl_access.c.



inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:07