1BaseType_t xTaskAbortDelay( TaskHandle_t xTask ); ҪǿƽһĽ̽ģʽ

2BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,TickType_t * const pxTicksToWait ); Ĺܣ
    vTaskSetTimeOutState( &xTimeOut );

ҪһȷʱȴУ˳ȴ̣ȷУ׼ܵʱʱʹã

size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
{
	size_t uxReceived = 0;
	TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
	TimeOut_t xTimeOut;

	vTaskSetTimeOutState( &xTimeOut );

	while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
	{
    		if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
    		{    

        		break;
    		}

    		ulTaskNotifyTake( pdTRUE, xTicksToWait );
	}

	uxReceived = UART_read_from_receive_buffer( pxUARTInstance, pucBuffer, uxWantedBytes );
	return uxReceived;
}

ʵܵĵȴʱ MAX_TIME_TO_WAIT յֽûдﵽҪʱuxWantedBytes ȴ̣ݽճɹ˳ȴǷ֪߽ճʱ̡

3xTaskCreateStatic()  ʱɳԱָĶջռ䣬ϵͳԶ

4void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, TickType_t xTimeIncrement );
   void vTaskDelay( TickType_t xTicksToDelay );
   
vTaskDelayUntil  vTaskDelayҪڼʼʱ䲻һvTaskDelayǴӵʱ㿪ʼʱ䣬vTaskDelayUntil*pxPreviousWakeTimeֵΪָĿʼʱ䡣

5 vTaskDelete() ɾ

6taskDISABLE_INTERRUPTS() 
   ʹconfigMAX_SYSCALL_INTERRUPT_PRIORITY/configMAX_API_CALL_INTERRUPT_PRIORITY,ôtaskDISABLE_INTERRUPTS()ʹ  configMAX_SYSCALL_INTERRUPT_PRIORITY ȼжЧڴȼжϲӰ졣
 ʹconfigMAX_SYSCALL_INTERRUPT_PRIORITY/configMAX_API_CALL_INTERRUPT_PRIORITY,ôtaskDISABLE_INTERRUPTS()ʹежЧ

taskDISABLE_INTERRUPTS() and taskENABLE_INTERRUPTS() ֧ǶףִtaskDISABLE_INTERRUPTS() ֻҪִһtaskENABLE_INTERRUPTS() ͿʹжϡҪ֧ǶҪʹtaskENTER_CRITICAL() and taskEXIT_CRITICAL()

7void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue );һǺ
   TaskHookFunction_t  pxTagValue  һӺָ룬xTaskCallApplicationTaskHookʹãӺ
Ҫʹ vTaskSetApplicationTaskTag configUSE_APPLICATION_TASK_TAG Ϊ1

static BaseType_t prvExampleTaskHook( void * pvParameter )
{
	return 0;
}

void vAnotherTask( void *pvParameters )
{

	vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook );
	for( ;; )
	{
	}
}

/* [As an example use of the hook (callback)] Define the traceTASK_SWITCHED_OUT()
macro to call the hook function. The kernel will then automatically call the task
hook each time the task is switched out. This technique can be used to generate
an execution trace. pxCurrentTCB references the currently executing task. */
#define traceTASK_SWITCHED_OUT() xTaskCallApplicationTaskHook( pxCurrentTCB, 0 )


8vTaskSetThreadLocalStoragePointer() ΪÿöĴ洢ռ䣬洢
configNUM_THREAD_LOCAL_STORAGE_POINTERS 洢ռС



9void vTaskStepTick( TickType_t xTicksToJump );͹ use tickless idle functionality

configUSE_TICKLESS_IDLE = 1 ֻ systick жЧֻidle task

portSUPPRESS_TICKS_AND_SLEEP() ʵֵĹΪرϵͳʱӣֹͣںУں궨庯ڲʹvTaskStepTickʵָֻʱӱĲ˵ϵͳʱ䡣

10vTaskSuspend() һ񱻹ֻͨ vTaskResume½״̬
FreeRTOS version 6.1.0 Ժ汾vTaskSuspend Scheduler ʼ֮ǰá

11vTaskSuspendAllֹӰжϣֹĹУϵͳAPI
 xTaskResumeAll() ָ˹Ƕ׹

12taskYIELD() ʱƬֹȼͬУУñ


xQueueCreateSet() ǳӵһ̣

#define QUEUE_LENGTH_1 10
#define QUEUE_LENGTH_2 10

#define BINARY_SEMAPHORE_LENGTH 1

#define ITEM_SIZE_QUEUE_1 sizeof( uint32_t )
#define ITEM_SIZE_QUEUE_2 sizeof( something_else_t )

