Skip to content

Commit 454156e

Browse files
committed
remove useless variables
1 parent c787084 commit 454156e

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
@@ -24,9 +24,6 @@
2424

2525
#define MAX_MODULES 6
2626

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

@@ -35,18 +32,18 @@ extern u8 _initEndpoints[];
3532
PUSBCallbacks cbs[MAX_MODULES];
3633
u8 modules_count = 0;
3734

38-
int PUSB_GetInterface(u8* interfaceNum)
35+
int8_t PUSB_GetInterface(u8* interfaceNum)
3936
{
40-
int ret = 0;
37+
int8_t ret = 0;
4138
for (u8 i=0; i<modules_count; i++) {
4239
ret = cbs[i].getInterface(interfaceNum);
4340
}
4441
return ret;
4542
}
4643

47-
int PUSB_GetDescriptor(int t)
44+
int8_t PUSB_GetDescriptor(int8_t t)
4845
{
49-
int ret = 0;
46+
int8_t ret = 0;
5047
for (u8 i=0; i<modules_count && ret == 0; i++) {
5148
ret = cbs[i].getDescriptor(t);
5249
}
@@ -62,7 +59,7 @@ bool PUSB_Setup(Setup& setup, u8 j)
6259
return ret;
6360
}
6461

65-
int PUSB_AddFunction(PUSBCallbacks *cb, u8* interface)
62+
int8_t PUSB_AddFunction(PUSBCallbacks *cb, u8* interface)
6663
{
6764
if (modules_count >= MAX_MODULES) {
6865
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
@@ -127,9 +127,9 @@ class HID_
127127
int begin(void);
128128
};
129129

130-
int HID_Plug(void);
131-
int HID_GetInterface(u8* interfaceNum);
132-
int HID_GetDescriptor(int t);
130+
int8_t HID_Plug(void);
131+
int8_t HID_GetInterface(u8* interfaceNum);
132+
int8_t HID_GetDescriptor(int8_t t);
133133
bool HID_Setup(Setup& setup, u8 i);
134134
void HID_SendReport(uint8_t id, const void* data, int len);
135135

0 commit comments

Comments
 (0)