Defines | |
#define | ENTRY_SIZE 32 |
FAT specification. | |
#define | LUN_0_EN 0 |
Computed the maximum of static lun (don't add the lun of Mass Storage in mode USB Host). | |
Enumerations | |
enum | Ctrl_status |
Define control status. | |
Functions | |
void | avrf_mem_init (void) |
This function initializes the hw/sw ressources required to drive the AVR Flash. | |
Ctrl_status | avrf_test_unit_ready (void) |
This function tests the state of the AVR Flash. | |
Ctrl_status | avrf_read_capacity (U32 *u32_nb_sector) |
This function gives the address of the last valid sector. | |
Bool | avrf_wr_protect (void) |
This function returns the write protected status of the memory. | |
Bool | avrf_removal (void) |
This function tells if the memory has been removed or not. | |
Ctrl_status | avrf_read_10 (U32 addr, U16 nb_sector) |
This function performs a read operation of n sectors from a given address on. | |
Ctrl_status | avrf_write_10 (U32 addr, U16 nb_sector) |
This fonction initialise the memory for a write operation. | |
bit | avrf_read_open (Uint32 pos) |
This function opens a DF memory in read mode at a given sector address. | |
void | avrf_read_close (void) |
This function unselects the current DF memory. | |
bit | avrf_read_sector (Uint16 nb_sector) |
This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller. | |
bit | avrf_write_open (Uint32 pos) |
This function opens a DF memory in write mode at a given sector address. | |
void | avrf_write_close (void) |
This function fills the end of the logical sector (512B) and launch page programming. | |
bit | avrf_write_sector (Uint16 nb_sector) |
This function is optimized and writes nb-sector * 512 Bytes from USB controller to DataFlash memory. | |
Ctrl_status | avrf_usb_read () |
This fonction transfer the memory data (programed in scsi_read_10) directly to the usb interface. | |
Ctrl_status | avrf_usb_write (void) |
This fonction transfer the usb data (programed in scsi_write_10) directly to the memory data. | |
U8 | get_nb_lun () |
This fonction return the number of logical unit. | |
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. | |
Ctrl_status | memory_2_usb (U8 lun, U32 addr, U16 nb_sector) |
This fonction returns a pointer to the LUN name. | |
Ctrl_status | usb_2_memory (U8 lun, U32 addr, U16 nb_sector) |
This fonction trabsfer a data from usb to memory. | |
Bool | scsi_decode_command (void) |
SCSI decoder function. | |
Bool | sbc_request_sense (void) |
This function manages the SCSI REQUEST SENSE command (0x03). | |
Bool | sbc_inquiry (void) |
This function manages the SCSI INQUIRY command (0x12). | |
Bool | sbc_mode_sense (Bool b_sense_10) |
This function manages the SCSI MODE SENSE command (0x1A for sense 6 and 0x5A for sense 10). | |
Bool | sbc_prevent_allow_medium_removal (void) |
This function manages the SCSI PREVENT ALLOW MEDIUM REMOVAL command (0x1E). | |
void | sbc_lun_status_is_good (void) |
This fonction send the UFI status GOOD. | |
void | sbc_lun_status_is_not_present (void) |
This fonction send the UFI status "lun not present". | |
void | sbc_lun_status_is_busy_or_change (void) |
This fonction send the UFI status busy and change. | |
void | sbc_lun_status_is_fail (void) |
This fonction send the UFI status FAIL. | |
void | sbc_lun_status_is_protected (void) |
This fonction send the UFI status FAIL because write protection. | |
void | usb_mass_storage_cbw (void) |
USB Command Block Wrapper (CBW) management. | |
void | usb_mass_storage_csw (void) |
USB Command Status Wrapper (CSW) management. | |
PROCESS_THREAD (storage_process, ev, data_proc) | |
USB Mass Storage Class Process. | |
Variables | |
U8 | usb_configuration_nb |
Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /. |
void avrf_mem_init | ( | void | ) |
This function initializes the hw/sw ressources required to drive the AVR Flash.
/
Ctrl_status avrf_read_10 | ( | U32 | addr, | |
U16 | nb_sector | |||
) |
This function performs a read operation of n sectors from a given address on.
(sector = 512B)
DATA FLOW is: AVRF => USB
addr | Sector address to start the read from | |
nb_sector | Number of sectors to transfer |
Ctrl_status avrf_read_capacity | ( | U32 * | u32_nb_sector | ) |
This function gives the address of the last valid sector.
*u32_nb_sector | number of sector (sector = 512B). OUT |
Definition at line 122 of file avr_flash.c.
void avrf_read_close | ( | void | ) |
This function unselects the current DF memory.
/
bit avrf_read_open | ( | Uint32 | pos | ) |
This function opens a DF memory in read mode at a given sector address.
NOTE: Address may not be synchronized on the beginning of a page (depending on the DF page size).
pos | Logical sector address |
bit avrf_read_sector | ( | Uint16 | nb_sector | ) |
This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller.
DATA FLOW is: DF => USB
NOTE:
nb_sector | number of contiguous sectors to read [IN] |
Bool avrf_removal | ( | void | ) |
This function tells if the memory has been removed or not.
Ctrl_status avrf_test_unit_ready | ( | void | ) |
This function tests the state of the AVR Flash.
Ctrl_status avrf_usb_read | ( | ) |
This fonction transfer the memory data (programed in scsi_read_10) directly to the usb interface.
Ctrl_status avrf_usb_write | ( | void | ) |
This fonction transfer the usb data (programed in scsi_write_10) directly to the memory data.
Bool avrf_wr_protect | ( | void | ) |
This function returns the write protected status of the memory.
Only used by memory removal with a HARDWARE SPECIFIC write protected detection !!! The customer must unplug the memory to change this write protected status, which cannot be for a DF.
Ctrl_status avrf_write_10 | ( | U32 | addr, | |
U16 | nb_sector | |||
) |
This fonction initialise the memory for a write operation.
DATA FLOW is: USB => DF
(sector = 512B)
addr | Sector address to start write | |
nb_sector | Number of sectors to transfer |
void avrf_write_close | ( | void | ) |
This function fills the end of the logical sector (512B) and launch page programming.
/
bit avrf_write_open | ( | Uint32 | pos | ) |
This function opens a DF memory in write mode at a given sector address.
NOTE: If page buffer > 512 bytes, page content is first loaded in buffer to be partially updated by write_byte or write64 functions.
pos | Sector address |
bit avrf_write_sector | ( | Uint16 | nb_sector | ) |
This function is optimized and writes nb-sector * 512 Bytes from USB controller to DataFlash memory.
Funtions to link USB DEVICE flow with data flash.
DATA FLOW is: USB => DF
NOTE:
nb_sector | number of contiguous sectors to write [IN] |
U8 get_cur_lun | ( | ) |
This fonction return the current logical unit.
Referenced by usb_mass_storage_cbw().
U8 get_nb_lun | ( | ) |
This fonction return the number of logical unit.
**** Listing of commun interface ****************************************
Referenced by usb_user_read_request().
Ctrl_status mem_read_capacity | ( | U8 | lun, | |
U32 _MEM_TYPE_SLOW_ * | u32_nb_sector | |||
) |
This fonction return the capacity of the memory.
lun | Logical unit number | |
u32_nb_sector | The sector to query |
Bool mem_removal | ( | U8 | lun | ) |
This fonction inform about the memory type.
lun | Logical unit number |
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.
lun | Logical unit number |
Bool mem_wr_protect | ( | U8 | lun | ) |
This fonction return is the write protected mode.
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.
Ctrl_status memory_2_usb | ( | U8 | lun, | |
U32 | addr, | |||
U16 | nb_sector | |||
) |
This fonction returns a pointer to the LUN name.
**** Listing of READ/WRITE interface ************************************
lun | Logical unit number |
lun | Logical unit number | |
addr | Sector address to start read (sector = 512B) | |
nb_sector | Number of sectors to transfer |
PROCESS_THREAD | ( | storage_process | , | |
ev | , | |||
data_proc | ||||
) |
USB Mass Storage Class Process.
This is the link between USB and the "good stuff". In this routine data is received and processed by USB Storage Class
Definition at line 108 of file storage_task.c.
References CLOCK_SECOND, etimer_expired(), etimer_set(), Is_device_enumerated, Is_usb_receive_out, PROCESS_BEGIN, PROCESS_END, PROCESS_WAIT_EVENT_UNTIL, usb_mass_storage_cbw(), usb_mass_storage_csw(), and Usb_select_endpoint.
Bool sbc_inquiry | ( | void | ) |
This function manages the SCSI INQUIRY command (0x12).
The SCSI Inquiry field contains information regarding parameters of the target. For example:
Bool sbc_mode_sense | ( | Bool | b_sense_10 | ) |
This function manages the SCSI MODE SENSE command (0x1A for sense 6 and 0x5A for sense 10).
The SCSI mode sense function returns parameters to an application client. It is a complementary command to the SCSI MODE SELECT command.
b_sense_10 | ( TRUE = sense 10, TRUE = sense 6) |
Bool sbc_prevent_allow_medium_removal | ( | void | ) |
This function manages the SCSI PREVENT ALLOW MEDIUM REMOVAL command (0x1E).
The SCSI prevent allow medium removal command requests that the target enable or disable the removal of the medium in the logical unit.
Bool sbc_request_sense | ( | void | ) |
This function manages the SCSI REQUEST SENSE command (0x03).
The SCSI Sense contains the status of the last command This status is composed of 3 Bytes :
Bool scsi_decode_command | ( | void | ) |
SCSI decoder function.
This function read the SCSI command and launches the appropriate function
Referenced by usb_mass_storage_cbw().
Ctrl_status usb_2_memory | ( | U8 | lun, | |
U32 | addr, | |||
U16 | nb_sector | |||
) |
This fonction trabsfer a data from usb to memory.
lun | Logical unit number | |
addr | Sector address to start write (sector = 512B) | |
nb_sector | Number of sectors to transfer |
void usb_mass_storage_cbw | ( | void | ) |
USB Command Block Wrapper (CBW) management.
This function decodes the CBW command and stores the SCSI command
check if dCBWSignature is correct
'U'
'S'
'B'
'C'
Store CBW Tag to be repeated in CSW
if (bmCBWFlags.bit7 == 1) {direction = IN}
dummy CBWCBLength read
Definition at line 150 of file storage_task.c.
References FALSE, get_cur_lun(), scsi_decode_command(), TRUE, Usb_ack_receive_out, Usb_enable_stall_handshake, Usb_read_byte, and Usb_select_endpoint.
Referenced by PROCESS_THREAD().
void usb_mass_storage_csw | ( | void | ) |
USB Command Status Wrapper (CSW) management.
This function sends the status in relation with the last CBW
write CSW Signature
'U'
'S'
'B'
'S' write stored CBW Tag
write data residue value
write command status
0 -> PASS, 1 -> FAIL
Definition at line 235 of file storage_task.c.
References Is_usb_endpoint_stall_requested, Is_usb_receive_setup, Is_usb_write_enabled, usb_process_request(), Usb_select_endpoint, Usb_send_in, and Usb_write_byte.
Referenced by PROCESS_THREAD().