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

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

?? port.c

?? STM32 FreeRTOS v5.2移植源代碼
?? C
字號:
/*
	FreeRTOS.org V5.2.0 - Copyright (C) 2003-2009 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 (version 2) as published
	by the Free Software Foundation and modified by the FreeRTOS exception.

	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 is included to allow you 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.


	***************************************************************************
	*                                                                         *
	* Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *
	*                                                                         *
	* This is a concise, step by step, 'hands on' guide that describes both   *
	* general multitasking concepts and FreeRTOS specifics. It presents and   *
	* explains numerous examples that are written using the FreeRTOS API.     *
	* Full source code for all the examples is provided in an accompanying    *
	* .zip file.                                                              *
	*                                                                         *
	***************************************************************************

	1 tab == 4 spaces!

	Please ensure to read the configuration and relevant port sections of the
	online documentation.

	http://www.FreeRTOS.org - Documentation, latest information, license and
	contact details.

	http://www.SafeRTOS.com - A version that is certified for use in safety
	critical systems.

	http://www.OpenRTOS.com - Commercial support, development, porting,
	licensing and training services.
*/

#include "FreeRTOS.h"
#include "task.h"
#include "mb91467d.h"

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

/* We require the address of the pxCurrentTCB variable, but don't want to know
any details of its type. */
typedef void tskTCB;
extern volatile tskTCB * volatile pxCurrentTCB;

/*-----------------------------------------------------------*/
 
#pragma asm
#macro  SaveContext
	 ORCCR #0x20								;Switch to user stack
	 ST RP,@-R15								;Store RP
	 STM0 (R7,R6,R5,R4,R3,R2,R1,R0)				;Store R7-R0
	 STM1 (R14,R13,R12,R11,R10,R9,R8)			;Store R14-R8
	 ST MDH, @-R15								;Store MDH
	 ST MDL, @-R15								;Store MDL
	 
	 ANDCCR #0xDF								;Switch back to system stack
	 LD @R15+,R0								;Store PC to R0 
	 ORCCR #0x20								;Switch to user stack
	 ST R0,@-R15								;Store PC to User stack
	 
	 ANDCCR #0xDF								;Switch back to system stack
	 LD @R15+,R0								;Store PS to R0
	 ORCCR #0x20								;Switch to user stack
	 ST R0,@-R15								;Store PS to User stack
	 
	 LDI #_pxCurrentTCB, R0						;Get pxCurrentTCB address
	 LD @R0, R0									;Get the pxCurrentTCB->pxTopOfStack address
	 ST R15,@R0									;Store USP to pxCurrentTCB->pxTopOfStack
	 
	 ANDCCR #0xDF								;Switch back to system stack for the rest of tick ISR
#endm

#macro RestoreContext
	 LDI #_pxCurrentTCB, R0						;Get pxCurrentTCB address
	 LD @R0, R0									;Get the pxCurrentTCB->pxTopOfStack address
	 ORCCR #0x20								;Switch to user stack
	 LD @R0, R15								;Restore USP from pxCurrentTCB->pxTopOfStack

	 LD @R15+,R0								;Store PS to R0
	 ANDCCR #0xDF								;Switch to system stack
	 ST R0,@-R15								;Store PS to system stack

	 ORCCR #0x20								;Switch to user stack
	 LD @R15+,R0								;Store PC to R0
	 ANDCCR #0xDF								;Switch to system stack
	 ST R0,@-R15								;Store PC to system stack

	 ORCCR #0x20								;Switch back to retrieve the remaining context

	 LD @R15+, MDL								;Restore MDL
	 LD @R15+, MDH								;Restore MDH
	 LDM1 (R14,R13,R12,R11,R10,R9,R8)			;Restore R14-R8
	 LDM0 (R7,R6,R5,R4,R3,R2,R1,R0)				;Restore R7-R0
	 LD @R15+, RP								;Restore RP
	 
	 ANDCCR #0xDF								;Switch back to system stack for the rest of tick ISR
#endm
#pragma endasm

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

/*
 * Perform hardware setup to enable ticks from timer 1,
 */
static void prvSetupTimerInterrupt( void );
/*-----------------------------------------------------------*/

/* 
 * Initialise the stack of a task to look exactly as if a call to 
 * portSAVE_CONTEXT had been called.
 * 
 * See the header file portable.h.
 */
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
	/* Place a few bytes of known values on the bottom of the stack. 
	This is just useful for debugging. */

	*pxTopOfStack = 0x11111111;
	pxTopOfStack--;
	*pxTopOfStack = 0x22222222;
	pxTopOfStack--;
	*pxTopOfStack = 0x33333333;
	pxTopOfStack--;

	/* This is a redundant push to the stack, it may be required if 
	in some implementations of the compiler the parameter to the task 
	is passed on to the stack rather than in R4 register. */
	*pxTopOfStack = (portSTACK_TYPE)(pvParameters);
	pxTopOfStack--;                  
    
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00000000;	/* RP */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00007777;	/* R7 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00006666;	/* R6 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00005555;	/* R5 */
	pxTopOfStack--;
	
	/* In the current implementation of the compiler the first 
	parameter to the task (or function) is passed via R4 parameter 
	to the task, hence the pvParameters pointer is copied into the R4 
	register. See compiler manual section 4.6.2 for more information. */
	*pxTopOfStack = ( portSTACK_TYPE ) (pvParameters);	/* R4 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00003333;	/* R3 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00002222;	/* R2 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00001111;	/* R1 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00000001;	/* R0 */
	pxTopOfStack--;	
	*pxTopOfStack = ( portSTACK_TYPE ) 0x0000EEEE;	/* R14 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x0000DDDD;	/* R13 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x0000CCCC;	/* R12 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x0000BBBB;	/* R11 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x0000AAAA;	/* R10 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00009999;	/* R9 */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x00008888;	/* R8 */
	pxTopOfStack--;	
	*pxTopOfStack = ( portSTACK_TYPE ) 0x11110000;	/* MDH */
	pxTopOfStack--;
	*pxTopOfStack = ( portSTACK_TYPE ) 0x22220000;	/* MDL */
	pxTopOfStack--;

	/* The start of the task code. */
	*pxTopOfStack = ( portSTACK_TYPE ) pxCode;	/* PC */
	pxTopOfStack--;
	 
    /* PS - User Mode, USP, ILM=31, Interrupts enabled */
	*pxTopOfStack = ( portSTACK_TYPE ) 0x001F0030;	/* PS */

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

portBASE_TYPE xPortStartScheduler( void )
{
	/* Setup the hardware to generate the tick. */
	prvSetupTimerInterrupt();

	/* Restore the context of the first task that is going to run. */
	#pragma asm
		RestoreContext
	#pragma endasm

	/* Simulate a function call end as generated by the compiler.  We will now
	jump to the start of the task the context of which we have just restored. */	
	__asm(" reti ");

	/* Should not get here. */
	return pdFAIL;
}
/*-----------------------------------------------------------*/

void vPortEndScheduler( void )
{
	/* Not implemented - unlikely to ever be required as there is nothing to
	return to. */
}
/*-----------------------------------------------------------*/

static void prvSetupTimerInterrupt( void )
{
/* The peripheral clock divided by 32 is used by the timer. */
const unsigned portSHORT usReloadValue = ( unsigned portSHORT ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL );

	/* Setup RLT0 to generate a tick interrupt. */

	TMCSR0_CNTE = 0;		/* Count Disable */
    TMCSR0_CSL = 0x2;		/* CLKP/32 */
    TMCSR0_MOD = 0;			/* Software trigger */
    TMCSR0_RELD = 1;		/* Reload */
    
    TMCSR0_UF = 0;			/* Clear underflow flag */
	TMRLR0 = usReloadValue;
	TMCSR0_INTE = 1;		/* Interrupt Enable */
	TMCSR0_CNTE = 1;		/* Count Enable */
	TMCSR0_TRG = 1;			/* Trigger */
	
    PORTEN = 0x3;			/* Port Enable */
}
/*-----------------------------------------------------------*/

#if configUSE_PREEMPTION == 1

	/* 
	 * Tick ISR for preemptive scheduler. The tick count is incremented 
	 * after the context is saved. Then the context is switched if required,
	 * and last the context of the task which is to be resumed is restored.
	 */

	#pragma asm

	.global _ReloadTimer0_IRQHandler
	_ReloadTimer0_IRQHandler:

	ANDCCR #0xEF							;Disable Interrupts
	SaveContext								;Save context
	ORCCR #0x10								;Re-enable Interrupts

	LDI #0xFFFB,R1
	LDI #_tmcsr0, R0
	AND R1,@R0								;Clear RLT0 interrupt flag

	CALL32	 _vTaskIncrementTick,R12		;Increment Tick
	CALL32	 _vTaskSwitchContext,R12		;Switch context if required

	ANDCCR #0xEF							;Disable Interrupts
	RestoreContext							;Restore context
	ORCCR #0x10								;Re-enable Interrupts

	RETI

	#pragma endasm
	
