Skip to content

Commit d598c2a

Browse files
committed
atmel-samd: Add USB HID mouse and keyboard support.
1 parent 062fac1 commit d598c2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+7594
-57
lines changed

atmel-samd/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ INC += -Iasf/common/services/storage/ctrl_access/
3838
INC += -Iasf/common/services/usb/
3939
INC += -Iasf/common/services/usb/class/cdc/
4040
INC += -Iasf/common/services/usb/class/cdc/device/
41+
INC += -Iasf/common/services/usb/class/hid/
42+
INC += -Iasf/common/services/usb/class/hid/device/
43+
INC += -Iasf/common/services/usb/class/hid/device/kbd/
44+
INC += -Iasf/common/services/usb/class/hid/device/mouse/
4145
INC += -Iasf/common/services/usb/class/msc/
4246
INC += -Iasf/common/services/usb/class/msc/device/
4347
INC += -Iasf/common/services/usb/udc/
@@ -183,6 +187,9 @@ SRC_C = \
183187
asf/common/services/storage/ctrl_access/ctrl_access.c \
184188
asf/common/services/usb/class/cdc/device/udi_cdc.c \
185189
asf/common/services/usb/class/composite/device/udi_composite_desc.c \
190+
asf/common/services/usb/class/hid/device/udi_hid.c \
191+
asf/common/services/usb/class/hid/device/mouse/udi_hid_mouse.c \
192+
asf/common/services/usb/class/hid/device/kbd/udi_hid_kbd.c \
186193
asf/common/services/usb/class/msc/device/udi_msc.c \
187194
asf/common/services/usb/udc/udc.c \
188195
asf/common/utils/interrupt/interrupt_sam_nvic.c \
@@ -221,7 +228,9 @@ SRC_BINDINGS = \
221228
nativeio/SPI.c \
222229
nativeio/UART.c \
223230
neopixel_write/__init__.c \
224-
time/__init__.c
231+
time/__init__.c \
232+
usb_hid/__init__.c \
233+
usb_hid/Device.c
225234

