FSG / System_

Fork of System_7_14 by Troy Holley

Revision:
0:45085dd174e7
Child:
1:e827d45c3948
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StaticDefs.cpp	Thu Apr 27 13:16:07 2017 +0000
@@ -0,0 +1,41 @@
+#include "StaticDefs.hpp"
+
+//Declare static global variables using 'construct on use' idiom to ensure they are always constructed correctly
+// and avoid "static initialization order fiasco".
+
+Timer &systemTime()
+{
+    static Timer s;
+    return s;
+}
+
+Serial & pc()
+{
+    //static MODSERIAL p(USBTX, USBRX, 512, 64); // tx, rx
+    static Serial p(USBTX, USBRX);
+    return p;
+}
+
+SpiADC & adc()
+{
+    static SpiADC adc;
+    return adc;
+}
+
+PosVelFilter  &   pvf()
+{
+    static PosVelFilter pvf;
+    return pvf;
+}
+
+BCEmotor & bce()
+{
+    static BCEmotor bce(p26, p29, p30);
+    return bce;
+}
+
+PositionController & posCon()
+{
+    static PositionController posCon;
+    return posCon;
+}