亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? queue.c

?? 一個開源的Modbus協議棧
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*

	FreeRTOS.org V4.1.1 - Copyright (C) 2003-2006 Richard Barry.



	This file is part of the FreeRTOS.org distribution.



	FreeRTOS.org is free software; you can redistribute it and/or modify

	it under the terms of the GNU General Public License as published by

	the Free Software Foundation; either version 2 of the License, or

	(at your option) any later version.



	FreeRTOS.org is distributed in the hope that it will be useful,

	but WITHOUT ANY WARRANTY; without even the implied warranty of

	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

	GNU General Public License for more details.



	You should have received a copy of the GNU General Public License

	along with FreeRTOS.org; if not, write to the Free Software

	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



	A special exception to the GPL can be applied should you wish to distribute

	a combined work that includes FreeRTOS.org, without being obliged to provide

	the source code for any proprietary components.  See the licensing section

	of http://www.FreeRTOS.org for full details of how and when the exception

	can be applied.



	***************************************************************************

	See http://www.FreeRTOS.org for documentation, latest information, license

	and contact details.  Please ensure to read the configuration and relevant

	port sections of the online documentation.

	***************************************************************************

*/



/*

Changes from V1.01



	+ More use of 8bit data types.

	+ Function name prefixes changed where the data type returned has changed.



Changed from V2.0.0



	+ Added the queue locking mechanism and make more use of the scheduler

	  suspension feature to minimise the time interrupts have to be disabled

	  when accessing a queue.



Changed from V2.2.0



	+ Explicit use of 'signed' qualifier on portCHAR types added.



Changes from V3.0.0



	+ API changes as described on the FreeRTOS.org WEB site.



Changes from V3.2.3



	+ Added the queue functions that can be used from co-routines.



Changes from V4.0.5



	+ Added a loop within xQueueSend() and xQueueReceive() to prevent the

	  functions exiting when a block time remains and the function has

	  not completed.



*/



#include <stdlib.h>

#include <string.h>

#include "FreeRTOS.h"

#include "task.h"

#include "croutine.h"



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

 * PUBLIC LIST API documented in list.h

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



/* Constants used with the cRxLock and cTxLock structure members. */

#define queueUNLOCKED	( ( signed portBASE_TYPE ) -1 )

#define queueERRONEOUS_UNBLOCK					( -1 )



/*

 * Definition of the queue used by the scheduler.

 * Items are queued by copy, not reference.

 */

typedef struct QueueDefinition

{

	signed portCHAR *pcHead;				/*< Points to the beginning of the queue storage area. */

	signed portCHAR *pcTail;				/*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */



	signed portCHAR *pcWriteTo;				/*< Points to the free next place in the storage area. */

	signed portCHAR *pcReadFrom;			/*< Points to the last place that a queued item was read from. */



	xList xTasksWaitingToSend;				/*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */

	xList xTasksWaitingToReceive;			/*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */



	unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of items currently in the queue. */

	unsigned portBASE_TYPE uxLength;		/*< The length of the queue defined as the number of items it will hold, not the number of bytes. */

	unsigned portBASE_TYPE uxItemSize;		/*< The size of each items that the queue will hold. */



	signed portBASE_TYPE xRxLock;				/*< Stores the number of items received from the queue (removed from the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */

	signed portBASE_TYPE xTxLock;				/*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */

} xQUEUE;

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



/*

 * Inside this file xQueueHandle is a pointer to a xQUEUE structure.

 * To keep the definition private the API header file defines it as a

 * pointer to void.

 */

typedef xQUEUE * xQueueHandle;



/*

 * Prototypes for public functions are included here so we don't have to

 * include the API header file (as it defines xQueueHandle differently).  These

 * functions are documented in the API header file.

 */

xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize );

signed portBASE_TYPE xQueueSend( xQueueHandle xQueue, const void * pvItemToQueue, portTickType xTicksToWait );

unsigned portBASE_TYPE uxQueueMessagesWaiting( xQueueHandle pxQueue );

void vQueueDelete( xQueueHandle xQueue );

signed portBASE_TYPE xQueueSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken );

signed portBASE_TYPE xQueueReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );

signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );



