microbit: Automatic defining of SERIAL_DEBUG symbol

Added support for automatic creation and assignment of the SERIAL_DEBUG symbol
when MICORBIT_DBG is enabled in MicroBitConfig.h

Also reordered the MicroBit constructor to bring up the serial object before
all other objects, to enable debugging of all code.
This commit is contained in:
Joe Finney 2016-03-26 17:11:35 +00:00
parent 7a0c5bfdd3
commit 81a3f9c984
2 changed files with 9 additions and 4 deletions

View file

@ -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;

View file

@ -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)
}
}