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

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

?? port.c

?? FreeRTOS V4.2.1,增加了AVR32 UC3 和 LPC2368 的支持
?? C
字號:
/*This file has been prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
 *
 * \brief FreeRTOS port source for AVR32 UC3.
 *
 * - Compiler:           GNU GCC for AVR32
 * - Supported devices:  All AVR32 devices can be used.
 * - AppNote:
 *
 * \author               Atmel Corporation: http://www.atmel.com \n
 *                       Support email: avr32@atmel.com
 *
 *****************************************************************************/

/*
	FreeRTOS.org V4.2.1 - 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.
	***************************************************************************
*/


/* Standard includes. */
#include <sys/cpu.h>
#include <sys/usart.h>
#include <malloc.h>

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

/* AVR32 UC3 includes. */
#include <avr32/io.h>
#include "gpio.h"
#if( configTICK_USE_TC==1 )
	#include "tc.h"
#endif


/* Constants required to setup the task context. */
#define portINITIAL_SR            ( ( portSTACK_TYPE ) 0x00400000 ) /* AVR32 : [M2:M0]=001 I1M=0 I0M=0, GM=0 */
#define portINSTRUCTION_SIZE      ( ( portSTACK_TYPE ) 0 )

/* Each task maintains its own critical nesting variable. */
#define portNO_CRITICAL_NESTING   ( ( unsigned portLONG ) 0 )
volatile unsigned portLONG ulCriticalNesting = 9999UL;

#if( configTICK_USE_TC==0 )
	static void prvScheduleNextTick( void );
#endif

/* Setup the timer to generate the tick interrupts. */
static void prvSetupTimerInterrupt( void );

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

/*
 * Low-level initialization routine called during Newlib's startup.
 * This version comes in replacement to the default one provided by Newlib.
 * Newlib's _init_startup only calls init_exceptions, but Newlib's exception
 * vectors are not compatible with the SCALL management in the current FreeRTOS
 * port. More low-level initializations are besides added here.
 */
void _init_startup(void)
{
	/* Import the Exception Vector Base Address. */
	extern void _evba;

	#if configHEAP_INIT
		extern void __heap_start__;
		extern void __heap_end__;
		portBASE_TYPE *pxMem;
	#endif

	/* Load the Exception Vector Base Address in the corresponding system register. */
	Set_system_register( AVR32_EVBA, ( int ) &_evba );

	/* Enable exceptions. */
	ENABLE_ALL_EXCEPTIONS();

	/* Initialize interrupt handling. */
	INTC_init_interrupts();

	#if configHEAP_INIT

		/* Initialize the heap used by malloc. */
		for( pxMem = &__heap_start__; pxMem < ( portBASE_TYPE * )&__heap_end__; )
		{
			*pxMem++ = 0xA5A5A5A5;
		}

	#endif

	/* Give the used CPU clock frequency to Newlib, so it can work properly. */
	set_cpu_hz( configCPU_CLOCK_HZ );

	/* Code section present if and only if the debug trace is activated. */
	#if configDBG

		/* Initialize the USART used for the debug trace with the configured parameters. */
		set_usart_base( ( void * ) configDBG_USART );
		gpio_enable_module_pin( configDBG_USART_RX_PIN, configDBG_USART_RX_FUNCTION );
		gpio_enable_module_pin( configDBG_USART_TX_PIN, configDBG_USART_TX_FUNCTION );
		usart_init( configDBG_USART_BAUDRATE );

	#endif
}
/*-----------------------------------------------------------*/

/*
 * malloc, realloc and free are meant to be called through respectively
 * pvPortMalloc, pvPortRealloc and vPortFree.
 * The latter functions call the former ones from within sections where tasks
 * are suspended, so the latter functions are task-safe. __malloc_lock and
 * __malloc_unlock use the same mechanism to also keep the former functions
 * task-safe as they may be called directly from Newlib's functions.
 * However, all these functions are interrupt-unsafe and SHALL THEREFORE NOT BE
 * CALLED FROM WITHIN AN INTERRUPT, because __malloc_lock and __malloc_unlock do
 * not call portENTER_CRITICAL and portEXIT_CRITICAL in order not to disable
 * interrupts during memory allocation management as this may be a very time-
 * consuming process.
 */

