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

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

?? serial.c

?? freertosV4.40 是一種small的嵌入式系統。利于嵌入式開好者入門學習嵌入式操作系統。通過對于源碼的學習可以很好的掌握freertos的運行機制。
?? C
字號:
/*
	FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 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.

	Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
	with commercial development and support options.
	***************************************************************************
*/


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






	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品不卡在线观看| 久久亚洲欧美国产精品乐播 | 日韩一区二区三区电影| 日韩和的一区二区| 精品动漫一区二区三区在线观看| 国产麻豆精品在线| 国产精品麻豆视频| 欧美日韩精品一区二区天天拍小说 | 9191久久久久久久久久久| 日韩电影在线一区| 久久久久久99精品| 91国产成人在线| 美腿丝袜亚洲色图| 欧美激情一区二区在线| 在线一区二区三区四区| 免费高清在线视频一区·| 国产精品午夜久久| 欧美性大战久久久久久久蜜臀| 免费观看在线色综合| 国产精品色哟哟| 7777精品伊人久久久大香线蕉完整版 | 亚洲伦理在线免费看| 欧美丰满美乳xxx高潮www| 国产精品996| 最新高清无码专区| 日韩一二三区视频| 色久综合一二码| 黄色资源网久久资源365| 亚洲日本va午夜在线影院| 日韩精品一区二区在线观看| 色综合天天综合在线视频| 久久91精品国产91久久小草| 综合久久国产九一剧情麻豆| 欧美一级生活片| 91亚洲精品久久久蜜桃网站| 精品一区二区在线看| 一区二区三区在线视频免费观看| 欧美精品一区男女天堂| 欧美日韩精品一区二区天天拍小说| 国产黄色成人av| 久久机这里只有精品| 亚洲欧美电影院| 日本一区二区久久| 精品91自产拍在线观看一区| 欧亚一区二区三区| 成人激情动漫在线观看| 国精品**一区二区三区在线蜜桃| 亚洲第一电影网| 亚洲视频电影在线| 国产精品午夜春色av| 久久亚洲精华国产精华液| 7777精品伊人久久久大香线蕉| 91原创在线视频| 国产69精品久久99不卡| 精品一区中文字幕| 性做久久久久久免费观看| 一区在线播放视频| 国产精品久久久久久妇女6080 | 久久99精品国产麻豆不卡| 亚洲不卡一区二区三区| 一区二区成人在线视频| 国产精品国产三级国产专播品爱网 | 欧美一区二区三区成人| 欧美性视频一区二区三区| 91亚洲国产成人精品一区二三| 成人一道本在线| 成人性视频免费网站| 国产大片一区二区| 高清国产午夜精品久久久久久| 韩国av一区二区三区四区| 久久91精品久久久久久秒播| 免费国产亚洲视频| 免费看欧美女人艹b| 久久精品国产亚洲5555| 久久不见久久见免费视频7| 精品制服美女久久| 韩国女主播成人在线观看| 国产一区二区三区电影在线观看| 久久成人av少妇免费| 国产精品123区| 成人av在线资源网站| 91视频免费播放| 欧美在线观看视频一区二区 | 色综合久久六月婷婷中文字幕| av不卡在线观看| 欧美性一级生活| 91精品国模一区二区三区| 欧美一区二区精品久久911| 日韩精品一区二区三区在线播放| 精品处破学生在线二十三| 久久久久久亚洲综合影院红桃| 亚洲国产精品精华液2区45| 亚洲欧洲精品一区二区精品久久久 | 亚洲欧洲成人自拍| 亚洲电影在线播放| 日本va欧美va精品| 国产xxx精品视频大全| 91香蕉视频黄| 欧美日韩激情一区| 久久久精品黄色| 亚洲精品视频免费观看| 天堂一区二区在线免费观看| 国产一区二区不卡| 99re视频精品| 欧美电影一区二区| 国产网站一区二区| 夜夜嗨av一区二区三区网页| 美国av一区二区| av成人免费在线观看| 欧美精品日韩精品| 久久久午夜精品理论片中文字幕| 国产精品成人免费| 青青草原综合久久大伊人精品优势| 国产成人av电影| 91精品免费观看| 一区视频在线播放| 蜜芽一区二区三区| 色婷婷一区二区三区四区| 精品国产髙清在线看国产毛片| 亚洲男人天堂av| 精品一区二区三区在线观看| 色婷婷av久久久久久久| 日韩精品中文字幕在线不卡尤物| 亚洲视频一区在线观看| 国内成+人亚洲+欧美+综合在线| 一本色道久久综合狠狠躁的推荐| 日韩精品一区国产麻豆| 亚洲一区视频在线观看视频| 国产精品一区二区在线观看不卡| 欧美系列日韩一区| 中文字幕不卡的av| 精品在线观看视频| 制服丝袜亚洲精品中文字幕| |精品福利一区二区三区| 精品一区二区三区蜜桃| 欧美三区免费完整视频在线观看| 国产日韩精品一区二区三区在线| 视频一区欧美精品| 欧美午夜理伦三级在线观看| 国产精品久久久久aaaa| 国产一区999| 日韩一区二区影院| 爽好多水快深点欧美视频| 91免费观看国产| 国产免费观看久久| 国产精品99久久久久久久女警| 欧美一级艳片视频免费观看| 亚洲bt欧美bt精品| 在线观看视频91| 亚洲免费资源在线播放| 99天天综合性| 亚洲视频 欧洲视频| a亚洲天堂av| 自拍av一区二区三区| 99在线热播精品免费| 国产精品区一区二区三| 粉嫩aⅴ一区二区三区四区五区| 日韩欧美一级二级三级| 免费在线视频一区| 欧美一区二区在线视频| 蜜桃久久精品一区二区| 日韩一级视频免费观看在线| 日韩精品视频网| 欧美一区二区三区四区五区| 爽好久久久欧美精品| 91精品国产综合久久福利| 日韩av成人高清| 日韩三级av在线播放| 久久精品免费观看| 久久精品一区四区| 不卡视频一二三| 曰韩精品一区二区| 欧美日本韩国一区二区三区视频| 视频一区二区三区中文字幕| 日韩视频国产视频| 国产综合久久久久久久久久久久| 久久亚洲春色中文字幕久久久| 国产成人鲁色资源国产91色综| 欧美国产精品一区二区三区| 91在线观看高清| 亚洲成人高清在线| 日韩精品中文字幕在线一区| 国产高清成人在线| 综合久久综合久久| 欧美人动与zoxxxx乱| 久久er99热精品一区二区| 中文字幕欧美三区| 色综合久久九月婷婷色综合| 亚洲第一福利一区| 久久先锋影音av鲁色资源| 成人午夜视频福利| 亚洲午夜电影在线| 欧美xxxx老人做受| 成人avav在线| 亚洲成人资源网| 久久久精品日韩欧美| 欧美午夜寂寞影院| 国产精品一品二品| 亚洲电影在线免费观看| 国产亚洲一区二区在线观看|