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