Skip to content

Commit bf609ec

Browse files
committed
[USB] remove all warnings from SAM USB core
1 parent ddae105 commit bf609ec

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

Diff for: hardware/arduino/sam/cores/arduino/USB/USBAPI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ bool CDC_Setup(USBSetup& setup);
131131
void USBD_InitControl(int end);
132132
int USBD_SendControl(uint8_t flags, const void* d, uint32_t len);
133133
int USBD_RecvControl(void* d, uint32_t len);
134-
int USBD_SendInterfaces(void);
134+
uint8_t USBD_SendInterfaces(void);
135135
bool USBD_ClassInterfaceRequest(USBSetup& setup);
136136

137137

Diff for: hardware/arduino/sam/cores/arduino/USB/USBCore.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const DeviceDescriptor USB_DeviceDescriptor =
101101
const DeviceDescriptor USB_DeviceDescriptorA =
102102
D_DEVICE(0xEF,0x02,0x01,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
103103

104-
const DeviceDescriptor USB_DeviceQualifier =
104+
const QualifierDescriptor USB_DeviceQualifier =
105105
D_QUALIFIER(0x00,0x00,0x00,64,1);
106106

107107
//! 7.1.20 Test Mode Support
@@ -130,7 +130,7 @@ class LockEP
130130
{
131131
irqflags_t flags;
132132
public:
133-
LockEP(uint32_t ep) : flags(cpu_irq_save())
133+
LockEP(uint32_t ep __attribute__ ((unused))) : flags(cpu_irq_save())
134134
{
135135
}
136136
~LockEP()
@@ -219,8 +219,8 @@ uint32_t USBD_Send(uint32_t ep, const void* d, uint32_t len)
219219
return r;
220220
}
221221

222-
int _cmark;
223-
int _cend;
222+
uint16_t _cmark;
223+
uint16_t _cend;
224224

225225
void USBD_InitControl(int end)
226226
{
@@ -229,7 +229,7 @@ void USBD_InitControl(int end)
229229
}
230230

231231
// Clipped by _cmark/_cend
232-
int USBD_SendControl(uint8_t flags, const void* d, uint32_t len)
232+
int USBD_SendControl(uint8_t flags __attribute__ ((unused)), const void* d, uint32_t len)
233233
{
234234
const uint8_t* data = (const uint8_t*)d;
235235
uint32_t length = len;
@@ -302,7 +302,7 @@ bool USBD_ClassInterfaceRequest(USBSetup& setup)
302302
return false;
303303
}
304304

305-
int USBD_SendInterfaces(void)
305+
uint8_t USBD_SendInterfaces(void)
306306
{
307307
uint8_t interfaces = 0;
308308

@@ -318,7 +318,7 @@ int USBD_SendInterfaces(void)
318318
return interfaces;
319319
}
320320

321-
int USBD_SendOtherInterfaces(void)
321+
uint8_t USBD_SendOtherInterfaces(void)
322322
{
323323
uint8_t interfaces = 0;
324324

@@ -342,7 +342,7 @@ static bool USBD_SendConfiguration(int maxlen)
342342
// Count and measure interfaces
343343
USBD_InitControl(0);
344344
//TRACE_CORE(printf("=> USBD_SendConfiguration _cmark1=%d\r\n", _cmark);)
345-
int interfaces = USBD_SendInterfaces();
345+
uint8_t interfaces = USBD_SendInterfaces();
346346
//TRACE_CORE(printf("=> USBD_SendConfiguration _cmark2=%d\r\n", _cmark);)
347347
//TRACE_CORE(printf("=> USBD_SendConfiguration sizeof=%d\r\n", sizeof(ConfigDescriptor));)
348348

@@ -365,7 +365,7 @@ static bool USBD_SendOtherConfiguration(int maxlen)
365365
// Count and measure interfaces
366366
USBD_InitControl(0);
367367
//TRACE_CORE(printf("=> USBD_SendConfiguration _cmark1=%d\r\n", _cmark);)
368-
int interfaces = USBD_SendOtherInterfaces();
368+
uint8_t interfaces = USBD_SendOtherInterfaces();
369369
//TRACE_CORE(printf("=> USBD_SendConfiguration _cmark2=%d\r\n", _cmark);)
370370
//TRACE_CORE(printf("=> USBD_SendConfiguration sizeof=%d\r\n", sizeof(ConfigDescriptor));)
371371

Diff for: hardware/arduino/sam/cores/arduino/USB/USBCore.h

+15-3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ typedef struct {
149149
uint8_t maxPower;
150150
} ConfigDescriptor;
151151

152+
// Device Qualifier (only needed for USB2.0 devices)
153+
typedef struct {
154+
uint8_t bLength;
155+
uint8_t dtype;
156+
uint16_t bDescriptorType;
157+
uint8_t bDeviceClass;
158+
uint8_t bDeviceSubClass;
159+
uint8_t bDeviceProtocol;
160+
uint8_t bMaxPacketSize0;
161+
uint8_t bNumConfigurations;
162+
} QualifierDescriptor;
163+
152164
// String
153165

154166
// Interface
@@ -257,16 +269,16 @@ _Pragma("pack()")
257269
{ 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs }
258270

259271
#define D_CONFIG(_totalLength,_interfaces) \
260-
{ 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_SELF_POWERED, USB_CONFIG_POWER_MA(500) }
272+
{ 9, 2, (uint16_t)(_totalLength),_interfaces, 1, 0, USB_CONFIG_SELF_POWERED, USB_CONFIG_POWER_MA(500) }
261273

262274
#define D_OTHERCONFIG(_totalLength,_interfaces) \
263-
{ 9, 7, _totalLength,_interfaces, 1, 0, USB_CONFIG_SELF_POWERED, USB_CONFIG_POWER_MA(500) }
275+
{ 9, 7, (uint16_t)(_totalLength),_interfaces, 1, 0, USB_CONFIG_SELF_POWERED, USB_CONFIG_POWER_MA(500) }
264276

265277
#define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \
266278
{ 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 }
267279

268280
#define D_ENDPOINT(_addr,_attr,_packetSize, _interval) \
269-
{ 7, 5, _addr,_attr,_packetSize, _interval }
281+
{ 7, 5, (uint8_t)(_addr),_attr,_packetSize, _interval }
270282

271283
#define D_QUALIFIER(_class,_subClass,_proto,_packetSize0,_configs) \
272284
{ 10, 6, 0x200, _class,_subClass,_proto,_packetSize0,_configs }

0 commit comments

Comments
 (0)