亚洲欧美第一页_禁久久精品乱码_粉嫩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.
	***************************************************************************
*/


/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER.   
 * 
 * This file only supports UART 1
 */

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

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

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

/* Constants required to setup the hardware. */
#define serTX_AND_RX			( ( unsigned portCHAR ) 0x03 )

/* Misc. constants. */
#define serNO_BLOCK				( ( portTickType ) 0 )

/* Enable the UART Tx interrupt. */
#define vInterruptOn() IFG2 |= UTXIFG1

/* The queue used to hold received characters. */
static xQueueHandle xRxedChars; 

/* The queue used to hold characters waiting transmission. */
static xQueueHandle xCharsForTx; 

static volatile portSHORT sTHREEmpty;

/* Interrupt service routines. */
interrupt (UART1RX_VECTOR) vRxISR( void );
interrupt (UART1TX_VECTOR) vTxISR( void );

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

xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
unsigned portLONG ulBaudRateCount;

	/* Initialise the hardware. */

	/* Generate the baud rate constants for the wanted baud rate. */
	ulBaudRateCount = configCPU_CLOCK_HZ / ulWantedBaud;

	portENTER_CRITICAL();
	{
		/* Create the queues used by the com test task. */
		xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
		xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );

		/* Reset UART. */
		UCTL1 |= SWRST;

		/* Set pin function. */
		P4SEL |= serTX_AND_RX;

		/* All other bits remain at zero for n, 8, 1 interrupt driven operation. 
		LOOPBACK MODE!*/
		U1CTL |= CHAR + LISTEN;
		U1TCTL |= SSEL1;

		/* Setup baud rate low byte. */
		U1BR0 = ( unsigned portCHAR ) ( ulBaudRateCount & ( unsigned portLONG ) 0xff );

		/* Setup baud rate high byte. */
		ulBaudRateCount >>= 8UL;
		U1BR1 = ( unsigned portCHAR ) ( ulBaudRateCount & ( unsigned portLONG ) 0xff );

		/* Enable ports. */
		ME2 |= UTXE1 + URXE1;

		/* Set. */
		UCTL1 &= ~SWRST;

		/* Nothing in the buffer yet. */
		sTHREEmpty = pdTRUE;

		/* Enable interrupts. */
		IE2 |= URXIE1 + UTXIE1;
	}
	portEXIT_CRITICAL();
	
	/* Unlike other ports, this serial code does not allow for more than one
	com port.  We therefore don't return a pointer to a port structure and can
	instead just return NULL. */
	return NULL;
}
/*-----------------------------------------------------------*/

signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
{
	/* 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;
	}
}
/*-----------------------------------------------------------*/

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

	/* Transmit a character. */

	portENTER_CRITICAL();
	{
		if( sTHREEmpty == pdTRUE )
		{
			/* If sTHREEmpty is true then the UART Tx ISR has indicated that 
			there are no characters queued to be transmitted - so we can
			write the character directly to the shift Tx register. */
			sTHREEmpty = pdFALSE;
			U1TXBUF = cOutChar;
			xReturn = pdPASS;
		}
		else
		{
			/* sTHREEmpty is false, so there are still characters waiting to be
			transmitted.  We have to queue this character so it gets 
			transmitted	in turn. */

			/* Return false if after the block time there is no room on the Tx 
			queue.  It is ok to block inside a critical section as each task
			maintains it's own critical section status. */
			xReturn = xQueueSend( xCharsForTx, &cOutChar, xBlockTime );

			/* Depending on queue sizing and task prioritisation:  While we 
			were blocked waiting to post on the queue 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
			writing directly to the Tx register. */
			if( ( sTHREEmpty == pdTRUE ) && ( xReturn == pdPASS ) )
			{
				/* Get back the character we just posted. */
				xQueueReceive( xCharsForTx, &cOutChar, serNO_BLOCK );
				sTHREEmpty = pdFALSE;
				U1TXBUF = cOutChar;
			}
		}
	}
	portEXIT_CRITICAL();

	return pdPASS;
}
/*-----------------------------------------------------------*/

/*
 * UART RX interrupt service routine.
 */
interrupt (UART1RX_VECTOR) vRxISR( void )
{
signed portCHAR cChar;

	/* Get the character from the UART and post it on the queue of Rxed 
	characters. */
	cChar = U1RXBUF;

	if( xQueueSendFromISR( xRxedChars, &cChar, pdFALSE ) )
	{
		/*If the post causes a task to wake force a context switch 
		as the woken task may have a higher priority than the task we have 
		interrupted. */
		taskYIELD();
	}
}
/*-----------------------------------------------------------*/

/*
 * UART Tx interrupt service routine.
 */
interrupt (UART1TX_VECTOR) vTxISR( void )
{
signed portCHAR cChar;
portBASE_TYPE xTaskWoken;

	/* The previous character has been transmitted.  See if there are any
	further characters waiting transmission. */

	if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xTaskWoken ) == pdTRUE )
	{
		/* There was another character queued - transmit it now. */
		U1TXBUF = cChar;
	}
	else
	{
		/* There were no other characters to transmit. */
		sTHREEmpty = pdTRUE;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产日本欧洲亚洲| 成人av先锋影音| 欧美大片在线观看| 理论电影国产精品| 欧美日韩国产a| 亚洲一区二区三区四区在线免费观看 | 欧美羞羞免费网站| 五月天激情小说综合| 69久久夜色精品国产69蝌蚪网| 有坂深雪av一区二区精品| 欧美日韩一级视频| 国产伦精品一区二区三区免费迷 | 国产精品天干天干在线综合| 粉嫩av一区二区三区粉嫩| 最新日韩av在线| 欧美中文一区二区三区| 蜜臀av亚洲一区中文字幕| 久久久午夜电影| 91丨porny丨国产入口| 亚洲一二三四在线| 精品国产乱码久久久久久牛牛| 成人的网站免费观看| 男人操女人的视频在线观看欧美| 精品区一区二区| av网站免费线看精品| 另类调教123区| 亚洲电影第三页| 伊人婷婷欧美激情| 日韩精品一区二区三区swag| 成人精品在线视频观看| 美女网站色91| 日本不卡一区二区三区| 亚洲欧美日韩中文播放| 久久久精品日韩欧美| 欧美美女喷水视频| 一本一道久久a久久精品| 国产成人av在线影院| 极品少妇xxxx精品少妇| 日本sm残虐另类| 理论电影国产精品| 视频在线在亚洲| 免费看黄色91| 麻豆精品视频在线观看视频| 日本在线不卡一区| 日韩二区三区在线观看| 日本成人在线看| 免费成人深夜小野草| 免费日韩伦理电影| 美女网站色91| 成人污视频在线观看| 91成人免费在线视频| 欧美亚洲一区二区在线观看| 91黄色免费看| 欧美日韩精品欧美日韩精品一综合| 精品视频色一区| 91精品国产91综合久久蜜臀| 欧美人牲a欧美精品| 91精品国产91热久久久做人人| 91精品国产色综合久久不卡电影| 欧美日韩成人激情| 精品国产一区二区三区四区四| 日韩一级免费观看| 欧美激情一区二区三区| 国产精品三级电影| 天天色天天爱天天射综合| 日韩电影在线观看网站| 国产在线观看免费一区| 丰满白嫩尤物一区二区| 国产片一区二区三区| 亚洲精品国产视频| 日日欢夜夜爽一区| 粉嫩av一区二区三区在线播放| 色天天综合色天天久久| 日韩一区二区视频| 亚洲视频狠狠干| 秋霞电影网一区二区| 国产成人一级电影| 欧美一区二区精品| 亚洲欧美另类久久久精品2019| 青青草视频一区| 欧美怡红院视频| 亚洲欧美色图小说| 国产传媒久久文化传媒| 91精品国产高清一区二区三区 | 国产亚洲精品资源在线26u| 夜夜嗨av一区二区三区四季av| 久久97超碰国产精品超碰| 欧美日韩一区久久| 久久 天天综合| 欧美精品在线一区二区三区| 国产精品电影一区二区| 国产制服丝袜一区| 欧美精品一区二区久久婷婷| 性做久久久久久免费观看欧美| 91视频一区二区| 亚洲视频一二区| 欧美性感一类影片在线播放| 一个色综合av| 欧美老人xxxx18| 日欧美一区二区| 日韩视频一区二区三区在线播放| 亚洲成a人v欧美综合天堂下载 | 欧美一区二区三区视频在线| 亚洲成人在线免费| 日韩一区二区三区免费看| 蜜桃一区二区三区在线观看| 精品免费国产一区二区三区四区| 裸体在线国模精品偷拍| 久久青草欧美一区二区三区| 91视频国产资源| 亚洲一区二区三区视频在线播放| 国产精品一区三区| 欧美在线不卡视频| 另类小说色综合网站| 亚洲成人先锋电影| 亚洲一线二线三线视频| 国产精品免费看片| 中文字幕制服丝袜成人av| 2欧美一区二区三区在线观看视频| 国产成人亚洲综合色影视| 一区二区三区欧美视频| 日韩欧美美女一区二区三区| 不卡视频免费播放| 九一久久久久久| 亚洲精品亚洲人成人网| 日韩一区二区三区免费看 | 日韩国产在线一| 国产精品短视频| 久久综合成人精品亚洲另类欧美| 成人国产在线观看| 蜜桃视频一区二区| 亚洲国产综合视频在线观看| 国产欧美精品一区| 久久久欧美精品sm网站| 日韩免费视频线观看| 555夜色666亚洲国产免| 色94色欧美sute亚洲13| 国产精品伊人色| 蜜桃免费网站一区二区三区| 免费在线观看一区| 国产一区二区三区香蕉| 国产91精品精华液一区二区三区 | 日本中文一区二区三区| 日日夜夜精品视频天天综合网| 麻豆成人av在线| 国产成人免费av在线| 99vv1com这只有精品| 欧美色图激情小说| 日韩亚洲电影在线| 久久久久久久一区| 亚洲视频在线一区二区| 香蕉乱码成人久久天堂爱免费| 蜜臀精品久久久久久蜜臀| 美女在线一区二区| 成人av网站免费观看| 欧美亚洲丝袜传媒另类| 精品国产乱码久久久久久浪潮| 精品国产乱码久久久久久1区2区 | 91在线高清观看| 日韩欧美一二区| 亚洲少妇屁股交4| 精品国产青草久久久久福利| 国产女同互慰高潮91漫画| 日本不卡不码高清免费观看| 97久久精品人人做人人爽| 精品福利一区二区三区| 天天av天天翘天天综合网 | 视频一区二区三区中文字幕| 99久久婷婷国产| 久久久久久久久久电影| 毛片一区二区三区| 欧美一级二级三级蜜桃| 亚洲不卡av一区二区三区| 成人在线综合网站| 777a∨成人精品桃花网| 亚洲欧美日韩久久| 国产福利一区二区三区| 777xxx欧美| 亚洲国产成人91porn| 色呦呦国产精品| 欧美激情一区二区三区四区| 轻轻草成人在线| 91精品婷婷国产综合久久| 亚洲国产一区视频| 国产91精品精华液一区二区三区 | 国产一区二区三区在线看麻豆| 99精品黄色片免费大全| 亚洲精品一区二区三区影院| 免费看精品久久片| 日韩一级欧美一级| 韩国一区二区在线观看| 日韩免费观看高清完整版| 美日韩一区二区三区| 欧美激情在线一区二区三区| 欧美中文一区二区三区| 国产精品一二二区| 日韩综合在线视频| 亚洲日本va午夜在线影院| 精品成a人在线观看| 欧美日韩免费高清一区色橹橹 |