diff --git a/cc3200/mptask.c b/cc3200/mptask.c index eb673b08cf144d3fdca6c9b64379b68afc3d5936..3c34ceeca049a2081280f415fffcb14a4f143eb1 100644 --- a/cc3200/mptask.c +++ b/cc3200/mptask.c @@ -98,7 +98,12 @@ static FATFS *sflash_fatfs; static const char fresh_main_py[] = "# main.py -- put your code here!\r\n"; static const char fresh_boot_py[] = "# boot.py -- run on boot-up\r\n" - "# can run arbitrary Python, but best to keep it minimal\r\n"; + "# can run arbitrary Python, but best to keep it minimal\r\n" + #if MICROPY_STDIO_UART + "import os, machine\r\n" + "os.dupterm(machine.UART(0, " MP_STRINGIFY(MICROPY_STDIO_UART_BAUD) "))\r\n" + #endif + ; /****************************************************************************** DECLARE PUBLIC FUNCTIONS diff --git a/py/misc.h b/py/misc.h index 7584bc017655b3bdfb411b8c4bbd646da3d26030..146b9a8e4a57df893494eea7a35c71790d8f818a 100644 --- a/py/misc.h +++ b/py/misc.h @@ -46,6 +46,10 @@ typedef unsigned int uint; #define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif +// Classical double-indirection stringification of preprocessor macro's value +#define _MP_STRINGIFY(x) #x +#define MP_STRINGIFY(x) _MP_STRINGIFY(x) + /** memory allocation ******************************************/ // TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)