aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/PluggableUSB.cpp
diff options
context:
space:
mode:
authorMartino Facchin <m.facchin@arduino.cc>2015-10-01 17:35:26 +0200
committerCristian Maglie <c.maglie@arduino.cc>2015-10-02 11:59:24 +0200
commit8cab209ef91cbda34bae8afa880f152c4f1473b0 (patch)
tree8dd9e1d4a4ded2f4de3c578d60502e0a3e6fda89 /cores/arduino/PluggableUSB.cpp
parent66d3eabe42fa4590b111d3fe8442c0e556acedcd (diff)
[PUSB] Fix static initialization order fiasco
For details see: https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use
Diffstat (limited to 'cores/arduino/PluggableUSB.cpp')
-rw-r--r--cores/arduino/PluggableUSB.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/cores/arduino/PluggableUSB.cpp b/cores/arduino/PluggableUSB.cpp
index acc6276..582379a 100644
--- a/cores/arduino/PluggableUSB.cpp
+++ b/cores/arduino/PluggableUSB.cpp
@@ -25,8 +25,6 @@
extern uint8_t _initEndpoints[];
-PluggableUSB_ PluggableUSB;
-
int PluggableUSB_::getInterface(uint8_t* interfaceNum)
{
int sent = 0;
@@ -90,6 +88,12 @@ bool PluggableUSB_::plug(PUSBListNode *node)
// restart USB layer???
}
+PluggableUSB_& PluggableUSB()
+{
+ static PluggableUSB_ obj;
+ return obj;
+}
+
PluggableUSB_::PluggableUSB_() : lastIf(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT),
lastEp(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT),
rootNode(NULL)