/*
 * Lock routine called by Newlib on malloc / realloc / free entry to guarantee a
 * safe section as memory allocation management uses global data.
 * See the aforementioned details.
 */
void __malloc_lock(struct _reent *ptr)
{
	vTaskSuspendAll();
}

/*
 * Unlock routine called by Newlib on malloc / realloc / free exit to guarantee
 * a safe section as memory allocation management uses global data.
 * See the aforementioned details.
 */
void __malloc_unlock(struct _reent *ptr)
{
	xTaskResumeAll();
}
/*-----------------------------------------------------------*/

/* Added as there is no such function in FreeRTOS. */
void *pvPortRealloc( void *pv, size_t xWantedSize )
{
void *pvReturn;

	vTaskSuspendAll();
	{
		pvReturn = realloc( pv, xWantedSize );
	}
	xTaskResumeAll();

	return pvReturn;
}
/*-----------------------------------------------------------*/

/* The cooperative scheduler requires a normal IRQ service routine to
simply increment the system tick. */
/* The preemptive scheduler is defined as "naked" as the full context is saved
on entry as part of the context switch. */
__attribute__((__naked__)) static void vTick( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT_OS_INT();

	/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
	clock cycles from now. */
	#if( configTICK_USE_TC==1 )
		/* Clear the interrupt flag. */
		AVR32_TC.channel[configTICK_TC_CHANNEL].sr;
	#else
		prvScheduleNextTick();
	#endif
	
	/* Because FreeRTOS is not supposed to run with nested interrupts, put all OS
	calls in a critical section . */
	portENTER_CRITICAL();
		vTaskIncrementTick();
	portEXIT_CRITICAL();

	/* Restore the context of the "elected task". */
	portRESTORE_CONTEXT_OS_INT();
}
/*-----------------------------------------------------------*/

__attribute__((__naked__)) void SCALLYield( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT_SCALL();
	vTaskSwitchContext();
	portRESTORE_CONTEXT_SCALL();
}
/*-----------------------------------------------------------*/

/* The code generated by the GCC compiler uses the stack in different ways at
different optimisation levels.  The interrupt flags can therefore not always
be saved to the stack.  Instead the critical section nesting level is stored
in a variable, which is then saved as part of the stack context. */
void vPortEnterCritical( void )
{
	/* Disable interrupts */
	portDISABLE_INTERRUPTS();

	/* Now interrupts are disabled ulCriticalNesting can be accessed
	 directly.  Increment ulCriticalNesting to keep a count of how many times
	 portENTER_CRITICAL() has been called. */
	ulCriticalNesting++;
}
/*-----------------------------------------------------------*/

void vPortExitCritical( void )
{
	if(ulCriticalNesting > portNO_CRITICAL_NESTING)
	{
		ulCriticalNesting--;
		if( ulCriticalNesting == portNO_CRITICAL_NESTING )
		{
			/* Enable all interrupt/exception. */
			portENABLE_INTERRUPTS();
		}
	}
}
/*-----------------------------------------------------------*/


