⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbc.h

📁 Include startup files and peripherial devices Code for Atmel ARM7 development
💻 H
📖 第 1 页 / 共 3 页
字号:
/// The device can not be accessed.
#define SBC_SENSE_KEY_NOT_READY                       0x02
/// Command terminated with a error condition that was probably caused by a
/// flaw in the medium or an error in the recorded data.
#define SBC_SENSE_KEY_MEDIUM_ERROR                    0x03
/// Hardware failure while performing the command or during a self test.
#define SBC_SENSE_KEY_HARDWARE_ERROR                  0x04
/// Illegal parameter found in the command or additional parameters.
#define SBC_SENSE_KEY_ILLEGAL_REQUEST                 0x05
/// Removable medium may have been changed or the %device has been reset.
#define SBC_SENSE_KEY_UNIT_ATTENTION                  0x06
/// Write on a block that is protected.
#define SBC_SENSE_KEY_DATA_PROTECT                    0x07
/// Indicates that a write-once device or a sequential-access device
/// encountered blank medium or format-defined end-of-data indication while
/// reading or a write-once device encountered a non-blank medium while writing.
#define SBC_SENSE_KEY_BLANK_CHECK                     0x08
/// Reporting vendor specific conditions.
#define SBC_SENSE_KEY_VENDOR_SPECIFIC                 0x09
/// EXTENDED COPY command was aborted.
#define SBC_SENSE_KEY_COPY_ABORTED                    0x0A
/// Device aborted the command.
#define SBC_SENSE_KEY_ABORTED_COMMAND                 0x0B
/// A buffered peripheral device is overflow.
#define SBC_SENSE_KEY_VOLUME_OVERFLOW                 0x0D
/// The source data did not match the data read from the medium.
#define SBC_SENSE_KEY_MISCOMPARE                      0x0E
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
/// \page "SBC Sense Additionals"
/// This page lists additional sense code values returned in REQUEST SENSE data
/// \see    spc4r06.pdf - Section 4.5.6 - Table 28
///
/// !Additional Codes
/// - SBC_ASC_LOGICAL_UNIT_NOT_READY
/// - SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE
/// - SBC_ASC_INVALID_FIELD_IN_CDB
/// - SBC_ASC_WRITE_PROTECTED
/// - SBC_ASC_FORMAT_CORRUPTED
/// - SBC_ASC_INVALID_COMMAND_OPERATION_CODE
/// - SBC_ASC_TOO_MUCH_WRITE_DATA
/// - SBC_ASC_NOT_READY_TO_READY_CHANGE
/// - SBC_ASC_MEDIUM_NOT_PRESENT

#define SBC_ASC_LOGICAL_UNIT_NOT_READY                0x04
#define SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE    0x21
#define SBC_ASC_INVALID_FIELD_IN_CDB                  0x24
#define SBC_ASC_WRITE_PROTECTED                       0x27
#define SBC_ASC_FORMAT_CORRUPTED                      0x31
#define SBC_ASC_INVALID_COMMAND_OPERATION_CODE        0x20
#define SBC_ASC_TOO_MUCH_WRITE_DATA                   0x26
#define SBC_ASC_NOT_READY_TO_READY_CHANGE             0x28
#define SBC_ASC_MEDIUM_NOT_PRESENT                    0x3A
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
/// \brief  MEDIUM TYPE field value for direct-access block devices
/// \see    sbc3r06.pdf - Section 6.3.1
#define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE    0x00
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
/// \brief  MRIE field values
/// \see    sbc3r06.pdf - Section 7.4.11 - Table 286
#define SBC_MRIE_NO_REPORTING                         0x00
#define SBC_MRIE_ASYNCHRONOUS                         0x01
#define SBC_MRIE_GENERATE_UNIT_ATTENTION              0x02
#define SBC_MRIE_COND_GENERATE_RECOVERED_ERROR        0x03
#define SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR      0x04
#define SBC_MRIE_GENERATE_NO_SENSE                    0x05
#define SBC_MRIE_ON_REQUEST                           0x06
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
/// \brief  Supported mode pages
/// \see    sbc3r06.pdf - Section 6.3.1 - Table 115
#define SBC_PAGE_READ_WRITE_ERROR_RECOVERY            0x01
#define SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL     0x1C
#define SBC_PAGE_RETURN_ALL                           0x3F
#define SBC_PAGE_VENDOR_SPECIFIC                      0x00
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
/// \page "MSD Endian Macros"
/// This page lists the macros for endianness conversion.
///
/// !Macros
/// - WORDB
/// - DWORDB
/// - STORE_DWORDB
/// - STORE_WORDB
/// \brief  Converts a byte array to a word value using the big endian format
#define WORDB(bytes)            ((unsigned short) ((bytes[0] << 8) | bytes[1]))

/// \brief  Converts a byte array to a dword value using the big endian format
#define DWORDB(bytes)   ((unsigned int) ((bytes[0] << 24) | (bytes[1] << 16) \
                                         | (bytes[2] << 8) | bytes[3]))

/// \brief  Stores a dword value in a byte array, in big endian format
#define STORE_DWORDB(dword, bytes) \
    bytes[0] = (unsigned char) (((dword) >> 24) & 0xFF); \
    bytes[1] = (unsigned char) (((dword) >> 16) & 0xFF); \
    bytes[2] = (unsigned char) (((dword) >> 8) & 0xFF); \
    bytes[3] = (unsigned char) ((dword) & 0xFF);

