Skip to content

Commit b809c02

Browse files
authored
Merge pull request #3957 from thread-liu/develop
[update] Dynamic change console
2 parents 92c54a5 + 01bdb2c commit b809c02

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

bsp/stm32/stm32mp157a-st-discovery/applications/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
#include <rtdevice.h>
1313
#include <board.h>
1414

15-
/* defined the LD8 pin: PD11 */
16-
#define LED8_PIN GET_PIN(D, 11)
15+
/* defined the LD7 pin: PH7 */
16+
#define LED7_PIN GET_PIN(H, 7)
1717

1818
int main(void)
1919
{
2020
int count = 1;
21-
/* set LD8 pin mode to output */
22-
rt_pin_mode(LED8_PIN, PIN_MODE_OUTPUT);
21+
/* set LD7 pin mode to output */
22+
rt_pin_mode(LED7_PIN, PIN_MODE_OUTPUT);
2323

2424
while (count++)
2525
{
26-
rt_pin_write(LED8_PIN, PIN_HIGH);
26+
rt_pin_write(LED7_PIN, PIN_HIGH);
2727
rt_thread_mdelay(500);
28-
rt_pin_write(LED8_PIN, PIN_LOW);
28+
rt_pin_write(LED7_PIN, PIN_LOW);
2929
rt_thread_mdelay(500);
3030
}
3131

bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ int rt_hw_openamp_init(void)
234234
openamp_init();
235235

236236
rt_hw_openamp_register(&dev_openamp, "openamp", 0, NULL);
237-
238-
rt_console_set_device("openamp");
239237

240238
return RT_EOK;
241239
}
@@ -289,4 +287,36 @@ static int creat_openamp_thread(void)
289287
}
290288
INIT_APP_EXPORT(creat_openamp_thread);
291289

290+
#ifdef FINSH_USING_MSH
291+
292+
static int console(int argc, char **argv)
293+
{
294+
rt_err_t result = RT_EOK;
295+
296+
if (argc > 1)
297+
{
298+
if (!strcmp(argv[1], "set"))
299+
{
300+
rt_kprintf("console change to %s\n", argv[2]);
301+
rt_console_set_device(argv[2]);
302+
finsh_set_device(argv[2]);
303+
}
304+
else
305+
{
306+
rt_kprintf("Unknown command. Please enter 'console' for help\n");
307+
result = -RT_ERROR;
308+
}
309+
}
310+
else
311+
{
312+
rt_kprintf("Usage: \n");
313+
rt_kprintf("console set <name> - change console by name\n");
314+
result = -RT_ERROR;
315+
}
316+
return result;
317+
}
318+
MSH_CMD_EXPORT(console, set console name);
319+
320+
#endif /* FINSH_USING_MSH */
321+
292322
#endif

0 commit comments

Comments
 (0)