Skip to content

Commit 47c9d59

Browse files
committed
USB: update core and class files after middleware update
Signed-off-by: Frederic Pillon <[email protected]>
1 parent f16a4e9 commit 47c9d59

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
@@ -82,122 +82,219 @@ extern "C" {
8282
#endif
8383

8484
#ifndef USBD_MAX_NUM_INTERFACES
85-
#define USBD_MAX_NUM_INTERFACES 2U
85+
#define USBD_MAX_NUM_INTERFACES 2U
8686
#endif /* USBD_MAX_NUM_INTERFACES */
8787

8888
#ifndef USBD_MAX_NUM_CONFIGURATION
89-
#define USBD_MAX_NUM_CONFIGURATION 1U
89+
#define USBD_MAX_NUM_CONFIGURATION 1U
9090
#endif /* USBD_MAX_NUM_CONFIGURATION */
9191

9292
#ifndef USBD_MAX_STR_DESC_SIZ
93-
#define USBD_MAX_STR_DESC_SIZ 0x100U
93+
#define USBD_MAX_STR_DESC_SIZ 0x100U
9494
#endif /* USBD_MAX_STR_DESC_SIZ */
9595

9696
#ifndef USBD_SELF_POWERED
97-
#define USBD_SELF_POWERED 1U
97+
#define USBD_SELF_POWERED 1U
9898
#endif /* USBD_SELF_POWERED */
9999

100100
#ifndef USBD_DEBUG_LEVEL
101-
#define USBD_DEBUG_LEVEL 0U
101+
#define USBD_DEBUG_LEVEL 0U
102102
#endif /* USBD_DEBUG_LEVEL */
103103

104104
/* ECM, RNDIS, DFU Class Config */
105105
#ifndef USBD_SUPPORT_USER_STRING_DESC
106-
#define USBD_SUPPORT_USER_STRING_DESC 0U
106+
#define USBD_SUPPORT_USER_STRING_DESC 0U
107107
#endif /* USBD_SUPPORT_USER_STRING_DESC */
108108

109109
/* BillBoard Class Config */
110110
#ifndef USBD_CLASS_USER_STRING_DESC
111-
#define USBD_CLASS_USER_STRING_DESC 1U
111+
#define USBD_CLASS_USER_STRING_DESC 1U
112112
#endif /* USBD_CLASS_USER_STRING_DESC */
113113

114114
#ifndef USBD_CLASS_BOS_ENABLED
115-
#define USBD_CLASS_BOS_ENABLED 0U
115+
#define USBD_CLASS_BOS_ENABLED 0U
116116
#endif /* USBD_CLASS_BOS_ENABLED */
117117

118118
#ifndef USB_BB_MAX_NUM_ALT_MODE
119-
#define USB_BB_MAX_NUM_ALT_MODE 0x2U
119+
#define USB_BB_MAX_NUM_ALT_MODE 0x2U
120120
#endif /* USB_BB_MAX_NUM_ALT_MODE */
121121

122122
/* MSC Class Config */
123123
#ifndef MSC_MEDIA_PACKET
124-
#define MSC_MEDIA_PACKET 8192U
124+
#define MSC_MEDIA_PACKET 8192U
125125
#endif /* MSC_MEDIA_PACKET */
126126

127127
/* CDC Class Config */
128128
#ifndef USBD_CDC_INTERVAL
129-
#define USBD_CDC_INTERVAL 2000U
129+
#define USBD_CDC_INTERVAL 2000U
130130
#endif /* USBD_CDC_INTERVAL */
131131

132132
/* DFU Class Config */
133133
#ifndef USBD_DFU_MAX_ITF_NUM
134-
#define USBD_DFU_MAX_ITF_NUM 1U
134+
#define USBD_DFU_MAX_ITF_NUM 1U
135135
#endif /* USBD_DFU_MAX_ITF_NUM */
136136
#ifndef USBD_DFU_XFERS_IZE
137-
#define USBD_DFU_XFERS_IZE 1024U
137+
#define USBD_DFU_XFERS_IZE 1024U
138138
#endif /* USBD_DFU_XFERS_IZE */
139139

140140
/* AUDIO Class Config */
141141
#ifndef USBD_AUDIO_FREQ
142-
#define USBD_AUDIO_FREQ 22100U
142+
#define USBD_AUDIO_FREQ 22100U
143143
#endif /* USBD_AUDIO_FREQ */
144144

145+
/* CustomHID Class Config */
146+
#ifndef CUSTOM_HID_HS_BINTERVAL
147+
#define CUSTOM_HID_HS_BINTERVAL 0x05U
148+
#endif /* CUSTOM_HID_HS_BINTERVAL */
149+
#ifndef CUSTOM_HID_FS_BINTERVAL
150+
#define CUSTOM_HID_FS_BINTERVAL 0x05U
151+
#endif /* CUSTOM_HID_FS_BINTERVAL */
152+
#ifndef USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
153+
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
154+
#endif /* USBD_CUSTOMHID_OUTREPORT_BUF_SIZE */
155+
#ifndef USBD_CUSTOM_HID_REPORT_DESC_SIZE
156+
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
157+
#endif /* USBD_CUSTOM_HID_REPORT_DESC_SIZE */
158+
159+
/* VIDEO Class Config */
160+
#ifndef UVC_1_1
161+
#define UVC_1_1 /* #define UVC_1_0 */
162+
#endif /* UVC_1_1 */
163+
164+
/* To be used only with YUY2 and NV12 Video format, shouldn't be defined for MJPEG format */
165+
#ifndef USBD_UVC_FORMAT_UNCOMPRESSED
166+
#define USBD_UVC_FORMAT_UNCOMPRESSED
167+
#endif /* USBD_UVC_FORMAT_UNCOMPRESSED */
168+
169+
#ifdef USBD_UVC_FORMAT_UNCOMPRESSED
170+
#ifndef UVC_BITS_PER_PIXEL
171+
#define UVC_BITS_PER_PIXEL 12U
172+
#endif /* UVC_BITS_PER_PIXEL */
173+
#ifndef UVC_UNCOMPRESSED_GUID
174+
#define UVC_UNCOMPRESSED_GUID UVC_GUID_NV12 /* UVC_GUID_YUY2 */
175+
#endif /* UVC_UNCOMPRESSED_GUID */
176+
177+
/* refer to Table 3-18 Color Matching Descriptor video class v1.1 */
178+
#ifndef UVC_COLOR_PRIMARIE
179+
#define UVC_COLOR_PRIMARIE 0x01U
180+
#endif /* UVC_COLOR_PRIMARIE */
181+
#ifndef UVC_TFR_CHARACTERISTICS
182+
#define UVC_TFR_CHARACTERISTICS 0x01U
183+
#endif /* UVC_TFR_CHARACTERISTICS */
184+
#ifndef UVC_MATRIX_COEFFICIENTS
185+
#define UVC_MATRIX_COEFFICIENTS 0x04U
186+
#endif /* UVC_MATRIX_COEFFICIENTS */
187+
#endif
188+
189+
/* Video Stream frame width and height */
190+
#ifndef UVC_WIDTH
191+
#define UVC_WIDTH 176U
192+
#endif /* UVC_WIDTH */
193+
#ifndef UVC_HEIGHT
194+
#define UVC_HEIGHT 144U
195+
#endif /* UVC_HEIGHT */
196+
197+
/* bEndpointAddress in Endpoint Descriptor */
198+
#ifndef UVC_IN_EP
199+
#define UVC_IN_EP 0x81U
200+
#endif /* UVC_IN_EP */
201+
202+
#ifndef UVC_CAM_FPS_FS
203+
#define UVC_CAM_FPS_FS 10U
204+
#endif /* UVC_CAM_FPS_FS */
205+
#ifndef UVC_CAM_FPS_HS
206+
#define UVC_CAM_FPS_HS 5U
207+
#endif /* UVC_CAM_FPS_HS */
208+
209+
#ifndef UVC_ISO_HS_MPS
210+
#define UVC_ISO_FS_MPS 512U
211+
#endif /* UVC_ISO_HS_MPS */
212+
#ifndef UVC_ISO_HS_MPS
213+
#define UVC_ISO_HS_MPS 512U
214+
#endif /* UVC_ISO_HS_MPS */
215+
216+
#ifndef UVC_PACKET_SIZE
217+
#define UVC_PACKET_SIZE UVC_ISO_FS_MPS
218+
#endif /* UVC_PACKET_SIZE */
219+
/* To be used with Device Only IP supporting double buffer mode */
220+
/* #define UVC_HEADER_PACKET_CNT 0x02U */
221+
/* #define UVC_PACKET_SIZE (UVC_ISO_FS_MPS * UVC_HEADER_PACKET_CNT) */
222+
223+
#ifndef UVC_MAX_FRAME_SIZE
224+
#define UVC_MAX_FRAME_SIZE (UVC_WIDTH * UVC_HEIGHT * 16U / 8U)
225+
#endif /* UVC_MAX_FRAME_SIZE */
226+
145227
/* Interrupt priority */
146228
#ifndef USBD_IRQ_PRIO
147-
#define USBD_IRQ_PRIO 1
229+
#define USBD_IRQ_PRIO 1
148230
#endif /* USBD_IRQ_PRIO */
231+
149232
#ifndef USBD_IRQ_SUBPRIO
150-
#define USBD_IRQ_SUBPRIO 0
233+
#define USBD_IRQ_SUBPRIO 0
151234
#endif /* USBD_IRQ_SUBPRIO */
152235

153-
/* Memory management macros */
236+
/* Memory management macros make sure to use static memory allocation */
237+
/* Currently dynamic memory allocation usage */
238+
/** Alias for memory allocation. */
154239
#ifndef USBD_malloc
155-
#define USBD_malloc malloc
240+
#define USBD_malloc malloc
156241
#endif /* USBD_malloc */
242+
243+
/** Alias for memory release. */
157244
#ifndef USBD_free
158-
#define USBD_free free
245+
#define USBD_free free
159246
#endif /* USBD_free */
247+
248+
/** Alias for memory set. */
160249
#ifndef USBD_memset
161-
#define USBD_memset memset
250+
#define USBD_memset memset
162251
#endif /* USBD_memset */
252+
253+
/** Alias for memory copy. */
163254
#ifndef USBD_memcpy
164-
#define USBD_memcpy memcpy
255+
#define USBD_memcpy memcpy
165256
#endif /* USBD_memcpy */
257+
258+
/** Alias for delay. */
166259
#ifndef USBD_Delay
167-
#define USBD_Delay HAL_Delay
260+
#define USBD_Delay HAL_Delay
168261
#endif /* USBD_Delay */
169262

170263
/* DEBUG macros */
171264
#if (USBD_DEBUG_LEVEL > 0U)
172265
#define USBD_UsrLog(...) do { \
173-
printf(__VA_ARGS__); \
174-
printf("\n"); \
175-
} while (0)
266+
printf(__VA_ARGS__); \
267+
printf("\n"); \
268+
} while (0)
176269
#else
177270
#define USBD_UsrLog(...) do {} while (0)
178271
#endif
179272

180273
#if (USBD_DEBUG_LEVEL > 1U)
181274

182275
#define USBD_ErrLog(...) do { \
183-
printf("ERROR: ") ; \
184-
printf(__VA_ARGS__); \
185-
printf("\n"); \
186-
} while (0)
276+
printf("ERROR: ") ; \
277+
printf(__VA_ARGS__); \
278+
printf("\n"); \
279+
} while (0)
187280
#else
188281
#define USBD_ErrLog(...) do {} while (0)
189282
#endif
190283

191284
#if (USBD_DEBUG_LEVEL > 2U)
192285
#define USBD_DbgLog(...) do { \
193-
printf("DEBUG : ") ; \
194-
printf(__VA_ARGS__); \
195-
printf("\n"); \
196-
} while (0)
286+
printf("DEBUG : ") ; \
287+
printf(__VA_ARGS__); \
288+
printf("\n"); \
289+
} while (0)
197290
#else
198291
#define USBD_DbgLog(...) do {} while (0)
199292
#endif
200293

294+
/* Exported functions -------------------------------------------------------*/
295+
void *USBD_static_malloc(uint32_t size);
296+
void USBD_static_free(void *p);
297+
201298
#endif /* USBCON */
202299

203300
#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)