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.
Fork of System_7_14 by
StaticDefs.cpp@0:45085dd174e7, 2017-04-27 (annotated)
- Committer:
- tzyoung
- Date:
- Thu Apr 27 13:16:07 2017 +0000
- Revision:
- 0:45085dd174e7
- Child:
- 1:e827d45c3948
initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tzyoung | 0:45085dd174e7 | 1 | #include "StaticDefs.hpp" |
tzyoung | 0:45085dd174e7 | 2 | |
tzyoung | 0:45085dd174e7 | 3 | //Declare static global variables using 'construct on use' idiom to ensure they are always constructed correctly |
tzyoung | 0:45085dd174e7 | 4 | // and avoid "static initialization order fiasco". |
tzyoung | 0:45085dd174e7 | 5 | |
tzyoung | 0:45085dd174e7 | 6 | Timer &systemTime() |
tzyoung | 0:45085dd174e7 | 7 | { |
tzyoung | 0:45085dd174e7 | 8 | static Timer s; |
tzyoung | 0:45085dd174e7 | 9 | return s; |
tzyoung | 0:45085dd174e7 | 10 | } |
tzyoung | 0:45085dd174e7 | 11 | |
tzyoung | 0:45085dd174e7 | 12 | Serial & pc() |
tzyoung | 0:45085dd174e7 | 13 | { |
tzyoung | 0:45085dd174e7 | 14 | //static MODSERIAL p(USBTX, USBRX, 512, 64); // tx, rx |
tzyoung | 0:45085dd174e7 | 15 | static Serial p(USBTX, USBRX); |
tzyoung | 0:45085dd174e7 | 16 | return p; |
tzyoung | 0:45085dd174e7 | 17 | } |
tzyoung | 0:45085dd174e7 | 18 | |
tzyoung | 0:45085dd174e7 | 19 | SpiADC & adc() |
tzyoung | 0:45085dd174e7 | 20 | { |
tzyoung | 0:45085dd174e7 | 21 | static SpiADC adc; |
tzyoung | 0:45085dd174e7 | 22 | return adc; |
tzyoung | 0:45085dd174e7 | 23 | } |
tzyoung | 0:45085dd174e7 | 24 | |
tzyoung | 0:45085dd174e7 | 25 | PosVelFilter & pvf() |
tzyoung | 0:45085dd174e7 | 26 | { |
tzyoung | 0:45085dd174e7 | 27 | static PosVelFilter pvf; |
tzyoung | 0:45085dd174e7 | 28 | return pvf; |
tzyoung | 0:45085dd174e7 | 29 | } |
tzyoung | 0:45085dd174e7 | 30 | |
tzyoung | 0:45085dd174e7 | 31 | BCEmotor & bce() |
tzyoung | 0:45085dd174e7 | 32 | { |
tzyoung | 0:45085dd174e7 | 33 | static BCEmotor bce(p26, p29, p30); |
tzyoung | 0:45085dd174e7 | 34 | return bce; |
tzyoung | 0:45085dd174e7 | 35 | } |
tzyoung | 0:45085dd174e7 | 36 | |
tzyoung | 0:45085dd174e7 | 37 | PositionController & posCon() |
tzyoung | 0:45085dd174e7 | 38 | { |
tzyoung | 0:45085dd174e7 | 39 | static PositionController posCon; |
tzyoung | 0:45085dd174e7 | 40 | return posCon; |
tzyoung | 0:45085dd174e7 | 41 | } |