Contiki 2.5
|
Macros | |
#define | ENTRY_SIZE 32 |
FAT specification. | |
#define | LUN_0_EN 1 |
Computed the maximum of static lun (don't add the lun of Mass Storage in mode USB Host) | |
#define | ID_STREAM_ERR 0xFF |
-— Interface for streaming interface -------------------------------— | |
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. More... | |
Ctrl_status | avrf_test_unit_ready (void) |
This function tests the state of the AVR Flash. More... | |
Ctrl_status | avrf_read_capacity (U32 *u32_nb_sector) |
This function gives the address of the last valid sector. More... | |
Bool | avrf_wr_protect (void) |
This function returns the write protected status of the memory. More... | |
Bool | avrf_removal (void) |
This function tells if the memory has been removed or not. More... | |
Ctrl_status | avrf_read_10 (U32 addr, U16 nb_sector) |
This function performs a read operation of n sectors from a given address on. More... | |
Ctrl_status | avrf_write_10 (U32 addr, U16 nb_sector) |
This fonction initialise the memory for a write operation. More... | |
bit | avrf_read_open (Uint32 pos) |
This function opens a DF memory in read mode at a given sector address. More... | |
void | avrf_read_close (void) |
This function unselects the current DF memory. More... | |
bit | avrf_read_sector (Uint16 nb_sector) |
This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller. More... | |
bit | avrf_write_open (Uint32 pos) |
This function opens a DF memory in write mode at a given sector address. More... | |
void | avrf_write_close (void) |
This function fills the end of the logical sector (512B) and launch page programming. More... | |
bit | avrf_write_sector (Uint16 nb_sector) |
This function is optimized and writes nb-sector * 512 Bytes from USB controller to DataFlash memory. More... | |
Ctrl_status | avrf_usb_read () |
This fonction transfer the memory data (programed in scsi_read_10) directly to the usb interface. More... | |
Ctrl_status | avrf_usb_write (void) |
This fonction transfer the usb data (programed in scsi_write_10) directly to the memory data. More... | |
U8 | get_nb_lun () |
This fonction return the number of logical unit. More... | |
U8 | get_cur_lun () |
This fonction return the current logical unit. More... | |
Ctrl_status | mem_test_unit_ready (U8 lun) |
This fonction test the state of memory, and start the initialisation of the memory. More... | |
Ctrl_status | mem_read_capacity (U8 lun, U32 _MEM_TYPE_SLOW_ *u32_nb_sector) |
This fonction return the capacity of the memory. More... | |
Bool | mem_wr_protect (U8 lun) |
This fonction return is the write protected mode. More... | |
Bool | mem_removal (U8 lun) |
This fonction inform about the memory type. More... | |
Ctrl_status | memory_2_usb (U8 lun, U32 addr, U16 nb_sector) |
This fonction returns a pointer to the LUN name. More... | |
Ctrl_status | usb_2_memory (U8 lun, U32 addr, U16 nb_sector) |
This fonction trabsfer a data from usb to memory. More... | |
Ctrl_status | memory_2_ram (U8 lun, const U32 _MEM_TYPE_SLOW_ *addr, U8 _MEM_TYPE_SLOW_ *ram) |
Interface for RAM. More... | |
Ctrl_status | ram_2_memory (U8 lun, const U32 _MEM_TYPE_SLOW_ *addr, U8 _MEM_TYPE_SLOW_ *ram) |
This fonction trabsfer a data from ram to memory. More... | |
U8 | stream_mem_to_mem (U8 src_lun, U32 src_addr, U8 dest_lun, U32 dest_addr, U16 nb_sector) |
Interface for streaming interface. More... | |
Ctrl_status | stream_state (U8 Id) |
Returns the state on a data transfer. More... | |
U16 | stream_stop (U8 Id) |
Stop the data transfer. More... | |
Bool | scsi_decode_command (void) |
SCSI decoder function. More... | |
Bool | sbc_request_sense (void) |
This function manages the SCSI REQUEST SENSE command (0x03) More... | |
Bool | sbc_inquiry (void) |
This function manages the SCSI INQUIRY command (0x12) More... | |
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) More... | |
Bool | sbc_prevent_allow_medium_removal (void) |
This function manages the SCSI PREVENT ALLOW MEDIUM REMOVAL command (0x1E) More... | |
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. More... | |
void | usb_mass_storage_csw (void) |
USB Command Status Wrapper (CSW) management. More... | |
PROCESS_THREAD (storage_process, ev, data_proc) | |
USB Mass Storage Class Process. More... | |
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.
/
Definition at line 91 of file avr_flash.c.
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 |
Definition at line 178 of file avr_flash.c.
References avrf_read_close(), avrf_read_open(), and avrf_read_sector().
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.
/
Definition at line 239 of file avr_flash.c.
Referenced by avrf_read_10().
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 |
Definition at line 224 of file avr_flash.c.
Referenced by avrf_read_10().
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] |
Definition at line 269 of file avr_flash.c.
References FALSE, Is_usb_write_enabled, Usb_send_in, and Usb_write_byte.
Referenced by avrf_read_10().
Bool avrf_removal | ( | void | ) |
This function tells if the memory has been removed or not.
Definition at line 153 of file avr_flash.c.
References FALSE.
Ctrl_status avrf_test_unit_ready | ( | void | ) |
This function tests the state of the AVR Flash.
Definition at line 106 of file avr_flash.c.
Ctrl_status avrf_usb_read | ( | ) |
This fonction transfer the memory data (programed in scsi_read_10) directly to the usb interface.
Definition at line 499 of file avr_flash.c.
Ctrl_status avrf_usb_write | ( | void | ) |
This fonction transfer the usb data (programed in scsi_write_10) directly to the memory data.
Definition at line 510 of file avr_flash.c.
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.
Definition at line 140 of file avr_flash.c.
References FALSE.
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 |
Definition at line 200 of file avr_flash.c.
References avrf_write_close(), avrf_write_open(), and avrf_write_sector().
void avrf_write_close | ( | void | ) |
This function fills the end of the logical sector (512B) and launch page programming.
/
Definition at line 329 of file avr_flash.c.
Referenced by avrf_write_10().
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 |
Definition at line 313 of file avr_flash.c.
Referenced by avrf_write_10().
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] |
Definition at line 400 of file avr_flash.c.
References FALSE, Is_usb_read_enabled, Usb_ack_receive_out, and Usb_read_byte.
Referenced by avrf_write_10().
U8 get_cur_lun | ( | ) |
This fonction return the current logical unit.
Definition at line 206 of file ctrl_access.c.
Referenced by usb_mass_storage_cbw().
U8 get_nb_lun | ( | ) |
This fonction return the number of logical unit.
**** Listing of commun interface ****************************************
Definition at line 192 of file ctrl_access.c.
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 |
Definition at line 288 of file ctrl_access.c.
Bool mem_removal | ( | U8 | lun | ) |
This fonction inform about the memory type.
lun | Logical unit number |
Definition at line 410 of file ctrl_access.c.
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 |
Definition at line 225 of file ctrl_access.c.
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.
Definition at line 350 of file ctrl_access.c.
Ctrl_status memory_2_ram | ( | U8 | lun, |
const U32 _MEM_TYPE_SLOW_ * | addr, | ||
U8 _MEM_TYPE_SLOW_ * | ram | ||
) |
Interface for RAM.
This fonction tranfer one sector data from memory to ram
lun | Logical unit number |
addr | Sector address to start read (sector = 512B) |
ram | Adresse of ram buffer (only xdata) |
Definition at line 726 of file ctrl_access.c.
Referenced by stream_mem_to_mem().
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 |
Definition at line 540 of file ctrl_access.c.
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.
Ctrl_status ram_2_memory | ( | U8 | lun, |
const U32 _MEM_TYPE_SLOW_ * | addr, | ||
U8 _MEM_TYPE_SLOW_ * | ram | ||
) |
This fonction trabsfer a data from ram to memory.
lun | Logical unit number |
addr | Sector address to start write (sector = 512B) |
ram | Adresse of ram buffer (only xdata) |
Definition at line 826 of file ctrl_access.c.
Referenced by stream_mem_to_mem().
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:
Definition at line 291 of file scsi_decoder.c.
References FALSE, sbc_lun_status_is_good(), TRUE, and Usb_write_byte.
Referenced by scsi_decode_command().
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) |
Definition at line 558 of file scsi_decoder.c.
References FALSE, sbc_lun_status_is_good(), and TRUE.
Referenced by scsi_decode_command().
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.
Definition at line 740 of file scsi_decoder.c.
References sbc_lun_status_is_good(), and TRUE.
Referenced by scsi_decode_command().
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 :
Definition at line 231 of file scsi_decoder.c.
References sbc_lun_status_is_good(), TRUE, and Usb_write_byte.
Referenced by scsi_decode_command().
Bool scsi_decode_command | ( | void | ) |
SCSI decoder function.
This function read the SCSI command and launches the appropriate function
Definition at line 138 of file scsi_decoder.c.
References FALSE, sbc_inquiry(), sbc_lun_status_is_good(), sbc_mode_sense(), sbc_prevent_allow_medium_removal(), sbc_request_sense(), and TRUE.
Referenced by usb_mass_storage_cbw().
U8 stream_mem_to_mem | ( | U8 | src_lun, |
U32 | src_addr, | ||
U8 | dest_lun, | ||
U32 | dest_addr, | ||
U16 | nb_sector | ||
) |
Interface for streaming interface.
This fonction copy a data from memory to other memory
src_lun | The LUN of the source |
src_addr | The address of the source |
dest_lun | The LUN of the destination |
dest_addr | The address of the destination |
nb_sector | Number of sectors to transfer |
Definition at line 931 of file ctrl_access.c.
References memory_2_ram(), and ram_2_memory().
Ctrl_status stream_state | ( | U8 | Id | ) |
Returns the state on a data transfer.
Id | transfer id |
Definition at line 957 of file ctrl_access.c.
U16 stream_stop | ( | U8 | Id | ) |
Stop the data transfer.
Id | Transfer id |
Definition at line 969 of file ctrl_access.c.
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 |
Definition at line 633 of file ctrl_access.c.
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().