Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
db7f4aa2
Commit
db7f4aa2
authored
Sep 22, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/usbdev: Make device descriptor callbacks take a state pointer.
parent
dbff0164
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
ports/stm32/usbd_desc.c
ports/stm32/usbd_desc.c
+10
-10
ports/stm32/usbdev/core/inc/usbd_def.h
ports/stm32/usbdev/core/inc/usbd_def.h
+9
-7
ports/stm32/usbdev/core/src/usbd_ctlreq.c
ports/stm32/usbdev/core/src/usbd_ctlreq.c
+7
-7
No files found.
ports/stm32/usbd_desc.c
View file @
db7f4aa2
...
...
@@ -111,7 +111,7 @@ void USBD_SetVIDPIDRelease(uint16_t vid, uint16_t pid, uint16_t device_release_n
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_DeviceDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
STATIC
uint8_t
*
USBD_DeviceDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
*
length
=
sizeof
(
hUSBDDeviceDesc
);
return
hUSBDDeviceDesc
;
}
...
...
@@ -122,7 +122,7 @@ STATIC uint8_t *USBD_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_LangIDStrDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
STATIC
uint8_t
*
USBD_LangIDStrDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
*
length
=
sizeof
(
USBD_LangIDDesc
);
return
USBD_LangIDDesc
;
}
...
...
@@ -133,8 +133,8 @@ STATIC uint8_t *USBD_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_ProductStrDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
0
)
{
STATIC
uint8_t
*
USBD_ProductStrDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
if
(
pdev
->
dev_speed
==
USBD_SPEED_HIGH
)
{
USBD_GetString
((
uint8_t
*
)
USBD_PRODUCT_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_PRODUCT_FS_STRING
,
USBD_StrDesc
,
length
);
...
...
@@ -148,7 +148,7 @@ STATIC uint8_t *USBD_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *len
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_ManufacturerStrDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
STATIC
uint8_t
*
USBD_ManufacturerStrDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
USBD_GetString
((
uint8_t
*
)
USBD_MANUFACTURER_STRING
,
USBD_StrDesc
,
length
);
return
USBD_StrDesc
;
}
...
...
@@ -159,7 +159,7 @@ STATIC uint8_t *USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_SerialStrDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
STATIC
uint8_t
*
USBD_SerialStrDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
// This document: http://www.usb.org/developers/docs/devclass_docs/usbmassbulk_10.pdf
// says that the serial number has to be at least 12 digits long and that
// the last 12 digits need to be unique. It also stipulates that the valid
...
...
@@ -189,8 +189,8 @@ STATIC uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_ConfigStrDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
USBD_SPEED_HIGH
)
{
STATIC
uint8_t
*
USBD_ConfigStrDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
if
(
pdev
->
dev_
speed
==
USBD_SPEED_HIGH
)
{
USBD_GetString
((
uint8_t
*
)
USBD_CONFIGURATION_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_CONFIGURATION_FS_STRING
,
USBD_StrDesc
,
length
);
...
...
@@ -204,8 +204,8 @@ STATIC uint8_t *USBD_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
STATIC
uint8_t
*
USBD_InterfaceStrDescriptor
(
USBD_
SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
0
)
{
STATIC
uint8_t
*
USBD_InterfaceStrDescriptor
(
USBD_
HandleTypeDef
*
pdev
,
uint16_t
*
length
)
{
if
(
pdev
->
dev_speed
==
USBD_SPEED_HIGH
)
{
USBD_GetString
((
uint8_t
*
)
USBD_INTERFACE_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_INTERFACE_FS_STRING
,
USBD_StrDesc
,
length
);
...
...
ports/stm32/usbdev/core/inc/usbd_def.h
View file @
db7f4aa2
...
...
@@ -193,16 +193,18 @@ typedef enum {
USBD_FAIL
,
}
USBD_StatusTypeDef
;
struct
_USBD_HandleTypeDef
;
/* USB Device descriptors structure */
typedef
struct
{
uint8_t
*
(
*
GetDeviceDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetLangIDStrDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetManufacturerStrDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetProductStrDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetSerialStrDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetConfigurationStrDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetInterfaceStrDescriptor
)(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
(
*
GetDeviceDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
uint8_t
*
(
*
GetLangIDStrDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
uint8_t
*
(
*
GetManufacturerStrDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
uint8_t
*
(
*
GetProductStrDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
uint8_t
*
(
*
GetSerialStrDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
uint8_t
*
(
*
GetConfigurationStrDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
uint8_t
*
(
*
GetInterfaceStrDescriptor
)(
struct
_USBD_HandleTypeDef
*
pdev
,
uint16_t
*
length
);
}
USBD_DescriptorsTypeDef
;
/* USB Device handle structure */
...
...
ports/stm32/usbdev/core/src/usbd_ctlreq.c
View file @
db7f4aa2
...
...
@@ -330,7 +330,7 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev ,
switch
(
req
->
wValue
>>
8
)
{
case
USB_DESC_TYPE_DEVICE
:
pbuf
=
pdev
->
pDesc
->
GetDeviceDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetDeviceDescriptor
(
pdev
,
&
len
);
break
;
case
USB_DESC_TYPE_CONFIGURATION
:
...
...
@@ -350,27 +350,27 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev ,
switch
((
uint8_t
)(
req
->
wValue
))
{
case
USBD_IDX_LANGID_STR
:
pbuf
=
pdev
->
pDesc
->
GetLangIDStrDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetLangIDStrDescriptor
(
pdev
,
&
len
);
break
;
case
USBD_IDX_MFC_STR
:
pbuf
=
pdev
->
pDesc
->
GetManufacturerStrDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetManufacturerStrDescriptor
(
pdev
,
&
len
);
break
;
case
USBD_IDX_PRODUCT_STR
:
pbuf
=
pdev
->
pDesc
->
GetProductStrDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetProductStrDescriptor
(
pdev
,
&
len
);
break
;
case
USBD_IDX_SERIAL_STR
:
pbuf
=
pdev
->
pDesc
->
GetSerialStrDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetSerialStrDescriptor
(
pdev
,
&
len
);
break
;
case
USBD_IDX_CONFIG_STR
:
pbuf
=
pdev
->
pDesc
->
GetConfigurationStrDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetConfigurationStrDescriptor
(
pdev
,
&
len
);
break
;
case
USBD_IDX_INTERFACE_STR
:
pbuf
=
pdev
->
pDesc
->
GetInterfaceStrDescriptor
(
pdev
->
dev_speed
,
&
len
);
pbuf
=
pdev
->
pDesc
->
GetInterfaceStrDescriptor
(
pdev
,
&
len
);
break
;
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment