<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality) in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696610#M7486</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an update on the issue I am trying to resolve.&amp;nbsp; I found similar code to a USB+Host+msd, which doesn't use the&lt;/P&gt;&lt;P&gt;two lines of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OS_Task_create(Task_Start, NULL, 4L, 4000L, "task_start", NULL);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OSA_Start();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;instead in the main, it uses:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;#ifdef PEX_RTOS_START&lt;BR /&gt; PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt; #endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;which ties to the os_tasks.c-&amp;gt;APP_USB_task and inside this function, it has the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;#ifdef PEX_USE_RTOS&lt;BR /&gt; while (1) {&lt;BR /&gt;#endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;I noticed once again that APP_USB_task is locked in a while loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;My question is, does this function need to be locked in a while loop?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Oct 2017 14:46:21 GMT</pubDate>
    <dc:creator>neilporven</dc:creator>
    <dc:date>2017-10-13T14:46:21Z</dc:date>
    <item>
      <title>FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696609#M7485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After battling with trying to configure my custom board with similar settings on the demo (msd_fat_demo), stumbled&lt;/P&gt;&lt;P&gt;trying to make it recognize the USB stick.&amp;nbsp; I finally discovered that the following two lines of code are needed for my&lt;/P&gt;&lt;P&gt;custom board to be able to work as the demo software.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the two lines of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OS_Task_create(Task_Start, NULL, 4L, 4000L, "task_start", NULL);&lt;BR /&gt; OSA_Start();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not 100% sure about this but it seems that these two lines of code start a thread which locks the demo looking&lt;/P&gt;&lt;P&gt;into Task_Start() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Can someone confirm if this is true?&lt;/P&gt;&lt;P&gt;2. If the above question is true, if I remove these lines and call the Task_Start function at my own discretion could this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; work as well? Please explain why?&lt;/P&gt;&lt;P&gt;3. If question #1 is false, then what are these two lines of code affecting the overall function of the demo?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help on this would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Oct 2017 15:13:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696609#M7485</guid>
      <dc:creator>neilporven</dc:creator>
      <dc:date>2017-10-03T15:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696610#M7486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an update on the issue I am trying to resolve.&amp;nbsp; I found similar code to a USB+Host+msd, which doesn't use the&lt;/P&gt;&lt;P&gt;two lines of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OS_Task_create(Task_Start, NULL, 4L, 4000L, "task_start", NULL);&lt;/SPAN&gt;&lt;BR style="color: #000000; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OSA_Start();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;instead in the main, it uses:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;#ifdef PEX_RTOS_START&lt;BR /&gt; PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt; #endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;which ties to the os_tasks.c-&amp;gt;APP_USB_task and inside this function, it has the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;#ifdef PEX_USE_RTOS&lt;BR /&gt; while (1) {&lt;BR /&gt;#endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;I noticed once again that APP_USB_task is locked in a while loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;My question is, does this function need to be locked in a while loop?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Oct 2017 14:46:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696610#M7486</guid>
      <dc:creator>neilporven</dc:creator>
      <dc:date>2017-10-13T14:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696611#M7487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neil:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;The two lines ( &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OS_Task_create&lt;/SPAN&gt; and&amp;nbsp;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OSA_Start&lt;/SPAN&gt; ) are for all the three RTOSes and bare mental .&amp;nbsp; (For your case, you selected bare metal,&amp;nbsp; actually&amp;nbsp; you can choose FreeRTOS, maybe better ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Oct 2017 13:12:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696611#M7487</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2017-10-17T13:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696612#M7488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From bare metal,&amp;nbsp; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;OS_Task_create&lt;/SPAN&gt; will execute Task_start , will finally call app_task, waiting for usb mass storage device to be attached.&amp;nbsp; this function won't lock the demo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OS_START will execute&amp;nbsp; _usb_khci_task,&amp;nbsp; 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&lt;BR /&gt;as a function entry to create a task.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Oct 2017 13:13:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696612#M7488</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2017-10-17T13:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696613#M7489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your explanation, but I am a little confused.&amp;nbsp; I am in a bare metal environment, no RTOS.&amp;nbsp; Let me show you what is happening&lt;/P&gt;&lt;P&gt;as I step through my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I call my Init() function in my main, it handles all the CPU register configuration and such.&amp;nbsp; It also calls my USB initialization code which&lt;/P&gt;&lt;P&gt;as in the example project calls the following functions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OSA_Init();&lt;/P&gt;&lt;P&gt;OS_Task_create(USB_task, NULL, 4L, 4000L, "task_start", NULL);&lt;BR /&gt; OSA_Start();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; Init();//Initialize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for (;;) {&lt;/P&gt;&lt;P&gt;Function call 1&lt;BR /&gt;Function call 2&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once OSA_Start(); line is executed, the software is tied here (inside fsl_os_abstraction.bm):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;osa_status_t OSA_Start(void)&lt;BR /&gt;{&lt;BR /&gt;#if (TASK_MAX_NUM &amp;gt; 0)&lt;BR /&gt; g_curTask = &amp;amp;g_taskListHead;&lt;/P&gt;&lt;P&gt;for(;;)&lt;BR /&gt; {&lt;BR /&gt; if (g_curTask-&amp;gt;p_func)&lt;BR /&gt; {&lt;BR /&gt; g_curTask-&amp;gt;p_func(g_curTask-&amp;gt;param);&lt;BR /&gt; }&lt;BR /&gt; g_curTask = g_curTask-&amp;gt;next;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This executes the USB code which determines if a USB stick is introduced or not and then executes the fat_demo().&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; The&amp;nbsp;&lt;/P&gt;&lt;P&gt;program is stuck in the OSA_Start(void) function endlessly looping.&amp;nbsp; I need for it to check if a USB has been introduced and&lt;/P&gt;&lt;P&gt;if not, then continue to Function call 1, 2, etc.., then I will call the USB call again at a later time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you understand?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Oct 2017 14:07:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696613#M7489</guid>
      <dc:creator>neilporven</dc:creator>
      <dc:date>2017-10-17T14:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696614#M7490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a quick update and it seems to work, but I don't think this is the correct way of doing things.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;int main(void)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;------------ my main&lt;BR /&gt;{&lt;BR /&gt;Init();//Initialize&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;------------ my initialization code&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;for (;;) {&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;void Start_app(void *arg)&lt;BR /&gt; {&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;Function call 1&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;Function call 2&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;etc...&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;}&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;OS_Task_create(Start_app, NULL, 4L, 4000L, "Start_app", NULL);&lt;BR /&gt; OSA_Start();&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;}&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Is there documentation on how OS_Task_create work and OSA_Start() work and how to use it?&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Thanks,&lt;/P&gt;&lt;P style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Neil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Oct 2017 19:41:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696614#M7490</guid>
      <dc:creator>neilporven</dc:creator>
      <dc:date>2017-10-17T19:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64F + USB + Host + msd (OSA_Start and OS_Task_Create functionality)</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696615#M7491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check the following help page in your KSDK installation folder.&lt;/P&gt;&lt;P&gt;C:\Freescale\KSDK_1.3.0\doc\Kinetis SDK v.1.3.0 API Reference Manual\group__os__abstraction.html&lt;/P&gt;&lt;P&gt;and check&amp;nbsp; OS Abstraction Layer (OSA)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis SDK v.1.3 API Reference Manual: OS Abstraction Layer (OSA)&lt;/P&gt;&lt;DIV style="height: 579px; margin-left: 262px;"&gt;&lt;DIV class=""&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR class=""&gt;&lt;TD colspan="2"&gt;&lt;H2 class=""&gt;OSA initialize&lt;/H2&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class=""&gt;&lt;TD align="right" class="" valign="top"&gt;&lt;A class="" href="https://community.nxp.com/"&gt;osa_status_t&lt;/A&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD class="" valign="bottom"&gt;&lt;A class="" href="https://community.nxp.com/"&gt;OSA_Init&lt;/A&gt; (void)&lt;/TD&gt;&lt;/TR&gt;&lt;TR class=""&gt;&lt;TD class=""&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD class=""&gt;Initializes the RTOS services. &lt;A href="https://community.nxp.com/"&gt;More...&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class=""&gt;&lt;TD class="" colspan="2"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class=""&gt;&lt;TD align="right" class="" valign="top"&gt;&lt;A class="" href="https://community.nxp.com/"&gt;osa_status_t&lt;/A&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD class="" valign="bottom"&gt;&lt;A class="" href="https://community.nxp.com/"&gt;OSA_Start&lt;/A&gt; (void)&lt;/TD&gt;&lt;/TR&gt;&lt;TR class=""&gt;&lt;TD class=""&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD class=""&gt;Starts the RTOS. &lt;A href="https://community.nxp.com/"&gt;More...&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR class=""&gt;&lt;TD class="" colspan="2"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;H3&gt;&lt;A&gt;&lt;/A&gt;OS Abstraction Layer&lt;/H3&gt;&lt;DIV class=""&gt;&lt;H1&gt;Overview&lt;/H1&gt;Operating System Abstraction layer (OSA) provides a common set of services for drivers and applications so that they can work with or without the operating system. OSA provides services that abstract most of the OS kernel functionality. These services can either be mapped to the target OS functions directly, or implemented by OSA when no OS is used (bare metal) or when the service does not exist in the target OS. Freescale Kinetis SDK implements the OS abstraction layer for MQX™ RTOS, Free RTOS, µC/OS, and for OS-less usage (bare metal). The bare metal OS abstraction implementation is selected as the default option.&lt;BR /&gt; OSA provides these services: task management, semaphore, mutex, event, message queue, memory allocator, critical section, and time functions.&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;Task Management&lt;/H1&gt;With OSA, applications can create and destroy tasks dynamically. These services are mapped to the task functions of RTOSes. For bare metal, a function poll mechanism simulates a task scheduler.&lt;BR /&gt; OSA supports task priorities 0~15, where priority 0 is the highest priority and priority 15 is the lowest priority.&lt;BR /&gt; To create a task, applications must prepare different resources on different RTOSes. For example, µC/OS-II and µC/OS-III need pre-allocated task stack while other RTOSes do not need this. The µC/OS-III needs pre-allocated task control block OS_TCB while other RTOSes do not. To mask the differences, OSA uses a macro OSA_TASK_DEFINE to prepare resources for task creation. Then the function &lt;A class="" href="https://community.nxp.com/" title="Creates a task. "&gt;OSA_TaskCreate()&lt;/A&gt; creates a task based on the resources. This method makes it easy to use a copy of code on different RTOSes. However, it is not mandatory to use the OSA_TASK_DEFINE. Applications can also prepare the resources manually. There are two methods to create a task:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;OL type="1"&gt;&lt;LI&gt;Use the OSA_TASK_DEFINE macro and the function &lt;A class="" href="https://community.nxp.com/" title="Creates a task. "&gt;OSA_TaskCreate()&lt;/A&gt;. The macro OSA_TASK_DEFINE declares a task handler and task stack statically. The function &lt;A class="" href="https://community.nxp.com/" title="Creates a task. "&gt;OSA_TaskCreate()&lt;/A&gt; creates task base-on the resources declared by OSA_TASK_DEFINE.&lt;BR /&gt; This is an example code to create a task using method 1:&lt;BR /&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;// Define the task with entry function task_func.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;OSA_TASK_DEFINE&lt;/A&gt;(task_func, TASK_STACK_SIZE);&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;void&lt;/SPAN&gt; main(&lt;SPAN class=""&gt;void&lt;/SPAN&gt;)&lt;/DIV&gt;&lt;DIV class=""&gt;{&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;task_param_t&lt;/A&gt; parameter;&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;// Create the task.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;OSA_TaskCreate&lt;/A&gt;(task_func, &lt;SPAN class=""&gt;// Task function.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;"my_task"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Task name.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_STACK_SIZE, &lt;SPAN class=""&gt;// Stack size. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;task_func_stack, &lt;SPAN class=""&gt;// Stack address.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_PRIO, &lt;SPAN class=""&gt;// Task priority.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;parameter, &lt;SPAN class=""&gt;// Parameter.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;false&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Use float register or not.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;amp;task_func_task_handler); &lt;SPAN class=""&gt;// Task handler.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;// ...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;}&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;Prepare resources manually, then use the function &lt;A class="" href="https://community.nxp.com/" title="Creates a task. "&gt;OSA_TaskCreate()&lt;/A&gt; to create a task. &lt;BR /&gt; For example:&lt;BR /&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;task_param_t&lt;/A&gt; parameter;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;task_handler_t&lt;/A&gt; task_handler;&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;#if defined(FSL_RTOS_UCOSII)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt; &lt;A class="" href="https://community.nxp.com/"&gt;task_stack_t&lt;/A&gt; task_stack[TASK_STACK_SIZE/&lt;SPAN class=""&gt;sizeof&lt;/SPAN&gt;(&lt;A class="" href="https://community.nxp.com/"&gt;task_stack_t&lt;/A&gt;)];&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;OSA_TaskCreate&lt;/A&gt;(task_func, &lt;SPAN class=""&gt;// Task function.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;"my_task"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Task name.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_STACK_SIZE, &lt;SPAN class=""&gt;// Stack size. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;task_stack, &lt;SPAN class=""&gt;// Stack address.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_PRIO, &lt;SPAN class=""&gt;// Task priority.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;parameter, &lt;SPAN class=""&gt;// Parameter.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;false&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Use float register or not.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;amp;task_handler); &lt;SPAN class=""&gt;// Task handler.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;#elif defined(FSL_RTOS_UCOSIII)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt; &lt;A class="" href="https://community.nxp.com/"&gt;task_stack_t&lt;/A&gt; task_stack[TASK_STACK_SIZE/&lt;SPAN class=""&gt;sizeof&lt;/SPAN&gt;(&lt;A class="" href="https://community.nxp.com/"&gt;task_stack_t&lt;/A&gt;)];&lt;/DIV&gt;&lt;DIV class=""&gt;OS_TCB TCB_task;&lt;/DIV&gt;&lt;DIV class=""&gt;task_handler = &amp;amp;TCB_task;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A class="" href="https://community.nxp.com/"&gt;OSA_TaskCreate&lt;/A&gt;(task_func, &lt;SPAN class=""&gt;// Task function.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;"my_task"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Task name.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_STACK_SIZE, &lt;SPAN class=""&gt;// Stack size. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;task_stack, &lt;SPAN class=""&gt;// Stack address.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_PRIO, &lt;SPAN class=""&gt;// Task priority.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;parameter, &lt;SPAN class=""&gt;// Parameter.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;false&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Use float register or not.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;amp;task_handler); &lt;SPAN class=""&gt;// Task handler.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;#else // For MQX RTOS, FreeRTOS OS and bare metal.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt; &lt;A class="" href="https://community.nxp.com/"&gt;OSA_TaskCreate&lt;/A&gt;(task_func, &lt;SPAN class=""&gt;// Task function.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;"my_task"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Task name.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_STACK_SIZE, &lt;SPAN class=""&gt;// Stack size. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;NULL, &lt;SPAN class=""&gt;// Stack address.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;TASK_PRIO, &lt;SPAN class=""&gt;// Task priority.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;parameter, &lt;SPAN class=""&gt;// Parameter.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;false&lt;/SPAN&gt;, &lt;SPAN class=""&gt;// Use float register or not.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;amp;task_handler); &lt;SPAN class=""&gt;// Task handler.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;#endif&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;Method one is easy to use. The disadvantage is that one task function can only create one task instance. Method two can create multiple task instances using one task function, but the code must be divided by macros for different RTOSes. Applications can choose either method according to requirements.&lt;BR /&gt; After a task is created successfully, task handler can be used to manage the task, for example, get or set task priority, destroy task and so on.If task is not used any more, use the &lt;A class="" href="https://community.nxp.com/" title="Destroys a previously created task. "&gt;OSA_TaskDestroy()&lt;/A&gt; function to destroy the task. If the task function does not contain an infinite loop, or, in other words, the task function returns, call the &lt;A class="" href="https://community.nxp.com/" title="Destroys a previously created task. "&gt;OSA_TaskDestroy()&lt;/A&gt; function at the end of the task function.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV style="height: 579px; margin-left: 262px;"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Oct 2017 13:33:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/FRDM-K64F-USB-Host-msd-OSA-Start-and-OS-Task-Create/m-p/696615#M7491</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2017-10-18T13:33:47Z</dc:date>
    </item>
  </channel>
</rss>

