STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
cmsis_os.c
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------
2  * $Date: 5. February 2013
3  * $Revision: V1.02
4  *
5  * Project: CMSIS-RTOS API
6  * Title: cmsis_os.c
7  *
8  * Version 0.02
9  * Initial Proposal Phase
10  * Version 0.03
11  * osKernelStart added, optional feature: main started as thread
12  * osSemaphores have standard behavior
13  * osTimerCreate does not start the timer, added osTimerStart
14  * osThreadPass is renamed to osThreadYield
15  * Version 1.01
16  * Support for C++ interface
17  * - const attribute removed from the osXxxxDef_t typedef's
18  * - const attribute added to the osXxxxDef macros
19  * Added: osTimerDelete, osMutexDelete, osSemaphoreDelete
20  * Added: osKernelInitialize
21  * Version 1.02
22  * Control functions for short timeouts in microsecond resolution:
23  * Added: osKernelSysTick, osKernelSysTickFrequency, osKernelSysTickMicroSec
24  * Removed: osSignalGet
25  *
26  *
27  *----------------------------------------------------------------------------
28  *
29  * Portions Copyright © 2016 STMicroelectronics International N.V. All rights reserved.
30  * Portions Copyright (c) 2013 ARM LIMITED
31  * All rights reserved.
32  * Redistribution and use in source and binary forms, with or without
33  * modification, are permitted provided that the following conditions are met:
34  * - Redistributions of source code must retain the above copyright
35  * notice, this list of conditions and the following disclaimer.
36  * - Redistributions in binary form must reproduce the above copyright
37  * notice, this list of conditions and the following disclaimer in the
38  * documentation and/or other materials provided with the distribution.
39  * - Neither the name of ARM nor the names of its contributors may be used
40  * to endorse or promote products derived from this software without
41  * specific prior written permission.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46  * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
47  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
48  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
51  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
53  * POSSIBILITY OF SUCH DAMAGE.
54  *---------------------------------------------------------------------------*/
55 
99 #include <string.h>
100 #include "cmsis_os.h"
101 
102 extern void xPortSysTickHandler(void);
103 
104 /* Convert from CMSIS type osPriority to FreeRTOS priority number */
105 static unsigned portBASE_TYPE makeFreeRtosPriority (osPriority priority)
106 {
107  unsigned portBASE_TYPE fpriority = tskIDLE_PRIORITY;
108 
109  if (priority != osPriorityError) {
110  fpriority += (priority - osPriorityIdle);
111  }
112 
113  return fpriority;
114 }
115 
116 #if (INCLUDE_uxTaskPriorityGet == 1)
117 /* Convert from FreeRTOS priority number to CMSIS type osPriority */
118 static osPriority makeCmsisPriority (unsigned portBASE_TYPE fpriority)
119 {
120  osPriority priority = osPriorityError;
121 
122  if ((fpriority - tskIDLE_PRIORITY) <= (osPriorityRealtime - osPriorityIdle)) {
123  priority = (osPriority)((int)osPriorityIdle + (int)(fpriority - tskIDLE_PRIORITY));
124  }
125 
126  return priority;
127 }
128 #endif
129 
130 
131 /* Determine whether we are in thread mode or handler mode. */
132 static int inHandlerMode (void)
133 {
134  return __get_IPSR() != 0;
135 }
136 
137 /*********************** Kernel Control Functions *****************************/
144 
153 {
155 
156  return osOK;
157 }
158 
167 int32_t osKernelRunning(void)
168 {
169 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
171  return 0;
172  else
173  return 1;
174 #else
175  return (-1);
176 #endif
177 }
178 
179 #if (defined (osFeature_SysTick) && (osFeature_SysTick != 0)) // System Timer available
180 
186 uint32_t osKernelSysTick(void)
187 {
188  if (inHandlerMode()) {
189  return xTaskGetTickCountFromISR();
190  }
191  else {
192  return xTaskGetTickCount();
193  }
194 }
195 #endif // System Timer available
196 /*********************** Thread Management *****************************/
204 osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument)
205 {
206  TaskHandle_t handle;
207 
208 
209  if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name,
210  thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority),
211  &handle) != pdPASS) {
212  return NULL;
213  }
214 
215  return handle;
216 }
217 
224 {
225 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
226  return xTaskGetCurrentTaskHandle();
227 #else
228  return NULL;
229 #endif
230 }
231 
239 {
240 #if (INCLUDE_vTaskDelete == 1)
241  vTaskDelete(thread_id);
242  return osOK;
243 #else
244  return osErrorOS;
245 #endif
246 }
247 
254 {
255  taskYIELD();
256 
257  return osOK;
258 }
259 
268 {
269 #if (INCLUDE_vTaskPrioritySet == 1)
270  vTaskPrioritySet(thread_id, makeFreeRtosPriority(priority));
271  return osOK;
272 #else
273  return osErrorOS;
274 #endif
275 }
276 
284 {
285 #if (INCLUDE_uxTaskPriorityGet == 1)
286  if (inHandlerMode())
287  {
288  return makeCmsisPriority(uxTaskPriorityGetFromISR(thread_id));
289  }
290  else
291  {
292  return makeCmsisPriority(uxTaskPriorityGet(thread_id));
293  }
294 #else
295  return osPriorityError;
296 #endif
297 }
298 
299 /*********************** Generic Wait Functions *******************************/
305 osStatus osDelay (uint32_t millisec)
306 {
307 #if INCLUDE_vTaskDelay
308  TickType_t ticks = millisec / portTICK_PERIOD_MS;
309 
310  vTaskDelay(ticks ? ticks : 1); /* Minimum delay = 1 tick */
311 
312  return osOK;
313 #else
314  (void) millisec;
315 
316  return osErrorResource;
317 #endif
318 }
319 
320 #if (defined (osFeature_Wait) && (osFeature_Wait != 0)) /* Generic Wait available */
321 
327 osEvent osWait (uint32_t millisec);
328 
329 #endif /* Generic Wait available */
330 
331 /*********************** Timer Management Functions ***************************/
340 osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument)
341 {
342 #if (configUSE_TIMERS == 1)
343  return xTimerCreate((const char *)"",
344  1, // period should be filled when starting the Timer using osTimerStart
345  (type == osTimerPeriodic) ? pdTRUE : pdFALSE,
346  (void *) argument,
347  (TaskFunction_t)timer_def->ptimer);
348 #else
349  return NULL;
350 #endif
351 }
352 
360 osStatus osTimerStart (osTimerId timer_id, uint32_t millisec)
361 {
362  osStatus result = osOK;
363 #if (configUSE_TIMERS == 1)
364  portBASE_TYPE taskWoken = pdFALSE;
365  TickType_t ticks = millisec / portTICK_PERIOD_MS;
366 
367  if (ticks == 0)
368  ticks = 1;
369 
370  if (inHandlerMode())
371  {
372  if (xTimerChangePeriodFromISR(timer_id, ticks, &taskWoken) != pdPASS)
373  {
374  result = osErrorOS;
375  }
376  else
377  {
378  portEND_SWITCHING_ISR(taskWoken);
379  }
380  }
381  else
382  {
383  if (xTimerChangePeriod(timer_id, ticks, 0) != pdPASS)
384  result = osErrorOS;
385  }
386 
387 #else
388  result = osErrorOS;
389 #endif
390  return result;
391 }
392 
400 {
401  osStatus result = osOK;
402 #if (configUSE_TIMERS == 1)
403  portBASE_TYPE taskWoken = pdFALSE;
404 
405  if (inHandlerMode()) {
406  if (xTimerStopFromISR(timer_id, &taskWoken) != pdPASS) {
407  return osErrorOS;
408  }
409  portEND_SWITCHING_ISR(taskWoken);
410  }
411  else {
412  if (xTimerStop(timer_id, 0) != pdPASS) {
413  result = osErrorOS;
414  }
415  }
416 #else
417  result = osErrorOS;
418 #endif
419  return result;
420 }
421 
429 {
430 osStatus result = osOK;
431 
432 #if (configUSE_TIMERS == 1)
433 
434  if (inHandlerMode()) {
435  return osErrorISR;
436  }
437  else {
438  if ((xTimerDelete(timer_id, osWaitForever )) != pdPASS) {
439  result = osErrorOS;
440  }
441  }
442 
443 #else
444  result = osErrorOS;
445 #endif
446 
447  return result;
448 }
449 
450 /*************************** Signal Management ********************************/
458 int32_t osSignalSet (osThreadId thread_id, int32_t signal)
459 {
460 #if( configUSE_TASK_NOTIFICATIONS == 1 )
461  BaseType_t xHigherPriorityTaskWoken = pdFALSE;
462 
463  if (inHandlerMode())
464  {
465  if(xTaskNotifyFromISR( thread_id, (uint32_t)signal, eSetBits, &xHigherPriorityTaskWoken ) != pdPASS )
466  return osErrorOS;
467 
468  portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
469  }
470  else if(xTaskNotify( thread_id, (uint32_t)signal, eSetBits) != pdPASS )
471  {
472  return osErrorOS;
473  }
474 
475  return osOK;
476 #else
477  (void) thread_id;
478  (void) signal;
479 
480  return osErrorOS; /* Task Notification not supported */
481 #endif
482 }
483 
491 int32_t osSignalClear (osThreadId thread_id, int32_t signal);
492 
500 osEvent osSignalWait (int32_t signals, uint32_t millisec)
501 {
502  osEvent ret;
503 
504 #if( configUSE_TASK_NOTIFICATIONS == 1 )
505 
506  TickType_t ticks;
507 
508  ret.value.signals = 0;
509  ticks = 0;
510  if (millisec == osWaitForever) {
511  ticks = portMAX_DELAY;
512  }
513  else if (millisec != 0) {
514  ticks = millisec / portTICK_PERIOD_MS;
515  if (ticks == 0) {
516  ticks = 1;
517  }
518  }
519 
520  if (inHandlerMode())
521  {
522  ret.status = osErrorISR; /*Not allowed in ISR*/
523  }
524  else
525  {
526  if(xTaskNotifyWait( 0,(uint32_t) signals, (uint32_t *)&ret.value.signals, ticks) != pdTRUE)
527  {
528  if(ticks == 0) ret.status = osOK;
529  else ret.status = osEventTimeout;
530  }
531  else if(ret.value.signals < 0)
532  {
533  ret.status = osErrorValue;
534  }
535  else ret.status = osEventSignal;
536  }
537 #else
538  (void) signals;
539  (void) millisec;
540 
541  ret.status = osErrorOS; /* Task Notification not supported */
542 #endif
543 
544  return ret;
545 }
546 
547 /**************************** Mutex Management ********************************/
555 {
556 #if ( configUSE_MUTEXES == 1)
557  return xSemaphoreCreateMutex();
558 #else
559  return NULL;
560 #endif
561 }
562 
570 osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec)
571 {
572  TickType_t ticks;
573  portBASE_TYPE taskWoken = pdFALSE;
574 
575 
576  if (mutex_id == NULL) {
577  return osErrorParameter;
578  }
579 
580  ticks = 0;
581  if (millisec == osWaitForever) {
582  ticks = portMAX_DELAY;
583  }
584  else if (millisec != 0) {
585  ticks = millisec / portTICK_PERIOD_MS;
586  if (ticks == 0) {
587  ticks = 1;
588  }
589  }
590 
591  if (inHandlerMode()) {
592  if (xSemaphoreTakeFromISR(mutex_id, &taskWoken) != pdTRUE) {
593  return osErrorOS;
594  }
595  portEND_SWITCHING_ISR(taskWoken);
596  }
597  else if (xSemaphoreTake(mutex_id, ticks) != pdTRUE) {
598  return osErrorOS;
599  }
600 
601  return osOK;
602 }
603 
611 {
612  osStatus result = osOK;
613  portBASE_TYPE taskWoken = pdFALSE;
614 
615  if (inHandlerMode()) {
616  if (xSemaphoreGiveFromISR(mutex_id, &taskWoken) != pdTRUE) {
617  return osErrorOS;
618  }
619  portEND_SWITCHING_ISR(taskWoken);
620  }
621  else if (xSemaphoreGive(mutex_id) != pdTRUE)
622  {
623  result = osErrorOS;
624  }
625  return result;
626 }
627 
635 {
636  if (inHandlerMode()) {
637  return osErrorISR;
638  }
639 
640  vQueueDelete(mutex_id);
641 
642  return osOK;
643 }
644 
645 /******************** Semaphore Management Functions **************************/
646 
647 #if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0))
648 
656 osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count)
657 {
658  (void) semaphore_def;
659  osSemaphoreId sema;
660 
661  if (count == 1) {
663  return sema;
664  }
665 
666 #if (configUSE_COUNTING_SEMAPHORES == 1 )
667  return xSemaphoreCreateCounting(count, 0);
668 #else
669  return NULL;
670 #endif
671 }
672 
680 int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec)
681 {
682  TickType_t ticks;
683  portBASE_TYPE taskWoken = pdFALSE;
684 
685 
686  if (semaphore_id == NULL) {
687  return osErrorParameter;
688  }
689 
690  ticks = 0;
691  if (millisec == osWaitForever) {
692  ticks = portMAX_DELAY;
693  }
694  else if (millisec != 0) {
695  ticks = millisec / portTICK_PERIOD_MS;
696  if (ticks == 0) {
697  ticks = 1;
698  }
699  }
700 
701  if (inHandlerMode()) {
702  if (xSemaphoreTakeFromISR(semaphore_id, &taskWoken) != pdTRUE) {
703  return osErrorOS;
704  }
705  portEND_SWITCHING_ISR(taskWoken);
706  }
707  else if (xSemaphoreTake(semaphore_id, ticks) != pdTRUE) {
708  return osErrorOS;
709  }
710 
711  return osOK;
712 }
713 
721 {
722  osStatus result = osOK;
723  portBASE_TYPE taskWoken = pdFALSE;
724 
725 
726  if (inHandlerMode()) {
727  if (xSemaphoreGiveFromISR(semaphore_id, &taskWoken) != pdTRUE) {
728  return osErrorOS;
729  }
730  portEND_SWITCHING_ISR(taskWoken);
731  }
732  else {
733  if (xSemaphoreGive(semaphore_id) != pdTRUE) {
734  result = osErrorOS;
735  }
736  }
737 
738  return result;
739 }
740 
748 {
749  if (inHandlerMode()) {
750  return osErrorISR;
751  }
752 
753  vSemaphoreDelete(semaphore_id);
754 
755  return osOK;
756 }
757 
758 #endif /* Use Semaphores */
759 
760 /******************* Memory Pool Management Functions ***********************/
761 
762 #if (defined (osFeature_Pool) && (osFeature_Pool != 0))
763 
764 //TODO
765 //This is a primitive and inefficient wrapper around the existing FreeRTOS memory management.
766 //A better implementation will have to modify heap_x.c!
767 
768 
769 typedef struct os_pool_cb {
770  void *pool;
771  uint8_t *markers;
772  uint32_t pool_sz;
773  uint32_t item_sz;
774  uint32_t currentIndex;
775 } os_pool_cb_t;
776 
777 
785 {
786  osPoolId thePool;
787  int itemSize = 4 * ((pool_def->item_sz + 3) / 4);
788  uint32_t i;
789 
790  /* First have to allocate memory for the pool control block. */
791  thePool = pvPortMalloc(sizeof(os_pool_cb_t));
792  if (thePool) {
793  thePool->pool_sz = pool_def->pool_sz;
794  thePool->item_sz = itemSize;
795  thePool->currentIndex = 0;
796 
797  /* Memory for markers */
798  thePool->markers = pvPortMalloc(pool_def->pool_sz);
799  if (thePool->markers) {
800  /* Now allocate the pool itself. */
801  thePool->pool = pvPortMalloc(pool_def->pool_sz * itemSize);
802 
803  if (thePool->pool) {
804  for (i = 0; i < pool_def->pool_sz; i++) {
805  thePool->markers[i] = 0;
806  }
807  }
808  else {
809  vPortFree(thePool->markers);
810  vPortFree(thePool);
811  thePool = NULL;
812  }
813  }
814  else {
815  vPortFree(thePool);
816  thePool = NULL;
817  }
818  }
819 
820  return thePool;
821 }
822 
829 void *osPoolAlloc (osPoolId pool_id)
830 {
831  int dummy = 0;
832  void *p = NULL;
833  uint32_t i;
834  uint32_t index;
835 
836  if (inHandlerMode()) {
838  }
839  else {
841  }
842 
843  for (i = 0; i < pool_id->pool_sz; i++) {
844  index = pool_id->currentIndex + i;
845  if (index >= pool_id->pool_sz) {
846  index = 0;
847  }
848 
849  if (pool_id->markers[index] == 0) {
850  pool_id->markers[index] = 1;
851  p = (void *)((uint32_t)(pool_id->pool) + (index * pool_id->item_sz));
852  pool_id->currentIndex = index;
853  break;
854  }
855  }
856 
857  if (inHandlerMode()) {
859  }
860  else {
862  }
863 
864  return p;
865 }
866 
873 void *osPoolCAlloc (osPoolId pool_id)
874 {
875  void *p = osPoolAlloc(pool_id);
876 
877  if (p != NULL)
878  {
879  memset(p, 0, sizeof(pool_id->pool_sz));
880  }
881 
882  return p;
883 }
884 
892 osStatus osPoolFree (osPoolId pool_id, void *block)
893 {
894  uint32_t index;
895 
896  if (pool_id == NULL) {
897  return osErrorParameter;
898  }
899 
900  if (block == NULL) {
901  return osErrorParameter;
902  }
903 
904  if (block < pool_id->pool) {
905  return osErrorParameter;
906  }
907 
908  index = (uint32_t)block - (uint32_t)(pool_id->pool);
909  if (index % pool_id->item_sz) {
910  return osErrorParameter;
911  }
912  index = index / pool_id->item_sz;
913  if (index >= pool_id->pool_sz) {
914  return osErrorParameter;
915  }
916 
917  pool_id->markers[index] = 0;
918 
919  return osOK;
920 }
921 
922 
923 #endif /* Use Memory Pool Management */
924 
925 /******************* Message Queue Management Functions *********************/
926 
927 #if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) /* Use Message Queues */
928 
937 {
938  (void) thread_id;
939 
940  return xQueueCreate(queue_def->queue_sz, queue_def->item_sz);
941 }
942 
951 osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec)
952 {
953  portBASE_TYPE taskWoken = pdFALSE;
954  TickType_t ticks;
955 
956  ticks = millisec / portTICK_PERIOD_MS;
957  if (ticks == 0) {
958  ticks = 1;
959  }
960 
961  if (inHandlerMode()) {
962  if (xQueueSendFromISR(queue_id, &info, &taskWoken) != pdTRUE) {
963  return osErrorOS;
964  }
965  portEND_SWITCHING_ISR(taskWoken);
966  }
967  else {
968  if (xQueueSend(queue_id, &info, ticks) != pdTRUE) {
969  return osErrorOS;
970  }
971  }
972 
973  return osOK;
974 }
975 
983 osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec)
984 {
985  portBASE_TYPE taskWoken;
986  TickType_t ticks;
987  osEvent event;
988 
989  event.def.message_id = queue_id;
990  event.value.v = 0;
991 
992  if (queue_id == NULL) {
993  event.status = osErrorParameter;
994  return event;
995  }
996 
997  taskWoken = pdFALSE;
998 
999  ticks = 0;
1000  if (millisec == osWaitForever) {
1001  ticks = portMAX_DELAY;
1002  }
1003  else if (millisec != 0) {
1004  ticks = millisec / portTICK_PERIOD_MS;
1005  if (ticks == 0) {
1006  ticks = 1;
1007  }
1008  }
1009 
1010  if (inHandlerMode()) {
1011  if (xQueueReceiveFromISR(queue_id, &event.value.v, &taskWoken) == pdTRUE) {
1012  /* We have mail */
1013  event.status = osEventMessage;
1014  }
1015  else {
1016  event.status = osOK;
1017  }
1018  portEND_SWITCHING_ISR(taskWoken);
1019  }
1020  else {
1021  if (xQueueReceive(queue_id, &event.value.v, ticks) == pdTRUE) {
1022  /* We have mail */
1023  event.status = osEventMessage;
1024  }
1025  else {
1026  event.status = (ticks == 0) ? osOK : osEventTimeout;
1027  }
1028  }
1029 
1030  return event;
1031 }
1032 
1033 #endif /* Use Message Queues */
1034 
1035 /******************** Mail Queue Management Functions ***********************/
1036 #if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) /* Use Mail Queues */
1037 
1038 
1039 typedef struct os_mailQ_cb {
1043 } os_mailQ_cb_t;
1044 
1052 osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id)
1053 {
1054  (void) thread_id;
1055 
1056  osPoolDef_t pool_def = {queue_def->queue_sz, queue_def->item_sz, NULL};
1057 
1058 
1059  /* Create a mail queue control block */
1060  *(queue_def->cb) = pvPortMalloc(sizeof(struct os_mailQ_cb));
1061  if (*(queue_def->cb) == NULL) {
1062  return NULL;
1063  }
1064  (*(queue_def->cb))->queue_def = queue_def;
1065 
1066  /* Create a queue in FreeRTOS */
1067  (*(queue_def->cb))->handle = xQueueCreate(queue_def->queue_sz, sizeof(void *));
1068  if ((*(queue_def->cb))->handle == NULL) {
1069  vPortFree(*(queue_def->cb));
1070  return NULL;
1071  }
1072 
1073  /* Create a mail pool */
1074  (*(queue_def->cb))->pool = osPoolCreate(&pool_def);
1075  if ((*(queue_def->cb))->pool == NULL) {
1076  //TODO: Delete queue. How to do it in FreeRTOS?
1077  vPortFree(*(queue_def->cb));
1078  return NULL;
1079  }
1080 
1081  return *(queue_def->cb);
1082 }
1083 
1091 void *osMailAlloc (osMailQId queue_id, uint32_t millisec)
1092 {
1093  (void) millisec;
1094  void *p;
1095 
1096 
1097  if (queue_id == NULL) {
1098  return NULL;
1099  }
1100 
1101  p = osPoolAlloc(queue_id->pool);
1102 
1103  return p;
1104 }
1105 
1113 void *osMailCAlloc (osMailQId queue_id, uint32_t millisec)
1114 {
1115  uint32_t i;
1116  void *p = osMailAlloc(queue_id, millisec);
1117 
1118  if (p) {
1119  for (i = 0; i < sizeof(queue_id->queue_def->item_sz); i++) {
1120  ((uint8_t *)p)[i] = 0;
1121  }
1122  }
1123 
1124  return p;
1125 }
1126 
1134 osStatus osMailPut (osMailQId queue_id, void *mail)
1135 {
1136  portBASE_TYPE taskWoken;
1137 
1138 
1139  if (queue_id == NULL) {
1140  return osErrorParameter;
1141  }
1142 
1143  taskWoken = pdFALSE;
1144 
1145  if (inHandlerMode()) {
1146  if (xQueueSendFromISR(queue_id->handle, &mail, &taskWoken) != pdTRUE) {
1147  return osErrorOS;
1148  }
1149  portEND_SWITCHING_ISR(taskWoken);
1150  }
1151  else {
1152  if (xQueueSend(queue_id->handle, &mail, 0) != pdTRUE) {
1153  return osErrorOS;
1154  }
1155  }
1156 
1157  return osOK;
1158 }
1159 
1167 osEvent osMailGet (osMailQId queue_id, uint32_t millisec)
1168 {
1169  portBASE_TYPE taskWoken;
1170  TickType_t ticks;
1171  osEvent event;
1172 
1173  event.def.mail_id = queue_id;
1174 
1175  if (queue_id == NULL) {
1176  event.status = osErrorParameter;
1177  return event;
1178  }
1179 
1180  taskWoken = pdFALSE;
1181 
1182  ticks = 0;
1183  if (millisec == osWaitForever) {
1184  ticks = portMAX_DELAY;
1185  }
1186  else if (millisec != 0) {
1187  ticks = millisec / portTICK_PERIOD_MS;
1188  if (ticks == 0) {
1189  ticks = 1;
1190  }
1191  }
1192 
1193  if (inHandlerMode()) {
1194  if (xQueueReceiveFromISR(queue_id->handle, &event.value.p, &taskWoken) == pdTRUE) {
1195  /* We have mail */
1196  event.status = osEventMail;
1197  }
1198  else {
1199  event.status = osOK;
1200  }
1201  portEND_SWITCHING_ISR(taskWoken);
1202  }
1203  else {
1204  if (xQueueReceive(queue_id->handle, &event.value.p, ticks) == pdTRUE) {
1205  /* We have mail */
1206  event.status = osEventMail;
1207  }
1208  else {
1209  event.status = (ticks == 0) ? osOK : osEventTimeout;
1210  }
1211  }
1212 
1213  return event;
1214 }
1215 
1223 osStatus osMailFree (osMailQId queue_id, void *mail)
1224 {
1225  if (queue_id == NULL) {
1226  return osErrorParameter;
1227  }
1228 
1229  return osPoolFree(queue_id->pool, mail);
1230 }
1231 #endif /* Use Mail Queues */
1232 
1233 /*************************** Additional specific APIs to Free RTOS ************/
1240 {
1241 
1242 #if (INCLUDE_xTaskGetSchedulerState == 1 )
1244  {
1245 #endif /* INCLUDE_xTaskGetSchedulerState */
1247 #if (INCLUDE_xTaskGetSchedulerState == 1 )
1248  }
1249 #endif /* INCLUDE_xTaskGetSchedulerState */
1250 }
1251 
1252 #if ( INCLUDE_eTaskGetState == 1 )
1253 
1258 osThreadState osThreadGetState(osThreadId thread_id)
1259 {
1260  eTaskState ThreadState;
1261  osThreadState result;
1262 
1263  ThreadState = eTaskGetState(thread_id);
1264 
1265  switch (ThreadState)
1266  {
1267  case eRunning :
1268  result = osThreadRunning;
1269  break;
1270  case eReady :
1271  result = osThreadReady;
1272  break;
1273  case eBlocked :
1274  result = osThreadBlocked;
1275  break;
1276  case eSuspended :
1277  result = osThreadSuspended;
1278  break;
1279  case eDeleted :
1280  result = osThreadDeleted;
1281  break;
1282  default:
1283  result = osThreadError;
1284  }
1285 
1286  return result;
1287 }
1288 #endif /* INCLUDE_eTaskGetState */
1289 
1290 #if (INCLUDE_eTaskGetState == 1)
1291 
1296 osStatus osThreadIsSuspended(osThreadId thread_id)
1297 {
1298  if (eTaskGetState(thread_id) == eSuspended)
1299  return osOK;
1300  else
1301  return osErrorOS;
1302 }
1303 #endif /* INCLUDE_eTaskGetState */
1304 
1310 {
1311 #if (INCLUDE_vTaskSuspend == 1)
1312  vTaskSuspend(thread_id);
1313 
1314  return osOK;
1315 #else
1316  return osErrorResource;
1317 #endif
1318 }
1319 
1326 {
1327 #if (INCLUDE_vTaskSuspend == 1)
1328  if(inHandlerMode())
1329  {
1330  if (xTaskResumeFromISR(thread_id) == pdTRUE)
1331  {
1333  }
1334  }
1335  else
1336  {
1337  vTaskResume(thread_id);
1338  }
1339  return osOK;
1340 #else
1341  return osErrorResource;
1342 #endif
1343 }
1344 
1350 {
1351  vTaskSuspendAll();
1352 
1353  return osOK;
1354 }
1355 
1361 {
1362  if (xTaskResumeAll() == pdTRUE)
1363  return osOK;
1364  else
1365  return osErrorOS;
1366 
1367 }
1368 
1377 osStatus osDelayUntil (uint32_t *PreviousWakeTime, uint32_t millisec)
1378 {
1379 #if INCLUDE_vTaskDelayUntil
1380  TickType_t ticks = (millisec / portTICK_PERIOD_MS);
1381  vTaskDelayUntil((TickType_t *) PreviousWakeTime, ticks ? ticks : 1);
1382 
1383  return osOK;
1384 #else
1385  (void) millisec;
1386  (void) PreviousWakeTime;
1387 
1388  return osErrorResource;
1389 #endif
1390 }
1391 
1399 osStatus osThreadList (uint8_t *buffer)
1400 {
1401 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) )
1402  vTaskList((char *)buffer);
1403 #endif
1404  return osOK;
1405 }
1406 
1413 osEvent osMessagePeek (osMessageQId queue_id, uint32_t millisec)
1414 {
1415  TickType_t ticks;
1416  osEvent event;
1417 
1418  event.def.message_id = queue_id;
1419 
1420  if (queue_id == NULL) {
1421  event.status = osErrorParameter;
1422  return event;
1423  }
1424 
1425  ticks = 0;
1426  if (millisec == osWaitForever) {
1427  ticks = portMAX_DELAY;
1428  }
1429  else if (millisec != 0) {
1430  ticks = millisec / portTICK_PERIOD_MS;
1431  if (ticks == 0) {
1432  ticks = 1;
1433  }
1434  }
1435 
1436  if (xQueuePeek(queue_id, &event.value.v, ticks) == pdTRUE)
1437  {
1438  /* We have mail */
1439  event.status = osEventMessage;
1440  }
1441  else
1442  {
1443  event.status = (ticks == 0) ? osOK : osEventTimeout;
1444  }
1445 
1446  return event;
1447 }
1448 
1455 {
1456  (void) mutex_def;
1457 #if (configUSE_RECURSIVE_MUTEXES == 1)
1459 #else
1460  return NULL;
1461 #endif
1462 }
1463 
1470 {
1471 #if (configUSE_RECURSIVE_MUTEXES == 1)
1472  osStatus result = osOK;
1473 
1474  if (xSemaphoreGiveRecursive(mutex_id) != pdTRUE)
1475  {
1476  result = osErrorOS;
1477  }
1478  return result;
1479 #else
1480  return osErrorResource;
1481 #endif
1482 }
1483 
1490 osStatus osRecursiveMutexWait (osMutexId mutex_id, uint32_t millisec)
1491 {
1492 #if (configUSE_RECURSIVE_MUTEXES == 1)
1493  TickType_t ticks;
1494 
1495  if (mutex_id == NULL)
1496  {
1497  return osErrorParameter;
1498  }
1499 
1500  ticks = 0;
1501  if (millisec == osWaitForever)
1502  {
1503  ticks = portMAX_DELAY;
1504  }
1505  else if (millisec != 0)
1506  {
1507  ticks = millisec / portTICK_PERIOD_MS;
1508  if (ticks == 0)
1509  {
1510  ticks = 1;
1511  }
1512  }
1513 
1514  if (xSemaphoreTakeRecursive(mutex_id, ticks) != pdTRUE)
1515  {
1516  return osErrorOS;
1517  }
1518  return osOK;
1519 #else
1520  return osErrorResource;
1521 #endif
1522 }
#define pdTRUE
Definition: projdefs.h:83
Header of cmsis_os.c A new set of APIs are added in addition to existing ones, these APIs are specifi...
osStatus osKernelStart(void)
Start the RTOS Kernel with executing the specified thread.
Definition: cmsis_os.c:152
osThreadId osThreadGetId(void)
Return the thread ID of the current running thread.
Definition: cmsis_os.c:223
void vPortFree(void *pv) PRIVILEGED_FUNCTION
Definition: heap_1.c:149
#define xTimerChangePeriod(xTimer, xNewPeriod, xTicksToWait)
Definition: timers.h:525
osPoolId osPoolCreate(const osPoolDef_t *pool_def)
Create and Initialize a memory pool.
Definition: cmsis_os.c:784
osStatus osDelayUntil(uint32_t *PreviousWakeTime, uint32_t millisec)
Delay a task until a specified time.
Definition: cmsis_os.c:1377
uint32_t item_sz
size of an item
Definition: cmsis_os.h:360
#define portTICK_PERIOD_MS
Definition: portmacro.h:116
uint32_t v
message as 32-bit value
Definition: cmsis_os.h:386
#define portMAX_DELAY
Definition: portmacro.h:106
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
Delete a Semaphore.
Definition: cmsis_os.c:747
resource not available: a specified resource was not available.
Definition: cmsis_os.h:259
UBaseType_t uxTaskPriorityGetFromISR(TaskHandle_t xTask) PRIVILEGED_FUNCTION
void vQueueDelete(QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1738
function completed; signal event occurred.
Definition: cmsis_os.h:254
osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, void *argument)
Create a timer.
Definition: cmsis_os.c:340
#define xSemaphoreCreateCounting(uxMaxCount, uxInitialCount)
Definition: semphr.h:811
struct os_mailQ_cb ** cb
Definition: cmsis_os.h:377
int32_t signals
signal flags
Definition: cmsis_os.h:388
TaskHandle_t xTaskGetCurrentTaskHandle(void) PRIVILEGED_FUNCTION
#define xTimerStopFromISR(xTimer, pxHigherPriorityTaskWoken)
Definition: timers.h:836
osPriority tpriority
initial thread priority
Definition: cmsis_os.h:333
osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, int32_t count)
Create and Initialize a Semaphore object used for managing resources.
Definition: cmsis_os.c:656
uint8_t * markers
Definition: cmsis_os.c:771
value of a parameter is out of range.
Definition: cmsis_os.h:265
osStatus osMailPut(osMailQId queue_id, void *mail)
Put a mail to a queue.
Definition: cmsis_os.c:1134
union osEvent::@45 def
event definition
void vTaskPrioritySet(TaskHandle_t xTask, UBaseType_t uxNewPriority) PRIVILEGED_FUNCTION
osStatus osRecursiveMutexWait(osMutexId mutex_id, uint32_t millisec)
Release a Recursive Mutex.
Definition: cmsis_os.c:1490
osPoolId pool
Definition: cmsis_os.c:1042
void vTaskSuspendAll(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1633
int32_t osSignalSet(osThreadId thread_id, int32_t signal)
Set the specified Signal Flags of an active thread.
Definition: cmsis_os.c:458
uint32_t item_sz
size of an item
Definition: cmsis_os.h:376
uint32_t pool_sz
number of items (elements) in the pool
Definition: cmsis_os.h:359
function completed; no error or event occurred.
Definition: cmsis_os.h:253
osStatus osKernelInitialize(void)
Initialize the RTOS Kernel for creating objects.
TimerHandle_t xTimerCreate(const char *const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void *const pvTimerID, TimerCallbackFunction_t pxCallbackFunction) PRIVILEGED_FUNCTION
struct os_pool_cb os_pool_cb_t
priority: realtime (highest)
Definition: cmsis_os.h:242
Definition: task.h:114
uint32_t osKernelSysTick(void)
Get the value of the Kernel SysTick timer.
Definition: cmsis_os.c:186
QueueHandle_t handle
Definition: cmsis_os.c:1041
#define taskSCHEDULER_NOT_STARTED
Definition: task.h:257
function completed; message event occurred.
Definition: cmsis_os.h:255
#define taskYIELD()
Definition: task.h:202
void osSystickHandler(void)
Handles the tick increment.
Definition: cmsis_os.c:1239
Definition: task.h:118
#define vSemaphoreDelete(xSemaphore)
Definition: semphr.h:825
os_pthread pthread
start address of thread function
Definition: cmsis_os.h:332
BaseType_t xTaskResumeFromISR(TaskHandle_t xTaskToResume) PRIVILEGED_FUNCTION
void * pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION
Definition: heap_1.c:99
uint32_t pool_sz
Definition: cmsis_os.c:772
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedStatusValue)
Definition: FreeRTOS.h:301
osMailQId osMailCreate(const osMailQDef_t *queue_def, osThreadId thread_id)
Create and Initialize mail queue.
Definition: cmsis_os.c:1052
osStatus osThreadResumeAll(void)
Resume execution of a all suspended threads.
Definition: cmsis_os.c:1360
void vTaskList(char *pcWriteBuffer) PRIVILEGED_FUNCTION
Definition: task.h:115
unspecified RTOS error: run-time error but no other error message fits.
Definition: cmsis_os.h:266
void vPortEnterCritical(void)
Definition: port.c:391
parameter error: a mandatory parameter was missing or specified an incorrect object.
Definition: cmsis_os.h:258
#define xQueueReceive(xQueue, pvBuffer, xTicksToWait)
Definition: queue.h:814
#define xTaskNotifyFromISR(xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken)
Definition: task.h:1567
osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec)
Wait until a Mutex becomes available.
Definition: cmsis_os.c:570
uint32_t currentIndex
Definition: cmsis_os.c:774
uint32_t TickType_t
Definition: portmacro.h:105
void * p
message or mail as void pointer
Definition: cmsis_os.h:387
osStatus osMutexRelease(osMutexId mutex_id)
Release a Mutex that was obtained by osMutexWait.
Definition: cmsis_os.c:610
osMailQId mail_id
mail id obtained by osMailCreate
Definition: cmsis_os.h:391
#define portSET_INTERRUPT_MASK_FROM_ISR()
Definition: FreeRTOS.h:297
#define xTimerChangePeriodFromISR(xTimer, xNewPeriod, pxHigherPriorityTaskWoken)
Definition: timers.h:909
osMutexId osRecursiveMutexCreate(const osMutexDef_t *mutex_def)
Create and Initialize a Recursive Mutex.
Definition: cmsis_os.c:1454
eTaskState
Definition: task.h:112
void vTaskStartScheduler(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1543
#define NULL
Definition: usbd_def.h:53
BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
#define xTimerDelete(xTimer, xTicksToWait)
Definition: timers.h:563
UBaseType_t uxTaskPriorityGet(TaskHandle_t xTask) PRIVILEGED_FUNCTION
TickType_t xTaskGetTickCountFromISR(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1779
osStatus status
status code: event or error information
Definition: cmsis_os.h:384
#define xSemaphoreTakeRecursive(xMutex, xBlockTime)
Definition: semphr.h:345
osStatus osThreadSuspendAll(void)
Suspend execution of a all active threads.
Definition: cmsis_os.c:1349
Definition: task.h:125
osStatus osThreadSuspend(osThreadId thread_id)
Suspend execution of a thread.
Definition: cmsis_os.c:1309
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1764
int32_t osKernelRunning(void)
Check if the RTOS kernel is already started.
Definition: cmsis_os.c:167
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create and Initialize a Message Queue.
Definition: cmsis_os.c:936
void * osPoolAlloc(osPoolId pool_id)
Allocate a memory block from a memory pool.
Definition: cmsis_os.c:829
#define portYIELD_FROM_ISR(x)
Definition: portmacro.h:135
osStatus osSemaphoreRelease(osSemaphoreId semaphore_id)
Release a Semaphore token.
Definition: cmsis_os.c:720
osStatus osMailFree(osMailQId queue_id, void *mail)
Free a memory block from a mail.
Definition: cmsis_os.c:1223
void vTaskDelete(TaskHandle_t xTaskToDelete) PRIVILEGED_FUNCTION
repeating timer
Definition: cmsis_os.h:286
#define osWaitForever
wait forever timeout value
Definition: cmsis_os.h:248
SemaphoreHandle_t osSemaphoreId
Definition: cmsis_os.h:313
#define xTimerStop(xTimer, xTicksToWait)
Definition: timers.h:445
SemaphoreHandle_t osMutexId
Definition: cmsis_os.h:309
void vTaskDelayUntil(TickType_t *const pxPreviousWakeTime, const TickType_t xTimeIncrement) PRIVILEGED_FUNCTION
osStatus osThreadList(uint8_t *buffer)
Lists all the current threads, along with their current state and stack usage high water mark...
Definition: cmsis_os.c:1399
long BaseType_t
Definition: portmacro.h:98
#define xQueuePeek(xQueue, pvBuffer, xTicksToWait)
Definition: queue.h:688
void vTaskSuspend(TaskHandle_t xTaskToSuspend) PRIVILEGED_FUNCTION
osEvent osSignalWait(int32_t signals, uint32_t millisec)
Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
Definition: cmsis_os.c:500
#define pdPASS
Definition: projdefs.h:85
osMessageQId message_id
message id obtained by osMessageCreate
Definition: cmsis_os.h:392
void * osMailAlloc(osMailQId queue_id, uint32_t millisec)
Allocate a memory block from a mail.
Definition: cmsis_os.c:1091
#define xQueueSend(xQueue, pvItemToQueue, xTicksToWait)
Definition: queue.h:421
function completed; timeout occurred.
Definition: cmsis_os.h:257
union osEvent::@44 value
event value
int32_t osSignalClear(osThreadId thread_id, int32_t signal)
Clear the specified Signal Flags of an active thread.
void * TaskHandle_t
Definition: task.h:103
not allowed in ISR context: the function cannot be called from interrupt service routines.
Definition: cmsis_os.h:261
void * QueueHandle_t
Definition: queue.h:88
osStatus osThreadTerminate(osThreadId thread_id)
Terminate execution of a thread and remove it from Active Threads.
Definition: cmsis_os.c:238
osStatus osTimerDelete(osTimerId timer_id)
Delete a timer.
Definition: cmsis_os.c:428
priority: idle (lowest)
Definition: cmsis_os.h:236
osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *argument)
Create a thread and add it to Active Threads and set it to state READY.
Definition: cmsis_os.c:204
struct os_mailQ_cb os_mailQ_cb_t
QueueHandle_t osMessageQId
Definition: cmsis_os.h:321
os_ptimer ptimer
start address of a timer function
Definition: cmsis_os.h:341
#define xSemaphoreGive(xSemaphore)
Definition: semphr.h:423
#define xSemaphoreTake(xSemaphore, xBlockTime)
Definition: semphr.h:252
#define portCHAR
Definition: portmacro.h:89
osPriority osThreadGetPriority(osThreadId thread_id)
Get current priority of an active thread.
Definition: cmsis_os.c:283
void vTaskResume(TaskHandle_t xTaskToResume) PRIVILEGED_FUNCTION
uint32_t item_sz
size of an item
Definition: cmsis_os.h:368
#define xSemaphoreTakeFromISR(xSemaphore, pxHigherPriorityTaskWoken)
Definition: semphr.h:646
#define pdFALSE
Definition: projdefs.h:82
BaseType_t xQueueReceiveFromISR(QueueHandle_t xQueue, void *const pvBuffer, BaseType_t *const pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
Definition: queue.c:1551
#define xTaskNotify(xTaskToNotify, ulValue, eAction)
Definition: task.h:1476
osStatus osTimerStart(osTimerId timer_id, uint32_t millisec)
Start or restart a timer.
Definition: cmsis_os.c:360
BaseType_t xTaskResumeAll(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1671
uint32_t queue_sz
number of elements in the queue
Definition: cmsis_os.h:367
BaseType_t xTaskGetSchedulerState(void) PRIVILEGED_FUNCTION
uint32_t queue_sz
number of elements in the queue
Definition: cmsis_os.h:375
osStatus osRecursiveMutexRelease(osMutexId mutex_id)
Release a Recursive Mutex.
Definition: cmsis_os.c:1469
osStatus osMutexDelete(osMutexId mutex_id)
Delete a Mutex.
Definition: cmsis_os.c:634
#define xSemaphoreCreateRecursiveMutex()
Definition: semphr.h:748
TimerHandle_t osTimerId
Definition: cmsis_os.h:305
const osMailQDef_t * queue_def
Definition: cmsis_os.c:1040
void * osPoolCAlloc(osPoolId pool_id)
Allocate a memory block from a memory pool and set memory block to zero.
Definition: cmsis_os.c:873
uint32_t stacksize
stack size requirements in bytes; 0 is default stack size
Definition: cmsis_os.h:335
#define portBASE_TYPE
Definition: portmacro.h:95
osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority)
Change priority of an active thread.
Definition: cmsis_os.c:267
osStatus osThreadYield(void)
Pass control to next thread that is in state READY.
Definition: cmsis_os.c:253
osEvent osMessagePeek(osMessageQId queue_id, uint32_t millisec)
Receive an item from a queue without removing the item from the queue.
Definition: cmsis_os.c:1413
__STATIC_INLINE uint32_t __get_IPSR(void)
Get IPSR Register.
Definition: cmsis_armcc.h:81
osEvent osMailGet(osMailQId queue_id, uint32_t millisec)
Get a mail from a queue.
Definition: cmsis_os.c:1167
char * name
Thread name.
Definition: cmsis_os.h:331
void * pool
Definition: cmsis_os.c:770
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
Definition: cmsis_os.c:951
void vTaskDelay(const TickType_t xTicksToDelay) PRIVILEGED_FUNCTION
#define tskIDLE_PRIORITY
Definition: task.h:192
Definition: task.h:116
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
Definition: cmsis_os.c:680
#define xSemaphoreGiveRecursive(xMutex)
Definition: semphr.h:507
osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
Get a Message or Wait for a Message from a Queue.
Definition: cmsis_os.c:983
#define vSemaphoreCreateBinary(xSemaphore)
Definition: semphr.h:131
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:305
#define portEND_SWITCHING_ISR(xSwitchRequired)
Definition: portmacro.h:134
#define xQueueCreate(uxQueueLength, uxItemSize)
Definition: queue.h:173
void xPortSysTickHandler(void)
Definition: port.c:479
osMutexId osMutexCreate(const osMutexDef_t *mutex_def)
Create and Initialize a Mutex object.
Definition: cmsis_os.c:554
uint32_t item_sz
Definition: cmsis_os.c:773
#define xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask)
Definition: task.h:345
osStatus osTimerStop(osTimerId timer_id)
Stop a timer.
Definition: cmsis_os.c:399
osStatus osThreadResume(osThreadId thread_id)
Resume execution of a suspended thread.
Definition: cmsis_os.c:1325
osStatus
Definition: cmsis_os.h:252
void * osMailCAlloc(osMailQId queue_id, uint32_t millisec)
Allocate a memory block from a mail and set memory block to zero.
Definition: cmsis_os.c:1113
#define xQueueSendFromISR(xQueue, pvItemToQueue, pxHigherPriorityTaskWoken)
Definition: queue.h:1261
#define xSemaphoreCreateMutex()
Definition: semphr.h:693
void(* TaskFunction_t)(void *)
Definition: projdefs.h:77
osStatus osPoolFree(osPoolId pool_id, void *block)
Return an allocated memory block back to a specific memory pool.
Definition: cmsis_os.c:892
#define xSemaphoreGiveFromISR(xSemaphore, pxHigherPriorityTaskWoken)
Definition: semphr.h:612
eTaskState eTaskGetState(TaskHandle_t xTask) PRIVILEGED_FUNCTION
function completed; mail event occurred.
Definition: cmsis_os.h:256
TaskHandle_t osThreadId
Definition: cmsis_os.h:301
void vPortExitCritical(void)
Definition: port.c:408
osPriority
Definition: cmsis_os.h:235
os_timer_type
Definition: cmsis_os.h:284
system cannot determine priority or thread has illegal priority
Definition: cmsis_os.h:243