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

📄 task.h

📁 freemodbus-v1-1-1-0.zip v1.1.1版本的代码 支持多个平台
💻 H
📖 第 1 页 / 共 2 页
字号:
 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 );/*----------------------------------------------------------- * 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 ();     } } 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 only get here when the vTaskCode () task has called     // vTaskEndScheduler ().  When we get here we are back to single task     // execution. }   </pre> * * \defgroup vTaskEndScheduler vTaskEndScheduler * \ingroup SchedulerControl */void vTaskEndScheduler( void );/** * task. h * <pre>void vTaskSuspendAll( void );</pre> * * Suspends all real time kernel activity while keeping interrupts (including the * kernel tick) enabled. * * After calling vTaskSuspendAll () the calling task will continue to execute * without risk of being swapped out until a call to xTaskResumeAll () has been * made. * * Example usage:   <pre> void vTask1( void * pvParameters ) {     for( ;; )     {         // Task code goes here.         // ...         // At some point the task wants to perform a long operation during         // which it does not want to get swapped out.  It cannot use         // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the         // operation may cause interrupts to be missed - including the         // ticks.         // Prevent the real time kernel swapping out the task.         vTaskSuspendAll ();         // Perform the operation here.  There is no need to use critical         // sections as we have all the microcontroller processing time.         // During this time interrupts will still operate and the kernel         // tick count will be maintained.         // ...         // The operation is complete.  Restart the kernel.         xTaskResumeAll ();     } }   </pre> * \defgroup vTaskSuspendAll vTaskSuspendAll * \ingroup SchedulerControl */void vTaskSuspendAll( void );/** * task. h * <pre>portCHAR xTaskResumeAll( void );</pre> * * Resumes real time kernel activity following a call to vTaskSuspendAll (). * After a call to vTaskSuspendAll () the kernel will take control of which * task is executing at any time. * * @return If resuming the scheduler caused a context switch then pdTRUE is *         returned, otherwise pdFALSE is returned. * * Example usage:   <pre> void vTask1( void * pvParameters ) {     for( ;; )     {         // Task code goes here.         // ...         // At some point the task wants to perform a long operation during         // which it does not want to get swapped out.  It cannot use         // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the         // operation may cause interrupts to be missed - including the         // ticks.         // Prevent the real time kernel swapping out the task.         vTaskSuspendAll ();         // Perform the operation here.  There is no need to use critical         // sections as we have all the microcontroller processing time.         // During this time interrupts will still operate and the real         // time kernel tick count will be maintained.         // ...         // The operation is complete.  Restart the kernel.  We want to force         // a context switch - but there is no point if resuming the scheduler         // caused a context switch already.         if( !xTaskResumeAll () )         {              taskYIELD ();         }     } }   </pre> * \defgroup xTaskResumeAll xTaskResumeAll * \ingroup SchedulerControl */signed portBASE_TYPE xTaskResumeAll( void );/*----------------------------------------------------------- * TASK UTILITIES *----------------------------------------------------------*//** * task. h * <PRE>volatile portTickType xTaskGetTickCount( void );</PRE> * * @return The count of ticks since vTaskStartScheduler was called. * * \page xTaskGetTickCount xTaskGetTickCount * \ingroup TaskUtils */portTickType xTaskGetTickCount( void );/** * task. h * <PRE>unsigned portSHORT uxTaskGetNumberOfTasks( void );</PRE> * * @return The number of tasks that the real time kernel is currently managing. * This includes all ready, blocked and suspended tasks.  A task that * has been deleted but not yet freed by the idle task will also be * included in the count. * * \page uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks * \ingroup TaskUtils */unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void );/** * task. h * <PRE>void vTaskList( portCHAR *pcWriteBuffer );</PRE> * * configUSE_TRACE_FACILITY, INCLUDE_vTaskDelete and INCLUDE_vTaskSuspend * must all be defined as 1 for this function to be available. * See the configuration section for more information. * * NOTE: This function will disable interrupts for its duration.  It is * not intended for normal application runtime use but as a debug aid. * * Lists all the current tasks, along with their current state and stack * usage high water mark. * * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or * suspended ('S'). * * @param pcWriteBuffer A buffer into which the above mentioned details * will be written, in ascii form.  This buffer is assumed to be large * enough to contain the generated report.  Approximately 40 bytes per * task should be sufficient. * * \page vTaskList vTaskList * \ingroup TaskUtils */void vTaskList( signed portCHAR *pcWriteBuffer );/** * task. h * <PRE>void vTaskStartTrace( portCHAR * pcBuffer, unsigned portBASE_TYPE uxBufferSize );</PRE> * * Starts a real time kernel activity trace.  The trace logs the identity of * which task is running when. * * The trace file is stored in binary format.  A separate DOS utility called * convtrce.exe is used to convert this into a tab delimited text file which * can be viewed and plotted in a spread sheet. * * @param pcBuffer The buffer into which the trace will be written. * * @param ulBufferSize The size of pcBuffer in bytes.  The trace will continue * until either the buffer in full, or ulTaskEndTrace () is called. * * \page vTaskStartTrace vTaskStartTrace * \ingroup TaskUtils */void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize );/** * task. h * <PRE>unsigned portLONG ulTaskEndTrace( void );</PRE> * * Stops a kernel activity trace.  See vTaskStartTrace (). * * @return The number of bytes that have been written into the trace buffer. * * \page usTaskEndTrace usTaskEndTrace * \ingroup TaskUtils */unsigned portLONG ulTaskEndTrace( void );/*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES *----------------------------------------------------------*//* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. * * Called from the real time kernel tick (either preemptive or cooperative), * this increments the tick count and checks if any tasks that are blocked * for a finite period required removing from a blocked list and placing on * a ready list. */inline void vTaskIncrementTick( void );/* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. * * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. * * Removes the calling task from the ready list and places it both * on the list of tasks waiting for a particular event, and the * list of delayed tasks.  The task will be removed from both lists * and replaced on the ready list should either the event occur (and * there be no higher priority tasks waiting on the same event) or * the delay period expires. * * @param pxEventList The list containing tasks that are blocked waiting * for the event to occur. * * @param xTicksToWait The maximum amount of time that the task should wait * for the event to occur.  This is specified in kernel ticks,the constant * portTICK_RATE_MS can be used to convert kernel ticks into a real time * period. */void vTaskPlaceOnEventList( xList *pxEventList, portTickType xTicksToWait );/* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. * * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. * * Removes a task from both the specified event list and the list of blocked * tasks, and places it on a ready queue. * * xTaskRemoveFromEventList () will be called if either an event occurs to * unblock a task, or the block timeout period expires. * * @return pdTRUE if the task being removed has a higher priority than the task * making the call, otherwise pdFALSE. */signed portBASE_TYPE xTaskRemoveFromEventList( const xList *pxEventList );/* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. * * INCLUDE_vTaskCleanUpResources and INCLUDE_vTaskSuspend must be defined as 1 * for this function to be available. * See the configuration section for more information. * * Empties the ready and delayed queues of task control blocks, freeing the * memory allocated for the task control block and task stacks as it goes. */void vTaskCleanUpResources( void );/* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. * * Sets the pointer to the current TCB to the TCB of the highest priority task * that is ready to run. */inline void vTaskSwitchContext( void );/* * Return the handle of the calling task. */xTaskHandle xTaskGetCurrentTaskHandle( void );#endif /* TASK_H */

⌨️ 快捷键说明

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