#else
	
	/* 
	 * Tick ISR for the cooperative scheduler.  All this does is increment the
	 * tick count.  We don't need to switch context, this can only be done by
	 * manual calls to taskYIELD();
	 */
	__interrupt void ReloadTimer0_IRQHandler( void )
	{
		/* Clear RLT0 interrupt flag */
		TMCSR0_UF = 0; 
		vTaskIncrementTick();
	}

#endif

/*
 * Manual context switch. We can use a __nosavereg attribute  as the context 
 * would be saved by PortSAVE_CONTEXT().  The context is switched and then 
 * the context of the new task is restored saved. 
 */
#pragma asm

	.global _vPortYieldDelayed
	_vPortYieldDelayed:

	ANDCCR #0xEF							;Disable Interrupts
	SaveContext								;Save context
	ORCCR #0x10								;Re-enable Interrupts

	LDI #_dicr, R0
	BANDL #0x0E, @R0						;Clear Delayed interrupt flag

	CALL32	 _vTaskSwitchContext,R12		;Switch context if required

	ANDCCR #0xEF							;Disable Interrupts
	RestoreContext							;Restore context
	ORCCR #0x10								;Re-enable Interrupts

	RETI

#pragma endasm
/*-----------------------------------------------------------*/

/*
 * Manual context switch. We can use a __nosavereg attribute  as the context 
 * would be saved by PortSAVE_CONTEXT().  The context is switched and then 
 * the context of the new task is restored saved. 
 */ 	 
#pragma asm

	.global _vPortYield
	_vPortYield:

	SaveContext								;Save context
	CALL32	 _vTaskSwitchContext,R12		;Switch context if required
	RestoreContext							;Restore context
	
	RETI

