Merge pull request #93 from zyp/master
[fw/stlink] / example / stm32f4 / STM32_USB_HOST_Library / Class / HID / inc / usbh_hid_core.h
1 /**
2   ******************************************************************************
3   * @file    usbh_hid_core.h
4   * @author  MCD Application Team
5   * @version V2.0.0
6   * @date    22-July-2011
7   * @brief   This file contains all the prototypes for the usbh_hid_core.c
8   ******************************************************************************
9   * @attention
10   *
11   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17   *
18   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19   ******************************************************************************
20   */ 
21
22 /* Define to prevent recursive  ----------------------------------------------*/
23 #ifndef __USBH_HID_CORE_H
24 #define __USBH_HID_CORE_H
25
26 /* Includes ------------------------------------------------------------------*/
27 #include "usbh_core.h"
28 #include "usbh_stdreq.h"
29 #include "usb_bsp.h"
30 #include "usbh_ioreq.h"
31 #include "usbh_hcs.h"
32  
33 /** @addtogroup USBH_LIB
34   * @{
35   */
36
37 /** @addtogroup USBH_CLASS
38   * @{
39   */
40
41 /** @addtogroup USBH_HID_CLASS
42   * @{
43   */
44   
45 /** @defgroup USBH_HID_CORE
46   * @brief This file is the Header file for USBH_HID_CORE.c
47   * @{
48   */ 
49
50
51 /** @defgroup USBH_HID_CORE_Exported_Types
52   * @{
53   */ 
54
55
56 /* States for HID State Machine */
57 typedef enum
58 {
59   HID_IDLE= 0,
60   HID_SEND_DATA,
61   HID_BUSY,
62   HID_GET_DATA,   
63   HID_POLL,
64   HID_ERROR,
65 }
66 HID_State;
67
68 typedef enum
69 {
70   HID_REQ_IDLE = 0,
71   HID_REQ_GET_REPORT_DESC,
72   HID_REQ_GET_HID_DESC,
73   HID_REQ_SET_IDLE,
74   HID_REQ_SET_PROTOCOL,
75   HID_REQ_SET_REPORT,
76
77 }
78 HID_CtlState;
79
80 typedef struct HID_cb
81 {
82   void  (*Init)   (void);             
83   void  (*Decode) (uint8_t *data);       
84   
85 } HID_cb_TypeDef;
86
87 typedef  struct  _HID_Report 
88 {
89     uint8_t   ReportID;    
90     uint8_t   ReportType;  
91     uint16_t  UsagePage;   
92     uint32_t  Usage[2]; 
93     uint32_t  NbrUsage;                      
94     uint32_t  UsageMin;                      
95     uint32_t  UsageMax;                      
96     int32_t   LogMin;                        
97     int32_t   LogMax;                        
98     int32_t   PhyMin;                        
99     int32_t   PhyMax;                        
100     int32_t   UnitExp;                       
101     uint32_t  Unit;                          
102     uint32_t  ReportSize;                    
103     uint32_t  ReportCnt;                     
104     uint32_t  Flag;                          
105     uint32_t  PhyUsage;                      
106     uint32_t  AppUsage;                      
107     uint32_t  LogUsage;   
108
109 HID_Report_TypeDef;
110
111 /* Structure for HID process */
112 typedef struct _HID_Process
113 {
114   uint8_t              buff[64];
115   uint8_t              hc_num_in; 
116   uint8_t              hc_num_out; 
117   HID_State            state; 
118   uint8_t              HIDIntOutEp;
119   uint8_t              HIDIntInEp;
120   HID_CtlState         ctl_state;
121   uint16_t             length;
122   uint8_t              ep_addr;
123   uint16_t             poll; 
124   __IO uint16_t        timer; 
125   HID_cb_TypeDef             *cb;
126 }
127 HID_Machine_TypeDef;
128
129 /**
130   * @}
131   */ 
132
133 /** @defgroup USBH_HID_CORE_Exported_Defines
134   * @{
135   */ 
136
137 #define USB_HID_REQ_GET_REPORT       0x01
138 #define USB_HID_GET_IDLE             0x02
139 #define USB_HID_GET_PROTOCOL         0x03
140 #define USB_HID_SET_REPORT           0x09
141 #define USB_HID_SET_IDLE             0x0A
142 #define USB_HID_SET_PROTOCOL         0x0B    
143 /**
144   * @}
145   */ 
146
147 /** @defgroup USBH_HID_CORE_Exported_Macros
148   * @{
149   */ 
150 /**
151   * @}
152   */ 
153
154 /** @defgroup USBH_HID_CORE_Exported_Variables
155   * @{
156   */ 
157 extern USBH_Class_cb_TypeDef  HID_cb;
158 /**
159   * @}
160   */ 
161
162 /** @defgroup USBH_HID_CORE_Exported_FunctionsPrototype
163   * @{
164   */ 
165
166 USBH_Status USBH_Set_Report (USB_OTG_CORE_HANDLE *pdev,
167                              USBH_HOST *phost,
168                                   uint8_t reportType,
169                                   uint8_t reportId,
170                                   uint8_t reportLen,
171                                   uint8_t* reportBuff);
172 /**
173   * @}
174   */ 
175
176
177 #endif /* __USBH_HID_CORE_H */
178
179 /**
180   * @}
181   */ 
182
183 /**
184   * @}
185   */ 
186
187 /**
188   * @}
189   */ 
190
191 /**
192   * @}
193   */ 
194 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
195