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

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

?? comtest.c

?? Este é um rtos free para a familia arm7
?? C
字號:
/*
	FreeRTOS V4.0.0 - Copyright (C) 2003-2006 Richard Barry.

	This file is part of the FreeRTOS distribution.

	FreeRTOS 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 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; 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, 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, "ISRSemTst", 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一区二区三区免费野_久草精品视频
精品国产91亚洲一区二区三区婷婷 | 国产福利精品一区二区| 国产精品免费久久久久| 欧美大片免费久久精品三p| 在线观看日韩高清av| 亚洲一二三级电影| 一区二区三区四区五区视频在线观看| 精品国产成人在线影院| 欧美一级艳片视频免费观看| 99精品黄色片免费大全| av在线综合网| 99这里只有久久精品视频| 国产精品资源网| 99精品视频在线观看| 色婷婷激情一区二区三区| 懂色av中文字幕一区二区三区| 黄色日韩网站视频| 99久久精品情趣| 成人不卡免费av| 色呦呦国产精品| 偷拍自拍另类欧美| 九九九精品视频| 国产精品亚洲专一区二区三区 | 欧美一级生活片| 欧美色老头old∨ideo| 欧美日精品一区视频| 欧美久久久久久久久| 91精品国产色综合久久| 欧美tickling网站挠脚心| 欧美韩日一区二区三区| 一区二区三区蜜桃| 五月婷婷久久综合| 青青青伊人色综合久久| 成人激情午夜影院| 秋霞av亚洲一区二区三| 国产一区二区三区日韩| av日韩在线网站| 日韩一区二区三区四区| 国产清纯白嫩初高生在线观看91 | aaa亚洲精品| 欧美色综合网站| 精品国产一区二区亚洲人成毛片| 久久综合九色综合97婷婷女人| 国产精品色噜噜| 亚洲va欧美va国产va天堂影院| 国产激情91久久精品导航| 99久久777色| 精品国产三级电影在线观看| 精品黑人一区二区三区久久| 中文字幕日本乱码精品影院| 日韩高清一区在线| 日本亚洲免费观看| 欧美日韩视频在线第一区| 久久综合一区二区| 一区二区在线观看视频在线观看| av资源网一区| 91精品国产综合久久久久久漫画| 久久精品日韩一区二区三区| 亚洲午夜激情网站| 日本久久一区二区三区| 久久综合九色综合97婷婷| 亚洲第一在线综合网站| 91视频观看免费| 久久久精品黄色| 蜜桃视频一区二区三区在线观看| 免费在线一区观看| 69堂国产成人免费视频| 亚洲国产精品久久一线不卡| 国产精品18久久久久久久久 | 精品日韩在线观看| 亚洲一区在线免费观看| 国v精品久久久网| 日韩午夜在线影院| 国产婷婷一区二区| 免费的国产精品| 91影院在线观看| 国产精品麻豆欧美日韩ww| 久久91精品久久久久久秒播| 欧美欧美午夜aⅴ在线观看| 日韩毛片一二三区| 99综合影院在线| 日韩精品中午字幕| 国内精品写真在线观看| 欧美一区二区视频网站| 日韩激情av在线| 亚洲精品一区二区三区福利| 麻豆91在线看| 久久久久久毛片| 日韩精品每日更新| 91精品黄色片免费大全| 免费在线成人网| 久久精品夜夜夜夜久久| 国产成人综合亚洲网站| 国产午夜精品美女毛片视频| 国产乱人伦偷精品视频不卡| 精品国产乱码久久久久久久| 国产一区二区91| 国产精品乱人伦| 精品一区中文字幕| 亚洲欧洲成人自拍| 欧美在线高清视频| 婷婷成人综合网| 国产欧美日韩综合| 91麻豆国产香蕉久久精品| 一区二区三区四区高清精品免费观看| 国产乱码精品一品二品| 亚洲精品一二三| 欧美日韩一区国产| 日本欧美一区二区| 欧美成人a在线| 成人激情电影免费在线观看| 中文字幕一区av| 欧美日韩精品久久久| 国产不卡视频在线观看| 亚洲精品你懂的| 日韩一区二区视频| 色综合色综合色综合色综合色综合 | 欧美专区亚洲专区| 免费av网站大全久久| 国产欧美日韩在线看| 色综合天天综合给合国产| 五月天激情综合网| 欧美国产精品专区| 欧美日韩高清一区二区| www.亚洲国产| 美国精品在线观看| 中文字幕在线视频一区| 欧美精品久久久久久久多人混战| 国产 欧美在线| 亚洲va韩国va欧美va精品| 久久久久久久久久久久久女国产乱| 91性感美女视频| 国产伦精品一区二区三区免费| 久久久久久电影| 欧美男生操女生| 91蝌蚪porny九色| 精品一区二区免费视频| 亚洲午夜激情网页| 日韩欧美的一区| 欧美色手机在线观看| 国产精品一区久久久久| 日本不卡免费在线视频| 中文字幕视频一区| 国产情人综合久久777777| 欧美一区二区三区四区在线观看 | 欧美成人video| 欧美在线|欧美| 91色乱码一区二区三区| 成人国产精品免费网站| 麻豆精品国产传媒mv男同| 蜜臀va亚洲va欧美va天堂| 日本中文字幕不卡| 久久精品99国产精品日本| 免费久久99精品国产| 蜜臀久久久99精品久久久久久| 日韩av午夜在线观看| 无码av中文一区二区三区桃花岛| 亚洲国产美女搞黄色| 天堂一区二区在线免费观看| 日本亚洲免费观看| 免费看欧美美女黄的网站| 国产乱码字幕精品高清av| 日本sm残虐另类| 国产剧情一区二区| 91久久精品一区二区二区| 国产在线视视频有精品| 久久这里只有精品视频网| 日韩美女在线视频| 国产午夜亚洲精品午夜鲁丝片| 久久久久久97三级| 欧美激情综合网| 亚洲综合在线电影| 日韩**一区毛片| 国产伦精品一区二区三区免费迷| 成人做爰69片免费看网站| 97久久久精品综合88久久| 欧美日韩久久不卡| 精品日韩一区二区| 亚洲色欲色欲www| 免费成人av资源网| 成人精品视频一区| 欧美在线你懂得| 欧美精品一区二区三区四区 | 午夜视频在线观看一区二区| 久久国产人妖系列| 91原创在线视频| 日韩欧美在线123| 亚洲国产高清在线| 亚洲小说春色综合另类电影| 美女国产一区二区三区| 成人av动漫网站| 日韩三区在线观看| 亚洲色图视频网| 久久99精品一区二区三区三区| 丁香桃色午夜亚洲一区二区三区| 欧美日韩成人一区| 国产精品国产三级国产aⅴ入口| 午夜影视日本亚洲欧洲精品| 成人小视频免费观看| 日韩欧美aaaaaa|