@@ -58,7 +58,7 @@ bool USBDevice::requestGetDescriptor(void)
58
58
printf (" device descr\r\n " );
59
59
#endif
60
60
transfer.remaining = DEVICE_DESCRIPTOR_LENGTH;
61
- transfer.ptr = deviceDesc ();
61
+ transfer.ptr = ( uint8_t *) deviceDesc ();
62
62
transfer.direction = DEVICE_TO_HOST;
63
63
success = true ;
64
64
}
@@ -77,7 +77,7 @@ bool USBDevice::requestGetDescriptor(void)
77
77
transfer.remaining = configurationDesc ()[2 ] \
78
78
| (configurationDesc ()[3 ] << 8 );
79
79
80
- transfer.ptr = configurationDesc ();
80
+ transfer.ptr = ( uint8_t *) configurationDesc ();
81
81
transfer.direction = DEVICE_TO_HOST;
82
82
success = true ;
83
83
}
@@ -94,7 +94,7 @@ bool USBDevice::requestGetDescriptor(void)
94
94
printf (" 1\r\n " );
95
95
#endif
96
96
transfer.remaining = stringLangidDesc ()[0 ];
97
- transfer.ptr = stringLangidDesc ();
97
+ transfer.ptr = ( uint8_t *) stringLangidDesc ();
98
98
transfer.direction = DEVICE_TO_HOST;
99
99
success = true ;
100
100
break ;
@@ -103,7 +103,7 @@ bool USBDevice::requestGetDescriptor(void)
103
103
printf (" 2\r\n " );
104
104
#endif
105
105
transfer.remaining = stringImanufacturerDesc ()[0 ];
106
- transfer.ptr = stringImanufacturerDesc ();
106
+ transfer.ptr = ( uint8_t *) stringImanufacturerDesc ();
107
107
transfer.direction = DEVICE_TO_HOST;
108
108
success = true ;
109
109
break ;
@@ -112,7 +112,7 @@ bool USBDevice::requestGetDescriptor(void)
112
112
printf (" 3\r\n " );
113
113
#endif
114
114
transfer.remaining = stringIproductDesc ()[0 ];
115
- transfer.ptr = stringIproductDesc ();
115
+ transfer.ptr = ( uint8_t *) stringIproductDesc ();
116
116
transfer.direction = DEVICE_TO_HOST;
117
117
success = true ;
118
118
break ;
@@ -121,7 +121,7 @@ bool USBDevice::requestGetDescriptor(void)
121
121
printf (" 4\r\n " );
122
122
#endif
123
123
transfer.remaining = stringIserialDesc ()[0 ];
124
- transfer.ptr = stringIserialDesc ();
124
+ transfer.ptr = ( uint8_t *) stringIserialDesc ();
125
125
transfer.direction = DEVICE_TO_HOST;
126
126
success = true ;
127
127
break ;
@@ -130,7 +130,7 @@ bool USBDevice::requestGetDescriptor(void)
130
130
printf (" 5\r\n " );
131
131
#endif
132
132
transfer.remaining = stringIConfigurationDesc ()[0 ];
133
- transfer.ptr = stringIConfigurationDesc ();
133
+ transfer.ptr = ( uint8_t *) stringIConfigurationDesc ();
134
134
transfer.direction = DEVICE_TO_HOST;
135
135
success = true ;
136
136
break ;
@@ -139,7 +139,7 @@ bool USBDevice::requestGetDescriptor(void)
139
139
printf (" 6\r\n " );
140
140
#endif
141
141
transfer.remaining = stringIinterfaceDesc ()[0 ];
142
- transfer.ptr = stringIinterfaceDesc ();
142
+ transfer.ptr = ( uint8_t *) stringIinterfaceDesc ();
143
143
transfer.direction = DEVICE_TO_HOST;
144
144
success = true ;
145
145
break ;
@@ -790,7 +790,7 @@ uint8_t * USBDevice::findDescriptor(uint8_t descriptorType)
790
790
}
791
791
792
792
/* Start at first descriptor after the configuration descriptor */
793
- ptr = &(configurationDesc ()[CONFIGURATION_DESCRIPTOR_LENGTH]);
793
+ ptr = &((( uint8_t *) configurationDesc () )[CONFIGURATION_DESCRIPTOR_LENGTH]);
794
794
795
795
do {
796
796
if (ptr[1 ] /* bDescriptorType */ == descriptorType)
@@ -926,8 +926,8 @@ bool USBDevice::readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, u
926
926
927
927
928
928
929
- uint8_t * USBDevice::deviceDesc () {
930
- static uint8_t deviceDescriptor [] = {
929
+ const uint8_t * USBDevice::deviceDesc () {
930
+ uint8_t deviceDescriptorTemp [] = {
931
931
DEVICE_DESCRIPTOR_LENGTH, /* bLength */
932
932
DEVICE_DESCRIPTOR, /* bDescriptorType */
933
933
LSB (USB_VERSION_2_0), /* bcdUSB (LSB) */
@@ -947,56 +947,58 @@ uint8_t * USBDevice::deviceDesc() {
947
947
STRING_OFFSET_ISERIAL, /* iSerialNumber */
948
948
0x01 /* bNumConfigurations */
949
949
};
950
+ MBED_ASSERT (sizeof (deviceDescriptorTemp) == sizeof (deviceDescriptor));
951
+ memcpy (deviceDescriptor, deviceDescriptorTemp, sizeof (deviceDescriptor));
950
952
return deviceDescriptor;
951
953
}
952
954
953
- uint8_t * USBDevice::stringLangidDesc () {
954
- static uint8_t stringLangidDescriptor[] = {
955
+ const uint8_t * USBDevice::stringLangidDesc () {
956
+ static const uint8_t stringLangidDescriptor[] = {
955
957
0x04 , /* bLength*/
956
958
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
957
959
0x09 ,0x04 , /* bString Lang ID - 0x0409 - English*/
958
960
};
959
- return stringLangidDescriptor;
961
+ return ( uint8_t *) stringLangidDescriptor;
960
962
}
961
963
962
- uint8_t * USBDevice::stringImanufacturerDesc () {
963
- static uint8_t stringImanufacturerDescriptor[] = {
964
+ const uint8_t * USBDevice::stringImanufacturerDesc () {
965
+ static const uint8_t stringImanufacturerDescriptor[] = {
964
966
0x12 , /* bLength*/
965
967
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
966
968
' m' ,0 ,' b' ,0 ,' e' ,0 ,' d' ,0 ,' .' ,0 ,' o' ,0 ,' r' ,0 ,' g' ,0 , /* bString iManufacturer - mbed.org*/
967
969
};
968
970
return stringImanufacturerDescriptor;
969
971
}
970
972
971
- uint8_t * USBDevice::stringIserialDesc () {
972
- static uint8_t stringIserialDescriptor[] = {
973
+ const uint8_t * USBDevice::stringIserialDesc () {
974
+ static const uint8_t stringIserialDescriptor[] = {
973
975
0x16 , /* bLength*/
974
976
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
975
977
' 0' ,0 ,' 1' ,0 ,' 2' ,0 ,' 3' ,0 ,' 4' ,0 ,' 5' ,0 ,' 6' ,0 ,' 7' ,0 ,' 8' ,0 ,' 9' ,0 , /* bString iSerial - 0123456789*/
976
978
};
977
979
return stringIserialDescriptor;
978
980
}
979
981
980
- uint8_t * USBDevice::stringIConfigurationDesc () {
981
- static uint8_t stringIconfigurationDescriptor[] = {
982
+ const uint8_t * USBDevice::stringIConfigurationDesc () {
983
+ static const uint8_t stringIconfigurationDescriptor[] = {
982
984
0x06 , /* bLength*/
983
985
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
984
986
' 0' ,0 ,' 1' ,0 , /* bString iConfiguration - 01*/
985
987
};
986
988
return stringIconfigurationDescriptor;
987
989
}
988
990
989
- uint8_t * USBDevice::stringIinterfaceDesc () {
990
- static uint8_t stringIinterfaceDescriptor[] = {
991
+ const uint8_t * USBDevice::stringIinterfaceDesc () {
992
+ static const uint8_t stringIinterfaceDescriptor[] = {
991
993
0x08 , /* bLength*/
992
994
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
993
995
' U' ,0 ,' S' ,0 ,' B' ,0 , /* bString iInterface - USB*/
994
996
};
995
997
return stringIinterfaceDescriptor;
996
998
}
997
999
998
- uint8_t * USBDevice::stringIproductDesc () {
999
- static uint8_t stringIproductDescriptor[] = {
1000
+ const uint8_t * USBDevice::stringIproductDesc () {
1001
+ static const uint8_t stringIproductDescriptor[] = {
1000
1002
0x16 , /* bLength*/
1001
1003
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
1002
1004
' U' ,0 ,' S' ,0 ,' B' ,0 ,' ' ,0 ,' D' ,0 ,' E' ,0 ,' V' ,0 ,' I' ,0 ,' C' ,0 ,' E' ,0 /* bString iProduct - USB DEVICE*/
0 commit comments