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.
master
Joe Finney 7 years ago
parent 7a0c5bfdd3
commit 81a3f9c984

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

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

Loading…
Cancel
Save