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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? serial.c

?? MCS-51的一個Free小型操作系統(tǒng),在KeilC中下編譯工作
?? C
字號:
/*
	FreeRTOS.org V4.1.3 - 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.
	***************************************************************************
*/


/* 
	BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART0. 

	This file contains all the serial port components that can be compiled to
	either ARM or THUMB mode.  Components that must be compiled to ARM mode are
	contained in serialISR.c.
*/

/* Standard includes. */
#include <stdlib.h>

/* Scheduler includes. */
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"

/* Demo application includes. */
#include "serial.h"

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

/* Constants to setup and access the UART. */
#define serDLAB							( ( unsigned portCHAR ) 0x80 )
#define serENABLE_INTERRUPTS			( ( unsigned portCHAR ) 0x03 )
#define serNO_PARITY					( ( unsigned portCHAR ) 0x00 )
#define ser1_STOP_BIT					( ( unsigned portCHAR ) 0x00 )
#define ser8_BIT_CHARS					( ( unsigned portCHAR ) 0x03 )
#define serFIFO_ON						( ( unsigned portCHAR ) 0x01 )
#define serCLEAR_FIFO					( ( unsigned portCHAR ) 0x06 )
#define serWANTED_CLOCK_SCALING			( ( unsigned portLONG ) 16 )

/* Constants to setup and access the VIC. */
#define serU0VIC_CHANNEL				( ( unsigned portLONG ) 0x0006 )
#define serU0VIC_CHANNEL_BIT			( ( unsigned portLONG ) 0x0040 )
#define serU0VIC_ENABLE					( ( unsigned portLONG ) 0x0020 )

/* Misc. */
#define serINVALID_QUEUE				( ( xQueueHandle ) 0 )
#define serHANDLE						( ( xComPortHandle ) 1 )
#define serNO_BLOCK						( ( portTickType ) 0 )

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

/* Queues used to hold received characters, and characters waiting to be
transmitted. */
static xQueueHandle xRxedChars; 
static xQueueHandle xCharsForTx; 

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

/* Communication flag between the interrupt service routine and serial API. */
static volatile portLONG *plTHREEmpty;

/* 
 * The queues are created in serialISR.c as they are used from the ISR.
 * Obtain references to the queues and THRE Empty flag. 
 */
extern void vSerialISRCreateQueues(	unsigned portBASE_TYPE uxQueueLength, xQueueHandle *pxRxedChars, xQueueHandle *pxCharsForTx, portLONG volatile **pplTHREEmptyFlag );

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

xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
unsigned portLONG ulDivisor, ulWantedClock;
xComPortHandle xReturn = serHANDLE;

	/* The queues are used in the serial ISR routine, so are created from
	serialISR.c (which is always compiled to ARM mode). */
	vSerialISRCreateQueues( uxQueueLength, &xRxedChars, &xCharsForTx, &plTHREEmpty );

	if( 
		( xRxedChars != serINVALID_QUEUE ) && 
		( xCharsForTx != serINVALID_QUEUE ) && 
		( ulWantedBaud != ( unsigned portLONG ) 0 ) 
	  )
	{
		portENTER_CRITICAL();
		{
			/* The reference to the ISR function is required to load into the 
			interrupt controller.  The prototype is slightly different 
			depending on whether in ARM or THUMB mode. */
			#ifdef KEIL_THUMB_INTERWORK
				extern void ( vUART_ISR )( void ) __arm __task;
			#else
				extern void ( vUART_ISR )( void ) __task;
			#endif

			/* Setup the baud rate:  Calculate the divisor value. */
			ulWantedClock = ulWantedBaud * serWANTED_CLOCK_SCALING;
			ulDivisor = configCPU_CLOCK_HZ / ulWantedClock;

			/* Set the DLAB bit so we can access the divisor. */
			U0LCR |= serDLAB;

			/* Setup the divisor. */
			U0DLL = ( unsigned portCHAR ) ( ulDivisor & ( unsigned portLONG ) 0xff );
			ulDivisor >>= 8;
			U0DLM = ( unsigned portCHAR ) ( ulDivisor & ( unsigned portLONG ) 0xff );

			/* Turn on the FIFO's and clear the buffers. */
			U0FCR = ( serFIFO_ON | serCLEAR_FIFO );

			/* Setup transmission format. */
			U0LCR = serNO_PARITY | ser1_STOP_BIT | ser8_BIT_CHARS;

			/* Setup the VIC for the UART. */
			VICIntSelect &= ~( serU0VIC_CHANNEL_BIT );
			VICIntEnable |= serU0VIC_CHANNEL_BIT;
			VICVectAddr1 = ( unsigned portLONG ) vUART_ISR;
			VICVectCntl1 = serU0VIC_CHANNEL | serU0VIC_ENABLE;

			/* Enable UART0 interrupts. */
			U0IER |= serENABLE_INTERRUPTS;
		}
		portEXIT_CRITICAL();
	}
	else
	{
		xReturn = ( xComPortHandle ) 0;
	}

	return xReturn;
}
/*-----------------------------------------------------------*/

signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
{
	/* The port handle is not required as this driver only supports UART0. */
	( void ) pxPort;

	/* Get the next character from the buffer.  Return false if no characters
	are available, or arrive before xBlockTime expires. */
	if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )
	{
		return pdTRUE;
	}
	else
	{
		return pdFALSE;
	}
}
/*-----------------------------------------------------------*/

void vSerialPutString( xComPortHandle pxPort, const signed portCHAR * const pcString, unsigned portSHORT usStringLength )
{
signed portCHAR *pxNext;

	/* NOTE: This implementation does not handle the queue being full as no
	block time is used! */

	/* The port handle is not required as this driver only supports UART0. */
	( void ) pxPort;
	( void ) usStringLength;

	/* Send each character in the string, one at a time. */
	pxNext = ( signed portCHAR * ) pcString;
	while( *pxNext )
	{
		xSerialPutChar( pxPort, *pxNext, serNO_BLOCK );
		pxNext++;
	}
}
/*-----------------------------------------------------------*/

signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
{
signed portBASE_TYPE xReturn;

	/* The port handle is not required as this driver only supports UART0. */
	( void ) pxPort;

	portENTER_CRITICAL();
	{
		/* Is there space to write directly to the UART? */
		if( *plTHREEmpty == ( portLONG ) pdTRUE )
		{
			/* We wrote the character directly to the UART, so was 
			successful. */
			*plTHREEmpty = pdFALSE;
			U0THR = cOutChar;
			xReturn = pdPASS;
		}
		else 
		{
			/* We cannot write directly to the UART, so queue the character.
			Block for a maximum of xBlockTime if there is no space in the
			queue.  It is ok to block within a critical section as each
			task has it's own critical section management. */
			xReturn = xQueueSend( xCharsForTx, &cOutChar, xBlockTime );

			/* Depending on queue sizing and task prioritisation:  While we 
			were blocked waiting to post interrupts were not disabled.  It is 
			possible that the serial ISR has emptied the Tx queue, in which
			case we need to start the Tx off again. */
			if( *plTHREEmpty == ( portLONG ) pdTRUE )
			{
				xQueueReceive( xCharsForTx, &cOutChar, serNO_BLOCK );
				*plTHREEmpty = pdFALSE;
				U0THR = cOutChar;
			}
		}
	}
	portEXIT_CRITICAL();

	return xReturn;
}
/*-----------------------------------------------------------*/






	

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
伊人婷婷欧美激情| 亚洲第一在线综合网站| 欧美精品少妇一区二区三区| 国产成人在线看| 亚洲成a天堂v人片| 国产精品久久久久久福利一牛影视| 欧美久久久久中文字幕| 99国产精品久久久久久久久久久 | 91在线国产观看| 麻豆精品在线播放| 亚洲一区二区美女| 国产视频视频一区| 欧美一区二区三区人| 欧美影院午夜播放| 99视频国产精品| 制服丝袜中文字幕亚洲| 91猫先生在线| www.欧美.com| 成人黄色一级视频| 国产精品一区二区三区99| 日韩精品免费专区| 天天做天天摸天天爽国产一区| 日韩理论在线观看| 国产精品拍天天在线| 久久精品亚洲精品国产欧美kt∨ | 欧美日韩专区在线| 色综合天天综合狠狠| 成人午夜电影久久影院| 国产精品一区在线观看乱码| 久久国产精品无码网站| 美女视频第一区二区三区免费观看网站| 亚洲高清免费在线| 亚洲一区二区免费视频| 亚洲高清不卡在线| 亚洲综合在线视频| 亚洲精品videosex极品| 中文字幕综合网| 亚洲免费在线电影| 亚洲最新视频在线播放| 一区二区三区在线观看视频| 一区二区三区高清不卡| 亚洲国产精品综合小说图片区| 亚洲免费色视频| 亚洲一区二区五区| 亚洲国产精品人人做人人爽| 亚洲电影你懂得| 蜜臀av性久久久久蜜臀aⅴ四虎| 日本成人中文字幕在线视频 | 国产精品99久久久| 懂色中文一区二区在线播放| 成人蜜臀av电影| 一本色道久久综合狠狠躁的推荐 | 奇米精品一区二区三区在线观看| 蜜臀久久99精品久久久久久9| 美女视频黄免费的久久| 精品在线观看视频| 国产电影精品久久禁18| 91玉足脚交白嫩脚丫在线播放| 91精彩视频在线观看| 欧美日韩国产区一| 精品免费99久久| 亚洲国产电影在线观看| 亚洲三级小视频| 天天综合网天天综合色| 国产中文字幕精品| 99在线视频精品| 欧美日韩美少妇| 久久综合色婷婷| 亚洲色图另类专区| 免费精品视频在线| 成人一级片在线观看| 欧美午夜一区二区| 久久综合色婷婷| 亚洲精品videosex极品| 另类调教123区| av在线一区二区| 国产精品传媒视频| 亚洲成av人片一区二区三区| 国产剧情一区二区| 欧洲精品在线观看| 精品国产91久久久久久久妲己 | 欧美久久久一区| 亚洲精品一区二区在线观看| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 婷婷一区二区三区| 国产成a人亚洲| 91麻豆精品国产91久久久更新时间 | 国产精品一二一区| 在线观看日韩av先锋影音电影院| 欧美一区二区久久| 亚洲视频免费观看| 国产一区二区按摩在线观看| 精品视频1区2区3区| 久久精品水蜜桃av综合天堂| 亚洲国产精品久久久男人的天堂| 国产精品1区二区.| 678五月天丁香亚洲综合网| 国产日韩欧美精品一区| 婷婷久久综合九色综合绿巨人 | 国产精品一二三在| 91精品国产免费| 亚洲免费视频中文字幕| 国产成人午夜精品影院观看视频| 欧美精品三级日韩久久| 亚洲视频免费在线| 国产成人精品亚洲777人妖| 日韩三级视频在线看| 亚洲卡通动漫在线| av在线播放成人| 国产欧美一区二区精品婷婷| 日韩av电影一区| 欧美日韩一区精品| 亚洲视频一区二区在线观看| 国产精品18久久久久久久网站| 日韩一区二区免费在线观看| 五月天网站亚洲| 日本韩国欧美三级| 亚洲欧美偷拍卡通变态| 丁香亚洲综合激情啪啪综合| 欧美精品一区视频| 免费成人在线观看视频| 欧美日韩精品系列| 亚洲一区二区三区四区五区中文| 99久久精品免费看国产| 国产精品免费丝袜| 成人免费看片app下载| 欧美激情一区二区三区在线| 国产成人免费视频一区| 国产日本亚洲高清| 国产成人夜色高潮福利影视| 国产偷v国产偷v亚洲高清| 国产一区二区三区黄视频 | 欧洲精品一区二区三区在线观看| 亚洲色图欧美偷拍| 色视频欧美一区二区三区| 亚洲视频一二三| 日本精品免费观看高清观看| 一区二区三区四区五区视频在线观看| 91免费版在线| 一区二区不卡在线视频 午夜欧美不卡在| 成av人片一区二区| 亚洲天堂久久久久久久| 色综合色狠狠综合色| 一区二区视频在线看| 在线视频你懂得一区| 亚洲成av人片一区二区| 91精品婷婷国产综合久久| 久久精品国产精品亚洲综合| 亚洲精品一区二区三区蜜桃下载| 国产毛片精品视频| 中文字幕在线不卡一区二区三区| av一二三不卡影片| 亚洲综合在线免费观看| 欧美另类高清zo欧美| 另类小说图片综合网| 国产视频不卡一区| 91搞黄在线观看| 奇米色777欧美一区二区| 久久精品视频一区二区三区| 99免费精品在线观看| 洋洋av久久久久久久一区| 91精品国产高清一区二区三区蜜臀| 久久精品国产精品青草| 国产精品久久久久久久久免费丝袜 | 久久久久久综合| 91视视频在线观看入口直接观看www| 亚洲国产一区二区三区| 久久综合五月天婷婷伊人| 99久久精品国产网站| 丝袜国产日韩另类美女| 国产女同性恋一区二区| 欧美日韩精品一区二区三区蜜桃 | 欧美中文字幕不卡| 狠狠色综合色综合网络| 亚洲日本在线看| 欧美一区二区网站| 成人黄色国产精品网站大全在线免费观看 | 欧美另类久久久品| 成人性生交大片免费看中文| 玉米视频成人免费看| 欧美精品一区二区久久久| 99国产精品一区| 久久91精品国产91久久小草| 亚洲欧洲日产国产综合网| 六月丁香婷婷久久| 综合久久综合久久| 精品少妇一区二区三区在线视频| k8久久久一区二区三区| 免费在线看成人av| 亚洲三级久久久| 国产亚洲成aⅴ人片在线观看| 欧美日本一区二区| 成人av网站在线观看| 美女网站在线免费欧美精品| 有坂深雪av一区二区精品| 久久九九影视网| 日韩欧美一卡二卡| 欧美日免费三级在线| 99re这里只有精品6| 黄网站免费久久|