#if configUSE_CO_ROUTINES == 1

	signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );

	signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );

	signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );

	signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );

#endif



/*

 * Unlocks a queue locked by a call to prvLockQueue.  Locking a queue does not

 * prevent an ISR from adding or removing items to the queue, but does prevent

 * an ISR from removing tasks from the queue event lists.  If an ISR finds a

 * queue is locked it will instead increment the appropriate queue lock count

 * to indicate that a task may require unblocking.  When the queue in unlocked

 * these lock counts are inspected, and the appropriate action taken.

 */

static void prvUnlockQueue( xQueueHandle pxQueue );



/*

 * Uses a critical section to determine if there is any data in a queue.

 *

 * @return pdTRUE if the queue contains no items, otherwise pdFALSE.

 */

static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue );



/*

 * Uses a critical section to determine if there is any space in a queue.

 *

 * @return pdTRUE if there is no space, otherwise pdFALSE;

 */

static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue );



/*

 * Macro that copies an item into the queue.  This is done by copying the item

 * byte for byte, not by reference.  Updates the queue state to ensure it's

 * integrity after the copy.

 */

#define prvCopyQueueData( pxQueue, pvItemToQueue )												\

{																								\

	memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );	\

	++( pxQueue->uxMessagesWaiting );															\

	pxQueue->pcWriteTo += pxQueue->uxItemSize;													\

	if( pxQueue->pcWriteTo >= pxQueue->pcTail )													\

	{																							\

		pxQueue->pcWriteTo = pxQueue->pcHead;													\

	}																							\

}

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



/*

 * Macro to mark a queue as locked.  Locking a queue prevents an ISR from

 * accessing the queue event lists.

 */

#define prvLockQueue( pxQueue )			\

{										\

	taskENTER_CRITICAL();				\

		++( pxQueue->xRxLock );			\

		++( pxQueue->xTxLock );			\

	taskEXIT_CRITICAL();				\

}

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





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

 * PUBLIC QUEUE MANAGEMENT API documented in queue.h

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



xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize )

{

xQUEUE *pxNewQueue;

size_t xQueueSizeInBytes;



	/* Allocate the new queue structure. */

	if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )

	{

		pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );

		if( pxNewQueue != NULL )

		{

			/* Create the list of pointers to queue items.  The queue is one byte

			longer than asked for to make wrap checking easier/faster. */

			xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;



			pxNewQueue->pcHead = ( signed portCHAR * ) pvPortMalloc( xQueueSizeInBytes );

			if( pxNewQueue->pcHead != NULL )

			{

				/* Initialise the queue members as described above where the

				queue type is defined. */

				pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize );

				pxNewQueue->uxMessagesWaiting = 0;

				pxNewQueue->pcWriteTo = pxNewQueue->pcHead;

				pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - 1 ) * uxItemSize );

				pxNewQueue->uxLength = uxQueueLength;

				pxNewQueue->uxItemSize = uxItemSize;

				pxNewQueue->xRxLock = queueUNLOCKED;

				pxNewQueue->xTxLock = queueUNLOCKED;



				/* Likewise ensure the event queues start with the correct state. */

				vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );

				vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );



				return  pxNewQueue;

			}

			else

			{

				vPortFree( pxNewQueue );

			}

		}

	}



	/* Will only reach here if we could not allocate enough memory or no memory

	was required. */

	return NULL;

}

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



signed portBASE_TYPE xQueueSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait )

