Cordio Stack and Cordio Profiles  r2p3-02rel0
hid_api.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Human Interface Device Profile.
6  *
7  * Copyright (c) 2015-2018 Arm Ltd. All Rights Reserved.
8  * Arm Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact Arm Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef HID_API_H
20 #define HID_API_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /*! \addtogroup HUMAN_INTERFACE_DEVICE_PROFILE
27  * \{ */
28 
29 /**************************************************************************************************
30  Constant Values
31 **************************************************************************************************/
32 
33 /** \name Type of HID Information
34  *
35  */
36 /**@{*/
37 #define HID_INFO_CONTROL_POINT 0 /*!< \brief Control point information. */
38 #define HID_INFO_PROTOCOL_MODE 1 /*!< \brief Protocol mode information. */
39 /**@}*/
40 
41 /** \name HID Boot Report ID
42  *
43  */
44 /**@{*/
45 #define HID_KEYBOARD_BOOT_ID 0xFF /*!< \brief Keyboard boot ID. */
46 #define HID_MOUSE_BOOT_ID 0xFE /*!< \brief Mouse boot ID. */
47 /**@}*/
48 
49 /**************************************************************************************************
50  Callback Function Types
51 **************************************************************************************************/
52 
53 /*************************************************************************************************/
54 /*!
55  * \brief This callback function sends a received Output Report to the application.
56  *
57  * \param connId The connection identifier.
58  * \param id The ID of the report.
59  * \param len The length of the report data in pReport.
60  * \param pReport A buffer containing the report.
61  *
62  * \return None.
63  */
64 /*************************************************************************************************/
65 typedef void (*hidOutputReportCback_t)(dmConnId_t connId, uint8_t id, uint16_t len, uint8_t *pReport);
66 
67 /*************************************************************************************************/
68 /*!
69  * \brief This callback function sends a received Feature Report to the application.
70  *
71  * \param connId The connection identifier.
72  * \param id The ID of the report.
73  * \param len The length of the report data in pReport.
74  * \param pReport A buffer containing the report.
75  *
76  * \return None.
77  */
78 /*************************************************************************************************/
79 typedef void (*hidFeatureReportCback_t)(dmConnId_t connId, uint8_t id, uint16_t len, uint8_t *pReport);
80 
81 /*************************************************************************************************/
82 /*!
83  * \brief This callback function notifies the application of a change in the protocol mode or
84  * control point from the host.
85  *
86  * \param connId The connection identifier.
87  * \param mode The type of information (\ref HID_INFO_CONTROL_POINT or \ref HID_INFO_PROTOCOL_MODE)
88  * \param value The value of the information
89  *
90  * \return None.
91  */
92 /*************************************************************************************************/
93 typedef void (*hidInfoCback_t)(dmConnId_t connId, uint8_t type, uint8_t value);
94 
95 /*! \brief HID Report Type/ID to Attribute handle map item */
96 typedef struct
97 {
98  uint8_t type; /*!< \brief Type */
99  uint8_t id; /*!< \brief Id */
100  uint16_t handle; /*!< \brief Handle */
102 
103 /*! \brief HID Profile Configuration */
104 typedef struct
105 {
106  hidReportIdMap_t *pReportIdMap; /*!< \brief A map between report Type/ID and Attribute handle */
107  uint8_t reportIdMapSize; /*!< \brief The number of Reports in the ID map (pReportIdMap) */
108  hidOutputReportCback_t outputCback; /*!< \brief Callback called on receipt of an Output Report */
109  hidFeatureReportCback_t featureCback; /*!< \brief Callback called on receipt of a Feature Report */
110  hidInfoCback_t infoCback; /*!< \brief Callback called on receipt of protocol mode or control point */
111 } hidConfig_t;
112 
113 /**************************************************************************************************
114  API Functions
115 **************************************************************************************************/
116 
117 /*************************************************************************************************/
118 /*!
119  * \brief Sends an input report to the host
120  *
121  * \param connId The connection ID
122  * \param reportId The Report ID
123  * \param len The length of the report in bytes
124  * \param pValue A buffer containing the report
125  *
126  * \return none.
127  */
128 /*************************************************************************************************/
129 void HidSendInputReport(dmConnId_t connId, uint8_t reportId, uint16_t len, uint8_t *pValue);
130 
131 /*************************************************************************************************/
132 /*!
133  * \brief Sets the HID protocol mode for keyboard and mouse devices that support Boot Mode.
134  *
135  * \param protocolMode The protocol mode (\ref HID_PROTOCOL_MODE_REPORT or \ref HID_PROTOCOL_MODE_BOOT)
136  *
137  * \return None.
138  */
139 /*************************************************************************************************/
140 void HidSetProtocolMode(uint8_t protocolMode);
141 
142 /*************************************************************************************************/
143 /*!
144  * \brief Gets the HID protocol mode value.
145  *
146  * \return The protocol mode value (\ref HID_PROTOCOL_MODE_REPORT or \ref HID_PROTOCOL_MODE_BOOT).
147  */
148 /*************************************************************************************************/
150 
151 /*************************************************************************************************/
152 /*!
153  * \brief Gets the HID control point value.
154  *
155  * \return The control point value (\ref HID_CONTROL_POINT_SUSPEND or \ref HID_CONTROL_POINT_RESUME).
156  */
157 /*************************************************************************************************/
159 
160 /*************************************************************************************************/
161 /*!
162  * \brief Initialize the HID profile.
163  *
164  * \param pConfig HID Configuration structure
165  *
166  * \return None.
167  */
168 /*************************************************************************************************/
169 void HidInit(const hidConfig_t *pConfig);
170 
171 /*************************************************************************************************/
172 /*!
173  * \brief Called on an ATTS Write to the HID Service.
174  *
175  * \param connId DM connection identifier.
176  * \param handle ATT handle.
177  * \param operation ATT operation.
178  * \param offset Write offset.
179  * \param len Write length.
180  * \param pValue Value to write.
181  * \param pAttr Attribute to write.
182  *
183  * \return ATT status.
184  *
185  */
186 /*************************************************************************************************/
187 uint8_t HidAttsWriteCback(dmConnId_t connId, uint16_t handle, uint8_t operation,
188  uint16_t offset, uint16_t len, uint8_t *pValue,
189  attsAttr_t *pAttr);
190 
191 
192 /*! \} */ /* HUMAN_INTERFACE_DEVICE_PROFILE */
193 
194 #ifdef __cplusplus
195 };
196 #endif
197 
198 #endif /* HID_API_H */
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:501
uint8_t reportIdMapSize
The number of Reports in the ID map (pReportIdMap)
Definition: hid_api.h:107
void(* hidOutputReportCback_t)(dmConnId_t connId, uint8_t id, uint16_t len, uint8_t *pReport)
This callback function sends a received Output Report to the application.
Definition: hid_api.h:65
void(* hidFeatureReportCback_t)(dmConnId_t connId, uint8_t id, uint16_t len, uint8_t *pReport)
This callback function sends a received Feature Report to the application.
Definition: hid_api.h:79
hidFeatureReportCback_t featureCback
Callback called on receipt of a Feature Report.
Definition: hid_api.h:109
uint8_t HidGetControlPoint(void)
Gets the HID control point value.
void HidInit(const hidConfig_t *pConfig)
Initialize the HID profile.
void HidSetProtocolMode(uint8_t protocolMode)
Sets the HID protocol mode for keyboard and mouse devices that support Boot Mode. ...
HID Report Type/ID to Attribute handle map item.
Definition: hid_api.h:96
hidOutputReportCback_t outputCback
Callback called on receipt of an Output Report.
Definition: hid_api.h:108
hidReportIdMap_t * pReportIdMap
A map between report Type/ID and Attribute handle.
Definition: hid_api.h:106
void(* hidInfoCback_t)(dmConnId_t connId, uint8_t type, uint8_t value)
This callback function notifies the application of a change in the protocol mode or control point fro...
Definition: hid_api.h:93
void HidSendInputReport(dmConnId_t connId, uint8_t reportId, uint16_t len, uint8_t *pValue)
Sends an input report to the host.
uint8_t id
Id.
Definition: hid_api.h:99
Attribute structure.
Definition: att_api.h:186
uint8_t HidGetProtocolMode(void)
Gets the HID protocol mode value.
hidInfoCback_t infoCback
Callback called on receipt of protocol mode or control point.
Definition: hid_api.h:110
unsigned short uint16_t
Unsigned 16-bit value.
Definition: wsf_types.h:67
HID Profile Configuration.
Definition: hid_api.h:104
unsigned char uint8_t
Unsigned 8-bit value.
Definition: wsf_types.h:63
uint16_t handle
Handle.
Definition: hid_api.h:100
uint8_t HidAttsWriteCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr)
Called on an ATTS Write to the HID Service.
uint8_t type
Type.
Definition: hid_api.h:98