#define COMBINED_LENGTH ( QUEUE_LENGTH_1 + QUEUE_LENGTH_2 + BINARY_SEMAPHORE_LENGTH )
void vAFunction( void )
{
    static QueueSetHandle_t xQueueSet;
    QueueHandle_t xQueue1, xQueue2, xSemaphore;
    QueueSetMemberHandle_t xActivatedMember;
    uint32_t xReceivedFromQueue1;
    something_else_t xReceivedFromQueue2;

    xQueueSet = xQueueCreateSet( COMBINED_LENGTH );

    xQueue1 = xQueueCreate( QUEUE_LENGTH_1, ITEM_SIZE_QUEUE_1 );
    xQueue2 = xQueueCreate( QUEUE_LENGTH_2, ITEM_SIZE_QUEUE_2 );

    xSemaphore = xSemaphoreCreateBinary();

    xSemaphoreTake( xSemaphore, 0 );

    xQueueAddToSet( xQueue1, xQueueSet );
    xQueueAddToSet( xQueue2, xQueueSet );
    xQueueAddToSet( xSemaphore, xQueueSet );



    for( ;; )
    {

        xActivatedMember = xQueueSelectFromSet( xQueueSet, pdMS_TO_TICKS( 200 ) );

        if( xActivatedMember == xQueue1 )
        {
            xQueueReceive( xActivatedMember, &xReceivedFromQueue1, 0 );
            vProcessValueFromQueue1( xReceivedFromQueue1 );
        }
        else if( xActivatedQueue == xQueue2 )
        {
            xQueueReceive( xActivatedMember, &xReceivedFromQueue2, 0 );
            vProcessValueFromQueue2( &xReceivedFromQueue2 );
        }
        else if( xActivatedQueue == xSemaphore )
        {
            xSemaphoreTake( xActivatedMember, 0 );
            vProcessEventNotifiedBySemaphore();
        break;
        }
        else
        {

        }
    }
}


13vQueueDelete()  Ҫ÷вɹɾ

int main( void )
{
	QueueHandle_t xQueue;

	xQueue = xQueueCreate( QUEUE_LENGTH, QUEUE_ITEM_SIZE );
	if( xQueue == NULL )
	{

	}
	else
	{
		vQueueDelete( xQueue );
	}
}

14UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );ѯжĿֵΪĿ

15BaseType_t xQueueOverwrite( QueueHandle_t xQueue, const void *pvItemToQueue ); ֵӦã
xQueue Ϊ1вǿգ

16xQueueResetλУն

17 xQueueSend() = xQueueSendToBack()

18uxQueueSpacesAvailableȡпĿ

19vSemaphoreCreateBinaryϰ汾ģΪڴڣӦʹ xSemaphoreCreateBinary滻

20xSemaphoreCreateCountingֵź

21xSemaphoreCreateMutexź

22xSemaphoreCreateRecursiveMutexݹĻź

23xSemaphoreGetMutexHolderȡʹźľ

24xTimerGetExpiryTimeȡʱʱʱ

25pcTimerGetNameȡʱ

26xTimerGetPeriodȡʱ

27pvTimerGetTimerIDȡʱID,Ҫڶʱʹͬһصж ID

28xTimerIsTimerActiveж϶ʱǷڹ

29xTimerPendFunctionCallڻصӦãΪ

30xTimerResetʱУú󣬶ʱУʱڵ֮ǰ

If xTimerReset() is called before the scheduler is started, then the timer will not start running
until the scheduler has been started, and the timers expiry time will be relative to when the
scheduler started.

31xEventGroupCreate
The number of event bits in an event group is dependent on the configUSE_16_BIT_TICKS
compile time configuration constant within FreeRTOSConfig.h1:
? If configUSE_16_BIT_TICKS is 1, then each event group contains 8 usable event bits.
? If configUSE_16_BIT_TICKS is 0, then each event group contains 24 usable event bits.



EventBits_t xEventGroupSync( 	EventGroupHandle_t xEventGroup,
				const EventBits_t uxBitsToSet,
				const EventBits_t uxBitsToWaitFor,
				TickType_t xTicksToWait );

˺ʵֹΪΪ event_group uxBitsToSet λΪ1Ȼ󣬵ȴ uxBitsToWaitForλõ¼

EventBits_t xEventGroupWaitBits( const EventGroupHandle_t xEventGroup,
				 const EventBits_t uxBitsToWaitFor,
				 const BaseType_t xClearOnExit,
				 const BaseType_t xWaitForAllBits,
				 TickType_t xTicksToWait );

˺ʵֹΪ ȴuxBitsToWaitFor¼xWaitForAllBits,Ƿȴȫ¼ǵȴuxBitsToWaitForλ¼

xEventGroupSync(), xEventGroupWaitBits() Ĺܺܽӽв







32 configCHECK_FOR_STACK_OVERFLOW ջ

33configCPU_CLOCK_HZ

34configTICK_RATE_HZ ϵͳʱжƵ

35configTIMER_QUEUE_LENGTH ʱеȣܱδ

36configTOTAL_HEAP_SIZE ϵͳʹõĶջСϵͳǾ̬ʱʹ heap1.c heap2.c heap4.c 

37configUSE_16_BIT_TICKS = 0 TickType_t Ϊ16 bits  configUSE_16_BIT_TICKS = 1TickType_t Ϊ32 bits 

37configUSE_COUNTING_SEMAPHORES ֵź

38configUSE_MUTEXES ź


INCLUDE_uxTaskGetStackHighWaterMark == 1    prvTaskCheckFreeStackSpace() ȡʹùٵʣռ
xPortGetFreeHeapSize() ͳܶջʣռ
