Microchip® Advanced Software Framework

ctrl_access.h File Reference
#include "compiler.h"
#include "conf_access.h"
#include <LUN_0_INCLUDE>
#include <LUN_1_INCLUDE>
#include <LUN_2_INCLUDE>
#include <LUN_3_INCLUDE>
#include <LUN_4_INCLUDE>
#include <LUN_5_INCLUDE>
#include <LUN_6_INCLUDE>
#include <LUN_7_INCLUDE>
#include <LUN_USB_INCLUDE>

Macros

#define SECTOR_SIZE   512
 
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)
 First dynamic LUN (USB host mass storage). More...
 

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

Functions

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

Variables

bool g_wr_protect
 Write protect. More...
 

Streaming MEM <-> MEM Interface

#define ID_STREAM_ERR   0xFF
 Erroneous streaming data transfer ID. More...
 
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...