/*
 * Initialise the stack of a task to look exactly as if a call to
 * portSAVE_CONTEXT had been called.
 *
 * See header file for description.
 */
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
	/* Setup the initial stack of the task.  The stack is set exactly as
	expected by the portRESTORE_CONTEXT() macro. */

	/* When the task starts, it will expect to find the function parameter in R12. */
	pxTopOfStack--;
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x08080808;					/* R8 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x09090909;					/* R9 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x0A0A0A0A;					/* R10 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x0B0B0B0B;					/* R11 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) pvParameters;					/* R12 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0xDEADBEEF;					/* R14/LR */
	*pxTopOfStack-- = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE; /* R15/PC */
	*pxTopOfStack-- = ( portSTACK_TYPE ) portINITIAL_SR;				/* SR */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0xFF0000FF;					/* R0 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x01010101;					/* R1 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x02020202;					/* R2 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x03030303;					/* R3 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x04040404;					/* R4 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x05050505;					/* R5 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x06060606;					/* R6 */
	*pxTopOfStack-- = ( portSTACK_TYPE ) 0x07070707;					/* R7 */
	*pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_NESTING;			/* ulCriticalNesting */

	return pxTopOfStack;
}
/*-----------------------------------------------------------*/

portBASE_TYPE xPortStartScheduler( void )
{
	/* Start the timer that generates the tick ISR.  Interrupts are disabled
	here already. */
	prvSetupTimerInterrupt();

	/* Start the first task. */
	portRESTORE_CONTEXT();

	/* Should not get here! */
	return 0;
}
/*-----------------------------------------------------------*/

void vPortEndScheduler( void )
{
	/* It is unlikely that the AVR32 port will require this function as there
	is nothing to return to.  */
}
/*-----------------------------------------------------------*/

/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
clock cycles from now. */
#if( configTICK_USE_TC==0 )
	static void prvScheduleNextTick(void)
	{
		unsigned long lCountVal, lCompareVal;

		lCountVal = Get_system_register(AVR32_COUNT);
		lCompareVal = lCountVal + (configCPU_CLOCK_HZ/configTICK_RATE_HZ);
		Set_system_register(AVR32_COMPARE, lCompareVal);
	}
#endif
/*-----------------------------------------------------------*/

