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 Orefatoi

util/DebugIO.hpp

Committer:
wataloh
Date:
2017-06-09
Revision:
21:d03c7bbb9f37
Parent:
9:4d5ecf38636e

File content as of revision 21:d03c7bbb9f37:

#ifndef _MARUSOL_DEBUG_IO_HPP_
#define _MARUSOL_DEBUG_IO_HPP_

#if defined (TARGET_TEENSY3_1)
    #include "USBSerial.h"
#else
    #include "mbed.h"
#endif

#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
{
#if defined (TARGET_KL25Z)
    static Serial *debugIO;
#elif defined (TARGET_TEENSY3_1)
    static USBSerial *debugIO;
#endif
};

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(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",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_