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

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

?? comtest.c

?? 最新版FreeRTOS, 包擴多種開發平臺的移植
?? C
字號:
/*
	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.
	***************************************************************************
*/

/**
 * Creates two tasks that operate on an interrupt driven serial port.  A loopback 
 * connector should be used so that everything that is transmitted is also received.  
 * The serial port does not use any flow control.  On a standard 9way 'D' connector 
 * pins two and three should be connected together.
 *
 * The first task repeatedly sends a string to a queue, character at a time.  The 
 * serial port interrupt will empty the queue and transmit the characters.  The 
 * task blocks for a pseudo random period before resending the string.
 *
 * The second task blocks on a queue waiting for a character to be received.  
 * Characters received by the serial port interrupt routine are posted onto the 
 * queue - unblocking the task making it ready to execute.  If this is then the 
 * highest priority task ready to run it will run immediately - with a context 
 * switch occurring at the end of the interrupt service routine.  The task 
 * receiving characters is spawned with a higher priority than the task 
 * transmitting the characters.
 *
 * With the loop back connector in place, one task will transmit a string and the 
 * other will immediately receive it.  The receiving task knows the string it 
 * expects to receive so can detect an error.
 *
 * This also creates a third task.  This is used to test semaphore usage from an
 * ISR and does nothing interesting.  
 * 
 * \page ComTestC comtest.c
 * \ingroup DemoFiles
 * <HR>
 */

/*
Changes from V1.00:
	
	+ The priority of the Rx task has been lowered.  Received characters are
	  now processed (read from the queue) at the idle priority, allowing low
	  priority tasks to run evenly at times of a high communications overhead.

Changes from V1.01:

	+ The Tx task now waits a pseudo random time between transissions.
	  Previously a fixed period was used but this was not such a good test as
	  interrupts fired at regular intervals.

Changes From V1.2.0:

	+ Use vSerialPutString() instead of single character puts.
	+ Only stop the check variable incrementing after two consecutive errors. 

Changed from V1.2.5

	+ Made the Rx task 2 priorities higher than the Tx task.  Previously it was
	  only 1.  This is done to tie in better with the other demo application 
	  tasks.

Changes from V2.0.0

	+ Delay periods are now specified using variables and constants of
	  portTickType rather than unsigned portLONG.
	+ Slight modification to task priorities.

*/


/* Scheduler include files. */
#include <stdlib.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"

/* Demo program include files. */
#include "serial.h"
#include "comtest.h"
#include "print.h"

/* The Tx task will transmit the sequence of characters at a pseudo random
interval.  This is the maximum and minimum block time between sends. */
#define comTX_MAX_BLOCK_TIME		( ( portTickType ) 0x15e )
#define comTX_MIN_BLOCK_TIME		( ( portTickType ) 0xc8 )

#define comMAX_CONSECUTIVE_ERRORS	( 2 )

#define comSTACK_SIZE				( ( unsigned portSHORT ) 256 )

#define comRX_RELATIVE_PRIORITY		( 1 )

/* Handle to the com port used by both tasks. */
static xComPortHandle xPort;

/* The transmit function as described at the top of the file. */
static void vComTxTask( void *pvParameters );

/* The receive function as described at the top of the file. */
static void vComRxTask( void *pvParameters );

/* The semaphore test function as described at the top of the file. */
static void vSemTestTask( void * pvParameters );

/* The string that is repeatedly transmitted. */
const portCHAR * const pcMessageToExchange = 	"Send this message over and over again to check communications interrupts. "
									   			"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";

/* Variables that are incremented on each cycle of each task.  These are used to 
check that both tasks are still executing. */
volatile portSHORT sTxCount = 0, sRxCount = 0, sSemCount = 0;


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

