Skip to content

Commit 49a7fdc

Browse files
committed
【提升】字符串输出效率。
Signed-off-by: armink <[email protected]>
1 parent 7e76504 commit 49a7fdc

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

port/mpconfigport.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ typedef unsigned mp_uint_t; // must be pointer size
286286

287287
typedef long mp_off_t;
288288

289-
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
289+
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_stream(str, len)
290290

291-
#define MICROPY_PY_SYS_PLATFORM "rt-thread"
292-
#define MICROPY_HW_BOARD_NAME "Universal python platform"
293-
#define MICROPY_HW_MCU_NAME "RT-Thread"
294-
#define MICROPY_PY_PATH "/libs/mpy/"
291+
#define MICROPY_PY_SYS_PLATFORM "rt-thread"
292+
#define MICROPY_HW_BOARD_NAME "Universal python platform"
293+
#define MICROPY_HW_MCU_NAME "RT-Thread"
294+
#define MICROPY_PY_PATH "/libs/mpy/"
295295

296296
#define MICROPY_BEGIN_ATOMIC_SECTION() rt_hw_interrupt_disable()
297297
#define MICROPY_END_ATOMIC_SECTION(state) rt_hw_interrupt_enable(state)

port/mphalport.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
5656
}
5757
}
5858

59+
void mp_hal_stdout_tx_strn_stream(const char *str, size_t len) {
60+
rt_kprintf("%.*s", len, str);
61+
}
62+
5963
mp_uint_t mp_hal_ticks_us(void) {
6064
return rt_tick_get() * 1000000UL / RT_TICK_PER_SECOND;
6165
}

port/mphalport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
extern void mp_hal_set_interrupt_char (int c);
3333
extern void mp_pin_od_write(void *machine_pin, int stat);
3434
extern void mp_hal_pin_open_set(void *machine_pin, int mode);
35+
extern void mp_hal_stdout_tx_strn_stream(const char *str, size_t len);
3536

3637
#define mp_hal_quiet_timing_enter() MICROPY_BEGIN_ATOMIC_SECTION()
3738
#define mp_hal_quiet_timing_exit(irq_state) MICROPY_END_ATOMIC_SECTION(irq_state)

0 commit comments

Comments
 (0)