📄 ms_device.h
字号:
// ----------------------------------------------------------------------------
// ATMEL Microcontroller Software Support - ROUSSET -
// ----------------------------------------------------------------------------
// DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
// DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
// File Name : ms_device.h
// Object : Internal definitions
// Creation : JCB 15/apr/2005
// Modif :
// ----------------------------------------------------------------------------
#ifndef _USBMS_DEVICE_H_
#define _USBMS_DEVICE_H_
#include "ms_rbc.h"
#include "ms_bot.h"
/***************/
/* DEFINITIONS */
/***************/
#define MAX_PACKET_SIZE 64 /* USB Max Packet size */
/* Maximum transfer size between USB and Mass Storage */
/* must be at least one FLASH block */
#ifndef NANDFLASH
#define MAX_TRANSFER_SIZE 8*MAX_PACKET_SIZE // be careful with FW_FIFO_SIZE
#else
#define MAX_TRANSFER_SIZE 256*MAX_PACKET_SIZE // be careful with FW_FIFO_SIZE
#endif
#define MAX_LUN_NUM 1 /* Logical Unit Number !!!beware!!! the stack pool size depends on it */
// *********************************************
// usbmassbulk_10.pdf : Class Specific Requests
// *********************************************
// 3.1 Bulk-Only Mass Storage Reset (class-specific request)
// This request is used to reset the mass storage device and its associated interface.
#define RESET_REQUEST_TYPE 0x21 // bmRequestType
#define RESET_REQUEST 0xFF // bRequest
// wValue field set to 0
// wIndex field set to the interface number
// wLength field set to 0
// 3.2 Get Max LUN (class-specific request)
#define MAX_LUN_REQUEST_TYPE 0xA1 // bmRequestType
#define MAX_LUN_REQUEST 0xFE // bRequest
// wValue field set to 0
// wIndex field set to the interface
// wLength field set to 1
/***************************************************/
/* Logical Unit Number (LUN) MANAGEMENT DATA TYPES */
/***************************************************/
/* USBMS_XFER : Data structure describing the transfer to execute */
typedef struct
{
USHORT current_block; /* Number of the bloc currently transferred */
RING_ID data_buff; /* Buffer containing the data to transferred */
ULONG buffer_size; /* Size of the data to transfer */
ULONG command_size; /* Size of the command */
ULONG transferred_size; /* size of the data actually transferred at this point */
}USBMS_XFER;
/* USB_LUN : Structure specific to each Logical Unit Number */
typedef struct
{
ULONG BlockSize; /* */
ULONG TotBlockNumber; /* */
USHORT fail_reason; /* Variable for storing the ID of the cause of the data transfer failure */
USHORT media_state; /* Variable for storing the media state */
UCHAR fail_request; /* Informs state machine to skip data until the state changes */
USBMS_XFER cur_request; /* Data structure describing the write transfer to process */
}USB_LUN;
/* USBMS_CONTEXT : Data structure specific to the Mass Storage driver */
typedef struct
{
USB_LUN usb_lun[MAX_LUN_NUM];
USBMS_INQUIRY_DATA inquiry_data; /* Structure containing the standard inquiry data */
USBMS_CSW csw; /* CSW structure for the bot stats phase */
UCHAR current_lun; /* Number of the currently used lun */
MODE_SENSE_PARAMETER mode_parameter_sense; /* Structure returned for a MODE_SENSE command */
USBMS_READ_CAPACITY_DATA read_capacity_data; /* Structure containing the read capacity of the lun */
UCHAR state;
} USBMS_CONTEXT;
extern USBMS_CONTEXT usbms_context;
extern USBMS_RETURN rbc_commun_write( USBMS_XFER *request, USB_LUN *lun );
#endif /* _USBMS_DEVICE_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -