⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 task.h

📁 一个开源的Modbus协议栈
💻 H
📖 第 1 页 / 共 3 页
字号:
 * The constant portTICK_RATE_MS can be used to calculate real time from the tick

 * rate - with the resolution of one tick period.

 *

 * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the

 * task was last unblocked.  The variable must be initialised with the current time

 * prior to its first use (see the example below).  Following this the variable is

 * automatically updated within vTaskDelayUntil ().

 *

 * @param xTimeIncrement The cycle time period.  The task will be unblocked at

 * time *pxPreviousWakeTime + xTimeIncrement.  Calling vTaskDelayUntil with the

 * same xTimeIncrement parameter value will cause the task to execute with

 * a fixed interface period.

 *

 * Example usage:

   <pre>

 // Perform an action every 10 ticks.

 void vTaskFunction( void * pvParameters )

 {

 portTickType xLastWakeTime;

 const portTickType xFrequency = 10;



     // Initialise the xLastWakeTime variable with the current time.

     xLastWakeTime = xTaskGetTickCount ();

     for( ;; )

     {

         // Wait for the next cycle.

         vTaskDelayUntil( &xLastWakeTime, xFrequency );



         // Perform action here.

     }

 }

   </pre>

 * \defgroup vTaskDelayUntil vTaskDelayUntil

 * \ingroup TaskCtrl

 */

void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );



/**

 * task. h

 * <pre>unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );</pre>

 *

 * INCLUDE_xTaskPriorityGet must be defined as 1 for this function to be available.

 * See the configuration section for more information.

 *

 * Obtain the priority of any task.

 *

 * @param pxTask Handle of the task to be queried.  Passing a NULL

 * handle results in the priority of the calling task being returned.

 *

 * @return The priority of pxTask.

 *

 * Example usage:

   <pre>

 void vAFunction( void )

 {

 xTaskHandle xHandle;

		

     // Create a task, storing the handle.

     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );

		

     // ...



     // Use the handle to obtain the priority of the created task.

     // It was created with tskIDLE_PRIORITY, but may have changed

     // it itself.

     if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )

     {

         // The task has changed it's priority.

     }



     // ...



     // Is our priority higher than the created task?

     if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )

     {

         // Our priority (obtained using NULL handle) is higher.

     }

 }

   </pre>

 * \defgroup uxTaskPriorityGet uxTaskPriorityGet

 * \ingroup TaskCtrl

 */

unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );



/**

 * task. h

 * <pre>void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );</pre>

 *

 * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.

 * See the configuration section for more information.

 *

 * Set the priority of any task.

 *

 * A context switch will occur before the function returns if the priority

 * being set is higher than the currently executing task.

 *

 * @param pxTask Handle to the task for which the priority is being set.

 * Passing a NULL handle results in the priority of the calling task being set.

 *

 * @param uxNewPriority The priority to which the task will be set.

 *

 * Example usage:

   <pre>

 void vAFunction( void )

 {

 xTaskHandle xHandle;

		

     // Create a task, storing the handle.

     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );



     // ...



     // Use the handle to raise the priority of the created task.

     vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );



     // ...



     // Use a NULL handle to raise our priority to the same value.

     vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );

 }

   </pre>

 * \defgroup vTaskPrioritySet vTaskPrioritySet

 * \ingroup TaskCtrl

 */

void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );



/**

 * task. h

 * <pre>void vTaskSuspend( xTaskHandle pxTaskToSuspend );</pre>

 *

 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.

 * See the configuration section for more information.

 *

 * Suspend any task.  When suspended a task will never get any microcontroller

 * processing time, no matter what its priority.

 *

 * Calls to vTaskSuspend are not accumulative -

 * i.e. calling vTaskSuspend () twice on the same task still only requires one

 * call to vTaskResume () to ready the suspended task.

 *

 * @param pxTaskToSuspend Handle to the task being suspended.  Passing a NULL

 * handle will cause the calling task to be suspended.

 *

 * Example usage:

   <pre>

 void vAFunction( void )

 {

 xTaskHandle xHandle;

		

     // Create a task, storing the handle.

     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );

		

     // ...



     // Use the handle to suspend the created task.

     vTaskSuspend( xHandle );



     // ...

		

     // The created task will not run during this period, unless

     // another task calls vTaskResume( xHandle ).

		

     //...

		



     // Suspend ourselves.

     vTaskSuspend( NULL );



     // We cannot get here unless another task calls vTaskResume

     // with our handle as the parameter.

 }

   </pre>

 * \defgroup vTaskSuspend vTaskSuspend

 * \ingroup TaskCtrl

 */

