@@ -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 ;
@@ -771,7 +771,7 @@ uint8_t * USBDevice::findDescriptor(uint8_t descriptorType)
771
771
}
772
772
773
773
/* Start at first descriptor after the configuration descriptor */
774
- ptr = &(configurationDesc ()[CONFIGURATION_DESCRIPTOR_LENGTH]);
774
+ ptr = &((( uint8_t *) configurationDesc () )[CONFIGURATION_DESCRIPTOR_LENGTH]);
775
775
776
776
do {
777
777
if (ptr[1 ] /* bDescriptorType */ == descriptorType)
@@ -907,8 +907,8 @@ bool USBDevice::readEP_NB(uint8_t endpoint, uint8_t * buffer, uint32_t * size, u
907
907
908
908
909
909
910
- uint8_t * USBDevice::deviceDesc () {
911
- static uint8_t deviceDescriptor [] = {
910
+ const uint8_t * USBDevice::deviceDesc () {
911
+ uint8_t deviceDescriptorTemp [] = {
912
912
DEVICE_DESCRIPTOR_LENGTH, /* bLength */
913
913
DEVICE_DESCRIPTOR, /* bDescriptorType */
914
914
LSB (USB_VERSION_2_0), /* bcdUSB (LSB) */
@@ -928,56 +928,58 @@ uint8_t * USBDevice::deviceDesc() {
928
928
STRING_OFFSET_ISERIAL, /* iSerialNumber */
929
929
0x01 /* bNumConfigurations */
930
930
};
931
+ MBED_ASSERT (sizeof (deviceDescriptorTemp) == sizeof (deviceDescriptor));
932
+ memcpy (deviceDescriptor, deviceDescriptorTemp, sizeof (deviceDescriptor));
931
933
return deviceDescriptor;
932
934
}
933
935
934
- uint8_t * USBDevice::stringLangidDesc () {
935
- static uint8_t stringLangidDescriptor[] = {
936
+ const uint8_t * USBDevice::stringLangidDesc () {
937
+ static const uint8_t stringLangidDescriptor[] = {
936
938
0x04 , /* bLength*/
937
939
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
938
940
0x09 ,0x04 , /* bString Lang ID - 0x0409 - English*/
939
941
};
940
- return stringLangidDescriptor;
942
+ return ( uint8_t *) stringLangidDescriptor;
941
943
}
942
944
943
- uint8_t * USBDevice::stringImanufacturerDesc () {
944
- static uint8_t stringImanufacturerDescriptor[] = {
945
+ const uint8_t * USBDevice::stringImanufacturerDesc () {
946
+ static const uint8_t stringImanufacturerDescriptor[] = {
945
947
0x12 , /* bLength*/
946
948
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
947
949
' m' ,0 ,' b' ,0 ,' e' ,0 ,' d' ,0 ,' .' ,0 ,' o' ,0 ,' r' ,0 ,' g' ,0 , /* bString iManufacturer - mbed.org*/
948
950
};
949
951
return stringImanufacturerDescriptor;
950
952
}
951
953
952
- uint8_t * USBDevice::stringIserialDesc () {
953
- static uint8_t stringIserialDescriptor[] = {
954
+ const uint8_t * USBDevice::stringIserialDesc () {
955
+ static const uint8_t stringIserialDescriptor[] = {
954
956
0x16 , /* bLength*/
955
957
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
956
958
' 0' ,0 ,' 1' ,0 ,' 2' ,0 ,' 3' ,0 ,' 4' ,0 ,' 5' ,0 ,' 6' ,0 ,' 7' ,0 ,' 8' ,0 ,' 9' ,0 , /* bString iSerial - 0123456789*/
957
959
};
958
960
return stringIserialDescriptor;
959
961
}
960
962
961
- uint8_t * USBDevice::stringIConfigurationDesc () {
962
- static uint8_t stringIconfigurationDescriptor[] = {
963
+ const uint8_t * USBDevice::stringIConfigurationDesc () {
964
+ static const uint8_t stringIconfigurationDescriptor[] = {
963
965
0x06 , /* bLength*/
964
966
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
965
967
' 0' ,0 ,' 1' ,0 , /* bString iConfiguration - 01*/
966
968
};
967
969
return stringIconfigurationDescriptor;
968
970
}
969
971
970
- uint8_t * USBDevice::stringIinterfaceDesc () {
971
- static uint8_t stringIinterfaceDescriptor[] = {
972
+ const uint8_t * USBDevice::stringIinterfaceDesc () {
973
+ static const uint8_t stringIinterfaceDescriptor[] = {
972
974
0x08 , /* bLength*/
973
975
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
974
976
' U' ,0 ,' S' ,0 ,' B' ,0 , /* bString iInterface - USB*/
975
977
};
976
978
return stringIinterfaceDescriptor;
977
979
}
978
980
979
- uint8_t * USBDevice::stringIproductDesc () {
980
- static uint8_t stringIproductDescriptor[] = {
981
+ const uint8_t * USBDevice::stringIproductDesc () {
982
+ static const uint8_t stringIproductDescriptor[] = {
981
983
0x16 , /* bLength*/
982
984
STRING_DESCRIPTOR, /* bDescriptorType 0x03*/
983
985
' 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