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

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

?? serial.c

?? 最新版FreeRTOS, 包擴多種開發平臺的移植
?? C
字號:
/*
	FreeRTOS.org V4.1.1 - 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.5

	+  Clear overrun errors in the Rx ISR.  Overrun errors prevent any further
	   characters being received.

Changes from V2.0.0

	+ Use portTickType in place of unsigned pdLONG for delay periods.
	+ cQueueReieveFromISR() used in place of xQueueReceive() in ISR.
*/

/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER. */

/* Scheduler header files. */
#include "FreeRTOS.h"
#include "task.h"
#include "serial.h"
#include "queue.h"

/*
 * Prototypes for ISR's.  The PIC architecture means that these functions
 * have to be called from port.c.  The prototypes are not however included
 * in the header as the header is common to all ports.
 */
void vSerialTxISR( void );
void vSerialRxISR( void );

/* Hardware pin definitions. */
#define serTX_PIN	TRISCbits.TRISC6
#define serRX_PIN	TRISCbits.TRISC7

/* Bit/register definitions. */
#define serINPUT				( 1 )
#define serOUTPUT				( 0 )
#define serTX_ENABLE			( ( unsigned portSHORT ) 1 )
#define serRX_ENABLE			( ( unsigned portSHORT ) 1 )
#define serHIGH_SPEED			( ( unsigned portSHORT ) 1 )
#define serCONTINUOUS_RX		( ( unsigned portSHORT ) 1 )
#define serCLEAR_OVERRUN		( ( unsigned portSHORT ) 0 )
#define serINTERRUPT_ENABLED 	( ( unsigned portSHORT ) 1 )
#define serINTERRUPT_DISABLED 	( ( unsigned portSHORT ) 0 )

/* All ISR's use the PIC18 low priority interrupt. */
#define							serLOW_PRIORITY ( 0 )

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

/* Queues to interface between comms API and interrupt routines. */
static xQueueHandle xRxedChars; 
static xQueueHandle xCharsForTx;

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

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

	/* Calculate the baud rate generator constant.
	SPBRG = ( (FOSC / Desired Baud Rate) / 16 ) - 1 */
	ulBaud = configCPU_CLOCK_HZ / ulWantedBaud;
	ulBaud /= ( unsigned portLONG ) 16;
	ulBaud -= ( unsigned portLONG ) 1;

	/* Create the queues used by the ISR's to interface to tasks. */
	xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( portCHAR ) );
	xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( portCHAR ) );

	portENTER_CRITICAL();
	{
		/* Start with config registers cleared, so we can just set the wanted
		bits. */
		TXSTA = ( unsigned portSHORT ) 0;
		RCSTA = ( unsigned portSHORT ) 0;

		/* Set the baud rate generator using the above calculated constant. */
		SPBRG = ( unsigned portCHAR ) ulBaud;

		/* Setup the IO pins to enable the USART IO. */
		serTX_PIN = serOUTPUT;
		serRX_PIN = serINPUT;

		/* Set the serial interrupts to use the same priority as the tick. */
		IPR1bits.TXIP = serLOW_PRIORITY;
		IPR1bits.RCIP = serLOW_PRIORITY;

		/* Setup Tx configuration. */
		TXSTAbits.BRGH = serHIGH_SPEED;
		TXSTAbits.TXEN = serTX_ENABLE;

		/* Setup Rx configuration. */
		RCSTAbits.SPEN = serRX_ENABLE;
		RCSTAbits.CREN = serCONTINUOUS_RX;

		/* Enable the Rx interrupt now, the Tx interrupt will get enabled when
		we have data to send. */
		PIE1bits.RCIE = serINTERRUPT_ENABLED;
	}
	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;
}
/*-----------------------------------------------------------*/

xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength )
{
	/* This is not implemented in this port.
	Use xSerialPortInitMinimal() instead. */
}
/*-----------------------------------------------------------*/

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;
	}
}
/*-----------------------------------------------------------*/

portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
{
	/* Return false if after the block time there is no room on the Tx queue. */
	if( xQueueSend( xCharsForTx, ( const void * ) &cOutChar, xBlockTime ) != pdPASS )
	{
		return pdFAIL;
	}

	/* Turn interrupt on - ensure the compiler only generates a single 
	instruction for this. */
	PIE1bits.TXIE = serINTERRUPT_ENABLED;

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

void vSerialClose( xComPortHandle xPort )
{
	/* Not implemented for this port.
	To implement, turn off the interrupts and delete the memory
	allocated to the queues. */
}
/*-----------------------------------------------------------*/

#pragma interruptlow vSerialRxISR save=PRODH, PRODL, TABLAT, section(".tmpdata")
void vSerialRxISR( void )
{
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 = RCREG;

	/* Clear any overrun errors. */
	if( RCSTAbits.OERR )
	{
		RCSTAbits.CREN = serCLEAR_OVERRUN;
		RCSTAbits.CREN = serCONTINUOUS_RX;	
	}

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

#pragma interruptlow vSerialTxISR save=PRODH, PRODL, TABLAT, section(".tmpdata")
void vSerialTxISR( void )
{
portCHAR cChar, cTaskWoken;

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



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷av久久久久久久| 91同城在线观看| 自拍偷拍亚洲激情| 日韩欧美一区二区视频| 91亚洲精品久久久蜜桃| 韩国成人精品a∨在线观看| 亚洲精品欧美二区三区中文字幕| 91精品国产一区二区人妖| 不卡一区在线观看| 韩国欧美一区二区| 视频一区二区中文字幕| 亚洲色大成网站www久久九九| 日韩欧美www| 欧美精品日韩一本| 在线观看国产一区二区| 成人毛片视频在线观看| 精品综合免费视频观看| 亚洲国产精品久久人人爱| 国产精品久久久久久久久久久免费看| 日韩一区二区三免费高清| 在线日韩国产精品| 99久久精品国产网站| 国产高清成人在线| 激情偷乱视频一区二区三区| 亚洲国产视频在线| 亚洲在线观看免费视频| 一区视频在线播放| 国产精品久久久久影院亚瑟| 久久色在线观看| www久久久久| 26uuu精品一区二区| 777奇米成人网| 在线成人av网站| 欧美日韩成人综合在线一区二区| 色妹子一区二区| 色偷偷一区二区三区| 成人a免费在线看| 成人黄色a**站在线观看| 岛国av在线一区| 成人高清视频免费观看| www.日韩大片| 91麻豆产精品久久久久久| 91丨porny丨首页| 色美美综合视频| 欧美午夜精品一区二区三区| 在线这里只有精品| 欧美日韩国产高清一区二区三区 | 国产亚洲婷婷免费| 精品女同一区二区| 久久久久久免费| 亚洲国产精品成人久久综合一区| 欧美高清一级片在线观看| 国产精品国产三级国产aⅴ原创 | 亚洲欧洲日产国码二区| 国产精品久久久久久久久免费桃花| 国产视频一区不卡| 国产精品久久久久久久久免费丝袜| 亚洲欧洲美洲综合色网| 亚洲最大的成人av| 日产欧产美韩系列久久99| 久久激情五月激情| 成人综合婷婷国产精品久久| 9人人澡人人爽人人精品| 欧洲精品中文字幕| 日韩欧美一级精品久久| 国产精品久久久久三级| 亚洲成人综合在线| 久久99精品国产91久久来源| 国产99久久久国产精品潘金网站| gogogo免费视频观看亚洲一| 在线观看91精品国产入口| 欧美一区二区三区系列电影| 久久九九国产精品| 一区二区三区四区精品在线视频| 婷婷开心久久网| 国产盗摄精品一区二区三区在线| 91一区二区在线| 精品国产91洋老外米糕| 国产精品二区一区二区aⅴ污介绍| 亚洲综合清纯丝袜自拍| 久久不见久久见免费视频7| 波多野结衣中文字幕一区二区三区| 欧美三级中文字| 国产欧美一区视频| 亚洲成人一二三| 国产91精品一区二区麻豆网站| 在线影视一区二区三区| 久久久不卡影院| 亚洲国产成人porn| 国产精品自拍三区| 欧美日韩亚洲综合一区二区三区 | 亚洲情趣在线观看| 久久精品二区亚洲w码| 日本高清免费不卡视频| 久久久精品免费观看| 天天影视色香欲综合网老头| 国产大陆亚洲精品国产| 欧美一级欧美一级在线播放| 国产精品久久久久精k8| 久久99最新地址| 欧美日韩一区精品| 欧美国产禁国产网站cc| 久久99精品久久久久久久久久久久| 在线日韩av片| 国产精品国产三级国产普通话99| 久久精品国产色蜜蜜麻豆| 欧美日本韩国一区二区三区视频| 中文字幕精品—区二区四季| 久久97超碰色| 88在线观看91蜜桃国自产| 亚洲女子a中天字幕| 福利一区二区在线| 精品久久人人做人人爽| 日本va欧美va精品发布| 在线看国产一区二区| 亚洲三级小视频| 国产**成人网毛片九色 | 成人欧美一区二区三区视频网页| 另类小说综合欧美亚洲| 欧美精品 国产精品| 亚洲精品国产视频| 成人va在线观看| 国产亚洲欧洲一区高清在线观看| 精品在线一区二区| 日韩一级黄色大片| 日本一道高清亚洲日美韩| 5858s免费视频成人| 亚洲妇熟xx妇色黄| 色婷婷av一区二区三区gif| 亚洲精品免费一二三区| 色综合久久99| 亚洲一区在线视频| 欧美中文字幕不卡| 亚洲韩国精品一区| 欧美日本在线一区| 日韩专区中文字幕一区二区| 欧美日本精品一区二区三区| 亚洲一区二区三区四区不卡| 欧美日韩一区二区在线观看视频| 亚洲国产成人高清精品| 在线不卡一区二区| 久久99最新地址| 国产香蕉久久精品综合网| 成人一区二区三区在线观看| 国产精品色婷婷| av欧美精品.com| 一区二区三区在线免费视频| 在线亚洲高清视频| 婷婷开心久久网| 日韩精品中文字幕一区| 国产一区二区毛片| 国产精品久久久久影院老司| 色噜噜狠狠色综合欧洲selulu| 一区二区三区成人| 日韩丝袜情趣美女图片| 国产二区国产一区在线观看| 国产精品久久久久久久久久久免费看 | 亚洲香肠在线观看| 欧美日本不卡视频| 久久精品噜噜噜成人av农村| 久久久一区二区| 91免费视频网址| 视频一区视频二区中文| ww久久中文字幕| 色婷婷久久久综合中文字幕| 午夜精品福利一区二区三区蜜桃| 久久综合久久99| 91免费视频网址| 精品在线一区二区| 亚洲精品乱码久久久久久黑人 | 国产精品久久久久一区二区三区 | 性做久久久久久| 国产亚洲欧美日韩在线一区| 色呦呦日韩精品| 经典三级一区二区| 国产精品国模大尺度视频| 欧美日韩中文国产| 国产麻豆精品久久一二三| 亚洲摸摸操操av| 精品国产百合女同互慰| 在线中文字幕一区| 国产福利一区二区三区视频在线 | 国产日产欧美一区二区三区| 色婷婷综合在线| 激情伊人五月天久久综合| 一区二区三区不卡视频在线观看| 精品乱码亚洲一区二区不卡| 91精品1区2区| 国产乱一区二区| 亚洲成人av资源| 国产精品短视频| 精品国产免费一区二区三区四区| 91丨九色丨蝌蚪丨老版| 黄页视频在线91| 亚洲一区二区三区三| 欧美国产日韩在线观看| 日韩欧美亚洲一区二区| 欧美在线观看禁18| 成人视屏免费看| 国产精品一品视频|