pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
util/DebugIO.hpp@2:dfe671e31221, 2017-01-24 (annotated)
- Committer:
- wataloh
- Date:
- Tue Jan 24 10:00:28 2017 +0000
- Revision:
- 2:dfe671e31221
- Child:
- 5:9d5c7ee80f3b
latest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 2:dfe671e31221 | 1 | #ifndef _MARUSOL_DEBUG_IO_HPP_ |
wataloh | 2:dfe671e31221 | 2 | #define _MARUSOL_DEBUG_IO_HPP_ |
wataloh | 2:dfe671e31221 | 3 | #if 0 |
wataloh | 2:dfe671e31221 | 4 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 2:dfe671e31221 | 5 | #include "USBSerial.h" |
wataloh | 2:dfe671e31221 | 6 | #endif |
wataloh | 2:dfe671e31221 | 7 | |
wataloh | 2:dfe671e31221 | 8 | namespace MaruSolSensorManager |
wataloh | 2:dfe671e31221 | 9 | { |
wataloh | 2:dfe671e31221 | 10 | template<type A> class debug_io_singleton |
wataloh | 2:dfe671e31221 | 11 | { |
wataloh | 2:dfe671e31221 | 12 | protected: |
wataloh | 2:dfe671e31221 | 13 | static A *self; |
wataloh | 2:dfe671e31221 | 14 | public: |
wataloh | 2:dfe671e31221 | 15 | static A* getInstance() |
wataloh | 2:dfe671e31221 | 16 | { |
wataloh | 2:dfe671e31221 | 17 | return self!=NULL ? self : new A(); |
wataloh | 2:dfe671e31221 | 18 | } |
wataloh | 2:dfe671e31221 | 19 | static void destroy() |
wataloh | 2:dfe671e31221 | 20 | { |
wataloh | 2:dfe671e31221 | 21 | if(self!=NULL) |
wataloh | 2:dfe671e31221 | 22 | { |
wataloh | 2:dfe671e31221 | 23 | delete self; |
wataloh | 2:dfe671e31221 | 24 | self = NULL; |
wataloh | 2:dfe671e31221 | 25 | } |
wataloh | 2:dfe671e31221 | 26 | } |
wataloh | 2:dfe671e31221 | 27 | }; |
wataloh | 2:dfe671e31221 | 28 | |
wataloh | 2:dfe671e31221 | 29 | template<> A debug_io_singleton<A>::self = NULL; |
wataloh | 2:dfe671e31221 | 30 | |
wataloh | 2:dfe671e31221 | 31 | class DebugIO : public debug_io_singleton<DebugIO> |
wataloh | 2:dfe671e31221 | 32 | { |
wataloh | 2:dfe671e31221 | 33 | #if defined (TARGET_KL25Z) |
wataloh | 2:dfe671e31221 | 34 | Serial *debugIO; |
wataloh | 2:dfe671e31221 | 35 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 2:dfe671e31221 | 36 | USBSerial *debugIO; |
wataloh | 2:dfe671e31221 | 37 | #endif |
wataloh | 2:dfe671e31221 | 38 | public: |
wataloh | 2:dfe671e31221 | 39 | friend class debug_io_singleton; |
wataloh | 2:dfe671e31221 | 40 | DebugIO::DebugIO() |
wataloh | 2:dfe671e31221 | 41 | { |
wataloh | 2:dfe671e31221 | 42 | if(PREFERENCES::DBG_ENABLED == true || PREFERENCES::DBG_ASR_ENABLED == true) |
wataloh | 2:dfe671e31221 | 43 | { |
wataloh | 2:dfe671e31221 | 44 | #if defined (TARGET_KL25Z) |
wataloh | 2:dfe671e31221 | 45 | debugIO = new Serial(); |
wataloh | 2:dfe671e31221 | 46 | debugIO->baud(PINS::UART::BAUD_RATE); |
wataloh | 2:dfe671e31221 | 47 | pPrintf = &DebugIO::printf; |
wataloh | 2:dfe671e31221 | 48 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 2:dfe671e31221 | 49 | debugIO = new USBSerial(); |
wataloh | 2:dfe671e31221 | 50 | #endif |
wataloh | 2:dfe671e31221 | 51 | } |
wataloh | 2:dfe671e31221 | 52 | else |
wataloh | 2:dfe671e31221 | 53 | { |
wataloh | 2:dfe671e31221 | 54 | pPrintf = &DebugIO::printfNOP; |
wataloh | 2:dfe671e31221 | 55 | } |
wataloh | 2:dfe671e31221 | 56 | } |
wataloh | 2:dfe671e31221 | 57 | enum MSG_TYPE |
wataloh | 2:dfe671e31221 | 58 | { |
wataloh | 2:dfe671e31221 | 59 | DBG = 0, |
wataloh | 2:dfe671e31221 | 60 | DBG_ASR_1, |
wataloh | 2:dfe671e31221 | 61 | INFO |
wataloh | 2:dfe671e31221 | 62 | }; |
wataloh | 2:dfe671e31221 | 63 | template <typename... Args> void (DebugIO::*pPrintf)(MSG_TYPE type, char *fmt, ...); |
wataloh | 2:dfe671e31221 | 64 | template <typename... Args> void printfNOP(MSG_TYPE type, char *fmt, Args... args) |
wataloh | 2:dfe671e31221 | 65 | { |
wataloh | 2:dfe671e31221 | 66 | |
wataloh | 2:dfe671e31221 | 67 | } |
wataloh | 2:dfe671e31221 | 68 | |
wataloh | 2:dfe671e31221 | 69 | template <class... Args> void f(Args... args); |
wataloh | 2:dfe671e31221 | 70 | |
wataloh | 2:dfe671e31221 | 71 | template <typename... Args> printf(MSG_TYPE type, char *fmt, Args... args) |
wataloh | 2:dfe671e31221 | 72 | { |
wataloh | 2:dfe671e31221 | 73 | |
wataloh | 2:dfe671e31221 | 74 | debugIO->printf(type,fmt,args...); |
wataloh | 2:dfe671e31221 | 75 | |
wataloh | 2:dfe671e31221 | 76 | if(type == MSG_TYPE::DBG || PREFERENCES::DBG_ENABLED == true) |
wataloh | 2:dfe671e31221 | 77 | { |
wataloh | 2:dfe671e31221 | 78 | |
wataloh | 2:dfe671e31221 | 79 | } |
wataloh | 2:dfe671e31221 | 80 | } |
wataloh | 2:dfe671e31221 | 81 | template <typename... Args> print_dbg(char* fmt, Args... args) |
wataloh | 2:dfe671e31221 | 82 | { |
wataloh | 2:dfe671e31221 | 83 | this->printf(DBG, fmt,args...); |
wataloh | 2:dfe671e31221 | 84 | } |
wataloh | 2:dfe671e31221 | 85 | template <typename... Args> print_dbg_asr(char* fmt, Args... args) |
wataloh | 2:dfe671e31221 | 86 | { |
wataloh | 2:dfe671e31221 | 87 | this->printf(DBG_ASR, fmt,args...); |
wataloh | 2:dfe671e31221 | 88 | } |
wataloh | 2:dfe671e31221 | 89 | }; |
wataloh | 2:dfe671e31221 | 90 | }; |
wataloh | 2:dfe671e31221 | 91 | #endif |
wataloh | 2:dfe671e31221 | 92 | #endif //_MARUSOL_DEBUG_IO_HPP_ |