remove setupUSB weak hook and replace with global constructors

thanks @matthijskooijman
This commit is contained in:
Martino Facchin 2015-06-23 17:50:53 +00:00 committed by Cristian Maglie
parent 071323196d
commit e211f1ea76
7 changed files with 4 additions and 31 deletions

View File

@ -37,7 +37,6 @@ int main(void)
initVariant();
#if defined(USBCON)
setupUSB();
USBDevice.attach();
#endif

View File

@ -111,8 +111,7 @@ bool WEAK HID_Setup(Setup& setup, u8 i)
}
}
// to be called by begin(), will trigger USB disconnection and reconnection
int8_t HID_Plug(void)
HID_::HID_(void)
{
static uint8_t endpointType[1];
@ -137,17 +136,10 @@ int8_t HID_Plug(void)
D_HIDREPORT(getsizeof_hidReportDescriptor()),
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
};
return HID_ENDPOINT_INT;
}
HID_::HID_(void)
{
}
int HID_::begin(void)
{
return HID_Plug();
}
#endif /* if defined(USBCON) */

View File

@ -221,10 +221,6 @@ size_t getsizeof_hidReportDescriptor() {
return sizeof(_hidReportDescriptor);
}
void WEAK setupUSB() {
HID.begin();
}
uint8_t USBPutChar(uint8_t c);
// press() adds the specified key (printing, non-printing, or modifier)

View File

@ -39,10 +39,6 @@ ring_bufferMIDI midi_rx_buffer = {{0,0,0,0 }, 0, 0};
static MIDIDescriptor _midiInterface;
void WEAK setupUSB() {
MidiUSB.begin();
}
int8_t WEAK MIDI_GetInterface(uint8_t* interfaceNum)
{
interfaceNum[0] += 2; // uses 2
@ -171,9 +167,8 @@ void MIDI_::sendMIDI(midiEventPacket_t event)
write(data, 4);
}
int8_t MIDI_plug(void)
MIDI_::MIDI_(void)
{
static uint8_t endpointType[2];
endpointType[0] = EP_TYPE_BULK_OUT_MIDI; // MIDI_ENDPOINT_OUT
@ -210,13 +205,10 @@ int8_t MIDI_plug(void)
D_MIDI_JACK_EP(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN),USB_ENDPOINT_TYPE_BULK,512),
D_MIDI_AC_JACK_EP (1, 3)
};
return MIDI_ENDPOINT_IN;
}
int8_t MIDI_::begin()
{
return MIDI_plug();
}

View File

@ -26,6 +26,8 @@ class MIDI_
// private:
// RingBuffer *_midi_rx_buffer;
public:
MIDI_(void);
int8_t begin();
virtual uint32_t available(void);

View File

@ -66,10 +66,6 @@ Mouse_ Mouse;
//================================================================================
// Mouse
void WEAK setupUSB() {
HID.begin();
}
Mouse_::Mouse_(void) : _buttons(0)
{
}

View File

@ -91,10 +91,6 @@ size_t getsizeof_hidReportDescriptor() {
return sizeof(_hidReportDescriptor);
}
void WEAK setupUSB() {
HID.begin();
}
Mouse_ Mouse;
//================================================================================