void vTaskSuspend( xTaskHandle pxTaskToSuspend );



/**

 * task. h

 * <pre>void vTaskResume( xTaskHandle pxTaskToResume );</pre>

 *

 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.

 * See the configuration section for more information.

 *

 * Resumes a suspended task.

 *

 * A task that has been suspended by one of more calls to vTaskSuspend ()

 * will be made available for running again by a single call to

 * vTaskResume ().

 *

 * @param pxTaskToResume Handle to the task being readied.

 *

 * Example usage:

   <pre>

 void vAFunction( void )

 {

 xTaskHandle xHandle;

		

     // Create a task, storing the handle.

     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );

		

     // ...



     // Use the handle to suspend the created task.

     vTaskSuspend( xHandle );



     // ...

	

     // The created task will not run during this period, unless

     // another task calls vTaskResume( xHandle ).

		

     //...

		



     // Resume the suspended task ourselves.

     vTaskResume( xHandle );



     // The created task will once again get microcontroller processing

     // time in accordance with it priority within the system.

 }

   </pre>

 * \defgroup vTaskResume vTaskResume

 * \ingroup TaskCtrl

 */

void vTaskResume( xTaskHandle pxTaskToResume );



/**

 * task. h

 * <pre>void xTaskResumeFromISR( xTaskHandle pxTaskToResume );</pre>

 *

 * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be 

 * available.  See the configuration section for more information.

 *

 * An implementation of vTaskResume() that can be called from within an ISR.

 *

 * A task that has been suspended by one of more calls to vTaskSuspend ()

 * will be made available for running again by a single call to

 * xTaskResumeFromISR ().

 *

 * @param pxTaskToResume Handle to the task being readied.

 *

 * \defgroup vTaskResumeFromISR vTaskResumeFromISR

 * \ingroup TaskCtrl

 */

portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );



/*-----------------------------------------------------------

 * SCHEDULER CONTROL

 *----------------------------------------------------------*/



/**

 * task. h

 * <pre>void vTaskStartScheduler( void );</pre>

 *

 * Starts the real time kernel tick processing.  After calling the kernel

 * has control over which tasks are executed and when.  This function

 * does not return until an executing task calls vTaskEndScheduler ().

 *

 * At least one task should be created via a call to xTaskCreate ()

 * before calling vTaskStartScheduler ().  The idle task is created

 * automatically when the first application task is created.

 *

 * See the demo application file main.c for an example of creating

 * tasks and starting the kernel.

 *

 * Example usage:

   <pre>

 void vAFunction( void )

 {

     // Create at least one task before starting the kernel.

     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );



     // Start the real time kernel with preemption.

     vTaskStartScheduler ();



     // Will not get here unless a task calls vTaskEndScheduler ()

 }

   </pre>

 *

 * \defgroup vTaskStartScheduler vTaskStartScheduler

 * \ingroup SchedulerControl

 */

void vTaskStartScheduler( void );



/**

 * task. h

 * <pre>void vTaskEndScheduler( void );</pre>

 *

 * Stops the real time kernel tick.  All created tasks will be automatically

 * deleted and multitasking (either preemptive or cooperative) will

 * stop.  Execution then resumes from the point where vTaskStartScheduler ()

 * was called, as if vTaskStartScheduler () had just returned.

 *

 * See the demo application file main. c in the demo/PC directory for an

 * example that uses vTaskEndScheduler ().

 *

 * vTaskEndScheduler () requires an exit function to be defined within the

 * portable layer (see vPortEndScheduler () in port. c for the PC port).  This

 * performs hardware specific operations such as stopping the kernel tick.

 *

 * vTaskEndScheduler () will cause all of the resources allocated by the

 * kernel to be freed - but will not free resources allocated by application

 * tasks.

 *

 * Example usage:

   <pre>

 void vTaskCode( void * pvParameters )

 {

     for( ;; )

     {

         // Task code goes here.



         // At some point we want to end the real time kernel processing

         // so call ...

         vTaskEndScheduler ();

     }

 }



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -