When building an MQX application, compiler searches into /lib directory for the MQX include header files and libraries. For your own shell functions, just simply add them into your application project, not to the MQX library project.
If you used Freescale CodeWarrior for MCU, I would recommend to create a new application using the CW New Project Wizard for MQX. In a new empty workspace, go to File->New->MQX 4.0 Project and then in next steps
-enter the name of your new application
-select the board you will be using
-select New Application
-select Freescale compiler in case of Kinetis (GCC use only with MQX 4.0.1)
-check "Add Shell Support"
-select "Basic Application"
-check "Create shell command structure"
In the generated project, see main.c. There is the following structure defined:
const SHELL_COMMAND_STRUCT Shell_commands[] = {
/* Add your custom shell commands here */
/* { "command_name", Your_function }, */
{ "sh", Shell_sh },
{ "help", Shell_help },
{ "?", Shell_command_list },
{ "exit", Shell_exit },
{ NULL, NULL },
};
and you can start adding your commands, for example:
const SHELL_COMMAND_STRUCT Shell_commands[] = {
/* Add your custom shell commands here */
/* { "command_name", Your_function }, */
{ "mycmd", Shell_mycmd }
{ "sh", Shell_sh },
{ "help", Shell_help },
{ "?", Shell_command_list },
{ "exit", Shell_exit },
{ NULL, NULL },
};
Then you need to define your "Shell_mycmd" function. In may look like this:
int_32 Shell_mycmd (int_32 argc, char_ptr argv[])
{
boolean print_usage, shorthelp = FALSE;
print_usage = Shell_check_help_request(argc, argv, &shorthelp );
if(!print_usage)
{
MyFunc0();
}
if (print_usage)
{
if (shorthelp)
{
printf("%s\n", argv[0]);
}
else
{
printf("Usage: %s\n", argv[0]);
}
}
return SHELL_EXIT_SUCCESS;
}
where "MyFunc0" is the user function to be called and implementataon of "print_usage" conditions you can put your own help text.