Skip to content

Commit 2b3ddd9

Browse files
committedApr 29, 2021
USB: update core and class files after middleware update
Signed-off-by: Frederic Pillon <[email protected]>
1 parent b54d2e8 commit 2b3ddd9

File tree

8 files changed

+717
-540
lines changed

8 files changed

+717
-540
lines changed
 

‎cores/arduino/stm32/usb/cdc/usbd_cdc.c

Lines changed: 297 additions & 241 deletions
Large diffs are not rendered by default.

‎cores/arduino/stm32/usb/cdc/usbd_cdc.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern "C" {
3838
* @{
3939
*/
4040

41+
4142
/** @defgroup usbd_cdc_Exported_Defines
4243
* @{
4344
*/
@@ -58,6 +59,7 @@ extern "C" {
5859
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
5960
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
6061

62+
#define CDC_REQ_MAX_DATA_SIZE 0x7U
6163
/*---------------------------------------------------------------------*/
6264
/* CDC definitions */
6365
/*---------------------------------------------------------------------*/
@@ -100,7 +102,7 @@ typedef struct _USBD_CDC_Itf {
100102

101103

102104
typedef struct {
103-
uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */
105+
uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */
104106
uint8_t CmdOpCode;
105107
uint8_t CmdLength;
106108
uint8_t *RxBuffer;
@@ -126,25 +128,25 @@ typedef struct {
126128
* @{
127129
*/
128130

129-
extern USBD_ClassTypeDef USBD_CDC;
130-
#define USBD_CDC_CLASS &USBD_CDC
131+
extern USBD_ClassTypeDef USBD_CDC;
132+
#define USBD_CDC_CLASS &USBD_CDC
131133
/**
132134
* @}
133135
*/
134136

135137
/** @defgroup USB_CORE_Exported_Functions
136138
* @{
137139
*/
138-
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
139-
USBD_CDC_ItfTypeDef *fops);
140+
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
141+
USBD_CDC_ItfTypeDef *fops);
140142

141-
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
142-
uint32_t length);
143+
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
144+
uint32_t length);
143145

144-
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
145-
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
146-
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);
147-
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
146+
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
147+
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
148+
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);
149+
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
148150
/**
149151
* @}
150152
*/

‎cores/arduino/stm32/usb/cdc/usbd_cdc_if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int8_t USBD_CDC_Receive(uint8_t *Buf, uint32_t *Len)
243243

244244
/**
245245
* @brief USBD_CDC_TransmitCplt
246-
* Data transmited callback
246+
* Data transmitted callback
247247
*
248248
* @note
249249
* This function is IN transfer complete callback used to inform user that

‎cores/arduino/stm32/usb/hid/usbd_hid_composite.c

Lines changed: 268 additions & 246 deletions
Large diffs are not rendered by default.

‎cores/arduino/stm32/usb/usbd_conf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
633633
/**
634634
* @brief Assigns a USB address to the device.
635635
* @param pdev: Device handle
636-
* @param ep_addr: Endpoint Number
636+
* @param dev_addr: Endpoint Number
637637
* @retval USBD Status
638638
*/
639639
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)

‎cores/arduino/stm32/usb/usbd_conf.h

Lines changed: 130 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎cores/arduino/stm32/usb/usbd_desc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ __ALIGN_BEGIN uint8_t USBD_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = {
257257

258258
0x00, /* bAlternateMode[0] Index of the Alternate Mode within the SVID as
259259
returned in response to a Discover Modes command. Example:
260-
0 – first Mode entry
261-
1 – second mode entry */
260+
0 first Mode entry
261+
1 second mode entry */
262262

263263
USBD_BB_ALTMODE0_STRING_INDEX, /* iAlternateModeString[0]: Index of string descriptor describing protocol.
264264
It is optional to support this string. */
@@ -268,8 +268,8 @@ __ALIGN_BEGIN uint8_t USBD_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = {
268268

269269
0x01, /* bAlternateMode[1] Index of the Alternate Mode within the SVID as
270270
returned in response to a Discover Modes command. Example:
271-
0 – first Mode entry
272-
1 – second Mode entry */
271+
0 first Mode entry
272+
1 second Mode entry */
273273

274274
USBD_BB_ALTMODE1_STRING_INDEX, /* iAlternateModeString[1]: Index of string descriptor describing protocol.
275275
It is optional to support this string. */

‎cores/arduino/stm32/usb/usbd_desc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
/* Exported types ------------------------------------------------------------*/
2828
/* Exported constants --------------------------------------------------------*/
2929
#define DEVICE_ID1 (UID_BASE)
30-
#define DEVICE_ID2 (UID_BASE + 0x4)
31-
#define DEVICE_ID3 (UID_BASE + 0x8)
30+
#define DEVICE_ID2 (UID_BASE + 0x4U)
31+
#define DEVICE_ID3 (UID_BASE + 0x8U)
3232

3333
/*
3434
* USB Billboard Class USER string desc Defines Template
@@ -46,7 +46,7 @@
4646
#define USBD_BB_ALTMODE1_STR_DESC (uint8_t *)"STM32 Alternate1 Mode"
4747
#endif
4848

49-
#define USB_SIZ_STRING_SERIAL 0x1A
49+
#define USB_SIZ_STRING_SERIAL 0x1AU
5050

5151
#if (USBD_LPM_ENABLED == 1)
5252
#define USB_SIZ_BOS_DESC 0x0CU

0 commit comments

Comments
 (0)
Please sign in to comment.