Skip to content

Commit 42657b6

Browse files
committed
Merge branch 'master' of github.com:CXSforHPU/rt-thread
2 parents 4dda6bf + aa79cd8 commit 42657b6

7 files changed

Lines changed: 136 additions & 285 deletions

File tree

bsp/stm32/stm32u575-st-nucleo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**English** | [中文](README_zh.md)
44

5-
## MCU: STM32U575ZI @110MHz, 2048 KB FLASH, 786 KB RAM
5+
## MCU: STM32U575ZI @160MHz, 2048 KB FLASH, 786 KB RAM
66

77
The STM32U575xx devices belong to an ultra-low-power microcontrollers family (STM32U5 Series) based on the high-performance Arm® Cortex®-M33 32-bit RISC core. They operate at a frequency of up to 160 MHz.
88

bsp/stm32/stm32u585-iot02a/README.md

Lines changed: 62 additions & 273 deletions
Large diffs are not rendered by default.

bsp/stm32/stm32u585-iot02a/README_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 第一部分:NUCLEO-U575ZI-Q 开发板 BSP 说明
1+
# 第一部分:STM32 B-U585I-IOT02A 开发板 BSP 说明
22

33
[English](README.md) | **中文**
44

components/fal/src/fal_rtt.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ struct rt_device *fal_blk_device_create(const char *parition_name)
167167
return NULL;
168168
}
169169

170-
if ((fal_flash = fal_flash_device_find(fal_part->flash_name)) == NULL)
170+
fal_flash = fal_flash_device_find(fal_part->flash_name);
171+
if (fal_flash == NULL)
171172
{
172173
LOG_E("Error: the flash device name (%s) is not found.", fal_part->flash_name);
173174
return NULL;
@@ -309,7 +310,8 @@ struct rt_device *fal_mtd_nor_device_create(const char *parition_name)
309310
return NULL;
310311
}
311312

312-
if ((fal_flash = fal_flash_device_find(fal_part->flash_name)) == NULL)
313+
fal_flash = fal_flash_device_find(fal_part->flash_name);
314+
if (fal_flash == NULL)
313315
{
314316
LOG_E("Error: the flash device name (%s) is not found.", fal_part->flash_name);
315317
return NULL;
@@ -620,19 +622,24 @@ static void fal(rt_uint8_t argc, char **argv) {
620622
if (argc >= 3)
621623
{
622624
char *dev_name = argv[2];
623-
if ((flash_dev = fal_flash_device_find(dev_name)) != NULL)
625+
flash_dev = fal_flash_device_find(dev_name);
626+
if (flash_dev != NULL)
624627
{
625628
part_dev = NULL;
626629
}
627-
else if ((part_dev = fal_partition_find(dev_name)) != NULL)
628-
{
629-
flash_dev = NULL;
630-
}
631630
else
632631
{
633-
rt_kprintf("Device %s NOT found. Probe failed.\n", dev_name);
634-
flash_dev = NULL;
635-
part_dev = NULL;
632+
part_dev = fal_partition_find(dev_name);
633+
if (part_dev != NULL)
634+
{
635+
flash_dev = NULL;
636+
}
637+
else
638+
{
639+
rt_kprintf("Device %s NOT found. Probe failed.\n", dev_name);
640+
flash_dev = NULL;
641+
part_dev = NULL;
642+
}
636643
}
637644
}
638645

include/rtthread.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,13 @@ void rt_components_board_init(void);
783783
#else
784784
int rt_kprintf(const char *fmt, ...);
785785
void rt_kputs(const char *str);
786+
#ifdef RT_USING_CONSOLE_OUTPUT_CTL
787+
void rt_console_output_set_enabled(rt_bool_t enabled);
788+
rt_bool_t rt_console_output_get_enabled(void);
789+
#else
790+
#define rt_console_output_set_enabled(enabled) ((void)0)
791+
#define rt_console_output_get_enabled() (RT_TRUE)
792+
#endif /* RT_USING_CONSOLE_OUTPUT_CTL */
786793
#endif /* RT_USING_CONSOLE */
787794

788795
rt_err_t rt_backtrace(void);

src/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,18 @@ if RT_USING_CONSOLE
430430
string "the device name for console"
431431
default "uart1"
432432

433+
config RT_USING_CONSOLE_OUTPUT_CTL
434+
bool "Enable runtime console output control"
435+
default y
436+
help
437+
Enable runtime control for console output.
438+
When enabled, rt_console_output_set_enabled() and
439+
rt_console_output_get_enabled() can be used to switch
440+
rt_kputs()/rt_kprintf() output on or off dynamically.
441+
442+
When disabled, these APIs are not compiled as real symbols and
443+
output path has no runtime check, so console output stays enabled.
444+
433445
endif
434446

435447
config RT_VER_NUM

src/kservice.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,32 @@ rt_device_t rt_console_set_device(const char *name)
208208
RTM_EXPORT(rt_console_set_device);
209209
#endif /* RT_USING_DEVICE */
210210

211+
#ifdef RT_USING_CONSOLE_OUTPUT_CTL
212+
static volatile rt_bool_t _console_output_enabled = RT_TRUE;
213+
214+
/**
215+
* @brief Enable or disable console log output.
216+
*
217+
* @param enabled RT_TRUE to enable output, RT_FALSE to disable output.
218+
*/
219+
void rt_console_output_set_enabled(rt_bool_t enabled)
220+
{
221+
_console_output_enabled = enabled;
222+
}
223+
RTM_EXPORT(rt_console_output_set_enabled);
224+
225+
/**
226+
* @brief Get current console log output enable state.
227+
*
228+
* @return RT_TRUE if output is enabled, RT_FALSE otherwise.
229+
*/
230+
rt_bool_t rt_console_output_get_enabled(void)
231+
{
232+
return _console_output_enabled;
233+
}
234+
RTM_EXPORT(rt_console_output_get_enabled);
235+
#endif /* RT_USING_CONSOLE_OUTPUT_CTL */
236+
211237
rt_weak void rt_hw_console_output(const char *str)
212238
{
213239
/* empty console output */
@@ -346,6 +372,11 @@ void rt_kputs(const char *str)
346372
return;
347373
}
348374

375+
if (!rt_console_output_get_enabled())
376+
{
377+
return;
378+
}
379+
349380
_kputs(str, rt_strlen(str));
350381
}
351382

@@ -362,6 +393,11 @@ rt_weak int rt_kprintf(const char *fmt, ...)
362393
rt_size_t length = 0;
363394
static char rt_log_buf[RT_CONSOLEBUF_SIZE];
364395

396+
if (!rt_console_output_get_enabled())
397+
{
398+
return 0;
399+
}
400+
365401
va_start(args, fmt);
366402
PRINTF_BUFFER_TAKE;
367403

0 commit comments

Comments
 (0)