/// \brief  Stores a word value in a byte array, in big endian format
#define STORE_WORDB(word, bytes) \
    bytes[0] = (unsigned char) (((word) >> 8) & 0xFF); \
    bytes[1] = (unsigned char) ((word) & 0xFF);
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//      Structures
//------------------------------------------------------------------------------

#ifdef __ICCARM__          // IAR
#pragma pack(1)            // IAR
#define __attribute__(...) // IAR
#endif                     // IAR

//------------------------------------------------------------------------------
/// \brief  Structure for the INQUIRY command
/// \see    spc4r06.pdf - Section 6.4.1 - Table 81
//------------------------------------------------------------------------------
typedef struct {

    unsigned char bOperationCode;       //!< 0x12 : SBC_INQUIRY
    unsigned char isEVPD:1,             //!< Type of requested data
                  bReserved1:7;         //!< Reserved bits
    unsigned char bPageCode;            //!< Specifies the VPD to return
    unsigned char pAllocationLength[2]; //!< Size of host buffer
    unsigned char bControl;             //!< 0x00

} __attribute__ ((packed)) SBCInquiry; // GCC

//------------------------------------------------------------------------------
/// \brief  Standard INQUIRY data format returned by the device
/// \see    spc4r06.pdf - Section 6.4.2 - Table 82
//------------------------------------------------------------------------------
typedef struct {

    unsigned char  bPeripheralDeviceType:5, //!< Peripheral device type
                   bPeripheralQualifier :3; //!< Peripheral qualifier
    unsigned char  bReserved1:7,            //!< Reserved bits
                   isRMB     :1;            //!< Is media removable ?
    unsigned char  bVersion;                //!< SPC version used
    unsigned char  bResponseDataFormat:4,   //!< Must be 0x2
                   isHIGHSUP          :1,   //!< Hierarchical addressing used ?
                   isNORMACA          :1,   //!< ACA attribute supported ?
                   bObsolete1         :2;   //!< Obsolete bits
    unsigned char  bAdditionalLength;       //!< Length of remaining INQUIRY data
    unsigned char  isSCCS    :1,            //!< Embedded SCC ?
                   isACC     :1,            //!< Access control coordinator ?
                   bTPGS     :2,            //!< Target port support group
                   is3PC     :1,            //!< Third-party copy supported ?
                   bReserved2:2,            //!< Reserved bits
                   isProtect :1;            //!< Protection info supported ?
    unsigned char  bObsolete2:1,            //!< Obsolete bit
                   isEncServ :1,            //!< Embedded enclosure service comp?
                   isVS      :1,            //!< ???
                   isMultiP  :1,            //!< Multi-port device ?
                   bObsolete3:3,            //!< Obsolete bits
                   bUnused1  :1;            //!< Unused feature
    unsigned char  bUnused2:6,              //!< Unused features
                   isCmdQue:1,              //!< Task management model supported ?
                   isVS2   :1;              //!< ???
    unsigned char  pVendorID[8];            //!< T10 vendor identification
    unsigned char  pProductID[16];          //!< Vendor-defined product ID
    unsigned char  pProductRevisionLevel[4];//!< Vendor-defined product revision
    unsigned char  pVendorSpecific[20];     //!< Vendor-specific data
    unsigned char  bUnused3;                //!< Unused features
    unsigned char  bReserved3;              //!< Reserved bits
    unsigned short pVersionDescriptors[8];  //!< Standards the device complies to
    unsigned char  pReserved4[22];          //!< Reserved bytes

} __attribute__ ((packed)) SBCInquiryData; // GCC

//------------------------------------------------------------------------------
/// \brief  Data structure for the READ (10) command
/// \see    sbc3r07.pdf - Section 5.7 - Table 34
//------------------------------------------------------------------------------
typedef struct {

    unsigned char bOperationCode;          //!< 0x28 : SBC_READ_10
    unsigned char bObsolete1:1,            //!< Obsolete bit
                  isFUA_NV:1,              //!< Cache control bit
                  bReserved1:1,            //!< Reserved bit
                  isFUA:1,                 //!< Cache control bit
                  isDPO:1,                 //!< Cache control bit
                  bRdProtect:3;            //!< Protection information to send
    unsigned char pLogicalBlockAddress[4]; //!< Index of first block to read
    unsigned char bGroupNumber:5,          //!< Information grouping
                  bReserved2:3;            //!< Reserved bits
    unsigned char pTransferLength[2];      //!< Number of blocks to transmit
    unsigned char bControl;                //!< 0x00

} __attribute__ ((packed)) SBCRead10; // GCC

//------------------------------------------------------------------------------
/// \brief  Structure for the READ CAPACITY (10) command
/// \see    sbc3r07.pdf - Section 5.11.1 - Table 40
//------------------------------------------------------------------------------
typedef struct {

    unsigned char bOperationCode;          //!< 0x25 : RBC_READ_CAPACITY
    unsigned char bObsolete1:1,            //!< Obsolete bit
                  bReserved1:7;            //!< Reserved bits
    unsigned char pLogicalBlockAddress[4]; //!< Block to evaluate if PMI is set
    unsigned char pReserved2[2];           //!< Reserved bytes
    unsigned char isPMI:1,                 //!< Partial medium indicator bit
                  bReserved3:7;            //!< Reserved bits
    unsigned char bControl;                //!< 0x00

} SBCReadCapacity10;

//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -