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

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

?? serial.c

?? MCS-51的一個Free小型操作系統,在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.
	***************************************************************************
*/

/*
	Changes from V2.4.0

		+ Made serial ISR handling more complete and robust.

	Changes from V2.4.1

		+ Split serial.c into serial.c and serialISR.c.  serial.c can be 
		  compiled using ARM or THUMB modes.  serialISR.c must always be
		  compiled in ARM mode.
		+ Another small change to cSerialPutChar().

	Changed from V2.5.1

		+ In cSerialPutChar() an extra check is made to ensure the post to
		  the queue was successful if then attempting to retrieve the posted
		  character.

*/

/* 
	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 serUART0_VIC_CHANNEL			( ( unsigned portLONG ) 0x0006 )
#define serUART0_VIC_CHANNEL_BIT		( ( unsigned portLONG ) 0x0040 )
#define serUART0_VIC_ENABLE				( ( unsigned portLONG ) 0x0020 )
#define serCLEAR_VIC_INTERRUPT			( ( unsigned portLONG ) 0 )

#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;
extern void ( vUART_ISR )( void );

	/* 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();
		{
			/* 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. */
			UART0_LCR |= serDLAB;

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

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

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

			/* Setup the VIC for the UART. */
			VICIntSelect &= ~( serUART0_VIC_CHANNEL_BIT );
			VICIntEnable |= serUART0_VIC_CHANNEL_BIT;
			VICVectAddr1 = ( portLONG ) vUART_ISR;
			VICVectCntl1 = serUART0_VIC_CHANNEL | serUART0_VIC_ENABLE;

			/* Enable UART0 interrupts. */
			UART0_IER |= 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;

	/* This demo driver only supports one port so the parameter is not used. */
	( 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;
			UART0_THR = 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. */
			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 ) && ( xReturn == pdPASS ) )
			{
				xQueueReceive( xCharsForTx, &cOutChar, serNO_BLOCK );
				*plTHREEmpty = pdFALSE;
				UART0_THR = cOutChar;
			}
		}
	}
	portEXIT_CRITICAL();

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

void vSerialClose( xComPortHandle xPort )
{
	/* Not supported as not required by the demo application. */
	( void ) xPort;
}
/*-----------------------------------------------------------*/





	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲婷婷国产精品电影人久久| 五月天亚洲婷婷| 久久久久国产精品麻豆ai换脸 | 精品国产精品网麻豆系列 | 亚洲伊人伊色伊影伊综合网| 久久99国产精品久久99| 97se狠狠狠综合亚洲狠狠| 欧美一区二区视频免费观看| 国产精品国产成人国产三级| 九九**精品视频免费播放| 在线视频观看一区| 国产精品久久久久久户外露出 | 中文字幕在线不卡| 国内精品伊人久久久久影院对白| 色综合夜色一区| 国产精品毛片无遮挡高清| 九一九一国产精品| 日韩视频一区在线观看| 天天操天天干天天综合网| 色老综合老女人久久久| 亚洲人成精品久久久久| 成人高清免费观看| 国产欧美一区二区精品性| 九九九精品视频| 久久蜜桃香蕉精品一区二区三区| 六月丁香综合在线视频| 欧美日韩精品福利| 亚洲午夜视频在线| 欧美三级电影网| 亚洲国产另类av| 欧美日韩一二三| 婷婷久久综合九色国产成人| 欧美色精品在线视频| 亚洲国产精品自拍| 欧美日本一区二区三区四区| 亚洲午夜免费电影| 欧美一卡二卡在线观看| 老司机午夜精品| 国产精品卡一卡二卡三| 国产成人欧美日韩在线电影| wwwwxxxxx欧美| 国产黄色成人av| 国产精品久久久爽爽爽麻豆色哟哟| 国产成人免费视频网站| 国产精品护士白丝一区av| aaa亚洲精品| 伊人色综合久久天天| 91福利精品第一导航| 一区二区三区蜜桃网| 欧美日韩视频在线观看一区二区三区 | 青草国产精品久久久久久| 91精品国产综合久久精品| 国产一区高清在线| 欧美国产日本视频| 欧美怡红院视频| 久久激情综合网| 国产精品丝袜黑色高跟| 在线看不卡av| 看片网站欧美日韩| 国产女同互慰高潮91漫画| 色网站国产精品| 日韩中文字幕麻豆| 久久精品综合网| 91久久精品一区二区| 日韩国产一区二| 国产午夜精品一区二区三区嫩草| 色婷婷av一区二区三区大白胸| 婷婷开心激情综合| 国产精品欧美久久久久无广告 | 久久夜色精品一区| 91免费精品国自产拍在线不卡| 性欧美疯狂xxxxbbbb| 2023国产精品视频| 91久久人澡人人添人人爽欧美| 蜜臀av一区二区在线观看| 国产精品久久久久一区二区三区共| 91久久香蕉国产日韩欧美9色| 国内精品伊人久久久久av一坑| 亚洲欧洲性图库| 日韩一区二区中文字幕| www.色精品| 精品一区二区免费视频| 亚洲综合一区二区精品导航| 日韩欧美成人激情| 欧美日韩精品一区二区三区蜜桃 | 欧美在线免费观看亚洲| 国产乱对白刺激视频不卡| 亚洲最新视频在线观看| 国产欧美一区二区三区鸳鸯浴| 制服丝袜在线91| 色88888久久久久久影院按摩| 国产美女娇喘av呻吟久久| 日本成人超碰在线观看| 一区二区三区日韩在线观看| 国产欧美日韩另类视频免费观看| 欧美三级电影网| 色欧美日韩亚洲| 成人美女视频在线观看18| 蜜桃久久av一区| 亚洲 欧美综合在线网络| 亚洲欧美激情小说另类| 国产亚洲精久久久久久| 欧美一区二区三区四区五区| 在线观看www91| 欧美这里有精品| 91亚洲精品一区二区乱码| 岛国av在线一区| 九九九精品视频| 狠狠色狠狠色综合系列| 久久国产精品99久久人人澡| 亚洲成av人片一区二区梦乃| 亚洲欧美日韩电影| 亚洲日本电影在线| 亚洲视频综合在线| 国产精品女主播av| 国产精品久久久久影院亚瑟| 中文在线免费一区三区高中清不卡| ww久久中文字幕| 久久嫩草精品久久久久| 久久综合av免费| 中文字幕乱码日本亚洲一区二区| 国产欧美精品一区二区三区四区| 久久久国产精品不卡| 2欧美一区二区三区在线观看视频| 日韩欧美视频一区| 精品国产一区二区三区四区四| 2021久久国产精品不只是精品| 国产亚洲精久久久久久| 中文字幕va一区二区三区| 国产精品二三区| 亚洲九九爱视频| 一区二区免费在线播放| 日韩高清在线一区| 国产成人日日夜夜| 色婷婷久久一区二区三区麻豆| 色婷婷精品大在线视频| 欧美群妇大交群中文字幕| 精品久久久久香蕉网| 久久免费电影网| 亚洲伦理在线精品| 亚洲电影第三页| 国产精品一线二线三线| 99re6这里只有精品视频在线观看| 色综合久久综合中文综合网| 欧美日韩成人高清| 国产偷v国产偷v亚洲高清| 亚洲精品午夜久久久| 日本不卡的三区四区五区| 国产精品夜夜爽| 91蝌蚪国产九色| 日韩欧美综合在线| 国产精品免费视频网站| 亚洲一区二区欧美激情| 狠狠色丁香婷婷综合久久片| 成人黄色片在线观看| 欧美日韩视频一区二区| 国产调教视频一区| 视频在线观看一区| 成人黄色在线看| 欧美老肥妇做.爰bbww| 国产色婷婷亚洲99精品小说| 亚洲不卡在线观看| 国产精品亚洲专一区二区三区| 在线看不卡av| 国产欧美va欧美不卡在线| 国产精品一色哟哟哟| 欧美日韩视频第一区| 国产精品少妇自拍| 天天综合色天天| 色婷婷久久综合| 国产女人18毛片水真多成人如厕| 亚洲午夜激情网站| 风间由美一区二区三区在线观看 | 色国产精品一区在线观看| 26uuu精品一区二区三区四区在线| 亚洲欧美视频在线观看| 国产麻豆精品theporn| 在线播放日韩导航| 亚洲欧美成人一区二区三区| 国产不卡视频在线播放| 欧美精品少妇一区二区三区| 中文字幕一区二区在线播放 | 色婷婷久久久亚洲一区二区三区| 2020国产精品自拍| 日本中文字幕一区| 欧美精品丝袜久久久中文字幕| 亚洲精品视频在线观看网站| 国产麻豆视频精品| 久久亚洲一级片| 蓝色福利精品导航| 精品久久人人做人人爽| 蜜桃av噜噜一区二区三区小说| 欧美在线视频日韩| 亚洲男人天堂av| 色综合久久久久久久久久久| 亚洲少妇中出一区| 97久久久精品综合88久久| 中文字幕一区视频| 91美女在线观看| 一区二区在线观看免费|