#include "compiler.h"
#include "preprocessor.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "ctrl_access.h"
Macros | |
#define | Lun_desc_entry(lun) |
Initializes an entry of the LUN descriptor table. More... | |
LUN Access Protection Macros | |
#define | Ctrl_access_lock() ctrl_access_lock() |
Locks accesses to LUNs. More... | |
#define | Ctrl_access_unlock() xSemaphoreGive(ctrl_access_semphr) |
Unlocks accesses to LUNs. More... | |
Functions | |
Control Interface | |
bool | ctrl_access_init (void) |
Initializes the LUN access locker. More... | |
static bool | ctrl_access_lock (void) |
Locks accesses to LUNs. More... | |
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... | |
Variables | |
static xSemaphoreHandle | ctrl_access_semphr = NULL |
Handle to the semaphore protecting accesses to LUNs. More... | |
struct { | |
const char * name | |
Ctrl_status(* read_capacity )(U32 *) | |
bool(* removal )(void) | |
Ctrl_status(* test_unit_ready )(void) | |
bool(* unload )(bool) | |
Ctrl_status(* usb_read_10 )(U32, U16) | |
Ctrl_status(* usb_write_10 )(U32, U16) | |
bool(* wr_protect )(void) | |
} | lun_desc [MAX_LUN] |
LUN descriptor table. More... | |
#define Ctrl_access_lock | ( | ) | ctrl_access_lock() |
Locks accesses to LUNs.
true
if the access was successfully locked, else false
. Referenced by get_nb_lun(), mem_read_capacity(), mem_removal(), mem_sector_size(), mem_test_unit_ready(), mem_unload(), mem_wr_protect(), memory_2_usb(), and usb_2_memory().
#define Ctrl_access_unlock | ( | ) | xSemaphoreGive(ctrl_access_semphr) |
Unlocks accesses to LUNs.
Referenced by get_nb_lun(), mem_read_capacity(), mem_removal(), mem_sector_size(), mem_test_unit_ready(), mem_unload(), mem_wr_protect(), memory_2_usb(), and usb_2_memory().
#define Lun_desc_entry | ( | lun | ) |
|
static |
Handle to the semaphore protecting accesses to LUNs.
Referenced by ctrl_access_init(), and ctrl_access_lock().
struct { ... } lun_desc[MAX_LUN] |
LUN descriptor table.
Referenced by mem_name(), mem_read_capacity(), mem_removal(), mem_test_unit_ready(), mem_unload(), mem_wr_protect(), memory_2_usb(), and usb_2_memory().
const char* name |
Referenced by mem_name().
Ctrl_status(* read_capacity)(U32 *) |
Referenced by mem_read_capacity().
bool(* removal)(void) |
Referenced by mem_removal().
Ctrl_status(* test_unit_ready)(void) |
Referenced by mem_test_unit_ready().
Referenced by mem_unload(), and virtual_unload().
Ctrl_status(* usb_read_10)(U32, U16) |
Referenced by memory_2_usb().
Ctrl_status(* usb_write_10)(U32, U16) |
Referenced by usb_2_memory().
bool(* wr_protect)(void) |
Referenced by mem_wr_protect().