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

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

?? serial.c

?? 最新版FreeRTOS, 包擴多種開發平臺的移植
?? C
字號:
/*
	FreeRTOS.org V4.1.1 - Copyright (C) 2003-2006 Richard Barry.

	This file is part of the FreeRTOS distribution.

	FreeRTOS 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 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; 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, 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 FOR UART1.
*/

/* Library includes. */
#include "91x_lib.h"

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

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

/* Misc defines. */
#define serINVALID_QUEUE				( ( xQueueHandle ) 0 )
#define serNO_BLOCK						( ( portTickType ) 0 )
#define serTX_BLOCK_TIME				( 40 / portTICK_RATE_MS )

/* Interrupt and status bit definitions. */
#define mainTXRIS 0x20	
#define mainRXRIS 0x50
#define serTX_FIFO_FULL 0x20
#define serCLEAR_ALL_INTERRUPTS 0x3ff
/*-----------------------------------------------------------*/

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

/* The semaphore used to wake a task waiting for space to become available
in the FIFO. */
static xSemaphoreHandle xTxFIFOSemaphore;

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

/* UART interrupt handler. */
void UART1_IRQHandler( void );

/* The interrupt service routine - called from the assembly entry point. */
__arm void UART1_IRQHandler( void );

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

/* Flag to indicate whether or not a task is blocked waiting for space on
the FIFO. */
static portLONG lTaskWaiting = pdFALSE;

/*
 * See the serial2.h header file.
 */
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn;
UART_InitTypeDef xUART1_Init;
GPIO_InitTypeDef GPIO_InitStructure;
	
	/* Create the queues used to hold Rx characters. */
	xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
	
	/* Create the semaphore used to wake a task waiting for space to become
	available in the FIFO. */
	vSemaphoreCreateBinary( xTxFIFOSemaphore );

	/* If the queue/semaphore was created correctly then setup the serial port
	hardware. */
	if( ( xRxedChars != serINVALID_QUEUE ) && ( xTxFIFOSemaphore != serINVALID_QUEUE ) )
	{
		/* Pre take the semaphore so a task will block if it tries to access
		it. */
		xSemaphoreTake( xTxFIFOSemaphore, 0 );
		
		/* Configure the UART. */
		xUART1_Init.UART_WordLength = UART_WordLength_8D;
		xUART1_Init.UART_StopBits = UART_StopBits_1;
		xUART1_Init.UART_Parity = UART_Parity_No;
		xUART1_Init.UART_BaudRate = ulWantedBaud;
		xUART1_Init.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
		xUART1_Init.UART_Mode = UART_Mode_Tx_Rx;
		xUART1_Init.UART_FIFO = UART_FIFO_Enable;

		/* Enable the UART1 Clock */
		SCU_APBPeriphClockConfig( __UART1, ENABLE );
		
		/* Enable the GPIO3 Clock */
		SCU_APBPeriphClockConfig( __GPIO3, ENABLE );
		
		/* Configure UART1_Rx pin GPIO3.2 */ 
		GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; 
		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; 
		GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; 
		GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; 
		GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; 
		GPIO_Init( GPIO3, &GPIO_InitStructure ); 
		
		/* Configure UART1_Tx pin GPIO3.3 */ 
		GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; 
		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; 
		GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; 
		GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; 
		GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ; 
		GPIO_Init( GPIO3, &GPIO_InitStructure ); 
		
		
		portENTER_CRITICAL();
		{		
			/* Configure the UART itself. */
			UART_DeInit( UART1 );		  
			UART_Init( UART1, &xUART1_Init );
			UART_ITConfig( UART1, UART_IT_Receive | UART_IT_Transmit, ENABLE );
			UART1->ICR = serCLEAR_ALL_INTERRUPTS;
			UART_LoopBackConfig( UART1, DISABLE );
			UART_IrDACmd( IrDA1, DISABLE );

			/* Configure the VIC for the UART interrupts. */			
			VIC_Config( UART1_ITLine, VIC_IRQ, 9 );
			VIC_ITCmd( UART1_ITLine, ENABLE );

			UART_Cmd( UART1, ENABLE );			
			lTaskWaiting = pdFALSE;
		}
		portEXIT_CRITICAL();
	}
	else
	{
		xReturn = ( xComPortHandle ) 0;
	}

	/* This demo file only supports a single port but we have to return
	something to comply with the standard demo header file. */
	return xReturn;
}
/*-----------------------------------------------------------*/

signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
{
	/* The port handle is not required as this driver only supports one port. */
	( 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;

	/* A couple of parameters that this port does not use. */
	( void ) usStringLength;
	( void ) pxPort;

	/* 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 UART1. */
	( void ) pxPort;

	/* 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 )
{
portBASE_TYPE xReturn;

	portENTER_CRITICAL();
	{
		/* Can we write to the FIFO? */
		if( UART1->FR & serTX_FIFO_FULL )
		{
			/* Wait for the interrupt letting us know there is space on the
			FIFO.  It is ok to block in a critical section, interrupts will be 
			enabled	for other tasks once we force a switch. */
			lTaskWaiting = pdTRUE;
			
			/* Just to be a bit different this driver uses a semaphore to 
			block the sending task when the FIFO is full.  The standard COMTest
			task assumes a queue of adequate length exists so does not use
			a block time.  For this demo the block time is therefore hard 
			coded. */
			xReturn = xSemaphoreTake( xTxFIFOSemaphore, serTX_BLOCK_TIME );
			if( xReturn )
			{
				UART1->DR = cOutChar;
			}
		}
		else
		{
			UART1->DR = cOutChar;
			xReturn = pdPASS;
		}
	}
	portEXIT_CRITICAL();

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

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

void UART1_IRQHandler( void )
{
signed portCHAR cChar;
portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByPost = pdFALSE;

	while( UART1->RIS &	mainRXRIS )
	{
		/* The interrupt was caused by a character being received.  Grab the
		character from the DR and place it in the queue of received
		characters. */
		cChar = UART1->DR;
		xTaskWokenByPost = xQueueSendFromISR( xRxedChars, &cChar, xTaskWokenByPost );
	}	
	
	if( UART1->RIS & mainTXRIS )
	{
		if( lTaskWaiting == pdTRUE )
		{
			/* This interrupt was caused by space becoming available on the Tx
			FIFO, wake any task that is waiting to post (if any). */
			xTaskWokenByTx = xSemaphoreGiveFromISR( xTxFIFOSemaphore, xTaskWokenByTx );
			lTaskWaiting = pdFALSE;
		}
		
		UART1->ICR = mainTXRIS;
	}

	/* If a task was woken by either a character being received or a character
	being transmitted then we may need to switch to another task. */
	portEND_SWITCHING_ISR( ( xTaskWokenByPost || xTaskWokenByTx ) );
}





	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕精品一区| 亚洲第一综合色| 亚洲国产美国国产综合一区二区| 日本一区中文字幕| 91在线视频观看| 精品久久免费看| 亚洲国产综合人成综合网站| 国产成人综合视频| 91精品国产综合久久久蜜臀粉嫩 | 51精品久久久久久久蜜臀| 国产亚洲欧美色| 久久精品国产澳门| 欧美韩国日本不卡| 日韩精品免费视频人成| 色婷婷综合中文久久一本| 国产欧美一区二区三区鸳鸯浴 | 一区二区三区精品在线观看| 国产一区二区视频在线播放| 欧美日韩电影在线| 亚洲午夜在线电影| 日本福利一区二区| 亚洲日穴在线视频| av网站一区二区三区| 久久久精品日韩欧美| 久久精品国产网站| 日韩欧美一级二级三级久久久| 亚洲曰韩产成在线| 欧美日韩一区二区在线观看视频| 亚洲天堂网中文字| 91网上在线视频| 国产精品国模大尺度视频| 成人黄色软件下载| 亚洲欧美在线视频观看| 成人永久aaa| 国产精品久久久久久久久动漫| 国产成人午夜片在线观看高清观看| 日韩精品一区二区在线观看| 毛片基地黄久久久久久天堂| 91精品在线麻豆| 蜜桃精品在线观看| 日韩精品一区二| 国产精品99久久久久久似苏梦涵| 久久久一区二区三区捆绑**| 国产99精品国产| 综合久久久久久| 欧美日免费三级在线| 天天av天天翘天天综合网| 91精品福利在线一区二区三区| 日本欧美一区二区三区乱码| 久久你懂得1024| 99国产精品久久久久久久久久 | 亚洲天堂免费看| 在线观看日韩国产| 免费观看91视频大全| 久久综合狠狠综合久久综合88 | 日韩一区二区免费高清| 久久91精品国产91久久小草| 欧美激情一区二区三区| 欧美在线一区二区三区| 麻豆精品蜜桃视频网站| 国产精品伦理在线| 欧美视频在线播放| 秋霞电影网一区二区| 欧美天堂一区二区三区| 午夜欧美大尺度福利影院在线看| 精品久久久久久无| 国产精品18久久久久| 亚洲私人黄色宅男| 在线观看视频91| 美女在线观看视频一区二区| 亚洲综合网站在线观看| 欧美精品一卡二卡| 午夜不卡在线视频| 精品久久一二三区| 99国内精品久久| 婷婷六月综合亚洲| 国产丝袜在线精品| 在线观看亚洲a| 成人在线综合网| 亚洲一二三专区| 久久女同性恋中文字幕| 一本到不卡精品视频在线观看| 五月综合激情网| 亚洲国产成人在线| 777午夜精品视频在线播放| 东方aⅴ免费观看久久av| 亚洲国产精品人人做人人爽| 日韩欧美国产综合在线一区二区三区| 国产精品系列在线播放| 亚洲国产成人91porn| 久久久激情视频| 欧美猛男超大videosgay| 国产精品伊人色| 亚洲电影一级黄| 玉米视频成人免费看| 久久精品人人爽人人爽| 色女孩综合影院| 国产不卡高清在线观看视频| 亚洲国产精品久久久久婷婷884| 国产婷婷色一区二区三区四区| 欧美日韩一二三| 国产91丝袜在线播放九色| 六月丁香综合在线视频| 亚洲高清不卡在线观看| 国产精品久久毛片a| 精品乱人伦一区二区三区| 精品视频在线免费观看| 国产黄人亚洲片| 精品一区二区免费视频| 首页综合国产亚洲丝袜| 一区二区三区四区视频精品免费 | 国产亚洲va综合人人澡精品| 欧美亚洲动漫制服丝袜| 成人爱爱电影网址| 日本成人在线网站| 美女一区二区三区| 人人狠狠综合久久亚洲| 亚洲综合999| 亚洲精品va在线观看| 国产精品毛片大码女人| 精品国产免费一区二区三区四区 | 最近日韩中文字幕| 国产午夜亚洲精品不卡| 欧美成人一区二区三区片免费 | 中文字幕一区二区三中文字幕| 精品国产乱码久久久久久蜜臀 | 国产激情视频一区二区在线观看| 久久精品国产一区二区| 成人午夜免费视频| 成人在线一区二区三区| 国产精品一区专区| 国产精品自在欧美一区| 成人手机电影网| 99久久精品免费看国产免费软件| 成人网页在线观看| 96av麻豆蜜桃一区二区| 97久久人人超碰| 欧美中文字幕一区| 欧美理论片在线| 欧美日本一区二区三区四区| 欧美日韩美少妇| 欧美丰满一区二区免费视频| 在线综合亚洲欧美在线视频 | 91丨九色丨黑人外教| 92国产精品观看| 欧美中文字幕一区| 欧美丰满少妇xxxxx高潮对白 | 偷拍日韩校园综合在线| 国产麻豆精品视频| 成人丝袜18视频在线观看| 一本高清dvd不卡在线观看| 欧美日韩视频在线一区二区| 7777精品伊人久久久大香线蕉经典版下载 | 国产69精品久久久久777| 国内精品久久久久影院色| 91在线国产观看| 精品视频一区二区三区免费| 91精品免费观看| 日本一区二区三区国色天香| 日韩一区日韩二区| 日韩电影在线一区二区| 国精品**一区二区三区在线蜜桃| 国产精品亚洲一区二区三区妖精| 欧美日韩在线一区二区| 日韩欧美一级二级三级久久久| 久久久久久久久久久久久久久99 | 亚洲精品一区二区三区福利| 中文字幕欧美一| 奇米色一区二区三区四区| 国产精品一区二区三区乱码| 色综合夜色一区| 久久综合av免费| 亚洲午夜久久久久久久久电影院| 久久精品国产免费| 99久久精品国产网站| 久久久精品黄色| 日韩精品午夜视频| 成人免费视频一区二区| 91精品啪在线观看国产60岁| 18涩涩午夜精品.www| 激情小说欧美图片| 欧美日韩一二三区| 中国色在线观看另类| 午夜电影一区二区三区| www.日韩精品| 中文字幕不卡的av| 精品在线一区二区三区| 一本色道亚洲精品aⅴ| 久久综合色8888| 综合亚洲深深色噜噜狠狠网站| 九九九精品视频| 欧美日韩国产乱码电影| 国产精品三级久久久久三级| 蜜臀av一级做a爰片久久| 欧美性三三影院| 综合激情成人伊人| 欧美一级高清片| 日韩国产在线观看一区| 欧美性受极品xxxx喷水| 亚洲青青青在线视频|