@@ -83,122 +83,219 @@ extern "C" {
8383#endif
8484
8585#ifndef USBD_MAX_NUM_INTERFACES
86- #define USBD_MAX_NUM_INTERFACES 2U
86+ #define USBD_MAX_NUM_INTERFACES 2U
8787#endif /* USBD_MAX_NUM_INTERFACES */
8888
8989#ifndef USBD_MAX_NUM_CONFIGURATION
90- #define USBD_MAX_NUM_CONFIGURATION 1U
90+ #define USBD_MAX_NUM_CONFIGURATION 1U
9191#endif /* USBD_MAX_NUM_CONFIGURATION */
9292
9393#ifndef USBD_MAX_STR_DESC_SIZ
94- #define USBD_MAX_STR_DESC_SIZ 0x100U
94+ #define USBD_MAX_STR_DESC_SIZ 0x100U
9595#endif /* USBD_MAX_STR_DESC_SIZ */
9696
9797#ifndef USBD_SELF_POWERED
98- #define USBD_SELF_POWERED 1U
98+ #define USBD_SELF_POWERED 1U
9999#endif /* USBD_SELF_POWERED */
100100
101101#ifndef USBD_DEBUG_LEVEL
102- #define USBD_DEBUG_LEVEL 0U
102+ #define USBD_DEBUG_LEVEL 0U
103103#endif /* USBD_DEBUG_LEVEL */
104104
105105/* ECM, RNDIS, DFU Class Config */
106106#ifndef USBD_SUPPORT_USER_STRING_DESC
107- #define USBD_SUPPORT_USER_STRING_DESC 0U
107+ #define USBD_SUPPORT_USER_STRING_DESC 0U
108108#endif /* USBD_SUPPORT_USER_STRING_DESC */
109109
110110/* BillBoard Class Config */
111111#ifndef USBD_CLASS_USER_STRING_DESC
112- #define USBD_CLASS_USER_STRING_DESC 1U
112+ #define USBD_CLASS_USER_STRING_DESC 1U
113113#endif /* USBD_CLASS_USER_STRING_DESC */
114114
115115#ifndef USBD_CLASS_BOS_ENABLED
116- #define USBD_CLASS_BOS_ENABLED 0U
116+ #define USBD_CLASS_BOS_ENABLED 0U
117117#endif /* USBD_CLASS_BOS_ENABLED */
118118
119119#ifndef USB_BB_MAX_NUM_ALT_MODE
120- #define USB_BB_MAX_NUM_ALT_MODE 0x2U
120+ #define USB_BB_MAX_NUM_ALT_MODE 0x2U
121121#endif /* USB_BB_MAX_NUM_ALT_MODE */
122122
123123/* MSC Class Config */
124124#ifndef MSC_MEDIA_PACKET
125- #define MSC_MEDIA_PACKET 8192U
125+ #define MSC_MEDIA_PACKET 8192U
126126#endif /* MSC_MEDIA_PACKET */
127127
128128/* CDC Class Config */
129129#ifndef USBD_CDC_INTERVAL
130- #define USBD_CDC_INTERVAL 2000U
130+ #define USBD_CDC_INTERVAL 2000U
131131#endif /* USBD_CDC_INTERVAL */
132132
133133/* DFU Class Config */
134134#ifndef USBD_DFU_MAX_ITF_NUM
135- #define USBD_DFU_MAX_ITF_NUM 1U
135+ #define USBD_DFU_MAX_ITF_NUM 1U
136136#endif /* USBD_DFU_MAX_ITF_NUM */
137137#ifndef USBD_DFU_XFERS_IZE
138- #define USBD_DFU_XFERS_IZE 1024U
138+ #define USBD_DFU_XFERS_IZE 1024U
139139#endif /* USBD_DFU_XFERS_IZE */
140140
141141/* AUDIO Class Config */
142142#ifndef USBD_AUDIO_FREQ
143- #define USBD_AUDIO_FREQ 22100U
143+ #define USBD_AUDIO_FREQ 22100U
144144#endif /* USBD_AUDIO_FREQ */
145145
146+ /* CustomHID Class Config */
147+ #ifndef CUSTOM_HID_HS_BINTERVAL
148+ #define CUSTOM_HID_HS_BINTERVAL 0x05U
149+ #endif /* CUSTOM_HID_HS_BINTERVAL */
150+ #ifndef CUSTOM_HID_FS_BINTERVAL
151+ #define CUSTOM_HID_FS_BINTERVAL 0x05U
152+ #endif /* CUSTOM_HID_FS_BINTERVAL */
153+ #ifndef USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
154+ #define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
155+ #endif /* USBD_CUSTOMHID_OUTREPORT_BUF_SIZE */
156+ #ifndef USBD_CUSTOM_HID_REPORT_DESC_SIZE
157+ #define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
158+ #endif /* USBD_CUSTOM_HID_REPORT_DESC_SIZE */
159+
160+ /* VIDEO Class Config */
161+ #ifndef UVC_1_1
162+ #define UVC_1_1 /* #define UVC_1_0 */
163+ #endif /* UVC_1_1 */
164+
165+ /* To be used only with YUY2 and NV12 Video format, shouldn't be defined for MJPEG format */
166+ #ifndef USBD_UVC_FORMAT_UNCOMPRESSED
167+ #define USBD_UVC_FORMAT_UNCOMPRESSED
168+ #endif /* USBD_UVC_FORMAT_UNCOMPRESSED */
169+
170+ #ifdef USBD_UVC_FORMAT_UNCOMPRESSED
171+ #ifndef UVC_BITS_PER_PIXEL
172+ #define UVC_BITS_PER_PIXEL 12U
173+ #endif /* UVC_BITS_PER_PIXEL */
174+ #ifndef UVC_UNCOMPRESSED_GUID
175+ #define UVC_UNCOMPRESSED_GUID UVC_GUID_NV12 /* UVC_GUID_YUY2 */
176+ #endif /* UVC_UNCOMPRESSED_GUID */
177+
178+ /* refer to Table 3-18 Color Matching Descriptor video class v1.1 */
179+ #ifndef UVC_COLOR_PRIMARIE
180+ #define UVC_COLOR_PRIMARIE 0x01U
181+ #endif /* UVC_COLOR_PRIMARIE */
182+ #ifndef UVC_TFR_CHARACTERISTICS
183+ #define UVC_TFR_CHARACTERISTICS 0x01U
184+ #endif /* UVC_TFR_CHARACTERISTICS */
185+ #ifndef UVC_MATRIX_COEFFICIENTS
186+ #define UVC_MATRIX_COEFFICIENTS 0x04U
187+ #endif /* UVC_MATRIX_COEFFICIENTS */
188+ #endif
189+
190+ /* Video Stream frame width and height */
191+ #ifndef UVC_WIDTH
192+ #define UVC_WIDTH 176U
193+ #endif /* UVC_WIDTH */
194+ #ifndef UVC_HEIGHT
195+ #define UVC_HEIGHT 144U
196+ #endif /* UVC_HEIGHT */
197+
198+ /* bEndpointAddress in Endpoint Descriptor */
199+ #ifndef UVC_IN_EP
200+ #define UVC_IN_EP 0x81U
201+ #endif /* UVC_IN_EP */
202+
203+ #ifndef UVC_CAM_FPS_FS
204+ #define UVC_CAM_FPS_FS 10U
205+ #endif /* UVC_CAM_FPS_FS */
206+ #ifndef UVC_CAM_FPS_HS
207+ #define UVC_CAM_FPS_HS 5U
208+ #endif /* UVC_CAM_FPS_HS */
209+
210+ #ifndef UVC_ISO_HS_MPS
211+ #define UVC_ISO_FS_MPS 512U
212+ #endif /* UVC_ISO_HS_MPS */
213+ #ifndef UVC_ISO_HS_MPS
214+ #define UVC_ISO_HS_MPS 512U
215+ #endif /* UVC_ISO_HS_MPS */
216+
217+ #ifndef UVC_PACKET_SIZE
218+ #define UVC_PACKET_SIZE UVC_ISO_FS_MPS
219+ #endif /* UVC_PACKET_SIZE */
220+ /* To be used with Device Only IP supporting double buffer mode */
221+ /* #define UVC_HEADER_PACKET_CNT 0x02U */
222+ /* #define UVC_PACKET_SIZE (UVC_ISO_FS_MPS * UVC_HEADER_PACKET_CNT) */
223+
224+ #ifndef UVC_MAX_FRAME_SIZE
225+ #define UVC_MAX_FRAME_SIZE (UVC_WIDTH * UVC_HEIGHT * 16U / 8U)
226+ #endif /* UVC_MAX_FRAME_SIZE */
227+
146228/* Interrupt priority */
147229#ifndef USBD_IRQ_PRIO
148- #define USBD_IRQ_PRIO 1
230+ #define USBD_IRQ_PRIO 1
149231#endif /* USBD_IRQ_PRIO */
232+
150233#ifndef USBD_IRQ_SUBPRIO
151- #define USBD_IRQ_SUBPRIO 0
234+ #define USBD_IRQ_SUBPRIO 0
152235#endif /* USBD_IRQ_SUBPRIO */
153236
154- /* Memory management macros */
237+ /* Memory management macros make sure to use static memory allocation */
238+ /* Currently dynamic memory allocation usage */
239+ /** Alias for memory allocation. */
155240#ifndef USBD_malloc
156- #define USBD_malloc malloc
241+ #define USBD_malloc malloc
157242#endif /* USBD_malloc */
243+
244+ /** Alias for memory release. */
158245#ifndef USBD_free
159- #define USBD_free free
246+ #define USBD_free free
160247#endif /* USBD_free */
248+
249+ /** Alias for memory set. */
161250#ifndef USBD_memset
162- #define USBD_memset memset
251+ #define USBD_memset memset
163252#endif /* USBD_memset */
253+
254+ /** Alias for memory copy. */
164255#ifndef USBD_memcpy
165- #define USBD_memcpy memcpy
256+ #define USBD_memcpy memcpy
166257#endif /* USBD_memcpy */
258+
259+ /** Alias for delay. */
167260#ifndef USBD_Delay
168- #define USBD_Delay HAL_Delay
261+ #define USBD_Delay HAL_Delay
169262#endif /* USBD_Delay */
170263
171264/* DEBUG macros */
172265#if (USBD_DEBUG_LEVEL > 0U )
173266#define USBD_UsrLog (...) do { \
174- printf(__VA_ARGS__); \
175- printf("\n"); \
176- } while (0)
267+ printf(__VA_ARGS__); \
268+ printf("\n"); \
269+ } while (0)
177270#else
178271#define USBD_UsrLog (...) do {} while (0)
179272#endif
180273
181274#if (USBD_DEBUG_LEVEL > 1U )
182275
183276#define USBD_ErrLog (...) do { \
184- printf("ERROR: ") ; \
185- printf(__VA_ARGS__); \
186- printf("\n"); \
187- } while (0)
277+ printf("ERROR: ") ; \
278+ printf(__VA_ARGS__); \
279+ printf("\n"); \
280+ } while (0)
188281#else
189282#define USBD_ErrLog (...) do {} while (0)
190283#endif
191284
192285#if (USBD_DEBUG_LEVEL > 2U )
193286#define USBD_DbgLog (...) do { \
194- printf("DEBUG : ") ; \
195- printf(__VA_ARGS__); \
196- printf("\n"); \
197- } while (0)
287+ printf("DEBUG : ") ; \
288+ printf(__VA_ARGS__); \
289+ printf("\n"); \
290+ } while (0)
198291#else
199292#define USBD_DbgLog (...) do {} while (0)
200293#endif
201294
295+ /* Exported functions -------------------------------------------------------*/
296+ void * USBD_static_malloc (uint32_t size );
297+ void USBD_static_free (void * p );
298+
202299#endif /* USBCON */
203300
204301#ifdef __cplusplus
0 commit comments