RobertBerger

disgusting wrapper

Mar 10th, 2021
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Create the thread(s) */
  2. /* definition and creation of THREAD1 */
  3. osThreadDef(THREAD1, LED_Thread1, osPriorityBelowNormal, 0, 128);
  4. THREAD1Handle = osThreadCreate(osThread(THREAD1), NULL);
  5.  
  6. /* definition and creation of THREAD2 */
  7. osThreadDef(THREAD2, LED_Thread2, osPriorityBelowNormal, 0, 128);
  8. THREAD2Handle = osThreadCreate(osThread(THREAD2), NULL);
  9.  
  10. /* USER CODE BEGIN RTOS_THREADS */
  11. /* Set thread 2 in suspend state */
  12. OsStatus = osThreadSuspend(THREAD2Handle);
  13. /* USER CODE END RTOS_THREADS */
  14.  
  15.  
  16. underneath:
  17.  
  18. osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument)
  19. {
  20. TaskHandle_t handle;
  21.  
  22. #if( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  23. if((thread_def->buffer != NULL) && (thread_def->controlblock != NULL)) {
  24. handle = xTaskCreateStatic((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
  25. thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
  26. thread_def->buffer, thread_def->controlblock);
  27. }
  28. else {
  29. if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
  30. thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
  31. &handle) != pdPASS) {
  32. return NULL;
  33. }
  34. }
  35. #elif( configSUPPORT_STATIC_ALLOCATION == 1 )
  36.  
  37. handle = xTaskCreateStatic((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
  38. thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
  39. thread_def->buffer, thread_def->controlblock);
  40. #else
  41. if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
  42. thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
  43. &handle) != pdPASS) {
  44. return NULL;
  45. }
  46. #endif
  47.  
  48. return handle;
  49. }
  50.  
  51.  
RAW Paste Data