Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MODSERIAL FATFileSystem
Diff: System/StaticDefs.cpp
- Revision:
- 45:16b8162188ca
- Child:
- 49:47ffa4feb6db
diff -r 01173b2cb466 -r 16b8162188ca System/StaticDefs.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/System/StaticDefs.cpp Thu Feb 15 02:39:13 2018 +0000
@@ -0,0 +1,134 @@
+#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;
+}
+
+Ticker & pulse() {
+ static Ticker pulse;
+ return pulse;
+}
+
+MODSERIAL & pc() {
+ static MODSERIAL pc(USBTX, USBRX);
+ //static MODSERIAL pc(p9, p10); //XBee tx, rx pins
+ return pc;
+}
+
+//MODSERIAL & xb() {
+// static MODSERIAL xb(p9, p10); //XBee tx, rx pins
+// return xb;
+//}
+
+
+//FIX THIS TO USE SPI data logger...
+
+MODSERIAL & datalogger() {
+ static MODSERIAL datalogger(p28, p27); //Data Logger tx, rx pins
+ return datalogger;
+}
+
+LocalFileSystem & local() {
+ static LocalFileSystem local("local");
+ return local;
+}
+
+SDFileSystem & sd_card() {
+ static SDFileSystem sd_card(p11, p12, p13, p14, "sd"); //SDFileSystem sd_card(MOSI, MISO, SCK, CS, "sd");
+ return sd_card;
+}
+
+SpiADC & adc() {
+ static SpiADC adc(p5,p6,p7,p8,LED2);
+ return adc;
+}
+
+LinearActuator & bce() {
+ static LinearActuator bce(0.01, p25, p29, p30, p18, 0); //interval , pwm, dir, reset, limit switch, adc channel
+ return bce;
+}
+
+LinearActuator & batt() {
+ static LinearActuator batt(0.01, p23, p21, p22, p17, 1); //interval , pwm, dir, reset, limit switchm, adc channel
+ return batt;
+}
+
+ServoDriver & servo() {
+ static ServoDriver servo(p24);
+ return servo;
+}
+
+
+omegaPX209 & depth() {
+ static omegaPX209 depth(p19); // pin
+ return depth;
+}
+
+IMU & imu() {
+ static IMU imu(p28, p27); // tx, rx pin
+ return imu;
+}
+
+OuterLoop & depthLoop() {
+ static OuterLoop depthLoop(0.1, 0); // interval, sensor type
+ return depthLoop;
+}
+
+OuterLoop & pitchLoop() {
+ static OuterLoop pitchLoop(0.1, 1); // interval, sensor type
+ return pitchLoop;
+}
+
+OuterLoop & rudderLoop() {
+ static OuterLoop rudderLoop(0.1, 2); // interval, sensor type
+ return rudderLoop;
+}
+
+StateMachine & stateMachine() {
+ static StateMachine stateMachine;
+ return stateMachine;
+}
+
+ConfigFileIO & configFileIO() {
+ static ConfigFileIO configFileIO;
+ return configFileIO;
+}
+
+SequenceController & sequenceController() {
+ static SequenceController sequenceController;
+ return sequenceController;
+}
+
+MbedLogger & mbedLogger() {
+ static MbedLogger mbedLogger("/local/"); //local file system
+ return mbedLogger;
+}
+
+MbedLogger & sdLogger() {
+ static MbedLogger sdLogger("/sd/");
+ return sdLogger;
+}
+
+DigitalOut & led1() {
+ static DigitalOut led1(LED1);
+ return led1;
+}
+
+DigitalOut & led2() {
+ static DigitalOut led2(LED2);
+ return led2;
+}
+
+DigitalOut & led3() {
+ static DigitalOut led3(LED3);
+ return led3;
+}
+
+DigitalOut & led4() {
+ static DigitalOut led4(LED4);
+ return led4;
+}
\ No newline at end of file