1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** ThreadX Component */ 16 /** */ 17 /** FreeRTOS compatibility Kit */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 /* RELEASE HISTORY */ 22 /* */ 23 /* DATE NAME DESCRIPTION */ 24 /* */ 25 /* 09-30-2020 William E. Lamie Initial Version 6.1 */ 26 /* 03-02-2021 Andres Mlinar Modified comment(s), fixed */ 27 /* interrupt macros, */ 28 /* resulting in version 6.1.5 */ 29 /**************************************************************************/ 30 31 #ifndef FREERTOS_H 32 #define FREERTOS_H 33 34 #include <stdint.h> 35 36 #include <tx_api.h> 37 38 #include <FreeRTOSConfig.h> 39 40 //// Hard coded configurations and other preprocessor definitions for compatibility. 41 #define portCRITICAL_NESTING_IN_TCB 0 42 #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB 43 #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) 44 #define portSETUP_TCB( pxTCB ) ( void ) pxTCB 45 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() 46 #define portPRIVILEGE_BIT ((UBaseType_t)0x00) 47 #define portYIELD_WITHIN_API portYIELD 48 #define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) 49 #define portTASK_USES_FLOATING_POINT() 50 #define portALLOCATE_SECURE_CONTEXT(ulSecureStackSize) 51 #define portDONT_DISCARD 52 #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() 53 #define mtCOVERAGE_TEST_MARKER() 54 #define mtCOVERAGE_TEST_DELAY() 55 #define portASSERT_IF_IN_ISR() 56 #define portTICK_TYPE_IS_ATOMIC 1 57 #define portTICK_TYPE_ENTER_CRITICAL() 58 #define portTICK_TYPE_EXIT_CRITICAL() 59 #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 60 #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR(x) (void) x 61 62 #if (configENABLE_BACKWARD_COMPATIBILITY == 1) 63 #define eTaskStateGet eTaskGetState 64 #define portTickType TickType_t 65 #define xTaskHandle TaskHandle_t 66 #define xQueueHandle QueueHandle_t 67 #define xSemaphoreHandle SemaphoreHandle_t 68 #define xQueueSetHandle QueueSetHandle_t 69 #define xQueueSetMemberHandle QueueSetMemberHandle_t 70 #define xTimeOutType TimeOut_t 71 #define xMemoryRegion MemoryRegion_t 72 #define xTaskParameters TaskParameters_t 73 #define xTaskStatusType TaskStatus_t 74 #define xTimerHandle TimerHandle_t 75 #define xCoRoutineHandle CoRoutineHandle_t 76 #define pdTASK_HOOK_CODE TaskHookFunction_t 77 #define portTICK_RATE_MS portTICK_PERIOD_MS 78 #define pcTaskGetTaskName pcTaskGetName 79 #define pcTimerGetTimerName pcTimerGetName 80 #define pcQueueGetQueueName pcQueueGetName 81 #define vTaskGetTaskInfo vTaskGetInfo 82 #define tmrTIMER_CALLBACK TimerCallbackFunction_t 83 #define pdTASK_CODE TaskFunction_t 84 #define xListItem ListItem_t 85 #define xList List_t 86 #define pxContainer pvContainer 87 #endif // (#if configENABLE_BACKWARD_COMPATIBILITY == 1) 88 89 #define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ 90 ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) 91 92 //// Trace is not supported. 93 #define traceSTART() 94 #define traceEND() 95 96 //// Other 97 #define vQueueAddToRegistry(xQueue, pcName) 98 #define vQueueUnregisterQueue(xQueue) 99 100 // Assertion failure macro invoked on internal errors. 101 #ifndef TX_FREERTOS_ASSERT_FAIL 102 #define TX_FREERTOS_ASSERT_FAIL() 103 #endif 104 105 // Assertion check macro used to check for invalid arguments. 106 #ifndef configASSERT 107 #define configASSERT(x) 108 #endif 109 110 #ifndef configSTACK_DEPTH_TYPE 111 #define configSTACK_DEPTH_TYPE uint16_t 112 #endif 113 114 typedef LONG BaseType_t; 115 typedef ULONG UBaseType_t; 116 typedef UINT StackType_t; 117 118 #ifndef TX_FREERTOS_AUTO_INIT 119 #define TX_FREERTOS_AUTO_INIT 0 120 #endif 121 122 #ifndef configMINIMAL_STACK_SIZE 123 #error "configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h" 124 #endif 125 126 #ifndef configUSE_16_BIT_TICKS 127 #define configUSE_16_BIT_TICKS 0 128 #endif 129 130 #if (configUSE_16_BIT_TICKS == 1) 131 typedef uint16_t TickType_t; 132 #define portMAX_DELAY (TickType_t) (0xffffU) 133 #else 134 typedef uint32_t TickType_t; 135 #define portMAX_DELAY (TickType_t) (0xffffffffUL) 136 137 #define portTICK_TYPE_IS_ATOMIC 1 // TODO - is this needed. 138 #endif 139 140 typedef void (*TaskFunction_t)(void *); 141 142 typedef enum 143 { 144 eNoAction = 0, 145 eSetBits, 146 eIncrement, 147 eSetValueWithOverwrite, 148 eSetValueWithoutOverwrite, 149 } eNotifyAction; 150 151 152 typedef enum 153 { 154 eRunning = 0, 155 eReady, 156 eBlocked, 157 eSuspended, 158 eDeleted, 159 eInvalid 160 } eTaskState; 161 162 #define TXFR_NOTIFYACTION_VALID(x) (((int)x >= (int)eNoAction) && ((int)x <= (int)eSetValueWithoutOverwrite)) 163 164 typedef struct txfr_queueset txfr_queueset_t; 165 166 typedef struct txfr_task txfr_task_t; 167 168 // Task related structures and type definitions. 169 struct txfr_task { 170 txfr_task_t *p_next; 171 TX_THREAD thread; 172 TaskFunction_t p_task_func; 173 void *p_task_arg; 174 uint32_t task_notify_val; 175 uint32_t task_notify_val_pend; 176 uint32_t *p_notify_val_ret; 177 TX_SEMAPHORE notification_sem; 178 uint8_t notification_pending; 179 uint8_t clear_on_pend; 180 uint32_t clear_mask; 181 uint8_t allocated; 182 }; 183 184 typedef txfr_task_t StaticTask_t; 185 typedef txfr_task_t* TaskHandle_t; 186 187 188 // Semaphore related structures and type definitions. 189 typedef struct txfr_sem { 190 TX_SEMAPHORE sem; 191 TX_MUTEX mutex; 192 UBaseType_t max_count; 193 uint8_t allocated; 194 uint8_t is_mutex; 195 txfr_queueset_t *p_set; 196 } txfr_sem_t; 197 198 typedef txfr_sem_t *SemaphoreHandle_t; 199 typedef txfr_sem_t StaticSemaphore_t; 200 201 202 // Queue related structures and type definitions. 203 typedef struct txfr_queue { 204 ULONG id; 205 uint8_t allocated; 206 txfr_queueset_t *p_set; 207 uint8_t *p_mem; 208 TX_SEMAPHORE read_sem; 209 TX_SEMAPHORE write_sem; 210 uint8_t *p_write; 211 uint8_t *p_read; 212 UBaseType_t queue_length; 213 UBaseType_t msg_size; 214 } txfr_queue_t; 215 216 typedef txfr_queue_t *QueueHandle_t; 217 typedef txfr_queue_t StaticQueue_t; 218 219 220 // Event group related structures and type definitions. 221 typedef TickType_t EventBits_t; 222 223 typedef struct txfr_event { 224 TX_EVENT_FLAGS_GROUP event; 225 uint8_t allocated; 226 } txfr_event_t; 227 228 typedef txfr_event_t *EventGroupHandle_t; 229 typedef txfr_event_t StaticEventGroup_t; 230 231 232 // Timers related structures and type definitions. 233 typedef struct txfr_timer txfr_timer_t; 234 typedef txfr_timer_t *TimerHandle_t; 235 typedef txfr_timer_t StaticTimer_t; 236 237 typedef void (*TimerCallbackFunction_t)(TimerHandle_t xTimer); 238 239 struct txfr_timer { 240 TX_TIMER timer; 241 uint32_t period; 242 uint8_t one_shot; 243 uint8_t allocated; 244 void *id; 245 TimerCallbackFunction_t callback; 246 }; 247 248 249 // Queue set related structures and type definitions. 250 struct txfr_queueset { 251 TX_QUEUE queue; 252 }; 253 254 typedef txfr_queueset_t *QueueSetHandle_t; 255 typedef void *QueueSetMemberHandle_t; 256 257 // Common definitions. 258 #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 259 #define errQUEUE_BLOCKED ( -4 ) 260 #define errQUEUE_YIELD ( -5 ) 261 262 #define pdFALSE ((BaseType_t)0) 263 #define pdTRUE ((BaseType_t)1) 264 265 #define pdPASS (pdTRUE) 266 #define pdFAIL (pdFALSE) 267 #define errQUEUE_EMPTY ((BaseType_t)0) 268 #define errQUEUE_FULL ((BaseType_t)0) 269 270 271 // Initialize the adaptation layer. 272 UINT tx_freertos_init(void); 273 274 #define tskIDLE_PRIORITY ((UBaseType_t)0U) 275 276 #define taskYIELD() tx_thread_relinquish() 277 #define taskYIELD_FROM_ISR() 278 279 void *pvPortMalloc(size_t xWantedSize); 280 void vPortFree(void *pv); 281 void vPortEnterCritical(void); 282 void vPortExitCritical(void); 283 284 //// 285 // Task API 286 #ifndef taskENTER_CRITICAL_FROM_ISR 287 #define taskENTER_CRITICAL_FROM_ISR() __get_interrupt_state(); __disable_interrupt(); 288 #endif 289 290 #ifndef taskEXIT_CRITICAL_FROM_ISR 291 #define taskEXIT_CRITICAL_FROM_ISR(x) __set_interrupt_state(x); 292 #endif 293 294 #ifndef portDISABLE_INTERRUPTS 295 #if defined(__IAR_SYSTEMS_ICC__) 296 #define portDISABLE_INTERRUPTS() __disable_interrupt() 297 #elif defined(__GNUC__ ) 298 #define portDISABLE_INTERRUPTS() __disable_interrupts() 299 #elif defined(__ARMCC_VERSION) 300 #define portDISABLE_INTERRUPTS() __disable_irq() 301 #else 302 UINT _tx_thread_interrupt_disable(VOID); 303 #define portDISABLE_INTERRUPTS() _tx_thread_interrupt_disable() 304 #endif 305 #endif 306 307 #ifndef portENABLE_INTERRUPTS 308 #if defined(__IAR_SYSTEMS_ICC__) 309 #define portENABLE_INTERRUPTS() __enable_interrupt() 310 #elif defined(__GNUC__ ) 311 #define portENABLE_INTERRUPTS() __enable_interrupts() 312 #elif defined(__ARMCC_VERSION) 313 #define portENABLE_INTERRUPTS() __enable_irq() 314 #else 315 VOID _tx_thread_interrupt_restore(UINT previous_posture); 316 #define portENABLE_INTERRUPTS() _tx_thread_interrupt_restore(TX_INT_ENABLE) 317 #endif 318 #endif 319 320 #define taskENTER_CRITICAL() portENTER_CRITICAL() 321 #define taskEXIT_CRITICAL() portEXIT_CRITICAL() 322 #define portENTER_CRITICAL() vPortEnterCritical() 323 #define portEXIT_CRITICAL() vPortExitCritical() 324 325 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() 326 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() 327 328 #define taskSCHEDULER_SUSPENDED ((BaseType_t)0) 329 #define taskSCHEDULER_NOT_STARTED ((BaseType_t)1) 330 #define taskSCHEDULER_RUNNING ((BaseType_t)2) 331 332 void vTaskStartScheduler(void); 333 334 BaseType_t xTaskGetSchedulerState(void); 335 336 void vTaskSuspendAll(void); 337 338 BaseType_t xTaskResumeAll(void); 339 340 TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, 341 const char *const pcName, 342 const configSTACK_DEPTH_TYPE ulStackDepth, 343 void *const pvParameters, 344 UBaseType_t uxPriority, 345 StackType_t *const puxStackBuffer, 346 StaticTask_t *const pxTaskBuffer); 347 348 BaseType_t xTaskCreate(TaskFunction_t pvTaskCode, 349 const char * const pcName, 350 const configSTACK_DEPTH_TYPE usStackDepth, 351 void *pvParameters, 352 UBaseType_t uxPriority, 353 TaskHandle_t * const pxCreatedTask); 354 355 UBaseType_t uxTaskGetNumberOfTasks(void); 356 357 void vTaskDelete(TaskHandle_t xTask); 358 359 void vTaskDelay(const TickType_t xTicksToDelay); 360 361 void vTaskDelayUntil(TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement); 362 363 TaskHandle_t xTaskGetCurrentTaskHandle(void); 364 365 void vTaskSuspend(TaskHandle_t xTaskToSuspend); 366 367 void vTaskResume(TaskHandle_t xTaskToResume); 368 369 BaseType_t xTaskResumeFromISR(TaskHandle_t xTaskToResume); 370 371 BaseType_t xTaskAbortDelay(TaskHandle_t xTask); 372 373 UBaseType_t uxTaskPriorityGet(const TaskHandle_t xTask); 374 375 UBaseType_t uxTaskPriorityGetFromISR(const TaskHandle_t xTask); 376 377 void vTaskPrioritySet(TaskHandle_t xTask, 378 UBaseType_t uxNewPriority); 379 380 char *pcTaskGetName(TaskHandle_t xTaskToQuery); 381 382 eTaskState eTaskGetState(TaskHandle_t xTask); 383 384 TickType_t xTaskGetTickCount(void); 385 386 TickType_t xTaskGetTickCountFromISR(void); 387 388 //// 389 // Task notification API. 390 391 BaseType_t xTaskNotifyGive(TaskHandle_t xTaskToNotify); 392 393 void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify, 394 BaseType_t *pxHigherPriorityTaskWoken); 395 396 uint32_t ulTaskNotifyTake(BaseType_t xClearCountOnExit, 397 TickType_t xTicksToWait); 398 399 BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry, 400 uint32_t ulBitsToClearOnExit, 401 uint32_t *pulNotificationValue, 402 TickType_t xTicksToWait ); 403 404 BaseType_t xTaskNotify(TaskHandle_t xTaskToNotify, 405 uint32_t ulValue, 406 eNotifyAction eAction); 407 408 BaseType_t xTaskNotifyFromISR(TaskHandle_t xTaskToNotify, 409 uint32_t ulValue, 410 eNotifyAction eAction, 411 BaseType_t *pxHigherPriorityTaskWoken); 412 413 BaseType_t xTaskNotifyAndQuery(TaskHandle_t xTaskToNotify, 414 uint32_t ulValue, 415 eNotifyAction eAction, 416 uint32_t *pulPreviousNotifyValue); 417 418 #define xTaskGenericNotify(a, b, c, d) xTaskNotifyAndQuery(a, b, c, d) 419 420 BaseType_t xTaskNotifyAndQueryFromISR(TaskHandle_t xTaskToNotify, 421 uint32_t ulValue, 422 eNotifyAction eAction, 423 uint32_t *pulPreviousNotifyValue, 424 BaseType_t *pxHigherPriorityTaskWoken); 425 426 #define xTaskGenericNotifyFromISR(a, b, c, d, e) xTaskNotifyAndQueryFromISR(a, b, c, d, e) 427 428 BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask); 429 430 uint32_t ulTaskNotifyValueClear(TaskHandle_t xTask, 431 uint32_t ulBitsToClear); 432 433 //// 434 // Semaphore API. 435 436 #define semBINARY_SEMAPHORE_QUEUE_LENGTH ((uint8_t)1U) 437 #define semSEMAPHORE_QUEUE_ITEM_LENGTH ((uint8_t)0U) 438 #define semGIVE_BLOCK_TIME ((TickType_t)0U) 439 440 441 SemaphoreHandle_t xSemaphoreCreateCounting(UBaseType_t uxMaxCount, 442 UBaseType_t uxInitialCount); 443 444 SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, 445 UBaseType_t uxInitialCount, 446 StaticSemaphore_t *pxSemaphoreBuffer); 447 448 SemaphoreHandle_t xSemaphoreCreateBinary(void); 449 450 SemaphoreHandle_t xSemaphoreCreateBinaryStatic(StaticSemaphore_t *pxSemaphoreBuffer); 451 452 SemaphoreHandle_t xSemaphoreCreateMutex(void); 453 454 SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t *pxMutexBuffer); 455 456 SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void); 457 458 SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic(StaticSemaphore_t *pxMutexBuffer); 459 460 void vSemaphoreDelete(SemaphoreHandle_t xSemaphore); 461 462 BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait); 463 464 BaseType_t xSemaphoreTakeFromISR(SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken); 465 466 BaseType_t xSemaphoreTakeRecursive(SemaphoreHandle_t xMutex, TickType_t xTicksToWait); 467 468 BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore); 469 470 BaseType_t xSemaphoreGiveFromISR(SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken); 471 472 BaseType_t xSemaphoreGiveRecursive(SemaphoreHandle_t xMutex); 473 474 UBaseType_t uxSemaphoreGetCount(SemaphoreHandle_t xSemaphore); 475 476 TaskHandle_t xSemaphoreGetMutexHolder(SemaphoreHandle_t xMutex); 477 478 TaskHandle_t xSemaphoreGetMutexHolderFromISR(SemaphoreHandle_t xMutex); 479 480 481 //// 482 // Queue API. 483 484 QueueHandle_t xQueueCreate(UBaseType_t uxQueueLength, UBaseType_t uxItemSize); 485 486 QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, 487 UBaseType_t uxItemSize, 488 uint8_t *pucQueueStorageBuffer, 489 StaticQueue_t *pxQueueBuffer ); 490 491 void vQueueDelete(QueueHandle_t xQueue); 492 493 BaseType_t xQueueSend(QueueHandle_t xQueue, 494 const void * pvItemToQueue, 495 TickType_t xTicksToWait); 496 497 BaseType_t xQueueSendFromISR(QueueHandle_t xQueue, 498 const void * pvItemToQueue, 499 BaseType_t *pxHigherPriorityTaskWoken); 500 501 BaseType_t xQueueSendToBack(QueueHandle_t xQueue, 502 const void * pvItemToQueue, 503 TickType_t xTicksToWait); 504 505 BaseType_t xQueueSendToBackFromISR(QueueHandle_t xQueue, 506 const void * pvItemToQueue, 507 BaseType_t *pxHigherPriorityTaskWoken); 508 509 BaseType_t xQueueSendToFront(QueueHandle_t xQueue, 510 const void * pvItemToQueue, 511 TickType_t xTicksToWait); 512 513 BaseType_t xQueueSendToFrontFromISR(QueueHandle_t xQueue, 514 const void * pvItemToQueue, 515 BaseType_t *pxHigherPriorityTaskWoken); 516 517 BaseType_t xQueueReceive(QueueHandle_t xQueue, 518 void *pvBuffer, 519 TickType_t xTicksToWait); 520 521 BaseType_t xQueueReceiveFromISR(QueueHandle_t xQueue, 522 void *pvBuffer, 523 BaseType_t *pxHigherPriorityTaskWoken); 524 525 BaseType_t xQueuePeek(QueueHandle_t xQueue, 526 void *pvBuffer, 527 TickType_t xTicksToWait); 528 529 BaseType_t xQueuePeekFromISR(QueueHandle_t xQueue, 530 void *pvBuffer); 531 532 UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue); 533 534 UBaseType_t uxQueueMessagesWaitingFromISR(QueueHandle_t xQueue); 535 536 UBaseType_t uxQueueSpacesAvailable(QueueHandle_t xQueue); 537 538 BaseType_t xQueueIsQueueEmptyFromISR(const QueueHandle_t xQueue); 539 540 BaseType_t xQueueIsQueueFullFromISR(const QueueHandle_t xQueue); 541 542 BaseType_t xQueueReset(QueueHandle_t xQueue); 543 544 BaseType_t xQueueOverwrite(QueueHandle_t xQueue, 545 const void * pvItemToQueue); 546 547 BaseType_t xQueueOverwriteFromISR(QueueHandle_t xQueue, 548 const void * pvItemToQueue, 549 BaseType_t *pxHigherPriorityTaskWoken); 550 551 552 //// 553 // Event group API. 554 555 EventGroupHandle_t xEventGroupCreate(void); 556 557 EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer); 558 559 void vEventGroupDelete(EventGroupHandle_t xEventGroup); 560 561 EventBits_t xEventGroupWaitBits(const EventGroupHandle_t xEventGroup, 562 const EventBits_t uxBitsToWaitFor, 563 const BaseType_t xClearOnExit, 564 const BaseType_t xWaitForAllBits, 565 TickType_t xTicksToWait); 566 567 EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup, 568 const EventBits_t uxBitsToSet); 569 570 BaseType_t xEventGroupSetBitsFromISR(EventGroupHandle_t xEventGroup, 571 const EventBits_t uxBitsToSet, 572 BaseType_t *pxHigherPriorityTaskWoken); 573 574 EventBits_t xEventGroupClearBits(EventGroupHandle_t xEventGroup, 575 const EventBits_t uxBitsToClear); 576 577 BaseType_t xEventGroupClearBitsFromISR(EventGroupHandle_t xEventGroup, 578 const EventBits_t uxBitsToClear); 579 580 EventBits_t xEventGroupGetBits(EventGroupHandle_t xEventGroup); 581 582 EventBits_t xEventGroupGetBitsFromISR(EventGroupHandle_t xEventGroup); 583 584 585 //// 586 // Software timer API. 587 588 #ifndef pdMS_TO_TICKS 589 #ifndef configTICK_RATE_HZ 590 #error "configTICK_RATE_HZ must be defined in FreeRTOSConfig.h" 591 #endif // #ifndef configTICK_RATE_HZ 592 #define pdMS_TO_TICKS(xTimeInMs) ((TickType_t) (((TickType_t) (xTimeInMs) * (TickType_t)configTICK_RATE_HZ) / (TickType_t)1000)) 593 #endif // #ifndef pdMS_TO_TICKS 594 595 TimerHandle_t xTimerCreate(const char * const pcTimerName, 596 const TickType_t xTimerPeriod, 597 const UBaseType_t uxAutoReload, 598 void * const pvTimerID, 599 TimerCallbackFunction_t pxCallbackFunction); 600 601 TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, 602 const TickType_t xTimerPeriod, 603 const UBaseType_t uxAutoReload, 604 void * const pvTimerID, 605 TimerCallbackFunction_t pxCallbackFunction, 606 StaticTimer_t *pxTimerBuffer); 607 608 BaseType_t xTimerDelete(TimerHandle_t xTimer, TickType_t xBlockTime); 609 610 BaseType_t xTimerIsTimerActive(TimerHandle_t xTimer); 611 612 BaseType_t xTimerStart(TimerHandle_t xTimer, 613 TickType_t xBlockTime); 614 615 BaseType_t xTimerStop(TimerHandle_t xTimer, 616 TickType_t xBlockTime); 617 618 BaseType_t xTimerChangePeriod(TimerHandle_t xTimer, 619 TickType_t xNewPeriod, 620 TickType_t xBlockTime); 621 622 BaseType_t xTimerReset(TimerHandle_t xTimer, 623 TickType_t xBlockTime); 624 625 BaseType_t xTimerStartFromISR(TimerHandle_t xTimer, 626 BaseType_t *pxHigherPriorityTaskWoken); 627 628 BaseType_t xTimerStopFromISR(TimerHandle_t xTimer, 629 BaseType_t *pxHigherPriorityTaskWoken); 630 631 BaseType_t xTimerChangePeriodFromISR(TimerHandle_t xTimer, 632 TickType_t xNewPeriod, 633 BaseType_t *pxHigherPriorityTaskWoken); 634 635 BaseType_t xTimerResetFromISR(TimerHandle_t xTimer, 636 BaseType_t *pxHigherPriorityTaskWoken); 637 638 void *pvTimerGetTimerID(TimerHandle_t xTimer); 639 640 void vTimerSetTimerID(TimerHandle_t xTimer, void *pvNewID); 641 642 void vTimerSetReloadMode(TimerHandle_t xTimer, 643 const UBaseType_t uxAutoReload); 644 645 const char * pcTimerGetName(TimerHandle_t xTimer); 646 647 TickType_t xTimerGetPeriod(TimerHandle_t xTimer); 648 649 TickType_t xTimerGetExpiryTime(TimerHandle_t xTimer); 650 651 UBaseType_t uxTimerGetReloadMode(TimerHandle_t xTimer); 652 653 //// 654 // Queue set API. 655 656 QueueSetHandle_t xQueueCreateSet(const UBaseType_t uxEventQueueLength); 657 658 BaseType_t xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore, 659 QueueSetHandle_t xQueueSet); 660 661 BaseType_t xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore, 662 QueueSetHandle_t xQueueSet); 663 664 QueueSetMemberHandle_t xQueueSelectFromSet(QueueSetHandle_t xQueueSet, 665 const TickType_t xTicksToWait); 666 667 QueueSetMemberHandle_t xQueueSelectFromSetFromISR(QueueSetHandle_t xQueueSet); 668 669 #endif /* FREERTOS_H */ 670