void vStartComTestTasks( unsigned portBASE_TYPE uxPriority, eCOMPort ePort, eBaud eBaudRate )
{
const unsigned portBASE_TYPE uxBufferLength = 255;

	/* Initialise the com port then spawn both tasks. */
	xPort = xSerialPortInit( ePort, eBaudRate, serNO_PARITY, serBITS_8, serSTOP_1, uxBufferLength );
	xTaskCreate( vComTxTask, "COMTx", comSTACK_SIZE, NULL, uxPriority, NULL );
	xTaskCreate( vComRxTask, "COMRx", comSTACK_SIZE, NULL, uxPriority + comRX_RELATIVE_PRIORITY, NULL );
	xTaskCreate( vSemTestTask, "ISRSem", comSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
}
/*-----------------------------------------------------------*/

static void vComTxTask( void *pvParameters )
{
const portCHAR * const pcTaskStartMsg = "COM Tx task started.\r\n";
portTickType xTimeToWait;

	/* Stop warnings. */
	( void ) pvParameters;

	/* Queue a message for printing to say the task has started. */
	vPrintDisplayMessage( &pcTaskStartMsg );

	for( ;; )
	{
		/* Send the string to the serial port. */
		vSerialPutString( xPort, pcMessageToExchange, strlen( pcMessageToExchange ) );

		/* We have posted all the characters in the string - increment the variable 
		used to check that this task is still running, then wait before re-sending 
		the string. */
		sTxCount++;

		xTimeToWait = xTaskGetTickCount();

		/* Make sure we don't wait too long... */
		xTimeToWait %= comTX_MAX_BLOCK_TIME;

		/* ...but we do want to wait. */
		if( xTimeToWait < comTX_MIN_BLOCK_TIME )
		{
			xTimeToWait = comTX_MIN_BLOCK_TIME;
		}

		vTaskDelay( xTimeToWait );
	}
} /*lint !e715 !e818 pvParameters is required for a task function even if it is not referenced. */
/*-----------------------------------------------------------*/

static void vComRxTask( void *pvParameters )
{
const portCHAR * const pcTaskStartMsg = "COM Rx task started.\r\n";
const portCHAR * const pcTaskErrorMsg = "COM read error\r\n";
const portCHAR * const pcTaskRestartMsg = "COM resynced\r\n";
const portCHAR * const pcTaskTimeoutMsg = "COM Rx timed out\r\n";
const portTickType xBlockTime = ( portTickType ) 0xffff / portTICK_RATE_MS;
const portCHAR *pcExpectedChar;
portBASE_TYPE xGotChar;
portCHAR cRxedChar;
portSHORT sResyncRequired, sConsecutiveErrors, sLatchedError;

	/* Stop warnings. */
	( void ) pvParameters;

	/* Queue a message for printing to say the task has started. */
	vPrintDisplayMessage( &pcTaskStartMsg );
	
	/* The first expected character is the first character in the string. */
	pcExpectedChar = pcMessageToExchange;
	sResyncRequired = pdFALSE;
	sConsecutiveErrors = 0;
	sLatchedError = pdFALSE;

	for( ;; )
	{
		/* Receive a message from the com port interrupt routine.  If a message is 
		not yet available the call will block the task. */
		xGotChar = xSerialGetChar( xPort, &cRxedChar, xBlockTime );
		if( xGotChar == pdTRUE )
		{
			if( sResyncRequired == pdTRUE )
			{
				/* We got out of sequence and are waiting for the start of the next 
				transmission of the string. */
				if( cRxedChar == '\n' )
				{
					/* This is the end of the message so we can start again - with 
					the first character in the string being the next thing we expect 
					to receive. */
					pcExpectedChar = pcMessageToExchange;
					sResyncRequired = pdFALSE;

					/* Queue a message for printing to say that we are going to try 
					again. */
					vPrintDisplayMessage( &pcTaskRestartMsg );

					/* Stop incrementing the check variable, if consecutive errors occur. */
					sConsecutiveErrors++;
					if( sConsecutiveErrors >= comMAX_CONSECUTIVE_ERRORS )
					{
						sLatchedError = pdTRUE;
					}
				}
			}
			else
			{
				/* We have received a character, but is it the expected character? */
				if( cRxedChar != *pcExpectedChar )
				{
					/* This was not the expected character so post a message for 
					printing to say that an error has occurred.  We will then wait 
					to resynchronise. */
					vPrintDisplayMessage( &pcTaskErrorMsg );					
					sResyncRequired = pdTRUE;
				}
				else
				{
					/* This was the expected character so next time we will expect 
					the next character in the string.  Wrap back to the beginning 
					of the string when the null terminator has been reached. */
					pcExpectedChar++;
					if( *pcExpectedChar == '\0' )
					{
						pcExpectedChar = pcMessageToExchange;

						/* We have got through the entire string without error. */
						sConsecutiveErrors = 0;
					}
				}
			}

			/* Increment the count that is used to check that this task is still 
			running.  This is only done if an error has never occurred. */
			if( sLatchedError == pdFALSE )
			{
				sRxCount++;			
			}
		}
		else
		{
			vPrintDisplayMessage( &pcTaskTimeoutMsg );
		}
	}
} /*lint !e715 !e818 pvParameters is required for a task function even if it is not referenced. */
/*-----------------------------------------------------------*/

static void vSemTestTask( void * pvParameters )
{
const portCHAR * const pcTaskStartMsg = "ISR Semaphore test started.\r\n";

 	/* Stop warnings. */
	( void ) pvParameters;

	/* Queue a message for printing to say the task has started. */
	vPrintDisplayMessage( &pcTaskStartMsg );

	for( ;; )
	{
		if( xSerialWaitForSemaphore( xPort ) )
		{
			sSemCount++;				
		}
	}
} /*lint !e715 !e830 !e818 pvParameters not used but function prototype must be standard for task function. */
/*-----------------------------------------------------------*/

/* This is called to check that all the created tasks are still running. */
portBASE_TYPE xAreComTestTasksStillRunning( void )
{
static portSHORT sLastTxCount = 0, sLastRxCount = 0, sLastSemCount = 0;
portBASE_TYPE xReturn;

	/* Not too worried about mutual exclusion on these variables as they are 16 
	bits and we are only reading them.  We also only care to see if they have 
	changed or not. */

	if( ( sTxCount == sLastTxCount ) || ( sRxCount == sLastRxCount ) || ( sSemCount == sLastSemCount ) )
	{
		xReturn = pdFALSE;
	}
	else
	{
		xReturn = pdTRUE;
	}

	sLastTxCount = sTxCount;
	sLastRxCount = sRxCount;
	sLastSemCount = sSemCount;

	return xReturn;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩午夜精品电影| 欧美最新大片在线看 | 国产片一区二区三区| 麻豆精品在线观看| 日韩欧美一区二区免费| 九九国产精品视频| 久久久777精品电影网影网| 国产电影一区二区三区| 国产精品全国免费观看高清| 97久久精品人人做人人爽50路| ㊣最新国产の精品bt伙计久久| 色婷婷精品久久二区二区蜜臂av| 亚洲综合色网站| 欧美一区二区三区在线观看视频| 久久国产精品99久久久久久老狼| 久久久久国色av免费看影院| 99精品国产视频| 丝袜亚洲另类丝袜在线| 久久这里只有精品首页| 91免费视频大全| 日本视频一区二区三区| 欧美国产日产图区| 91黄色激情网站| 蜜臀91精品一区二区三区| 国产精品网站在线观看| 欧美色精品天天在线观看视频| 久久66热偷产精品| 国产精品美女久久久久久久网站| 欧美日本一区二区| 国产精品一区二区免费不卡| 一区二区三区国产| 日韩免费一区二区三区在线播放| 丁香激情综合五月| 五月综合激情婷婷六月色窝| 国产性做久久久久久| 欧美性猛交xxxx乱大交退制版| 国产麻豆一精品一av一免费| 一区二区视频在线| 精品对白一区国产伦| 色哦色哦哦色天天综合| 久久69国产一区二区蜜臀| 一区二区成人在线| 久久精品网站免费观看| 在线播放91灌醉迷j高跟美女| 成人午夜看片网址| 免播放器亚洲一区| 伊人开心综合网| 久久综合成人精品亚洲另类欧美| 欧美综合亚洲图片综合区| 国产福利一区二区三区| 免费一级片91| 一区二区中文字幕在线| 日韩你懂的在线播放| 欧美日本免费一区二区三区| 91蜜桃免费观看视频| 国产一区二区主播在线| 免费亚洲电影在线| 亚洲v中文字幕| 一区二区三区中文字幕| 欧美高清在线精品一区| 26uuu精品一区二区在线观看| 欧美老女人在线| 欧美性大战久久| 色狠狠色噜噜噜综合网| 成人国产免费视频| 国产成人亚洲综合色影视| 日韩精品三区四区| 视频一区欧美精品| 午夜电影网亚洲视频| 亚洲一区二区在线观看视频| 久久先锋资源网| 26uuu精品一区二区三区四区在线| 538prom精品视频线放| 欧美影院一区二区| 91国产丝袜在线播放| 色综合网色综合| 在线一区二区观看| 在线中文字幕一区二区| 色噜噜狠狠成人网p站| 色婷婷香蕉在线一区二区| www.欧美日韩国产在线| 成人免费看的视频| 91亚洲精品久久久蜜桃网站| 91视频.com| 欧美午夜寂寞影院| 91精品午夜视频| 欧美电影免费提供在线观看| 精品国产髙清在线看国产毛片| 精品久久久久久久久久久院品网| 欧美tickling挠脚心丨vk| 久久婷婷一区二区三区| 久久人人97超碰com| 国产精品午夜在线观看| 亚洲色图在线播放| 亚洲第一精品在线| 日本成人超碰在线观看| 经典一区二区三区| 国产mv日韩mv欧美| 色综合一个色综合| 欧美日本视频在线| 久久久久久免费毛片精品| 日本一区二区三区四区在线视频| 国产精品久线在线观看| 亚洲一区二区三区四区在线观看| 午夜亚洲福利老司机| 另类的小说在线视频另类成人小视频在线 | 亚洲一级片在线观看| 视频在线观看一区| 国产大陆亚洲精品国产| 一本色道久久综合亚洲aⅴ蜜桃| 欧美日韩电影在线播放| 日韩欧美www| 亚洲欧洲三级电影| 日一区二区三区| 成人丝袜18视频在线观看| 欧洲激情一区二区| 久久久综合九色合综国产精品| 国产精品美日韩| 日韩vs国产vs欧美| 成人久久久精品乱码一区二区三区| 欧美在线免费观看亚洲| 久久一夜天堂av一区二区三区| 亚洲天堂精品视频| 久久99精品久久久久久| 色婷婷亚洲精品| 日韩一区二区三区视频在线观看 | 国产精品久久久久一区| 性久久久久久久久久久久| 国产精品一区二区久久精品爱涩| 在线精品视频一区二区| 久久这里只有精品首页| 亚洲综合一区二区精品导航| 国内久久精品视频| 欧美日韩精品专区| 国产精品久久福利| 国产一区二区免费看| 成人手机在线视频| 日韩午夜激情免费电影| 亚洲男人都懂的| 国产精品 日产精品 欧美精品| 欧美性猛交xxxx黑人交| 久久久久久久免费视频了| 亚洲亚洲精品在线观看| aaa亚洲精品一二三区| 久久综合网色—综合色88| 亚洲一区视频在线| av一区二区三区四区| 久久精品亚洲一区二区三区浴池| 日韩国产在线观看| 欧美色爱综合网| 亚洲欧美日韩国产另类专区| 国产凹凸在线观看一区二区| 欧美成人性战久久| 日韩精彩视频在线观看| 91久久线看在观草草青青| 国产精品久久久一区麻豆最新章节| 极品瑜伽女神91| 欧美xxxx老人做受| 日本aⅴ精品一区二区三区| 在线观看www91| 一区二区三区四区不卡视频 | 经典三级视频一区| 欧美电影免费观看完整版| 亚洲不卡在线观看| 欧美日韩精品欧美日韩精品一| 一区二区三区在线免费播放| 色综合天天综合网天天看片| 国产精品传媒视频| 成人av电影在线| 自拍偷拍亚洲综合| 97se亚洲国产综合自在线不卡 | 久久蜜桃一区二区| 国产老女人精品毛片久久| 日韩精品一区二区三区蜜臀 | 中文字幕永久在线不卡| 成人精品免费网站| 亚洲欧美一区二区三区久本道91| 97久久超碰国产精品电影| 亚洲三级小视频| 91亚洲精品久久久蜜桃网站| 伊人开心综合网| 在线成人免费观看| 精品在线亚洲视频| 久久中文字幕电影| www.视频一区| 亚洲一级不卡视频| 日韩美女在线视频| 国产不卡高清在线观看视频| 亚洲天天做日日做天天谢日日欢| 在线精品视频免费播放| 午夜精品一区二区三区电影天堂 | 人人超碰91尤物精品国产| 日韩你懂的在线播放| 福利视频网站一区二区三区| 亚洲欧洲日产国码二区| 欧美日韩一区二区三区在线| 极品少妇xxxx精品少妇| 国产精品成人免费| 欧美激情一区二区三区全黄| 91视频xxxx|