Esempio n. 1
0
/// Create a thread and add it to Active Threads and set it to state READY.
/// \param[in]     thread_def    thread definition referenced with \ref osThread.
/// \param[in]     argument      pointer that is passed to the thread function as start argument.
/// \return thread ID for reference by other functions or NULL in case of error.
/// \note MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS.
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument)
{
//    (void) argument;
    xTaskHandle handle;
    BaseType_t  result;

    result = xTaskCreate((pdTASK_CODE)thread_def->pthread,
                (const portCHAR *)thread_def->name,
                (thread_def->stacksize/4),
                argument,
                makeFreeRtosPriority(thread_def->tpriority),
                &handle);
    if (pdPASS == result) {
#if configSignalManagementSupport
        EventGroupHandle_t signals;
        
        signals = xEventGroupCreate();
        if (signals == NULL) {
            /* The event group was not created because there was insufficient
               FreeRTOS heap available. */            
            CMSIS_OS_ERR("Create a EventGroup for a new thread failed\n");
        }
        else
        {
            add_thread_signal_map(handle, signals);
        }
#endif        
    }
    else
    {
        CMSIS_OS_ERR("Create a new thread(%s) failed\r\n", thread_def->name);
    }

    return handle;
}
Esempio n. 2
0
/**
* @brief   Change priority of an active thread.
* @param   thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
* @param   priority      new priority value for the thread function.
* @retval  status code that indicates the execution status of the function.
* @note   MUST REMAIN UNCHANGED: \b osThreadSetPriority shall be consistent in every CMSIS-RTOS.
*/
osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority)
{
#if (INCLUDE_vTaskPrioritySet == 1)
  vTaskPrioritySet(thread_id, makeFreeRtosPriority(priority));
  return osOK;
#else
  return osErrorOS;
#endif
}
Esempio n. 3
0
/**
* @brief  Create a thread and add it to Active Threads and set it to state READY.
* @param  thread_def    thread definition referenced with \ref osThread.
* @param  argument      pointer that is passed to the thread function as start argument.
* @retval thread ID for reference by other functions or NULL in case of error.
* @note   MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS.
*/
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument)
{
  TaskHandle_t handle;
  
  
  if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
              thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
              &handle) != pdPASS)  {
    return NULL;
  }
  
  return handle;
}
/**
* @brief  Create a thread and add it to Active Threads and set it to state READY.
* @param  thread_def    thread definition referenced with \ref osThread.
* @param  argument      pointer that is passed to the thread function as start argument.
* @retval thread ID for reference by other functions or NULL in case of error.
* @note   MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS.
*/
osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument)
{
  xTaskHandle handle;
  
  
  xTaskCreate((pdTASK_CODE)thread_def->pthread,
              (const signed portCHAR *)thread_def->name,
              thread_def->stacksize,
              argument,
              makeFreeRtosPriority(thread_def->tpriority),
              &handle);
  
  return handle;
}
Esempio n. 5
0
/**
* @brief  Create a thread and add it to Active Threads and set it to state READY.
* @param  thread_def    thread definition referenced with \ref osThread.
* @param  argument      pointer that is passed to the thread function as start argument.
* @retval thread ID for reference by other functions or NULL in case of error.
* @note   MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS.
*/
osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument)
{
  xTaskHandle handle;
//  BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode,
//		  	  	  	  	  	  	  const char * const pcName,
//		  	  	  	  	  	  	  const uint16_t usStackDepth,
//		  	  	  	  	  	  	  void * const pvParameters,
//		  	  	  	  	  	  	  UBaseType_t uxPriority,
//		  	  	  	  	  	  	  TaskHandle_t * const pxCreatedTask,
//		  	  	  	  	  	  	  StackType_t * const puxStackBuffer,
//		  	  	  	  	  	  	  const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */

  
  xTaskCreate((TaskFunction_t)thread_def->pthread,
              (const portCHAR *)thread_def->name,
              thread_def->stacksize,
              argument,
              makeFreeRtosPriority(thread_def->tpriority),
              &handle);
  
  return handle;
}
Esempio n. 6
0
/**
* @brief   Change priority of an active thread.
* @param   thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
* @param   priority      new priority value for the thread function.
* @retval  status code that indicates the execution status of the function.
* @note   MUST REMAIN UNCHANGED: \b osThreadSetPriority shall be consistent in every CMSIS-RTOS.
*/
osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority)
{
  vTaskPrioritySet(thread_id, makeFreeRtosPriority(priority));
  
  return osOK;
}