Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "app_tx_cmsisrtos.h"
Private includes
#include "stdio.h"
Private typedef
Private define
Private macro
#define PUTCHAR_PROTOTYPE
#define PUTCHAR_PROTOTYPE
Private variables
OsStatus
ThreadOne
ThreadTwo
SyncObject
attr
Private function prototypes
Global user code
App_TX_CmsisRTOS_Init()
Private user code
ThreadOne_Entry(void *)
ThreadTwo_Entry(void *)
Led_Toggle(Led_TypeDef, uint32_t)
fputc(int, FILE *)
Files
loading...
CodeScopeSTM32 Libraries and SamplesTx_CMSIS_WrapperSrc/app_tx_cmsisrtos.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file ThreadX/Tx_CMSIS_Wrapper/CM7/Src/app_tx_cmsisrtos.c * @author MCD Application Team * @brief ThreadX CMSIS RTOS Wrapper applicative file ****************************************************************************** * @attention * * Copyright (c) 2021 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "app_tx_cmsisrtos.h" Includes /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "stdio.h" /* USER CODE END Includes */ Private includes /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ Private typedef /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ Private define /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ #if defined ( __GNUC__) && !defined(__clang__) /* With GCC, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() *//* ... */ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) /* ... */#else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif /* __GNUC__ */ /* USER CODE END PM */ Private macro /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ extern UART_HandleTypeDef huart3; __IO uint32_t OsStatus = 0; osThreadId_t ThreadOne; osThreadId_t ThreadTwo; APP_SYNC_TYPE SyncObject; static osThreadAttr_t attr = { .priority = osPriorityNormal, .stack_size = APP_THREAD_STACK_SIZE, ...}; /* USER CODE END PV */ Private variables /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ static void ThreadOne_Entry(void *argument); static void ThreadTwo_Entry(void *argument); static void Led_Toggle(Led_TypeDef led, uint32_t iter); /* USER CODE END PFP */ Private function prototypes /* Global user code ---------------------------------------------------------*/ /* USER CODE BEGIN Global user code */ /* USER CODE END Global user code */ /** * @brief Application ThreadX with CMSIS RTOS Wrapper Initialization. * @param memory_ptr: memory pointer * @retval int *//* ... */ uint32_t App_TX_CmsisRTOS_Init(void) { osStatus_t ret = osOK; /* USER CODE BEGIN App_TX_CmsisRTOS_Init */ ret = osKernelInitialize(); if (ret == osOK) { /* Create the thread(s) */ /* definition and creation of ThreadOne */ attr.name = "ThreadOne"; ThreadOne = osThreadNew(ThreadOne_Entry, NULL, (const osThreadAttr_t *)&attr); /* definition and creation of ThreadOne */ attr.name = "ThreadTwo"; ThreadOne = osThreadNew(ThreadTwo_Entry, NULL, (const osThreadAttr_t *)&attr); SyncObject = APP_SYNC_CREATE(); /* Start scheduler */ ret = osKernelStart(); }if (ret == osOK) { ... } /* USER CODE END App_TX_CmsisRTOS_Init */ return ((uint32_t)ret); }{ ... } Global user code/* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN Private user code */ /* USER CODE END Private user code */ /* USER CODE BEGIN 1 */ /** * @brief Function implementing the ThreadOne thread. * @param argument: Not used * @retval None *//* ... */ static void ThreadOne_Entry(void *argument) { (void) argument; uint32_t iteration = 0; /* Infinite loop */ while(1) { /* try to acquire the sync object without waiting */ if (APP_SYNC_GET(SyncObject, DEFAULT_WAIT_TIME) == osOK) { printf("** ThreadOne : SyncObject acquired ** \n"); /*sync object acquired, toggle the LED_GREEN each 500ms for 5s */ Led_Toggle(LED_GREEN, 10); /*release the sync object */ APP_SYNC_PUT(SyncObject); printf("** ThreadOne : SyncObject released ** \n"); osDelay(1); }if (APP_SYNC_GET(SyncObject, DEFAULT_WAIT_TIME) == osOK) { ... } else { if ((iteration % 20) == 0) { printf("** ThreadOne : waiting for SyncObject !! **\n"); }if ((iteration % 20) == 0) { ... } }else { ... } iteration++; }while (1) { ... } }{ ... } /** * @brief Function implementing the ThreadTwo thread. * @param argument: Not used * @retval None *//* ... */ static void ThreadTwo_Entry(void *argument) { (void) argument; uint32_t iteration = 0; /* Infinite loop */ while(1) { /* try to acquire the sync object without waiting */ if (APP_SYNC_GET(SyncObject, DEFAULT_WAIT_TIME) == osOK) { printf("** ThreadTwo : SyncObject acquired ** \n"); /*Sync object acquired toggle the LED_RED each 500ms for 5s*/ Led_Toggle(LED_RED, 10); /*release the sync object*/ APP_SYNC_PUT(SyncObject); printf("** ThreadTwo : SyncObject released ** \n"); osDelay(1); }if (APP_SYNC_GET(SyncObject, DEFAULT_WAIT_TIME) == osOK) { ... } else { if ((iteration % 20) == 0) { printf("** ThreadTwo : waiting for SyncObject !! **\n"); }if ((iteration % 20) == 0) { ... } }else { ... } iteration++; }while (1) { ... } }{ ... } /** * @brief Critical section function that needs acquiring SyncObject. * @param led: LED to toggle * @param iter: Number of iterations * @retval None *//* ... */ static void Led_Toggle(Led_TypeDef led, uint32_t iter) { uint32_t i; BSP_LED_Off(led); for (i =0; i < iter; i++) { BSP_LED_Toggle(led); osDelay(50); }for (i =0; i < iter; i++) { ... } BSP_LED_Off(led); }{ ... } /** * @brief Retargets the C library printf function to the USART. * @param None * @retval None *//* ... */ PUTCHAR_PROTOTYPE { /* Place your implementation of fputc here */ /* e.g. write a character to the USART3 and Loop until the end of transmission */ HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF); return ch; ...} Private user code/* USER CODE END 1 */