226235
SRC_BINDINGS_EXPANDED = $(addprefix shared-bindings/, $(SRC_BINDINGS)) \
227236
$(addprefix common-hal/, $(SRC_BINDINGS))
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/**
2+
* \file
3+
*
4+
* \brief USB configuration file
5+
*
6+
* Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
7+
*
8+
* \asf_license_start
9+
*
10+
* \page License
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions are met:
14+
*
15+
* 1. Redistributions of source code must retain the above copyright notice,
16+
* this list of conditions and the following disclaimer.
17+
*
18+
* 2. Redistributions in binary form must reproduce the above copyright notice,
19+
* this list of conditions and the following disclaimer in the documentation
20+
* and/or other materials provided with the distribution.
21+
*
22+
* 3. The name of Atmel may not be used to endorse or promote products derived
23+
* from this software without specific prior written permission.
24+
*
25+
* 4. This software may only be redistributed and used in connection with an
26+
* Atmel microcontroller product.
27+
*
28+
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31+
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38+
* POSSIBILITY OF SUCH DAMAGE.
39+
*
40+
* \asf_license_stop
41+
*
42+
*/
43+
/*
44+
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45+
*/
46+
47+
#ifndef _CONF_USB_H_
48+
#define _CONF_USB_H_
49+
50+
#include "compiler.h"
51+
52+
#warning You must refill the following definitions with a correct values
53+
54+
/**
55+
* USB Device Configuration
56+
* @{
57+
*/
58+
59+
//! Device definition (mandatory)
60+
#define USB_DEVICE_VENDOR_ID USB_VID_ATMEL
61+
#define USB_DEVICE_PRODUCT_ID USB_PID_ATMEL_ASF_HIDGENERIC
62+
#define USB_DEVICE_MAJOR_VERSION 1
63+
#define USB_DEVICE_MINOR_VERSION 0
64+
#define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA)
65+
#define USB_DEVICE_ATTR \
66+
(USB_CONFIG_ATTR_SELF_POWERED)
67+
// (USB_CONFIG_ATTR_BUS_POWERED)
68+
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
69+
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
70+
71+
//! USB Device string definitions (Optional)
72+
// #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name"
73+
// #define USB_DEVICE_PRODUCT_NAME "Product name"
74+
// #define USB_DEVICE_SERIAL_NAME "12...EF"
75+
76+
/**
77+
* Device speeds support
78+
* @{
79+
*/
80+
//! To define a Low speed device
81+
//#define USB_DEVICE_LOW_SPEED
82+
83+
//! To authorize the High speed
84+
#if (UC3A3||UC3A4)
85+
//#define USB_DEVICE_HS_SUPPORT
86+
#endif
87+
//@}
88+
89+
/**
90+
* USB Device Callbacks definitions (Optional)
91+
* @{
92+
*/
93+
// #define UDC_VBUS_EVENT(b_vbus_high) user_callback_vbus_action(b_vbus_high)
94+
// extern void user_callback_vbus_action(bool b_vbus_high);
95+
// #define UDC_SOF_EVENT() user_callback_sof_action()
96+
// extern void user_callback_sof_action(void);
97+
// #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
98+
// extern void user_callback_suspend_action(void);
99+
// #define UDC_RESUME_EVENT() user_callback_resume_action()
100+
// extern void user_callback_resume_action(void);
101+
//! Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature
102+
// #define UDC_REMOTEWAKEUP_ENABLE() user_callback_remotewakeup_enable()
103+
// extern void user_callback_remotewakeup_enable(void);
104+
// #define UDC_REMOTEWAKEUP_DISABLE() user_callback_remotewakeup_disable()
105+
// extern void user_callback_remotewakeup_disable(void);
106+
//! When a extra string descriptor must be supported
107+
//! other than manufacturer, product and serial string
108+
// #define UDC_GET_EXTRA_STRING()
109+
//@}
110+
111+
//@}
112+
113+
114+
/**
115+
* USB Interface Configuration
116+
* @{
117+
*/
118+
/**
119+
* Configuration of HID Generic interface
120+
* @{
121+
*/
122+
//! Interface callback definition
123+
#define UDI_HID_GENERIC_ENABLE_EXT() true
124+
#define UDI_HID_GENERIC_DISABLE_EXT()
125+
#define UDI_HID_GENERIC_REPORT_OUT(ptr)
126+
#define UDI_HID_GENERIC_SET_FEATURE(f)
127+
/*
128+
* #define UDI_HID_GENERIC_ENABLE_EXT() my_callback_generic_enable()
129+
* extern bool my_callback_generic_enable(void);
130+
* #define UDI_HID_GENERIC_DISABLE_EXT() my_callback_generic_disable()
131+
* extern void my_callback_generic_disable(void);
132+
* #define UDI_HID_GENERIC_REPORT_OUT(ptr) my_callback_generic_report_out(ptr)
133+
* extern void my_callback_generic_report_out(uint8_t *report);
134+
* #define UDI_HID_GENERIC_SET_FEATURE(f) my_callback_generic_set_feature(f)
135+
* extern void my_callback_generic_set_feature(uint8_t *report_feature);
136+
*/
137+
138+
//! Sizes of I/O reports
139+
#define UDI_HID_REPORT_IN_SIZE 64
140+
#define UDI_HID_REPORT_OUT_SIZE 64
141+
#define UDI_HID_REPORT_FEATURE_SIZE 4
142+
143+
//! Sizes of I/O endpoints
144+
#define UDI_HID_GENERIC_EP_SIZE 64
145+
//@}
146+
//@}
147+
148+
149+
/**
150+
* USB Device Driver Configuration
151+
* @{
152+
*/
153+
//@}
154+
155+
//! The includes of classes and other headers must be done at the end of this file to avoid compile error
156+
#include "udi_hid_generic_conf.h"
157+
158+
#endif // _CONF_USB_H_

0 commit comments

Comments
 (0)