Skip to content

Commit 7e3b59a

Browse files
committed
Made USP-API included flexible
1 parent 60e64cf commit 7e3b59a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
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

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ void initVariant() __attribute__((weak));
2828
void initVariant() { }
2929

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

3337
int main(void)
3438
{
@@ -37,9 +41,9 @@ int main(void)
3741
initVariant();
3842

3943
#if defined(USBCON)
40-
USBDevice.attach();
44+
setupUSB();
4145
#endif
42-
46+
4347
setup();
4448

4549
for (;;) {

0 commit comments

Comments
 (0)