-
Notifications
You must be signed in to change notification settings - Fork 3
/
lufa_callbacks.c
56 lines (51 loc) · 2.31 KB
/
lufa_callbacks.c
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
#include <LUFA/Drivers/USB/USB.h>
#include "Config/AdapterConfig.h"
void EVENT_USB_Device_Connect(void) {}
void EVENT_USB_Device_Disconnect(void) {}
void EVENT_USB_Device_ConfigurationChanged(void) {
Endpoint_ConfigureEndpoint(ADAPTER_IN_NUM, EP_TYPE_INTERRUPT, ADAPTER_IN_SIZE, 1);
Endpoint_ConfigureEndpoint(ADAPTER_OUT_NUM, EP_TYPE_INTERRUPT, ADAPTER_OUT_SIZE, 1);
}
const uint8_t PROGMEM request144_index_4[] = {
0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x58, 0x47, 0x49, 0x50, 0x31, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void EVENT_USB_Device_ControlRequest(void) {
if (USB_ControlRequest.bmRequestType & REQTYPE_VENDOR) {
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) {
if (USB_ControlRequest.bRequest == 144) {
uint8_t recipient = USB_ControlRequest.bmRequestType & 0x1F;
if (recipient == REQREC_DEVICE) {
if (USB_ControlRequest.wIndex == 0x0004) {
Endpoint_ClearSETUP();
Endpoint_Write_Control_PStream_LE(request144_index_4,
USB_ControlRequest.wLength);
Endpoint_ClearOUT();
}
} else if (recipient == REQREC_INTERFACE) {
if (USB_ControlRequest.wIndex == 0x0005) {
Endpoint_ClearSETUP();
Endpoint_ClearOUT();
}
}
}
}
} else {
if (USB_ControlRequest.bmRequestType & REQREC_INTERFACE) {
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) {
if (USB_ControlRequest.bRequest == REQ_GetInterface) {
uint8_t data[1] = {0x00};
Endpoint_ClearSETUP();
Endpoint_Write_Control_Stream_LE(data, sizeof(data));
Endpoint_ClearOUT();
}
} else {
if (USB_ControlRequest.bRequest == REQ_SetInterface) {
Endpoint_ClearSETUP();
// wLength is 0
Endpoint_ClearIN();
}
}
}
}
}