Skip to content

Commit 25f44c1

Browse files
committed
cc3200: Re-add support for UART REPL (MICROPY_STDIO_UART setting).
UART REPL support was lost in os.dupterm() refactorings, etc. As os.dupterm() is there, implement UART REPL support at the high level - if MICROPY_STDIO_UART is set, make default boot.py contain os.dupterm() call for a UART. This means that changing MICROPY_STDIO_UART value will also require erasing flash on a module to force boot.py re-creation.
1 parent cf96be6 commit 25f44c1

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

cc3200/mptask.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ static FATFS *sflash_fatfs;
9898

9999
static const char fresh_main_py[] = "# main.py -- put your code here!\r\n";
100100
static const char fresh_boot_py[] = "# boot.py -- run on boot-up\r\n"
101-
"# can run arbitrary Python, but best to keep it minimal\r\n";
101+
"# can run arbitrary Python, but best to keep it minimal\r\n"
102+
#if MICROPY_STDIO_UART
103+
"import os, machine\r\n"
104+
"os.dupterm(machine.UART(0, " MP_STRINGIFY(MICROPY_STDIO_UART_BAUD) "))\r\n"
105+
#endif
106+
;
102107

103108
/******************************************************************************
104109
DECLARE PUBLIC FUNCTIONS

py/misc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ typedef unsigned int uint;
4646
#define MAX(x, y) ((x) > (y) ? (x) : (y))
4747
#endif
4848

49+
// Classical double-indirection stringification of preprocessor macro's value
50+
#define _MP_STRINGIFY(x) #x
51+
#define MP_STRINGIFY(x) _MP_STRINGIFY(x)
52+
4953
/** memory allocation ******************************************/
5054

5155
// TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)

0 commit comments

Comments
 (0)