summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mscProtocol.h
blob: aa5964ad80441df0d1c2f0140a3fa378b05bda2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/****************************************************************************//**
  \file mscProtocol.h

  \brief Declaration of mass storage device protocol command.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    29/08/11 N. Fomin - Created
*******************************************************************************/
#ifndef _MSCPROTOCOL_H
#define _MSCPROTOCOL_H

/******************************************************************************
                   Includes section
******************************************************************************/
#include <types.h>
#include <usbSetupProcess.h>

/******************************************************************************
                   Define(s) section
******************************************************************************/
// data size in request structure
#define MSC_REQUEST_DATA_SIZE       1

// request codes for mass storage class
#define BULK_ONLY_MASS_STORAGE_RESET   0xFF
#define GET_MAX_LUN                    0xFE
// maximum size of CBW data
#define CBW_DATA_SIZE 16

/******************************************************************************
                   Types section
******************************************************************************/
BEGIN_PACK
typedef struct PACK
{
  UsbRequest_t request;
  uint8_t  bData[MSC_REQUEST_DATA_SIZE];
} UsbMscRequest_t;
// MSC command block wrapper (CBW)
typedef struct PACK
{
  uint32_t dCBWSignature;
  uint32_t cDBWTag;
  uint32_t dCBWDataTransferLength;
  uint8_t  bmCBWFlags;
  uint8_t  bCBWLUN;
  uint8_t  bCBWCBLength;
  uint8_t  CBWCB[CBW_DATA_SIZE];
} MscCBW_t;
// MSC command status wrapper (CSW)
typedef struct PACK
{
  uint32_t dCSWSignature;
  uint32_t cDSWTag;
  uint32_t dCSWDataResidue;
  uint8_t  bCSWStatus;
} MscCSW_t;
END_PACK

/******************************************************************************
                   Prototypes section
******************************************************************************/
/**************************************************************************//**
\brief Mass storage device request handler.
\param[in]
  data - pointer to host's request.
******************************************************************************/
void msdRequestHandler(uint8_t *data);

#endif /* _MSCPROTOCOL_H */
// eof msdProtocol.h