AnsweredAssumed Answered

Can I start task inside task on RTOS ?

Question asked by H.Rick on Apr 2, 2017

Everyone,

 

Can I start task inside task on RTOS? so after task 1 is finished, go to task 2, finish task 2 return to task one,

Here's what I have written, any advices ?thanks

 

/* StartDefaultTask function */
static void StartDefaultTask(void const * argument)
{
    
    uint32_t count = 0;
  (void) argument;
  /* init code for FATFS */
  MX_FATFS_Init();

 

  /* init code for USB_DEVICE */
  MX_USB_DEVICE_Init();

 

  /* USER CODE BEGIN StartDefaultTask */
  /* Infinite loop */
    printf("Start Default Task! \n");
    for (;;)
     {//thread1 endless loop begin
            printf("Task 1, DefaultTask running! \n");
         test_fatfs();          //task thread_2 1
   
            vTaskDelay(500);     
          
                   /* definition and creation of secondTask */
        osThreadDef(secondTask, StartSecondTask, osPriorityNormal, 0, 512);
        secondTaskHandle = osThreadCreate(osThread(secondTask), NULL);    
            /* Suspend Thread 1 */
                osThreadSuspend(NULL);
           
    
            /* Resume Thread 2*/
                osThreadResume(secondTaskHandle);
          
     }//thread1 endless loop end
    
 
  /* USER CODE END StartDefaultTask */
}

Outcomes