#pragma endasm
/*-----------------------------------------------------------*/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品色噜噜| 欧美精品少妇一区二区三区| 国产欧美日韩不卡| 国产精品自拍在线| 欧美国产欧美综合| 99国产精品久久久| 一区二区三区欧美亚洲| 欧美在线免费视屏| 石原莉奈一区二区三区在线观看| 91精品国产乱| 国产制服丝袜一区| 中文字幕亚洲综合久久菠萝蜜| 99精品久久免费看蜜臀剧情介绍| 亚洲一区二区在线观看视频| 4438x成人网最大色成网站| 九九**精品视频免费播放| 国产精品久久福利| 欧美日韩一级视频| 国产精品一区二区你懂的| 亚洲摸摸操操av| 欧美一区二区在线视频| 国产不卡视频一区二区三区| 亚洲一区二区三区爽爽爽爽爽| 日韩免费福利电影在线观看| 91在线精品一区二区| 亚洲成人av一区二区三区| 国产亚洲一区字幕| 欧美日韩亚洲综合一区 | 欧美变态凌虐bdsm| 国产白丝网站精品污在线入口| 亚洲国产一区在线观看| 日韩三级av在线播放| 不卡av在线免费观看| 喷水一区二区三区| 亚洲欧美日韩中文播放| 日韩欧美一级在线播放| 91免费视频网| 国产一区二区伦理片| 亚洲国产成人tv| 亚洲视频资源在线| 久久久久成人黄色影片| 制服丝袜亚洲精品中文字幕| 99精品视频在线观看免费| 精品亚洲成a人| 亚洲成人在线观看视频| 国产精品入口麻豆原神| 日韩精品一区在线| 欧美日韩一本到| 成人a免费在线看| 久久成人免费日本黄色| 天堂一区二区在线| 亚洲美女精品一区| 亚洲国产精品成人综合色在线婷婷| 日韩视频在线观看一区二区| 91成人国产精品| www.亚洲国产| 国产一区二区三区黄视频 | 亚洲精品成人少妇| 国产日韩精品一区二区三区在线| 欧美一区二区在线不卡| 欧美午夜精品一区| 色欧美片视频在线观看在线视频| 福利电影一区二区三区| 国产一区二区在线看| 美国毛片一区二区| 日韩精品一二区| 亚洲成人av资源| 亚洲超碰精品一区二区| 亚洲成av人片一区二区| 亚洲图片自拍偷拍| 亚洲已满18点击进入久久| 一色屋精品亚洲香蕉网站| 国产精品麻豆久久久| 中文字幕乱码亚洲精品一区| 久久精品视频在线看| 久久久无码精品亚洲日韩按摩| 精品播放一区二区| 久久综合色综合88| 国产亚洲精品bt天堂精选| 国产午夜一区二区三区| 国产亚洲女人久久久久毛片| 久久精品亚洲麻豆av一区二区| 久久嫩草精品久久久精品一| 久久精品夜色噜噜亚洲aⅴ| 国产欧美精品一区二区三区四区 | 精品成人一区二区三区四区| 欧美本精品男人aⅴ天堂| 日韩免费高清av| 久久综合国产精品| 亚洲国产高清不卡| ㊣最新国产の精品bt伙计久久| 综合久久久久久久| 一区二区三区四区五区视频在线观看| 一片黄亚洲嫩模| 婷婷一区二区三区| 精品系列免费在线观看| 国产一区二区0| av一区二区久久| 欧美视频完全免费看| 日韩免费观看高清完整版在线观看| 欧美精品一区二区三区很污很色的 | 亚洲免费观看高清完整版在线观看 | 午夜激情综合网| 久久精品国产亚洲a| 成人精品高清在线| 91久久精品日日躁夜夜躁欧美| 欧美日韩高清影院| 26uuu精品一区二区在线观看| 国产色一区二区| 亚洲综合免费观看高清完整版| 免费成人av资源网| 成人网页在线观看| 欧美日韩国产一级| 国产亚洲午夜高清国产拍精品| 亚洲视频一区二区免费在线观看| 亚洲成人精品一区| 国产一区二区成人久久免费影院| 色成人在线视频| 欧美成人精品高清在线播放 | 亚洲色图清纯唯美| 奇米四色…亚洲| 99国产精品99久久久久久| 欧美精品亚洲一区二区在线播放| 欧美国产乱子伦| 天天色图综合网| 成人自拍视频在线| 欧美精品日日鲁夜夜添| 国产欧美日韩麻豆91| 日韩在线一区二区三区| av一本久道久久综合久久鬼色| 3751色影院一区二区三区| 国产精品电影院| 狠狠久久亚洲欧美| 欧美精品久久久久久久久老牛影院| 国产欧美精品区一区二区三区| 午夜影院久久久| 91视频你懂的| 国产日产亚洲精品系列| 五月天网站亚洲| eeuss鲁片一区二区三区| 精品久久久影院| 日韩国产精品大片| 欧美综合在线视频| 亚洲欧美一区二区视频| 国产麻豆一精品一av一免费 | 91福利区一区二区三区| 国产日韩精品一区二区三区在线| 日韩av一区二区在线影视| 一本在线高清不卡dvd| 中文字幕高清一区| 国内成人精品2018免费看| 欧美综合在线视频| 一区二区在线电影| 91影视在线播放| 国产精品色呦呦| 成人免费高清在线观看| 亚洲精品一区二区三区香蕉| 日本亚洲最大的色成网站www| 在线免费不卡电影| 一区二区三区丝袜| 欧美午夜理伦三级在线观看| 玉米视频成人免费看| 一本久久a久久精品亚洲| 国产精品免费人成网站| 成人激情午夜影院| 亚洲欧洲无码一区二区三区| av电影在线不卡| 自拍偷拍欧美精品| 一本色道久久综合亚洲aⅴ蜜桃| 亚洲欧美怡红院| 在线观看视频一区二区欧美日韩| 亚洲综合在线第一页| 欧美调教femdomvk| 日韩精品成人一区二区在线| 欧美久久久一区| 日本中文字幕一区| 26uuuu精品一区二区| 国产黄色精品视频| 亚洲欧美日韩在线不卡| 欧美午夜精品一区| 免费观看一级特黄欧美大片| 欧美大白屁股肥臀xxxxxx| 久久99精品国产.久久久久久| 久久久国产午夜精品| av在线免费不卡| 亚洲va国产va欧美va观看| 日韩亚洲欧美中文三级| 精品一区二区综合| ...av二区三区久久精品| 欧美午夜精品久久久| 免费在线观看一区| 中文字幕高清不卡| 欧美视频一区二区三区| 极品美女销魂一区二区三区免费| 国产欧美精品一区二区色综合朱莉| 色综合久久综合中文综合网| 石原莉奈在线亚洲二区| 中文字幕精品—区二区四季| 欧美三级三级三级爽爽爽| 精品无码三级在线观看视频|