?? rtx_config.c
字號:
/*----------------------------------------------------------------------------
* R T L - K e r n e l
*----------------------------------------------------------------------------
* Name: RTX_CONFIG.C
* Purpose: Configuration of RTX Kernel for Philips LPC21xx
* Rev.: V3.00 / 17-mar-2006
*----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2006 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
#include <RTX_Config.h> /* RTX user configuration header */
#pragma O0
/*----------------------------------------------------------------------------
* RTX User configuration part BEGIN
*---------------------------------------------------------------------------*/
//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
// <e>Task Mode Select
// <o>Task Mode Select <0-1>
// <i> Define max. number of tasks that will run at the same time.
// <i> Default: 0
#ifndef OS_MODESEL
#define OS_MODESEL 1//OS選擇非典的中斷向量編號模式
#endif
#if (OS_MODESEL == 0) //OS中斷向量地址/編號模式選擇
#include <LPC213x.H> /* LPC21xx definitions */
#else
#include <LPC213xDEF.H> //ARM菜鳥HotPower創建定義文件(愚人節預演版)
#endif
// </e>
//
// <h>Task Definitions
// ===================
//
// <o>Number of concurrent running tasks <0-250>
// <i> Define max. number of tasks that will run at the same time.
// <i> Default: 6
#ifndef OS_TASKCNT//指定同時運行的任務數
#define OS_TASKCNT 10
#endif
// <o>Number of tasks with user-provided stack <0-250>
// <i> Define the number of tasks that will use a bigger stack.
// <i> The memory space for the stack is provided by the user.
// <i> Default: 0
#ifndef OS_PRIVCNT//指定用戶提供堆棧的任務數量
#define OS_PRIVCNT 0
#endif
// <o>Task stack size [bytes] <20-4096:8><#/4>
// <i> Set the stack size for tasks which is assigned by the system.
// <i> Default: 200
#ifndef OS_STKSIZE//指定每一個任務的棧尺寸(32位字,此數乘4為棧字節數)
#define OS_STKSIZE 100
#endif
// <q>Check for the stack overflow
// ===============================
// <i> Include the stack checking code for a stack overflow.
// <i> Note that additional code reduces the Kernel performance.
#ifndef OS_STKCHECK//使能(1) 或禁止(0) 堆棧檢查
#define OS_STKCHECK 1
#endif
// <o>Number of user timers <0-250>
// <i> Define max. number of user timers that will run at the same time.
// <i> Default: 0 (User timers disabled)
#ifndef OS_TIMERCNT//指定用戶定時器的數量(在回調函數os_tmr_call()里編寫程序)
#define OS_TIMERCNT 1
#endif
// </h>
// <h>System Timer Configuration
// =============================
// <o>ARTX Kernel timer number <0=> Timer 0 <1=> Timer 1
// <i> Define the ARM timer used as a system tick timer.
// <i> Default: Timer 0
#ifndef OS_TIMER//指定一個片上定時器, 用作實時系統的時基, 可以是0 或1
#define OS_TIMER 1
#endif
// <o>Timer clock value [Hz] <1-1000000000>
// <i> Set the timer clock value for selected timer.
// <i> Default: 15000000 (15MHz at 60MHz CCLK and VPBDIV = 4)
#ifndef OS_CLOCK//指定所選擇定時器的輸入信號頻率
#define OS_CLOCK 55296000
#endif
// <o>Timer tick value [us] <1-1000000>
// <i> Set the timer tick value for selected timer.
// <i> Default: 10000 (10ms)
#ifndef OS_TICK//指定系統定時的時間間隔, 單位為uS
#define OS_TICK 10000
#endif
// </h>
// <e>Round-Robin Task switching
// =============================
// <i> Enable Round-Robin Task switching.
#ifndef OS_ROBIN//使能(1) 或禁止(0) 時間片輪轉任務調度
#define OS_ROBIN 1
#endif
// <o>Round-Robin Timeout [ticks] <1-1000>
// <i> Define how long a task will execute before a task switch.
// <i> Default: 5
#ifndef OS_ROBINTOUT//時間片的大小, 以系統定時間隔為單位(節拍)
#define OS_ROBINTOUT 5
#endif
// </e>
//------------- <<< end of configuration section >>> -----------------------
/*----------------------------------------------------------------------------
* ARTX User configuration part END
*---------------------------------------------------------------------------*/
#if (OS_TIMER == 0) /* Timer 0 */
#define OS_TID_ 4 /* Timer ID */
#define OS_TIM_ (1 << OS_TID_) /* Interrupt Mask */
//OS_TRV指定定時器的重載值
#define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
//OS_TVAL用于讀取定時器的當前值
#if (OS_MODESEL == 0)
#define OS_TVAL T0TC /* Timer Value */
#else
#define OS_TVAL T0->TIMER_TC /* Timer Value */
#endif
//OS_TOVF指定定時器溢出標志
#if (OS_MODESEL == 0)
#define OS_TOVF (T0IR & 1) /* Overflow Flag */
#else
#define OS_TOVF (T0->TIMER_IR & 1) /* Overflow Flag */
#endif
//OS_TREL()定義定時器重載的指令序列
#define OS_TREL() ; /* Timer Reload */
//OS_TFIRQ()定義強制定時器中斷的指令序列
#if (OS_MODESEL == 0)
#define OS_TFIRQ() VICSoftInt |= OS_TIM_; /* Force Interrupt */
#else
#define OS_TFIRQ() VIC->SoftInt |= OS_TIM_; /* Force Interrupt */
#endif
//OS_TIACK()用于清除定時器中斷的邏輯
#if (OS_MODESEL == 0)
#define OS_TIACK() T0IR = 1; /* Interrupt Ack */ \
VICSoftIntClr = OS_TIM_; \
VICVectAddr = 0;
#else
#define OS_TIACK() T0->TIMER_IR = 1; /* Interrupt Ack */ \
VIC->SoftIntClr = OS_TIM_; \
VIC->VectAddr = 0;
#endif
//OS_TINIT()用于定義定時器的初始化代碼
#if (OS_MODESEL == 0)
#define OS_TINIT() T0MR0 = OS_TRV; /* Initialization */ \
T0MCR = 3; \
T0TCR = 1; \
VICDefVectAddr = (U32)os_def_interrupt; \
VICVectAddr15 = (U32)os_clock_interrupt; \
VICVectCntl15 = 0x20 | OS_TID_;
#else
#define OS_TINIT() T0->TIMER_MR0 = OS_TRV; /* Initialization */ \
T0->TIMER_MCR = 3; \
T0->TIMER_TCR = 1; \
VIC->DefVectAddr = 31;/*(U32)os_def_interrupt*/ \
VIC->VectAddrs[15] = 15;/*(U32)os_clock_interrupt*/ \
VIC->VectCntls[15] = 0x20 | OS_TID_;
#endif
#elif (OS_TIMER == 1) /* Timer 1 */
#define OS_TID_ 5 /* Timer ID */
#define OS_TIM_ (1 << OS_TID_) /* Interrupt Mask */
#define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
#if (OS_MODESEL == 0)
#define OS_TVAL T1TC /* Timer Value */
#else
#define OS_TVAL T1->TIMER_TC /* Timer Value */
#endif
#if (OS_MODESEL == 0)
#define OS_TOVF (T1IR & 1) /* Overflow Flag */
#else
#define OS_TOVF (T1->TIMER_IR & 1) /* Overflow Flag */
#endif
#define OS_TREL() ; /* Timer Reload */
#if (OS_MODESEL == 0)
#define OS_TFIRQ() VICSoftInt |= OS_TIM_; /* Force Interrupt */
#else
#define OS_TFIRQ() VIC->SoftInt |= OS_TIM_; /* Force Interrupt */
#endif
#if (OS_MODESEL == 0)
#define OS_TIACK() T1IR = 1; /* Interrupt Ack */ \
VICSoftIntClr = OS_TIM_; \
VICVectAddr = 0;
#else
#define OS_TIACK() T1->TIMER_IR = 1; /* Interrupt Ack */ \
VIC->SoftIntClr = OS_TIM_; \
VIC->VectAddr = 0;
#endif
#if (OS_MODESEL == 0)
#define OS_TINIT() T1MR0 = OS_TRV; /* Initialization */ \
T1MCR = 3; \
T1TCR = 1; \
VICDefVectAddr = (U32)os_def_interrupt; \
VICVectAddr15 = (U32)os_clock_interrupt; \
VICVectCntl15 = 0x20 | OS_TID_;
#else
#define OS_TINIT() T1->TIMER_MR0 = OS_TRV; /* Initialization */ \
T1->TIMER_MCR = 3; \
T1->TIMER_TCR = 1; \
VIC->DefVectAddr = 31;/*(U32)os_def_interrupt*/ \
VIC->VectAddrs[15] = 15;/*(U32)os_clock_interrupt*/ \
VIC->VectCntls[15] = 0x20 | OS_TID_;
#endif
#else
#error OS_TIMER invalid
#endif
#if (OS_MODESEL == 0)
#define OS_IACK() VICVectAddr = 0; /* Interrupt Ack */
#else
#define OS_IACK() VIC->VectAddr = 0; /* Interrupt Ack */
#endif
//OS_LOCK()禁止系統定時器中斷
#if (OS_MODESEL == 0)
#define OS_LOCK() VICIntEnClr = OS_TIM_; /* Task Lock */
#else
#define OS_LOCK() VIC->IntEnClr = OS_TIM_; /* Task Lock */
#endif
//OS_UNLOCK()使能系統定時器中斷
#if (OS_MODESEL == 0)
#define OS_UNLOCK() VICIntEnable |= OS_TIM_; /* Task Unlock */
#else
#define OS_UNLOCK() VIC->IntEnable |= OS_TIM_; /* Task Unlock */
#endif
/* WARNING ! Do not use IDLE mode if you are using a JTAG interface */
/* for debugging your application. */
#if (OS_MODESEL == 0)
#define _idle_() PCON = 1;
#else
#define _idle_() POWER->P_CON = 1;
#endif
#define INITIAL_CPSR 0x40000010
#define MAGIC_WORD 0xE25A2EA5
/*----------------------------------------------------------------------------
* Global Variables
*---------------------------------------------------------------------------*/
extern P_TCB os_runtask;
extern struct OS_XCB os_rdy;
extern struct OS_TCB os_clock_TCB;
extern U16 os_time;
U16 const os_maxtaskrun = OS_TASKCNT;
/* Export following defines to uVision debugger. */
U32 const os_stackinfo = (OS_STKCHECK<<24) | (OS_PRIVCNT<<16) | (OS_STKSIZE*4);
U32 const os_clockrate = OS_TICK;
U32 const os_timernum = (OS_TIMER << 16) | OS_TIMERCNT;
U32 const os_rrobin = (OS_ROBIN << 16) | OS_ROBINTOUT;
/*----------------------------------------------------------------------------
* Local Variables
*---------------------------------------------------------------------------*/
/* Memory pool for TCB allocation */
static U32 m_tcb[(sizeof(struct OS_TCB) * OS_TASKCNT)/4 + 4];
/* Memory pool for System stack allocation. Need to allocate 2 additional */
/* entries for 'os_clock_demon()' and 'os_idle_demon()'. */
static U64 m_stk[OS_STKSIZE * (OS_TASKCNT-OS_PRIVCNT+2)/2 + 2];
/* An array of Active task pointers. */
P_TCB os_active_TCB[OS_TASKCNT];
#if (OS_ROBIN == 1)
static U16 os_robin_time;
static P_TCB os_tsk_robin;
#endif
#if (OS_TIMERCNT != 0)
/* Memory pool for User Timer allocation */
static U32 m_tmr[(sizeof(struct OS_TMR) * OS_TIMERCNT)/4 + 4];
#endif
#if (OS_STKCHECK == 1)
static BIT os_del_flag;
#endif
/*----------------------------------------------------------------------------
* Global Functions
*---------------------------------------------------------------------------*/
extern void os_clock_interrupt (void);
/*--------------------------- os_idle_demon ---------------------------------*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -