-
Notifications
You must be signed in to change notification settings - Fork 0
/
usb_config.h
156 lines (119 loc) · 6.32 KB
/
usb_config.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/********************************************************************
FileName: usb_config.h
Dependencies: Always: GenericTypeDefs.h, usb_device.h
Situational: usb_function_hid.h, usb_function_cdc.h, usb_function_msd.h, etc.
Processor: PIC18 or PIC24 USB Microcontrollers
Hardware: The code is natively intended to be used on the following
hardware platforms: PICDEM™ FS USB Demo Board,
PIC18F87J50 FS USB Plug-In Module, or
Explorer 16 + PIC24 USB PIM. The firmware may be
modified for use on other USB platforms by editing the
HardwareProfile.h file.
Complier: Microchip C18 (for PIC18) or C30 (for PIC24)
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PIC® Microcontroller is intended and
supplied to you, the Company’s customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
********************************************************************
File Description:
Change History:
Rev Date Description
1.0 11/19/2004 Initial release
2.1 02/26/2007 Updated for simplicity and to use common
coding style
*******************************************************************/
/*********************************************************************
* Descriptor specific type definitions are defined in: usbd.h
********************************************************************/
#ifndef USBCFG_H
#define USBCFG_H
/** DEFINITIONS ****************************************************/
#define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes.
// Using larger options take more SRAM, but
// does not provide much advantage in most types
// of applications. Exceptions to this, are applications
// that use EP0 IN or OUT for sending large amounts of
// application related data.
#define USB_MAX_NUM_INT 1 // For tracking Alternate Setting
#define USB_MAX_EP_NUMBER 1
//Device descriptor - if these two definitions are not defined then
// a ROM USB_DEVICE_DESCRIPTOR variable by the exact name of device_dsc
// must exist.
#define USB_USER_DEVICE_DESCRIPTOR &device_dsc
#define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc
//Configuration descriptors - if these two definitions do not exist then
// a ROM BYTE *ROM variable named exactly USB_CD_Ptr[] must exist.
#define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr
#define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE *ROM USB_CD_Ptr[]
//Make sure only one of the below "#define USB_PING_PONG_MODE"
//is uncommented.
//#define USB_PING_PONG_MODE USB_PING_PONG__NO_PING_PONG
#define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG
//#define USB_PING_PONG_MODE USB_PING_PONG__EP0_OUT_ONLY
//#define USB_PING_PONG_MODE USB_PING_PONG__ALL_BUT_EP0 //NOTE: This mode is not supported in PIC18F4550 family rev A3 devices
//#define USB_POLLING
#define USB_INTERRUPT
/* Parameter definitions are defined in usb_device.h */
#define USB_PULLUP_OPTION USB_PULLUP_ENABLE
//#define USB_PULLUP_OPTION USB_PULLUP_DISABLED
#define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER
//External Transceiver support is not available on all product families. Please
// refer to the product family datasheet for more information if this feature
// is available on the target processor.
//#define USB_TRANSCEIVER_OPTION USB_EXTERNAL_TRANSCEIVER
#define USB_SPEED_OPTION USB_FULL_SPEED
//#define USB_SPEED_OPTION USB_LOW_SPEED //(not valid option for PIC24F devices)
/** DEVICE DESCRIPTOR CONSTANTS *******************************************/
#define MY_VID 0x04D8 //FIXED for the project
#define MY_PID 0x0013 //Number of project group
#define USB_SUPPORT_DEVICE
#define USB_NUM_STRING_DESCRIPTORS 3
//#define USB_INTERRUPT_LEGACY_CALLBACKS
#define USB_ENABLE_ALL_HANDLERS
//#define USB_ENABLE_SUSPEND_HANDLER
//#define USB_ENABLE_WAKEUP_FROM_SUSPEND_HANDLER
//#define USB_ENABLE_SOF_HANDLER
//#define USB_ENABLE_ERROR_HANDLER
//#define USB_ENABLE_OTHER_REQUEST_HANDLER
//#define USB_ENABLE_SET_DESCRIPTOR_HANDLER
//#define USB_ENABLE_INIT_EP_HANDLER
//#define USB_ENABLE_EP0_DATA_HANDLER
//#define USB_ENABLE_TRANSFER_COMPLETE_HANDLER
/** DEVICE CLASS USAGE *********************************************/
#define USB_USE_HID
/** ENDPOINTS ALLOCATION *******************************************/
/* HID */
#define HID_INTF_ID 0x00
#define HID_EP 1
#define HID_INT_OUT_EP_SIZE 3 //[NOT USED] This size is the number of bytes to be transmitted from array "hid_report_out", ALREADY DECLARED in usb_device.c when USB_USE_HID is defined!
#define HID_INT_IN_EP_SIZE 6 // The same, but for "hid_report_in" array (we have 6 bytes in the report data)
#define HID_NUM_OF_DSC 1 // Number of reports (=1)
#define HID_RPT01_SIZE 16 // Size of the report descriptor
#define HID_RPT02_SIZE 24
/** DEFINITIONS ****************************************************/
#define NA 0x8000 //"MEASURE NOT AVAILABLE" value -> most relevant bit is HIGH
typedef struct _MEASURE_STRUCT //Our PROJECT SPECIFIC structure type. Just use this in the program.
//It will then be mapped properly to hid_report_in[] automatically!!
{
WORD dust; //offset 0
WORD temp; //offset 2
WORD humid; //offset 4
} measure_struct; //Attenzione: measure_struct è il nome del tipo definito con typedef
// la variabile measure effettiva è dichiarata nel file .c
//USB_HID_DSC_HEADER hid_dsc_header[HID_NUM_OF_DSC];
/* HID_NUM_OF_DSC is defined in usbcfg.h */
#endif //USBCFG_H