Skip to content

Commit 35abe4f

Browse files
committed
Made USP-API included flexible
1 parent 60e64cf commit 35abe4f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Diff for: hardware/arduino/avr/cores/arduino/USBAPI.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class USBDevice_
6767
bool wakeupHost(); // returns false, when wakeup cannot be processed
6868
};
6969
extern USBDevice_ USBDevice;
70+
void setupUSB();
7071

7172
//================================================================================
7273
//================================================================================

Diff for: hardware/arduino/avr/cores/arduino/USBCore.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -828,4 +828,8 @@ bool USBDevice_::wakeupHost()
828828
return false;
829829
}
830830

831+
void setupUSB() {
832+
USBDevice.attach();
833+
}
834+
831835
#endif /* if defined(USBCON) */

Diff for: hardware/arduino/avr/cores/arduino/main.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ void initVariant() __attribute__((weak));
2828
void initVariant() { }
2929

3030
void setupUSB() __attribute__((weak));
31-
void setupUSB() { }
31+
void setupUSB() {
32+
#if MAGIC_KEY_POS != (RAMEND-1)
33+
USBDevice.attach();
34+
#endif
35+
}
3236

3337
int main(void)
3438
{
3539
init();
3640

3741
initVariant();
3842

39-
#if defined(USBCON)
40-
USBDevice.attach();
41-
#endif
43+
setupUSB();
4244

4345
setup();
4446

0 commit comments

Comments
 (0)