Skip to content

Commit e211f1e

Browse files
facchinmcmaglie
authored andcommitted
remove setupUSB weak hook and replace with global constructors
thanks @matthijskooijman
1 parent 0713231 commit e211f1e

File tree

7 files changed

+4
-31
lines changed

7 files changed

+4
-31
lines changed

hardware/arduino/avr/cores/arduino/main.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int main(void)
3737
initVariant();
3838

3939
#if defined(USBCON)
40-
setupUSB();
4140
USBDevice.attach();
4241
#endif
4342

libraries/HID/HID.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ bool WEAK HID_Setup(Setup& setup, u8 i)
111111
}
112112
}
113113

114-
// to be called by begin(), will trigger USB disconnection and reconnection
115-
int8_t HID_Plug(void)
114+
HID_::HID_(void)
116115
{
117116
static uint8_t endpointType[1];
118117

@@ -137,17 +136,10 @@ int8_t HID_Plug(void)
137136
D_HIDREPORT(getsizeof_hidReportDescriptor()),
138137
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
139138
};
140-
141-
return HID_ENDPOINT_INT;
142-
}
143-
144-
HID_::HID_(void)
145-
{
146139
}
147140

148141
int HID_::begin(void)
149142
{
150-
return HID_Plug();
151143
}
152144

153145
#endif /* if defined(USBCON) */

libraries/Keyboard/Keyboard.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ size_t getsizeof_hidReportDescriptor() {
221221
return sizeof(_hidReportDescriptor);
222222
}
223223

224-
void WEAK setupUSB() {
225-
HID.begin();
226-
}
227-
228224
uint8_t USBPutChar(uint8_t c);
229225

230226
// press() adds the specified key (printing, non-printing, or modifier)

libraries/MIDIUSB/MIDIUSB.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ ring_bufferMIDI midi_rx_buffer = {{0,0,0,0 }, 0, 0};
3939

4040
static MIDIDescriptor _midiInterface;
4141

42-
void WEAK setupUSB() {
43-
MidiUSB.begin();
44-
}
45-
4642
int8_t WEAK MIDI_GetInterface(uint8_t* interfaceNum)
4743
{
4844
interfaceNum[0] += 2; // uses 2
@@ -171,9 +167,8 @@ void MIDI_::sendMIDI(midiEventPacket_t event)
171167
write(data, 4);
172168
}
173169

174-
int8_t MIDI_plug(void)
170+
MIDI_::MIDI_(void)
175171
{
176-
177172
static uint8_t endpointType[2];
178173

179174
endpointType[0] = EP_TYPE_BULK_OUT_MIDI; // MIDI_ENDPOINT_OUT
@@ -210,13 +205,10 @@ int8_t MIDI_plug(void)
210205
D_MIDI_JACK_EP(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN),USB_ENDPOINT_TYPE_BULK,512),
211206
D_MIDI_AC_JACK_EP (1, 3)
212207
};
213-
214-
return MIDI_ENDPOINT_IN;
215208
}
216209

217210
int8_t MIDI_::begin()
218211
{
219-
return MIDI_plug();
220212
}
221213

222214

libraries/MIDIUSB/MIDIUSB.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class MIDI_
2626
// private:
2727
// RingBuffer *_midi_rx_buffer;
2828
public:
29+
MIDI_(void);
30+
2931
int8_t begin();
3032

3133
virtual uint32_t available(void);

libraries/Mouse/Mouse.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ Mouse_ Mouse;
6666
//================================================================================
6767
// Mouse
6868

69-
void WEAK setupUSB() {
70-
HID.begin();
71-
}
72-
7369
Mouse_::Mouse_(void) : _buttons(0)
7470
{
7571
}

libraries/MouseAndKeyboard/MouseAndKeyboard.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ size_t getsizeof_hidReportDescriptor() {
9191
return sizeof(_hidReportDescriptor);
9292
}
9393

94-
void WEAK setupUSB() {
95-
HID.begin();
96-
}
97-
9894
Mouse_ Mouse;
9995

10096
//================================================================================

0 commit comments

Comments
 (0)