Skip to content

Commit f67318a

Browse files
facchinmcmaglie
authored andcommitted
remove useless variables
1 parent 2aa2332 commit f67318a

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

hardware/arduino/avr/cores/arduino/PluggableUSB.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525

2626
#define MAX_MODULES 6
2727

28-
static u8 startIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT;
29-
static u8 firstEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT;
30-
3128
static u8 lastIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT;
3229
static u8 lastEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT;
3330

@@ -36,18 +33,18 @@ extern u8 _initEndpoints[];
3633
PUSBCallbacks cbs[MAX_MODULES];
3734
u8 modules_count = 0;
3835

39-
int PUSB_GetInterface(u8* interfaceNum)
36+
int8_t PUSB_GetInterface(u8* interfaceNum)
4037
{
41-
int ret = 0;
38+
int8_t ret = 0;
4239
for (u8 i=0; i<modules_count; i++) {
4340
ret = cbs[i].getInterface(interfaceNum);
4441
}
4542
return ret;
4643
}
4744

48-
int PUSB_GetDescriptor(int t)
45+
int8_t PUSB_GetDescriptor(int8_t t)
4946
{
50-
int ret = 0;
47+
int8_t ret = 0;
5148
for (u8 i=0; i<modules_count && ret == 0; i++) {
5249
ret = cbs[i].getDescriptor(t);
5350
}
@@ -63,7 +60,7 @@ bool PUSB_Setup(Setup& setup, u8 j)
6360
return ret;
6461
}
6562

66-
int PUSB_AddFunction(PUSBCallbacks *cb, u8* interface)
63+
int8_t PUSB_AddFunction(PUSBCallbacks *cb, u8* interface)
6764
{
6865
if (modules_count >= MAX_MODULES) {
6966
return 0;

hardware/arduino/avr/cores/arduino/PluggableUSB.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
typedef struct
2929
{
3030
bool (*setup)(Setup& setup, u8 i);
31-
int (*getInterface)(u8* interfaceNum);
32-
int (*getDescriptor)(int t);
33-
int numEndpoints;
31+
int8_t (*getInterface)(u8* interfaceNum);
32+
int8_t (*getDescriptor)(int8_t t);
33+
int8_t numEndpoints;
3434
u8 endpointType[6];
3535
} PUSBCallbacks;
3636

@@ -40,11 +40,11 @@ typedef struct
4040
u8 firstEndpoint;
4141
} PUSBReturn;
4242

43-
int PUSB_AddFunction(PUSBCallbacks *cb, u8 *interface);
43+
int8_t PUSB_AddFunction(PUSBCallbacks *cb, u8 *interface);
4444

45-
int PUSB_GetInterface(u8* interfaceNum);
45+
int8_t PUSB_GetInterface(u8* interfaceNum);
4646

47-
int PUSB_GetDescriptor(int t);
47+
int8_t PUSB_GetDescriptor(int8_t t);
4848

4949
bool PUSB_Setup(Setup& setup, u8 i);
5050

libraries/HID/HID.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Mouse_ Mouse;
2929
Keyboard_ Keyboard;
3030
HID_ HID;
3131

32+
static u8 HID_ENDPOINT_INT;
33+
3234
//================================================================================
3335
//================================================================================
3436

@@ -43,10 +45,6 @@ HID_ HID;
4345
#define RAWHID_RX_SIZE 64
4446

4547
static u8 HID_INTERFACE;
46-
static u8 HID_FIRST_ENDPOINT;
47-
static u8 HID_ENDPOINT_INT;
48-
49-
static PUSBCallbacks cb;
5048

5149
extern const u8 _hidReportDescriptor[] PROGMEM;
5250
const u8 _hidReportDescriptor[] = {
@@ -144,13 +142,13 @@ u8 _hid_idle = 1;
144142

145143
#define WEAK __attribute__ ((weak))
146144

147-
int WEAK HID_GetInterface(u8* interfaceNum)
145+
int8_t WEAK HID_GetInterface(u8* interfaceNum)
148146
{
149147
interfaceNum[0] += 1; // uses 1
150148
return USB_SendControl(0,&_hidInterface,sizeof(_hidInterface));
151149
}
152150

153-
int WEAK HID_GetDescriptor(int t)
151+
int8_t WEAK HID_GetDescriptor(int8_t t)
154152
{
155153
if (HID_REPORT_DESCRIPTOR_TYPE == t) {
156154
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
@@ -205,20 +203,16 @@ bool WEAK HID_Setup(Setup& setup, u8 i)
205203
}
206204

207205
// to be called by begin(), will trigger USB disconnection and reconnection
208-
int HID_Plug(void)
206+
int8_t HID_Plug(void)
209207
{
210-
u8 interface;
211-
u8 res;
208+
PUSBCallbacks cb;
212209

213210
cb.setup = &HID_Setup;
214211
cb.getInterface = &HID_GetInterface;
215212
cb.getDescriptor = &HID_GetDescriptor;
216213
cb.numEndpoints = 1;
217214
cb.endpointType[0] = EP_TYPE_INTERRUPT_IN;
218-
res = PUSB_AddFunction(&cb, &interface);
219-
HID_INTERFACE = interface;
220-
HID_FIRST_ENDPOINT = res;
221-
HID_ENDPOINT_INT = res;
215+
HID_ENDPOINT_INT = PUSB_AddFunction(&cb, &HID_INTERFACE);
222216

223217
_hidInterface =
224218
{
@@ -227,7 +221,7 @@ int HID_Plug(void)
227221
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
228222
};
229223

230-
return res;
224+
return HID_ENDPOINT_INT;
231225
}
232226

233227
HID_::HID_(void)

libraries/HID/HID.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ class HID_
129129
int begin(void);
130130
};
131131

132-
int HID_Plug(void);
133-
int HID_GetInterface(u8* interfaceNum);
134-
int HID_GetDescriptor(int t);
132+
int8_t HID_Plug(void);
133+
int8_t HID_GetInterface(u8* interfaceNum);
134+
int8_t HID_GetDescriptor(int8_t t);
135135
bool HID_Setup(Setup& setup, u8 i);
136136
void HID_SendReport(uint8_t id, const void* data, int len);
137137

0 commit comments

Comments
 (0)