Guest User

ThreadX problem

a guest
Mar 12th, 2022
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.76 KB | None | 0 0
  1. /* USER CODE BEGIN Header */
  2. /**
  3.   ******************************************************************************
  4.   * @file    app_threadx.c
  5.   * @author  MCD Application Team
  6.   * @brief   ThreadX applicative file
  7.   ******************************************************************************
  8.   * @attention
  9.   *
  10.   * Copyright (c) 2021 STMicroelectronics.
  11.   * All rights reserved.
  12.   *
  13.   * This software is licensed under terms that can be found in the LICENSE file
  14.   * in the root directory of this software component.
  15.   * If no LICENSE file comes with this software, it is provided AS-IS.
  16.   *
  17.   ******************************************************************************
  18.   */
  19. /* USER CODE END Header */
  20.  
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "app_threadx.h"
  23.  
  24. /* Private includes ----------------------------------------------------------*/
  25. /* USER CODE BEGIN Includes */
  26.  
  27. /* USER CODE END Includes */
  28.  
  29. /* Private typedef -----------------------------------------------------------*/
  30. /* USER CODE BEGIN PTD */
  31.  
  32. /* USER CODE END PTD */
  33.  
  34. /* Private define ------------------------------------------------------------*/
  35. /* USER CODE BEGIN PD */
  36. #define THREAD_STACK_SIZE 1024
  37. /* USER CODE END PD */
  38.  
  39. /* Private macro -------------------------------------------------------------*/
  40. /* USER CODE BEGIN PM */
  41.  
  42. /* USER CODE END PM */
  43.  
  44. /* Private variables ---------------------------------------------------------*/
  45. /* USER CODE BEGIN PV */
  46. uint8_t led_stack[THREAD_STACK_SIZE];
  47. TX_THREAD led_ptr;
  48. uint32_t ret_val;
  49. /* USER CODE END PV */
  50.  
  51. /* Private function prototypes -----------------------------------------------*/
  52. /* USER CODE BEGIN PFP */
  53. VOID blink_led(ULONG interval);
  54.  
  55. /* USER CODE END PFP */
  56.  
  57. /**
  58.   * @brief  Application ThreadX Initialization.
  59.   * @param memory_ptr: memory pointer
  60.   * @retval int
  61.   */
  62. UINT App_ThreadX_Init(VOID *memory_ptr)
  63. {
  64.   UINT ret = TX_SUCCESS;
  65.   TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr;
  66.  
  67.   /* USER CODE BEGIN App_ThreadX_Init */
  68.   (void)byte_pool;
  69.  
  70.  
  71.   ret_val = tx_thread_create(&led_ptr, "led_thread", blink_led, 0X1234,
  72.           led_stack, THREAD_STACK_SIZE, 15, 15, TX_NO_TIME_SLICE, TX_AUTO_START);
  73.  
  74.   /* USER CODE END App_ThreadX_Init */
  75.  
  76.   return ret;
  77. }
  78.  
  79. /**
  80.   * @brief  MX_ThreadX_Init
  81.   * @param  None
  82.   * @retval None
  83.   */
  84. void MX_ThreadX_Init(void)
  85. {
  86.   /* USER CODE BEGIN  Before_Kernel_Start */
  87.  
  88.   /* USER CODE END  Before_Kernel_Start */
  89.  
  90.   tx_kernel_enter();
  91.  
  92.   /* USER CODE BEGIN  Kernel_Start_Error */
  93.  
  94.   /* USER CODE END  Kernel_Start_Error */
  95. }
  96.  
  97. /* USER CODE BEGIN 1 */
  98. VOID blink_led(ULONG interval){
  99.     while(1){
  100.         HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
  101.         tx_thread_sleep(1);
  102.  
  103.     }
  104. }
  105. /* USER CODE END 1 */
  106.  
Advertisement
Add Comment
Please, Sign In to add comment