{

signed portBASE_TYPE xReturn;

xTimeOutType xTimeOut;



	/* Make sure other tasks do not access the queue. */

	vTaskSuspendAll();



	/* Capture the current time status for future reference. */

	vTaskSetTimeOutState( &xTimeOut );



	/* It is important that this is the only thread/ISR that modifies the

	ready or delayed lists until xTaskResumeAll() is called.  Places where

	the ready/delayed lists are modified include:



		+ vTaskDelay() -  Nothing can call vTaskDelay as the scheduler is

		  suspended, vTaskDelay() cannot be called from an ISR.

		+ vTaskPrioritySet() - Has a critical section around the access.

		+ vTaskSwitchContext() - This will not get executed while the scheduler

		  is suspended.

		+ prvCheckDelayedTasks() - This will not get executed while the

		  scheduler is suspended.

		+ xTaskCreate() - Has a critical section around the access.

		+ vTaskResume() - Has a critical section around the access.

		+ xTaskResumeAll() - Has a critical section around the access.

		+ xTaskRemoveFromEventList - Checks to see if the scheduler is

		  suspended.  If so then the TCB being removed from the event is

		  removed from the event and added to the xPendingReadyList.

	*/



	/* Make sure interrupts do not access the queue event list. */

	prvLockQueue( pxQueue );



	/* It is important that interrupts to not access the event list of the

	queue being modified here.  Places where the event list is modified

	include:



		+ xQueueSendFromISR().  This checks the lock on the queue to see if

		  it has access.  If the queue is locked then the Tx lock count is

		  incremented to signify that a task waiting for data can be made ready

		  once the queue lock is removed.  If the queue is not locked then

		  a task can be moved from the event list, but will not be removed

		  from the delayed list or placed in the ready list until the scheduler

		  is unlocked.



		+ xQueueReceiveFromISR().  As per xQueueSendFromISR().

	*/

		

	/* If the queue is already full we may have to block. */

	do

	{

		if( prvIsQueueFull( pxQueue ) )

		{

			/* The queue is full - do we want to block or just leave without

			posting? */

			if( xTicksToWait > ( portTickType ) 0 )

			{

				/* We are going to place ourselves on the xTasksWaitingToSend event

				list, and will get woken should the delay expire, or space become

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕中文字幕在线一区 | 国产美女精品人人做人人爽| 粗大黑人巨茎大战欧美成人| 精品国产欧美一区二区| 亚洲精品大片www| av一区二区三区四区| 中文字幕一区二区三区在线观看 | 欧美猛男男办公室激情| 亚洲欧美日韩国产综合在线| 国产不卡视频在线播放| 精品成人一区二区三区四区| 国产精品一区二区视频| 欧美高清视频不卡网| 日日夜夜免费精品| 欧美一级视频精品观看| 美腿丝袜亚洲综合| 精品国产一区二区三区忘忧草| 日韩不卡一二三区| 日韩精品一区二区三区三区免费| 男人操女人的视频在线观看欧美| 国产女人18水真多18精品一级做| 国产高清亚洲一区| 亚洲人成网站精品片在线观看| 97se亚洲国产综合自在线| 一区二区三区在线高清| 91麻豆精品国产91久久久更新时间| 人人超碰91尤物精品国产| 久久午夜色播影院免费高清| 大胆欧美人体老妇| 欧美激情综合五月色丁香小说| 亚洲综合在线免费观看| 欧美r级电影在线观看| 波多野结衣精品在线| 亚洲国产成人精品视频| 国产午夜精品福利| 欧美精品乱码久久久久久| 国产精品自拍av| 亚洲第一会所有码转帖| 国产精品你懂的| 日韩精品中文字幕在线一区| 91丨九色porny丨蝌蚪| 蜜乳av一区二区| 亚洲夂夂婷婷色拍ww47| 国产偷国产偷亚洲高清人白洁| 欧美日韩亚洲综合在线| 风流少妇一区二区| 美女视频免费一区| 午夜精品久久久久久久蜜桃app| 国产亚洲人成网站| 日韩一级高清毛片| 欧洲av一区二区嗯嗯嗯啊| 国产精品系列在线播放| 免费不卡在线观看| 亚洲一本大道在线| 亚洲素人一区二区| 中文字幕在线不卡视频| 国产校园另类小说区| 精品久久人人做人人爽| 91精品国产一区二区三区| 欧美综合一区二区| 一本色道久久加勒比精品| 国产精品18久久久| 黄色小说综合网站| 久久精品国产澳门| 麻豆国产精品视频| 日韩黄色片在线观看| 亚洲福中文字幕伊人影院| 综合久久一区二区三区| 国产女人18水真多18精品一级做| 精品国产一区二区三区久久久蜜月| 欧美福利电影网| 欧美日韩精品欧美日韩精品| 91国模大尺度私拍在线视频| 成人免费视频caoporn| 国产曰批免费观看久久久| 日本在线播放一区二区三区| 婷婷国产v国产偷v亚洲高清| 亚洲成av人片在www色猫咪| 亚洲午夜一区二区| 亚洲午夜一二三区视频| 午夜久久久久久| 五月婷婷综合激情| 日韩国产欧美在线视频| 日韩成人伦理电影在线观看| 亚洲午夜视频在线| 青草国产精品久久久久久| 蜜桃精品视频在线| 国产乱对白刺激视频不卡| 国产福利视频一区二区三区| 粉嫩aⅴ一区二区三区四区五区| 成人激情免费视频| 在线视频你懂得一区二区三区| 欧美日韩免费一区二区三区视频 | 国内精品国产成人国产三级粉色 | 最新国产の精品合集bt伙计| 国产精品久久夜| 一区二区三区视频在线观看| 午夜精品久久一牛影视| 精品一区二区三区久久| 高清av一区二区| 色综合久久六月婷婷中文字幕| 精品污污网站免费看| 日韩亚洲国产中文字幕欧美| 国产偷国产偷亚洲高清人白洁| 中文字幕亚洲精品在线观看 | 日韩av不卡一区二区| 激情深爱一区二区| www..com久久爱| 精品视频免费在线| 精品国产网站在线观看| 国产精品不卡一区二区三区| 亚洲国产欧美在线| 韩日精品视频一区| 91高清视频在线| 精品国产不卡一区二区三区| 国产精品网站在线观看| 偷偷要91色婷婷| 成人sese在线| 337p亚洲精品色噜噜| 欧美国产一区二区在线观看| 亚洲一二三专区| 国产福利精品一区| 欧美最猛性xxxxx直播| 久久精品视频免费| 亚洲1区2区3区4区| 成人av第一页| 日韩美女一区二区三区四区| 中文字幕一区二区视频| 精品一区二区免费在线观看| 一本大道久久精品懂色aⅴ| www亚洲一区| 亚洲第一av色| av影院午夜一区| 精品播放一区二区| 国产又粗又猛又爽又黄91精品| 色婷婷激情综合| 欧美激情一区在线| 久久99热这里只有精品| 欧美日本国产一区| 亚洲婷婷综合久久一本伊一区| 久久99蜜桃精品| 欧美日韩和欧美的一区二区| 欧美激情中文字幕一区二区| 久久精品国产久精国产爱| 精品污污网站免费看| 综合久久久久久久| 成人综合在线观看| 国产亚洲综合在线| 国产一区二区毛片| 欧美mv日韩mv国产| 人人爽香蕉精品| 欧美精品视频www在线观看 | 香蕉久久夜色精品国产使用方法 | 日本系列欧美系列| 欧美亚洲国产怡红院影院| 国产精品久久久久影院亚瑟| 国产一区二区伦理片| 久久免费的精品国产v∧| 另类中文字幕网| 日韩美女一区二区三区四区| 午夜精品久久久久久不卡8050| 91福利视频网站| 亚洲黄色小视频| 91国在线观看| 亚洲成年人网站在线观看| 欧美在线制服丝袜| 亚洲第一主播视频| 欧美日韩免费一区二区三区视频 | 欧美一区二区女人| 日韩精品久久久久久| 欧美一区二区视频观看视频| 琪琪久久久久日韩精品| 欧美成人艳星乳罩| 国产在线精品视频| 欧美激情在线观看视频免费| 成人av在线影院| 亚洲精品视频自拍| 欧美日韩国产成人在线免费| 日韩av电影免费观看高清完整版在线观看| 5858s免费视频成人| 强制捆绑调教一区二区| 精品久久久久99| 成人综合婷婷国产精品久久| 国产精品久久久久久久久免费樱桃| av爱爱亚洲一区| 亚洲主播在线观看| 欧美一区二区大片| 国产ts人妖一区二区| 亚洲手机成人高清视频| 欧美亚洲丝袜传媒另类| 日韩专区中文字幕一区二区| 精品久久免费看| 成人免费毛片嘿嘿连载视频| 亚洲你懂的在线视频| 欧美精品视频www在线观看| 极品美女销魂一区二区三区| 国产精品午夜免费| 欧美福利视频一区| 豆国产96在线|亚洲| 午夜精品视频在线观看|