Hi everyone,
After battling with trying to configure my custom board with similar settings on the demo (msd_fat_demo), stumbled
trying to make it recognize the USB stick. I finally discovered that the following two lines of code are needed for my
custom board to be able to work as the demo software.
Here are the two lines of code:
OS_Task_create(Task_Start, NULL, 4L, 4000L, "task_start", NULL);
OSA_Start();
I am not 100% sure about this but it seems that these two lines of code start a thread which locks the demo looking
into Task_Start() function.
1. Can someone confirm if this is true?
2. If the above question is true, if I remove these lines and call the Task_Start function at my own discretion could this
work as well? Please explain why?
3. If question #1 is false, then what are these two lines of code affecting the overall function of the demo?
Any help on this would be appreciated.
Thanks,
Neil
From bare metal, OS_Task_create will execute Task_start , will finally call app_task, waiting for usb mass storage device to be attached. this function won't lock the demo.
OS_START will execute _usb_khci_task, this function is used to handle KHCI controller message. In the bare metal environment, this function should be called periodically . In the RTOS environment, this function should be used
as a function entry to create a task.
Hi Daniel,
Thank you for your explanation, but I am a little confused. I am in a bare metal environment, no RTOS. Let me show you what is happening
as I step through my code.
I call my Init() function in my main, it handles all the CPU register configuration and such. It also calls my USB initialization code which
as in the example project calls the following functions:
OSA_Init();
OS_Task_create(USB_task, NULL, 4L, 4000L, "task_start", NULL);
OSA_Start();
int main(void)
{
Init();//Initialize
for (;;) {
Function call 1
Function call 2
etc...
}
Once OSA_Start(); line is executed, the software is tied here (inside fsl_os_abstraction.bm):
osa_status_t OSA_Start(void)
{
#if (TASK_MAX_NUM > 0)
g_curTask = &g_taskListHead;
for(;;)
{
if (g_curTask->p_func)
{
g_curTask->p_func(g_curTask->param);
}
g_curTask = g_curTask->next;
}
This executes the USB code which determines if a USB stick is introduced or not and then executes the fat_demo().
But if a USB stick is not introduced, if I place a breakpoint in my code say on Function call 1, it will never go there. The
program is stuck in the OSA_Start(void) function endlessly looping. I need for it to check if a USB has been introduced and
if not, then continue to Function call 1, 2, etc.., then I will call the USB call again at a later time.
Let me know if you understand?
Thank you,
Neil
Hi Daniel,
Here is a quick update and it seems to work, but I don't think this is the correct way of doing things.
int main(void) <------------ my main
{
Init();//Initialize <------------ my initialization code
for (;;) {
void Start_app(void *arg)
{
Function call 1
Function call 2
etc...
}
OS_Task_create(Start_app, NULL, 4L, 4000L, "Start_app", NULL);
OSA_Start();
}
Is there documentation on how OS_Task_create work and OSA_Start() work and how to use it?
Thanks,
Neil
Please check the following help page in your KSDK installation folder.
C:\Freescale\KSDK_1.3.0\doc\Kinetis SDK v.1.3.0 API Reference Manual\group__os__abstraction.html
and check OS Abstraction Layer (OSA)
Kinetis SDK v.1.3 API Reference Manual: OS Abstraction Layer (OSA)
OSA initialize | |
osa_status_t | OSA_Init (void) |
Initializes the RTOS services. More... | |
osa_status_t | OSA_Start (void) |
Starts the RTOS. More... | |
Hi Neil:
KSDK1.3 drivers are designed to work with or without an RTOS. The Operating System Abstraction layer (OSA) is designed and implemented for supported RTOS to provide a common set of service routines for drivers, integrated software solution, and upper-level applications. The usb host demo in KSDK1.3 supports FreeRTOS, MQX, ucOS, and bare metal.
The two lines ( OS_Task_create and OSA_Start ) are for all the three RTOSes and bare mental . (For your case, you selected bare metal, actually you can choose FreeRTOS, maybe better ).
Regards
Daniel
Hi everyone,
Here is an update on the issue I am trying to resolve. I found similar code to a USB+Host+msd, which doesn't use the
two lines of code:
OS_Task_create(Task_Start, NULL, 4L, 4000L, "task_start", NULL);
OSA_Start();
instead in the main, it uses:
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
which ties to the os_tasks.c->APP_USB_task and inside this function, it has the following:
#ifdef PEX_USE_RTOS
while (1) {
#endif
I noticed once again that APP_USB_task is locked in a while loop.
My question is, does this function need to be locked in a while loop?
Thank you,
Neil