diff --git a/inc/MicroBit.h b/inc/MicroBit.h index 9bf02b8..157622c 100644 --- a/inc/MicroBit.h +++ b/inc/MicroBit.h @@ -58,6 +58,9 @@ class MicroBit public: + // Serial Interface + MicroBitSerial serial; + // Reset Button InterruptIn resetButton; @@ -67,9 +70,6 @@ class MicroBit // I2C Interface MicroBitI2C i2c; - // Serial Interface - MicroBitSerial serial; - // Device level Message Bus abstraction MicroBitMessageBus messageBus; diff --git a/source/MicroBit.cpp b/source/MicroBit.cpp index 7d03dff..c981f23 100644 --- a/source/MicroBit.cpp +++ b/source/MicroBit.cpp @@ -22,6 +22,10 @@ #pragma GCC diagnostic pop #endif +#if CONFIG_ENABLED(MICROBIT_DBG) +// We create and initialize to NULL here, but MicroBitSerial will automatically update this as needed in its constructor. +RawSerial* SERIAL_DEBUG = NULL; +#endif /** * Constructor. @@ -43,10 +47,10 @@ * @endcode */ MicroBit::MicroBit() : + serial(USBTX, USBRX), resetButton(MICROBIT_PIN_BUTTON_RESET), storage(), i2c(I2C_SDA0, I2C_SCL0), - serial(USBTX, USBRX), messageBus(), display(), buttonA(MICROBIT_PIN_BUTTON_A, MICROBIT_ID_BUTTON_A), @@ -201,3 +205,4 @@ void MicroBit::onListenerRegisteredEvent(MicroBitEvent evt) } } +