All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be seperately included.
All LowLevel demos changed to use the constants and types defined in the USB class drivers.
This commit is contained in:
parent
8f3bee7d86
commit
b37d77eab3
208 changed files with 589 additions and 2910 deletions
|
|
@ -47,7 +47,6 @@
|
|||
#include "MassStorage.h"
|
||||
#include "Descriptors.h"
|
||||
#include "DataflashManager.h"
|
||||
#include "SCSI_Codes.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||
|
|
@ -109,7 +108,7 @@
|
|||
uint8_t VendorID[8];
|
||||
uint8_t ProductID[16];
|
||||
uint8_t RevisionID[4];
|
||||
} SCSI_Inquiry_Response_t;
|
||||
} MS_SCSI_Inquiry_Response_t;
|
||||
|
||||
/** Type define for a SCSI sense structure to a SCSI REQUEST SENSE command. For details of the
|
||||
* structure contents, refer to the SCSI specifications.
|
||||
|
|
@ -133,7 +132,7 @@
|
|||
uint8_t AdditionalSenseQualifier;
|
||||
uint8_t FieldReplaceableUnitCode;
|
||||
uint8_t SenseKeySpecific[3];
|
||||
} SCSI_Request_Sense_Response_t;
|
||||
} MS_SCSI_Request_Sense_Response_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool SCSI_DecodeSCSICommand(void);
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header containing macros for possible SCSI commands and SENSE data. Refer to
|
||||
* the SCSI standard documentation for more information on each SCSI command and
|
||||
* the SENSE data.
|
||||
*/
|
||||
|
||||
#ifndef _SCSI_CODES_H_
|
||||
#define _SCSI_CODES_H_
|
||||
|
||||
/* Macros: */
|
||||
#define SCSI_CMD_INQUIRY 0x12
|
||||
#define SCSI_CMD_REQUEST_SENSE 0x03
|
||||
#define SCSI_CMD_TEST_UNIT_READY 0x00
|
||||
#define SCSI_CMD_READ_CAPACITY_10 0x25
|
||||
#define SCSI_CMD_SEND_DIAGNOSTIC 0x1D
|
||||
#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSI_CMD_WRITE_10 0x2A
|
||||
#define SCSI_CMD_READ_10 0x28
|
||||
#define SCSI_CMD_WRITE_6 0x0A
|
||||
#define SCSI_CMD_READ_6 0x08
|
||||
#define SCSI_CMD_VERIFY_10 0x2F
|
||||
#define SCSI_CMD_MODE_SENSE_6 0x1A
|
||||
#define SCSI_CMD_MODE_SENSE_10 0x5A
|
||||
|
||||
#define SCSI_SENSE_KEY_GOOD 0x00
|
||||
#define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01
|
||||
#define SCSI_SENSE_KEY_NOT_READY 0x02
|
||||
#define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03
|
||||
#define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04
|
||||
#define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05
|
||||
#define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06
|
||||
#define SCSI_SENSE_KEY_DATA_PROTECT 0x07
|
||||
#define SCSI_SENSE_KEY_BLANK_CHECK 0x08
|
||||
#define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09
|
||||
#define SCSI_SENSE_KEY_COPY_ABORTED 0x0A
|
||||
#define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B
|
||||
#define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D
|
||||
#define SCSI_SENSE_KEY_MISCOMPARE 0x0E
|
||||
|
||||
#define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION 0x00
|
||||
#define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY 0x04
|
||||
#define SCSI_ASENSE_INVALID_COMMAND 0x20
|
||||
#define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21
|
||||
#define SCSI_ASENSE_INVALID_FIELD_IN_CDB 0x24
|
||||
#define SCSI_ASENSE_WRITE_PROTECTED 0x27
|
||||
#define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE 0x28
|
||||
#define SCSI_ASENSE_FORMAT_ERROR 0x31
|
||||
#define SCSI_ASENSE_MEDIUM_NOT_PRESENT 0x3A
|
||||
|
||||
#define SCSI_ASENSEQ_NO_QUALIFIER 0x00
|
||||
#define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED 0x01
|
||||
#define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED 0x02
|
||||
#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -38,13 +38,13 @@
|
|||
#include "MassStorage.h"
|
||||
|
||||
/** Structure to hold the latest Command Block Wrapper issued by the host, containing a SCSI command to execute. */
|
||||
CommandBlockWrapper_t CommandBlock;
|
||||
MS_CommandBlockWrapper_t CommandBlock;
|
||||
|
||||
/** Structure to hold the latest Command Status Wrapper to return to the host, containing the status of the last issued command. */
|
||||
CommandStatusWrapper_t CommandStatus = { .Signature = CSW_SIGNATURE };
|
||||
MS_CommandStatusWrapper_t CommandStatus = { .Signature = MS_CSW_SIGNATURE };
|
||||
|
||||
/** Flag to asynchronously abort any in-progress data transfers upon the reception of a mass storage reset command. */
|
||||
volatile bool IsMassStoreReset = false;
|
||||
volatile bool IsMassStoreReset = false;
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
|
@ -129,7 +129,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
/* Process UFI specific control requests */
|
||||
switch (USB_ControlRequest.bRequest)
|
||||
{
|
||||
case REQ_MassStorageReset:
|
||||
case MS_REQ_MassStorageReset:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
|
@ -140,7 +140,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
|
||||
break;
|
||||
case REQ_GetMaxLUN:
|
||||
case MS_REQ_GetMaxLUN:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
|
@ -172,11 +172,11 @@ void MassStorage_Task(void)
|
|||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
/* Check direction of command, select Data IN endpoint if data is from the device */
|
||||
if (CommandBlock.Flags & COMMAND_DIRECTION_DATA_IN)
|
||||
if (CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)
|
||||
Endpoint_SelectEndpoint(MASS_STORAGE_IN_EPNUM);
|
||||
|
||||
/* Decode the received SCSI command, set returned status code */
|
||||
CommandStatus.Status = SCSI_DecodeSCSICommand() ? Command_Pass : Command_Fail;
|
||||
CommandStatus.Status = SCSI_DecodeSCSICommand() ? MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail;
|
||||
|
||||
/* Load in the CBW tag into the CSW to link them together */
|
||||
CommandStatus.Tag = CommandBlock.Tag;
|
||||
|
|
@ -185,7 +185,7 @@ void MassStorage_Task(void)
|
|||
CommandStatus.DataTransferResidue = CommandBlock.DataTransferLength;
|
||||
|
||||
/* Stall the selected data pipe if command failed (if data is still to be transferred) */
|
||||
if ((CommandStatus.Status == Command_Fail) && (CommandStatus.DataTransferResidue))
|
||||
if ((CommandStatus.Status == MS_SCSI_COMMAND_Fail) && (CommandStatus.DataTransferResidue))
|
||||
Endpoint_StallTransaction();
|
||||
|
||||
/* Return command status block to the host */
|
||||
|
|
@ -237,11 +237,11 @@ static bool ReadInCommandBlock(void)
|
|||
return false;
|
||||
|
||||
/* Verify the command block - abort if invalid */
|
||||
if ((CommandBlock.Signature != CBW_SIGNATURE) ||
|
||||
(CommandBlock.LUN >= TOTAL_LUNS) ||
|
||||
(CommandBlock.Flags & 0x1F) ||
|
||||
(CommandBlock.SCSICommandLength == 0) ||
|
||||
(CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH))
|
||||
if ((CommandBlock.Signature != MS_CBW_SIGNATURE) ||
|
||||
(CommandBlock.LUN >= TOTAL_LUNS) ||
|
||||
(CommandBlock.Flags & 0x1F) ||
|
||||
(CommandBlock.SCSICommandLength == 0) ||
|
||||
(CommandBlock.SCSICommandLength > sizeof(CommandBlock.SCSICommandData)))
|
||||
{
|
||||
/* Stall both data pipes until reset by host */
|
||||
Endpoint_StallTransaction();
|
||||
|
|
|
|||
|
|
@ -53,27 +53,6 @@
|
|||
#include <LUFA/Drivers/Board/Dataflash.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Mass Storage Class specific request to reset the Mass Storage interface, ready for the next command. */
|
||||
#define REQ_MassStorageReset 0xFF
|
||||
|
||||
/** Mass Storage Class specific request to retrieve the total number of Logical Units (drives) in the SCSI device. */
|
||||
#define REQ_GetMaxLUN 0xFE
|
||||
|
||||
/** Maximum length of a SCSI command which can be issued by the device or host in a Mass Storage bulk wrapper. */
|
||||
#define MAX_SCSI_COMMAND_LENGTH 16
|
||||
|
||||
/** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */
|
||||
#define CBW_SIGNATURE 0x43425355UL
|
||||
|
||||
/** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */
|
||||
#define CSW_SIGNATURE 0x53425355UL
|
||||
|
||||
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */
|
||||
#define COMMAND_DIRECTION_DATA_OUT (0 << 7)
|
||||
|
||||
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */
|
||||
#define COMMAND_DIRECTION_DATA_IN (1 << 7)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
|
|
@ -89,41 +68,10 @@
|
|||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Signature; /**< Command block signature, must be CBW_SIGNATURE to indicate a valid Command Block */
|
||||
uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper */
|
||||
uint32_t DataTransferLength; /**< Length of the optional data portion of the issued command, in bytes */
|
||||
uint8_t Flags; /**< Command block flags, indicating command data direction */
|
||||
uint8_t LUN; /**< Logical Unit number this command is issued to */
|
||||
uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array */
|
||||
uint8_t SCSICommandData[MAX_SCSI_COMMAND_LENGTH]; /**< Issued SCSI command in the Command Block */
|
||||
} CommandBlockWrapper_t;
|
||||
|
||||
/** Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Signature; /**< Status block signature, must be CSW_SIGNATURE to indicate a valid Command Status */
|
||||
uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper */
|
||||
uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command */
|
||||
uint8_t Status; /**< Status code of the issued command - a value from the MassStorage_CommandStatusCodes_t enum */
|
||||
} CommandStatusWrapper_t;
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible command status wrapper return status codes. */
|
||||
enum MassStorage_CommandStatusCodes_t
|
||||
{
|
||||
Command_Pass = 0, /**< Command completed with no error */
|
||||
Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */
|
||||
Phase_Error = 2 /**< Command failed due to being invalid in the current phase */
|
||||
};
|
||||
|
||||
/* Global Variables: */
|
||||
extern CommandBlockWrapper_t CommandBlock;
|
||||
extern CommandStatusWrapper_t CommandStatus;
|
||||
extern volatile bool IsMassStoreReset;
|
||||
extern MS_CommandBlockWrapper_t CommandBlock;
|
||||
extern MS_CommandStatusWrapper_t CommandStatus;
|
||||
extern volatile bool IsMassStoreReset;
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue