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

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

?? serial.c

?? MCS-51的一個(gè)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.
	***************************************************************************
*/

/*
Changes from V1.2.3

	+ The function xPortInitMinimal() has been renamed to 
	  xSerialPortInitMinimal() and the function xPortInit() has been renamed
	  to xSerialPortInit().

Changes from V2.0.0

	+ Delay periods are now specified using variables and constants of
	  portTickType rather than unsigned portLONG.
	+ xQueueReceiveFromISR() used in place of xQueueReceive() within the ISR.

Changes from V2.6.0

	+ Replaced the inb() and outb() functions with direct memory
	  access.  This allows the port to be built with the 20050414 build of
	  WinAVR.
*/

/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER. */


#include <stdlib.h>
#include <avr/interrupt.h>
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"
#include "serial.h"

#define serBAUD_DIV_CONSTANT			( ( unsigned portLONG ) 16 )

/* Constants for writing to UCSRB. */
#define serRX_INT_ENABLE				( ( unsigned portCHAR ) 0x80 )
#define serRX_ENABLE					( ( unsigned portCHAR ) 0x10 )
#define serTX_ENABLE					( ( unsigned portCHAR ) 0x08 )
#define serTX_INT_ENABLE				( ( unsigned portCHAR ) 0x20 )

/* Constants for writing to UCSRC. */
#define serUCSRC_SELECT					( ( unsigned portCHAR ) 0x80 )
#define serEIGHT_DATA_BITS				( ( unsigned portCHAR ) 0x06 )

static xQueueHandle xRxedChars; 
static xQueueHandle xCharsForTx; 

#define vInterruptOn()										\
{															\
	unsigned portCHAR ucByte;								\
															\
	ucByte = UCSRB;											\
	ucByte |= serTX_INT_ENABLE;								\
	UCSRB = ucByte;											\
}																				
/*-----------------------------------------------------------*/

#define vInterruptOff()										\
{															\
	unsigned portCHAR ucInByte;								\
															\
	ucInByte = UCSRB;										\
	ucInByte &= ~serTX_INT_ENABLE;							\
	UCSRB = ucInByte;										\
}
/*-----------------------------------------------------------*/

xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
unsigned portLONG ulBaudRateCounter;
unsigned portCHAR ucByte;

	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 ) );

		/* Calculate the baud rate register value from the equation in the
		data sheet. */
		ulBaudRateCounter = ( configCPU_CLOCK_HZ / ( serBAUD_DIV_CONSTANT * ulWantedBaud ) ) - ( unsigned portLONG ) 1;

		/* Set the baud rate. */	
		ucByte = ( unsigned portCHAR ) ( ulBaudRateCounter & ( unsigned portLONG ) 0xff );	
		UBRRL = ucByte;

		ulBaudRateCounter >>= ( unsigned portLONG ) 8;
		ucByte = ( unsigned portCHAR ) ( ulBaudRateCounter & ( unsigned portLONG ) 0xff );	
		UBRRH = ucByte;

		/* Enable the Rx interrupt.  The Tx interrupt will get enabled
		later. Also enable the Rx and Tx. */
		UCSRB = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );

		/* Set the data bits to 8. */
		UCSRC = ( serUCSRC_SELECT | serEIGHT_DATA_BITS );
	}
	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 )
{
	/* Only one port is supported. */
	( 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;
	}
}
/*-----------------------------------------------------------*/

signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
{
	/* Only one port is supported. */
	( void ) pxPort;

	/* Return false if after the block time there is no room on the Tx queue. */
	if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
	{
		return pdFAIL;
	}

	vInterruptOn();

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

void vSerialClose( xComPortHandle xPort )
{
unsigned portCHAR ucByte;

	/* The parameter is not used. */
	( void ) xPort;

	/* Turn off the interrupts.  We may also want to delete the queues and/or
	re-install the original ISR. */

	portENTER_CRITICAL();
	{
		vInterruptOff();
		ucByte = UCSRB;
		ucByte &= ~serRX_INT_ENABLE;
		UCSRB = ucByte;
	}
	portEXIT_CRITICAL();
}
/*-----------------------------------------------------------*/

SIGNAL( SIG_UART_RECV )
{
signed portCHAR cChar;

	/* Get the character and post it on the queue of Rxed characters.
	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. */
	cChar = UDR;

	if( xQueueSendFromISR( xRxedChars, &cChar, pdFALSE ) )
	{
		taskYIELD();
	}
}
/*-----------------------------------------------------------*/

SIGNAL( SIG_UART_DATA )
{
signed portCHAR cChar, cTaskWoken;

	if( xQueueReceiveFromISR( xCharsForTx, &cChar, &cTaskWoken ) == pdTRUE )
	{
		/* Send the next character queued for Tx. */
		UDR = cChar;
	}
	else
	{
		/* Queue empty, nothing to send. */
		vInterruptOff();
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩天堂在线观看| 精品国产亚洲在线| 国产一区二区三区美女| 一区二区三区免费网站| 欧美精品一区二| 欧美日韩你懂得| 不卡电影免费在线播放一区| 日本亚洲欧美天堂免费| 亚洲天堂免费看| 国产欧美精品一区| 欧美一区二区大片| 色婷婷国产精品综合在线观看| 精品在线亚洲视频| 天天影视色香欲综合网老头| 亚洲黄色小说网站| 国产精品每日更新| 国产色综合一区| 日韩欧美亚洲一区二区| 欧美色视频在线| 91免费观看国产| 成人精品小蝌蚪| 成人一道本在线| 国产综合成人久久大片91| 石原莉奈在线亚洲三区| 亚洲一区二区三区四区在线免费观看| 久久久久久久久久久久久夜| 日韩精品资源二区在线| 欧美一区二区久久| 欧美伦理影视网| 欧美亚洲丝袜传媒另类| 色婷婷综合五月| 色综合色综合色综合| 成人av在线资源网| 成人国产在线观看| 成人黄色一级视频| 成人精品国产一区二区4080| 国产大陆a不卡| 国产精华液一区二区三区| 精彩视频一区二区三区| 麻豆专区一区二区三区四区五区| 亚洲一区二区三区在线播放| 亚洲一级二级在线| 香蕉成人啪国产精品视频综合网| 一区二区三区视频在线观看| 国产精品久久久久一区二区三区 | 精品视频全国免费看| 91高清视频在线| 欧美网站大全在线观看| 欧美日韩一区二区三区四区五区| 欧美色精品天天在线观看视频| 欧美色中文字幕| 欧美日本一道本在线视频| 91精品国产综合久久久久久漫画 | 91视频在线看| 在线免费视频一区二区| 欧美人妖巨大在线| 日韩欧美成人激情| 国产女人18毛片水真多成人如厕 | 欧美系列日韩一区| 欧美精品xxxxbbbb| 欧美成人精精品一区二区频| 精品国产网站在线观看| 国产亚洲欧美日韩日本| 国产精品麻豆视频| 一区二区免费视频| 五月婷婷另类国产| 韩日av一区二区| 成人av午夜电影| av电影天堂一区二区在线| 麻豆精品一区二区| 日韩电影免费一区| 国产高清视频一区| 色综合久久88色综合天天6| 欧美日韩三级视频| 欧美精品一区男女天堂| 国产精品天天看| 一区二区三区四区不卡在线| 国产精选一区二区三区| 不卡视频在线观看| 8x8x8国产精品| 欧美v日韩v国产v| 国产精品每日更新| 日本欧美大码aⅴ在线播放| 国产成人午夜99999| 欧美性猛片xxxx免费看久爱| 精品国产免费人成电影在线观看四季| 国产精品水嫩水嫩| 免费观看91视频大全| av一二三不卡影片| 日韩欧美久久一区| 国产精品灌醉下药二区| 免费成人你懂的| 91在线丨porny丨国产| 欧美男同性恋视频网站| 国产精品色噜噜| 老司机午夜精品| 色国产综合视频| 久久青草欧美一区二区三区| 亚洲最大色网站| 成人激情免费网站| 精品国内片67194| 亚洲国产aⅴ成人精品无吗| 国产精品亚洲第一| 日韩美女在线视频| 亚洲最新视频在线播放| 成人免费看视频| 日韩欧美国产一二三区| 亚洲卡通欧美制服中文| 国产成人三级在线观看| 91精品一区二区三区久久久久久| 中文字幕一区二区视频| 激情五月激情综合网| 欧美日韩三级视频| 亚洲精选免费视频| 成人教育av在线| 2020国产精品自拍| 蜜臀av性久久久久av蜜臀妖精| 欧美最新大片在线看| 亚洲视频 欧洲视频| 成人一道本在线| 国产亚洲短视频| 国产一区二区女| 久久久五月婷婷| 国产资源在线一区| 欧美tickle裸体挠脚心vk| 日日夜夜免费精品视频| 欧美久久一二区| 午夜欧美大尺度福利影院在线看| 91一区二区在线| 亚洲欧洲中文日韩久久av乱码| 不卡在线视频中文字幕| 国产人妖乱国产精品人妖| 国产精品综合视频| 国产欧美综合在线| 国产成人精品aa毛片| 国产婷婷精品av在线| 国产成人一级电影| 国产三级久久久| 丰满岳乱妇一区二区三区| 国产欧美精品国产国产专区| 高清成人免费视频| 亚洲人一二三区| 91国偷自产一区二区开放时间 | 99久久精品99国产精品 | 日韩电影免费一区| 日韩美女视频在线| www.综合网.com| 亚洲图片你懂的| 欧美偷拍一区二区| 免费不卡在线观看| 久久久亚洲高清| 99久久精品国产观看| 亚洲一区二区三区中文字幕| 欧美精品日韩精品| 国产剧情一区在线| 亚洲免费电影在线| 午夜精品久久久久久久久| 日本成人在线电影网| 日本vs亚洲vs韩国一区三区二区| 成人午夜在线视频| 亚洲精品videosex极品| 欧美人动与zoxxxx乱| 国内精品在线播放| 中文字幕欧美一| 欧美日韩在线观看一区二区| 日韩国产欧美一区二区三区| 久久色.com| 色综合久久九月婷婷色综合| 日韩电影一二三区| 亚洲国产精品国自产拍av| 日本高清不卡视频| 九九久久精品视频| 亚洲丝袜另类动漫二区| 日韩一区二区不卡| 99久久久精品免费观看国产蜜| 亚洲影视在线播放| 久久久久国产精品人| 欧美在线观看一二区| 精品系列免费在线观看| 亚洲免费av观看| 日韩精品中文字幕一区二区三区 | 欧美中文字幕久久| 激情文学综合丁香| 亚洲一区二区三区小说| 久久精品夜色噜噜亚洲aⅴ| 欧美亚洲国产一区二区三区va | 欧美色精品天天在线观看视频| 国产一区二区三区在线看麻豆| 洋洋av久久久久久久一区| 国产午夜精品美女毛片视频| 欧美无砖砖区免费| 国产.欧美.日韩| 六月婷婷色综合| 亚洲综合色网站| 一区二区中文视频| 精品欧美乱码久久久久久1区2区| 91久久免费观看| 成人免费精品视频| 国模娜娜一区二区三区| 亚洲动漫第一页|