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
Diff: util/DebugIO.hpp
- Revision:
- 5:9d5c7ee80f3b
- Parent:
- 2:dfe671e31221
- Child:
- 6:88cc04eb613a
diff -r b38e09f24711 -r 9d5c7ee80f3b util/DebugIO.hpp --- a/util/DebugIO.hpp Wed Jan 25 08:20:47 2017 +0000 +++ b/util/DebugIO.hpp Tue Feb 28 02:09:06 2017 +0000 @@ -1,92 +1,65 @@ #ifndef _MARUSOL_DEBUG_IO_HPP_ #define _MARUSOL_DEBUG_IO_HPP_ -#if 0 -#elif defined (TARGET_TEENSY3_1) - #include "USBSerial.h" + +#if defined (TARGET_TEENSY3_1) + #include "USBSerial.h" +#else + #include "mbed.h" #endif -namespace MaruSolSensorManager +#include "Preferences.hpp" + +//#define SERIAL_PRINT_DBG_ON +#ifdef SERIAL_PRINT_DBG_ON + #define SERIAL_PRINT_DBG(...) (DebugIO::debugIO->printf(__VA_ARGS__)) + #define SERIAL_PRINT_DBG_FUNCNAME() (DebugIO::debugIO->printf("%s,%d,%s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__)) +#else + #define SERIAL_PRINT_DBG(...) + #define SERIAL_PRINT_DBG_FUNCNAME() +#endif //SERIAL_PRINT_DBG_ON + +//#define SERIAL_PRINT_DBG_ASR_ON +#ifdef SERIAL_PRINT_DBG_ASR_ON + #define SERIAL_PRINT_DBG_ASR(...) (DebugIO::debugIO->printf(__VA_ARGS__)) +#else + #define SERIAL_PRINT_DBG_ASR(...) +#endif //SERIAL_PRINT_DBG_ASR_ON + +template<typename A> struct template_debug_io { - template<type A> class debug_io_singleton - { - protected: - static A *self; - public: - static A* getInstance() - { - return self!=NULL ? self : new A(); - } - static void destroy() - { - if(self!=NULL) - { - delete self; - self = NULL; - } - } - }; - - template<> A debug_io_singleton<A>::self = NULL; - - class DebugIO : public debug_io_singleton<DebugIO> - { #if defined (TARGET_KL25Z) - Serial *debugIO; + static Serial *debugIO; #elif defined (TARGET_TEENSY3_1) - USBSerial *debugIO; -#endif - public: - friend class debug_io_singleton; - DebugIO::DebugIO() - { - if(PREFERENCES::DBG_ENABLED == true || PREFERENCES::DBG_ASR_ENABLED == true) - { -#if defined (TARGET_KL25Z) - debugIO = new Serial(); - debugIO->baud(PINS::UART::BAUD_RATE); - pPrintf = &DebugIO::printf; -#elif defined (TARGET_TEENSY3_1) - debugIO = new USBSerial(); + static USBSerial *debugIO; #endif - } - else - { - pPrintf = &DebugIO::printfNOP; - } - } - enum MSG_TYPE - { - DBG = 0, - DBG_ASR_1, - INFO - }; - template <typename... Args> void (DebugIO::*pPrintf)(MSG_TYPE type, char *fmt, ...); - template <typename... Args> void printfNOP(MSG_TYPE type, char *fmt, Args... args) - { - - } - - template <class... Args> void f(Args... args); - - template <typename... Args> printf(MSG_TYPE type, char *fmt, Args... args) - { - - debugIO->printf(type,fmt,args...); - - if(type == MSG_TYPE::DBG || PREFERENCES::DBG_ENABLED == true) - { - - } - } - template <typename... Args> print_dbg(char* fmt, Args... args) - { - this->printf(DBG, fmt,args...); - } - template <typename... Args> print_dbg_asr(char* fmt, Args... args) - { - this->printf(DBG_ASR, fmt,args...); - } - }; }; + +struct DebugIO : public template_debug_io<DebugIO> +{ + static void init() + { +#if defined(SERIAL_PRINT_DBG_ON) || defined(SERIAL_PRINT_DBG_ASR_ON) + #if defined (TARGET_KL25Z) + debugIO = new Serial(USBTX, USBRX); + debugIO->baud(MaruSolSensorManager::PINS::UART::BAUD_RATE); + #elif defined (TARGET_TEENSY3_1) + debugIO = new USBSerial(); + #endif #endif + } + static void test() + { + SERIAL_PRINT_DBG("%s\n","dbg"); + SERIAL_PRINT_DBG_FUNCNAME(); + SERIAL_PRINT_DBG_ASR("%s\n","dbg asr"); + SERIAL_PRINT_DBG("baud rate:%ld\n",MaruSolSensorManager::PINS::UART::BAUD_RATE); + } +}; + +#if defined (TARGET_KL25Z) + template<> Serial *template_debug_io<DebugIO>::debugIO = NULL; +#elif defined (TARGET_TEENSY3_1) + template<> USBSerial *template_debug_io<DebugIO>::debugIO = NULL; +#endif + #endif //_MARUSOL_DEBUG_IO_HPP_ \ No newline at end of file