summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c
blob: 2a3b305e3cbdc52c92e5724c773c529e040b52b6 (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
80
81
82
83
84
85
86
87
88
89
90
/****************************************************************************//**
  \file usbSetupProcess.c

  \brief Implementation of setup (after numeration) proccess.

  \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:
    26/08/11 N. Fomin - Created
*******************************************************************************/
/******************************************************************************
                   Includes section
******************************************************************************/
#include <usbDescriptors.h>
#if (APP_INTERFACE == APP_INTERFACE_VCP)
  #include <vcpCdcProtocol.h>
  #if (MSD_SUPPORT == 1)
    #include <mscProtocol.h>
  #endif // (MSD_SUPPORT == 1)
#else
  #if (MSD_SUPPORT == 1)
    #include <mscProtocol.h>
  #else
    #include <usbSetupProcess.h>
  #endif // (MSD_SUPPORT == 1)
#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
#if (DFU_SUPPORT == 1)
  #include <dfuProtocol.h>
  #if (APP_INTERFACE != APP_INTERFACE_VCP) && (MSD_SUPPORT != 1)
    #error
  #endif // (APP_INTERFACE != APP_INTERFACE_VCP) || (MSD_SUPPORT != 1)
#endif // (DFU_SUPPORT == 1)

/******************************************************************************
Usb setup process request handler

Parameters:
  data - pointer to host's request
******************************************************************************/
void setupProcessRequestHandler(uint8_t *data)
{
  UsbRequest_t *pRequest = NULL;

  pRequest = (UsbRequest_t *)data;
  if (NULL == pRequest)
    return;

  switch (pRequest->wIndex)
  {
  #if (APP_INTERFACE == APP_INTERFACE_VCP)
    case NUMBER_OF_FIRST_INTERFACE:
      vcpRequestHandler(data);
      break;
  #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
    /* MSC commands */
  #if (MSD_SUPPORT == 1)
    #if (APP_INTERFACE == APP_INTERFACE_VCP)
      case NUMBER_OF_THIRD_INTERFACE:
    #else
      case NUMBER_OF_FIRST_INTERFACE:
    #endif
        msdRequestHandler(data);
        break;
  #endif // (MSD_SUPPORT == 1)
  #if (DFU_SUPPORT == 1)
    #if (APP_INTERFACE == APP_INTERFACE_VCP)
      #if (MSD_SUPPORT == 1)
        case NUMBER_OF_FOURTH_INTERFACE:
      #else
        case NUMBER_OF_THIRD_INTERFACE:
      #endif
    #else
      case NUMBER_OF_SECOND_INTERFACE:
    #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
        dfuRequestHandler(data);
        break;
  #endif // (DFU_SUPPORT == 1)
    default:
      HAL_Stall(0);
      break;
  }
}

// eof usbSetupProcess.c