/* Setup the timer to generate the tick interrupts. */
static void prvSetupTimerInterrupt(void)
{
#if( configTICK_USE_TC==1 )

	volatile avr32_tc_t *tc = &AVR32_TC;

	// Options for waveform genration.
	tc_waveform_opt_t waveform_opt =
	{
	.channel  = configTICK_TC_CHANNEL,             /* Channel selection. */

	.bswtrg   = TC_EVT_EFFECT_NOOP,                /* Software trigger effect on TIOB. */
	.beevt    = TC_EVT_EFFECT_NOOP,                /* External event effect on TIOB. */
	.bcpc     = TC_EVT_EFFECT_NOOP,                /* RC compare effect on TIOB. */
	.bcpb     = TC_EVT_EFFECT_NOOP,                /* RB compare effect on TIOB. */

	.aswtrg   = TC_EVT_EFFECT_NOOP,                /* Software trigger effect on TIOA. */
	.aeevt    = TC_EVT_EFFECT_NOOP,                /* External event effect on TIOA. */
	.acpc     = TC_EVT_EFFECT_NOOP,                /* RC compare effect on TIOA: toggle. */
	.acpa     = TC_EVT_EFFECT_NOOP,                /* RA compare effect on TIOA: toggle (other possibilities are none, set and clear). */

	.wavsel   = TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER,/* Waveform selection: Up mode without automatic trigger on RC compare. */
	.enetrg   = FALSE,                             /* External event trigger enable. */
	.eevt     = 0,                                 /* External event selection. */
	.eevtedg  = TC_SEL_NO_EDGE,                    /* External event edge selection. */
	.cpcdis   = FALSE,                             /* Counter disable when RC compare. */
	.cpcstop  = FALSE,                             /* Counter clock stopped with RC compare. */

	.burst    = FALSE,                             /* Burst signal selection. */
	.clki     = FALSE,                             /* Clock inversion. */
	.tcclks   = TC_CLOCK_SOURCE_TC2                /* Internal source clock 2. */
	};

	tc_interrupt_t tc_interrupt =
	{
		.etrgs=0,
		.ldrbs=0,
		.ldras=0,
		.cpcs =1,
		.cpbs =0,
		.cpas =0,
		.lovrs=0,
		.covfs=0,
	};

#endif

	/* Disable all interrupt/exception. */
	portDISABLE_INTERRUPTS();

	/* Register the compare interrupt handler to the interrupt controller and
	enable the compare interrupt. */

	#if( configTICK_USE_TC==1 )
	{
		INTC_register_interrupt(&vTick, configTICK_TC_IRQ, INT0);

		/* Initialize the timer/counter. */
		tc_init_waveform(tc, &waveform_opt);         

		/* Set the compare triggers.
		Remember TC counter is 16-bits, so counting second is not possible!
		That's why we configure it to count ms. */
		tc_write_rc( tc, configTICK_TC_CHANNEL, ( configPBA_CLOCK_HZ/ 4) / 1000 );

		tc_configure_interrupts( tc, configTICK_TC_CHANNEL, &tc_interrupt );

		/* Start the timer/counter. */
		tc_start(tc, configTICK_TC_CHANNEL);
	}
	#else
	{
		INTC_register_interrupt(&vTick, AVR32_CORE_COMPARE_IRQ, INT0);
		prvScheduleNextTick();
	}
	#endif
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品综合久久| 美女视频黄 久久| av在线这里只有精品| 日本一区二区在线不卡| 成人av网站免费| 日韩毛片高清在线播放| 日本韩国欧美一区| 日欧美一区二区| 久久久久久久久99精品| 成人激情免费网站| 亚洲最新视频在线观看| 4438成人网| 国产成人免费在线视频| 亚洲视频免费在线观看| 777午夜精品免费视频| 九色综合狠狠综合久久| 国产精品麻豆久久久| 欧美丝袜丝交足nylons| 精品在线一区二区三区| 亚洲视频在线观看一区| 欧美一区二区三区在线观看视频| 国产剧情一区二区| 亚洲综合免费观看高清完整版| 91精品国产黑色紧身裤美女| 国产99精品在线观看| 亚洲第一久久影院| 久久久久亚洲蜜桃| 欧美色精品天天在线观看视频| 黄页网站大全一区二区| 亚洲激情图片小说视频| 26uuu久久天堂性欧美| 91久久精品日日躁夜夜躁欧美| 美女视频第一区二区三区免费观看网站| 日本一区二区三区四区| 欧美高清视频一二三区 | 亚洲影视在线播放| 久久亚洲欧美国产精品乐播| 欧美做爰猛烈大尺度电影无法无天| 青青青爽久久午夜综合久久午夜| 国产精品青草综合久久久久99| 91精品国产欧美一区二区成人| 97久久精品人人做人人爽50路| 麻豆国产91在线播放| 亚洲一区二区三区四区在线 | 国产精品美女视频| 亚洲精品在线免费观看视频| 欧美日本乱大交xxxxx| fc2成人免费人成在线观看播放| 日本中文字幕一区二区有限公司| 综合色中文字幕| 国产欧美精品一区aⅴ影院| 日韩午夜三级在线| 欧美日韩日日摸| 色综合天天综合色综合av| 国产高清视频一区| 国内精品国产成人| 看电视剧不卡顿的网站| 天堂成人国产精品一区| 亚洲国产乱码最新视频| 亚洲老司机在线| 国产精品久久久久aaaa| 久久精品视频免费观看| 2014亚洲片线观看视频免费| 日韩欧美国产小视频| 欧美片网站yy| 欧美巨大另类极品videosbest | 美国欧美日韩国产在线播放| 视频一区二区三区在线| 亚洲自拍与偷拍| 一区二区不卡在线播放 | 国产麻豆精品久久一二三| 免费观看日韩电影| 日本亚洲一区二区| 日韩成人免费电影| 蜜臀av亚洲一区中文字幕| 婷婷夜色潮精品综合在线| 亚洲国产欧美在线| 亚洲第一av色| 日韩主播视频在线| 日韩在线一区二区三区| 蜜臀91精品一区二区三区 | 色婷婷激情综合| 一本一道波多野结衣一区二区| av电影在线观看一区| 色综合中文综合网| 久久成人久久鬼色| 国内精品伊人久久久久av一坑| 久久国产精品99久久人人澡| 国产一区欧美二区| 成人短视频下载| 色婷婷久久综合| 欧美日韩国产精选| 日韩精品一区二区三区中文不卡 | 午夜电影网一区| 日本强好片久久久久久aaa| 久久成人久久爱| 国产不卡视频在线观看| 91在线看国产| 欧美精品在线观看播放| 亚洲精品一区二区三区精华液| 欧美极品xxx| 一区二区三区在线免费观看| 日日骚欧美日韩| 国产毛片一区二区| 91国偷自产一区二区三区成为亚洲经典 | 精品国产乱码久久久久久牛牛| 久久久不卡网国产精品一区| 国产精品女人毛片| 亚洲成人高清在线| 精品无码三级在线观看视频| av激情综合网| 欧美一区二区三区不卡| 国产精品污www在线观看| 亚洲一区国产视频| 国产激情一区二区三区桃花岛亚洲| 欧美一级夜夜爽| 久久人人97超碰com| 亚洲一区二区中文在线| 国产美女精品在线| 欧美午夜精品久久久| 久久综合九色综合欧美亚洲| 亚洲激情五月婷婷| 国产综合久久久久久鬼色| 色婷婷精品大视频在线蜜桃视频| 欧美电影免费观看高清完整版在线观看 | 国产成人aaa| 欧美绝品在线观看成人午夜影视| 久久久精品影视| 日本亚洲电影天堂| 91免费国产视频网站| 精品福利在线导航| 亚洲成av人片一区二区三区| 成人免费视频播放| 精品久久久久久久久久久久包黑料| 亚洲色图第一区| 国产福利91精品| 日韩免费看的电影| 亚洲一区在线观看免费观看电影高清| 国产成人在线网站| 欧美成人伊人久久综合网| 亚洲国产综合在线| 97精品国产97久久久久久久久久久久| 肉色丝袜一区二区| 一本色道久久综合精品竹菊| 久久久久国产精品人| 麻豆精品国产传媒mv男同| 欧美人与禽zozo性伦| 一区二区免费在线| 99riav久久精品riav| 欧美激情资源网| 国产真实乱偷精品视频免| 欧美大片拔萝卜| 日本午夜精品一区二区三区电影 | 欧美日韩不卡一区二区| 亚洲欧美视频在线观看| 成人免费高清在线| 久久久精品一品道一区| 久久se这里有精品| 日韩精品一区二区三区视频播放| 天堂va蜜桃一区二区三区漫画版 | 久久99在线观看| 日韩视频免费直播| 理论片日本一区| 日韩欧美国产综合| 精品一区二区三区在线观看| 日韩女优视频免费观看| 美脚の诱脚舐め脚责91 | 欧美激情自拍偷拍| 成人久久18免费网站麻豆| 国产欧美日韩另类视频免费观看| 欧美精品第1页| 日韩成人午夜精品| 欧美成人精精品一区二区频| 麻豆视频一区二区| 国产亚洲人成网站| av中文字幕不卡| 一片黄亚洲嫩模| 欧美肥大bbwbbw高潮| 久久精品国产一区二区三区免费看| 日韩精品一区二区三区四区| 韩国成人在线视频| 国产女人18水真多18精品一级做| www.亚洲人| 亚洲大型综合色站| 日韩精品一区二区三区视频 | 成人综合婷婷国产精品久久 | 欧美伦理影视网| 男男视频亚洲欧美| 国产亚洲综合性久久久影院| 成人美女视频在线观看18| 亚洲免费大片在线观看| 欧美精品久久久久久久多人混战| 麻豆精品视频在线| 国产精品国产三级国产专播品爱网| 色爱区综合激月婷婷| 麻豆成人久久精品二区三区小说| 国产亚洲一区二区三区四区| 91福利视频久久久久| 久久精品72免费观看| 国产精品女人毛片|