I am looking at the shell demo for LPC54018. In the demo the SHELL_Main() function from fsl_shell.c was used, and it works when used this way
script in Main.c
SHELL_Main(&context);
console
SHELL (build: Oct 26 2018)
Copyright (c) 2017 NXP Semiconductor
SHELL>> start loop, context = 0x2fec0
Now if I wrap the SHELL_Main in xTaskCreate, and then run vTaskStartScheduler(). It doesn't work despite the pointer was successfully passed in
script in Main.c
xTaskCreate(
SHELL_Main,
"shell",
1024,
&context,
1,
NULL);
vTaskStartScheduler();
console
SHELL (build: Oct 26 2018)
Copyright (c) 2017 NXP Semiconductor
SHELL>> start loop, user_context = 0x2fec0
context->exit
This is the starting section of the source code, bolded are the printf I added to help debug. As can be seen the context passed into the function is the same, however, when wrapped by xTaskCreate, if (context->exit) was triggered.
int32_t SHELL_Main(p_shell_context_t context)
{
printf("entered shell_main\n");
uint8_t ch;
int32_t i;
if (!context)
{
return -1;
}
context->exit = false;
context->printf_data_func("\r\nSHELL (build: %s)\r\n", __DATE__);
context->printf_data_func("Copyright (c) 2017 NXP Semiconductor\r\n");
context->printf_data_func(context->prompt);
while (1)
{
printf("start loop, context = %p\n", context);
if (context->exit)
{
printf("context->exit");
break;
}
....
Why the same pointer will trigger different conditions when directly called and when wrapped in Tasks?