【原创】RL-ARM-RTX的配置文件翻译

单片机相关 徐 自远 914℃ 0评论

最近一个项目用到了STM32F107这块芯片,因为热敏打印机工作等待和液晶菜单GUI一起做还是用任务比较简单。所以考虑了几个方案,最后还是选用RTX Kernel这个MDK的原生系统。因为完全免费嘛。移植起来也方便的很。现在把翻译的RTX_CONFIG.C文件与一些新的做一个分享。

 

/*—————————————————————————-

* RL-ARM – RTX

*—————————————————————————-

* Name: RTX_CONFIG.C

* Purpose: Configuration of RTX Kernel for Cortex-M

* Rev.: V4.05

*—————————————————————————-

* This code is part of the RealView Run-Time Library.

* Copyright (c) 2004-2009 KEIL – An ARM Company. All rights reserved.

*—————————————————————————*/

 

#include <RTL.h>

 

/*—————————————————————————-

* RTX User configuration part BEGIN

*—————————————————————————*/

 

//——– <<< Use Configuration Wizard in Context Menu >>> —————–

//

// <h>Task Configuration

// =====================

//

// <o>Number of concurrent running tasks <0-250>//并发运行任务数

// <i> Define max. number of tasks that will run at the same time.//定义最大数量的任务将运行在同一时间

// <i> Default: 6 //默认6个任务

#ifndef OS_TASKCNT

#define OS_TASKCNT 6

#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//默认0?那些任务提供更大更大的堆栈呢?

#ifndef OS_PRIVCNT

#define OS_PRIVCNT 0

#endif

 

// <o>Task stack size [bytes] <20-4096:8><#/4>//任务堆栈大小[字节] <20-4096>

// <i> Set the stack size for tasks which is assigned by the system.//设置堆栈大小为任务分配的系统

//【注:每个任务分配堆栈,RTX_Kernel应该是私有堆栈任务系统。并非像RTX51一样为公有堆栈任务系统】

// <i> Default: 200//默认值为200

#ifndef OS_STKSIZE

#define OS_STKSIZE 50

#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

#define OS_STKCHECK 1

#endif

 

// <q>Run in privileged mode //运行在特权模式

// =========================

// <i> Run all Tasks in privileged mode.//运行的所有任务中的特权模式

// <i> Default: Unprivileged//默认:无特权模式

//【提问?什么是特权模式啊?privileged mode 是what?privileged 还能解释为专用的,保密的,难道是保密模式?此选项默认是关闭的。】

#ifndef OS_RUNPRIV

#define OS_RUNPRIV 0

#endif

 

// </h>

// <h>SysTick Timer Configuration//系统时钟

// =============================

// <o>Timer clock value [Hz] <1-1000000000>

// <i> Set the timer clock value for selected timer.

// <i> Default: 6000000 (6MHz)//本系统下为72MHZ

//【注:如果修改频率或者超频使用stm32芯片的话,需要修改此数值,否则会影响系统时间的准确】

#ifndef OS_CLOCK

#define OS_CLOCK 72000000

#endif

 

// <o>Timer tick value [us] <1-1000000>//时间片大小[单位:us]<1-1000000>

// <i> Set the timer tick value for selected timer.//设置时间片大小

// <i> Default: 10000 (10ms)//默认10ms

#ifndef OS_TICK

#define OS_TICK 10000

#endif

 

// </h>

 

// <h>System Configuration//系统配置

// =======================

// <e>Round-Robin Task switching//轮询任务切换

// =============================

// <i> Enable Round-Robin Task switching.//启用轮询任务切换

//【注:默认是打开的,如果需要关闭,把OS_ROBIN修改为0】

#ifndef OS_ROBIN

#define OS_ROBIN 1

#endif

 

// <o>Round-Robin Timeout [ticks] <1-1000>//时间片轮转

// <i> Define how long a task will execute before a task switch.//定义多久任务执行一个任务切换

//【注:疑问,默认值为5的话,就是当前任务超出5个时间片时间后进行自动任务切换,是这样吗?RTX51TINY的任务超时溢出是1个时间片。】

// <i> Default: 5

#ifndef OS_ROBINTOUT

#define OS_ROBINTOUT 5

#endif

 

// </e>

 

// <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)//默认:0,(用户定时器禁用)

#ifndef OS_TIMERCNT

#define OS_TIMERCNT 0

#endif

 

// <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries

// <12=> 12 entries <16=> 16 entries

// <24=> 24 entries <32=> 32 entries

// <48=> 48 entries <64=> 64 entries

// <96=> 96 entries

//侦察先进先出队列大小

// <i> ISR functions store requests to this buffer,//当从中断程序冲被调用时,侦察功能请求缓冲区【这边不懂】

// <i> when they are called from the iterrupt handler.

// <i> Default: 16 entries

#ifndef OS_FIFOSZ

#define OS_FIFOSZ 16

#endif

 

// </h>

 

//————- <<< end of configuration section >>> ———————–

//———————–最后配置节

// Standard library system mutexes//标准库系统

// ===============================

// Define max. number system mutexes that are used to protect //定义最大数系统互斥锁,是用来保护标准运行时库

// the arm standard runtime library. For microlib they are not used.

#ifndef OS_MUTEXCNT

#define OS_MUTEXCNT 8

#endif

 

/*—————————————————————————-

* RTX User configuration part END

*—————————————————————————*/

 

#define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)

 

/*—————————————————————————-

* Global Functions

*—————————————————————————*/

 

/*————————— os_idle_demon ———————————*/

 

__task void os_idle_demon (void) {

/* The idle demon is a system task, running when no other task is ready */

/* to run. The ‘os_xxx’ function calls are not allowed from this task. */

//闲置的demon是系统运行时的任务,没有其他的任务是准备运行。”os_xxx的函数调用是不允许从这个任务。【注:此任务函数优先级最高,作用是当其他任务都处于等待工作中时,系统运行在这个任务下,所以在这个任务的for循环函数中可以放置系统节能模式接口。但是需要注意的是,大部分的芯片,在节能模式下是不能进行JTAG仿真的。所以此函数最好在所有程序都调试完成后,才写入节能模式,否则会影响系统调试。此任务也是操作系统的节能精髓所在】

for (;;) {

/* HERE: include optional user code to be executed when no task runs.*/

//包括可选的用户代码被执行时,没有任务运行。

}

}

 

 

/*————————— os_tmr_call ———————————–*/

 

void os_tmr_call (U16 info) {

/* This function is called when the user timer has expired. Parameter */

/* ‘info’ holds the value, defined when the timer was created. */

/ *这个函数被调用时,用户计时器已过期。参数’ ‘info’的值,指当计时器创建。* /

/* HERE: include optional user code to be executed on timeout. */

/ *:包括可选的用户执行的代码对超时。* /

//【注:用户定时器益处程序,若要放代码,尽量短。】

}

 

 

/*————————— os_error ————————————–*/

 

void os_error (U32 err_code) {

/* This function is called when a runtime error is detected. Parameter */

/* ‘err_code’ holds the runtime error code (defined in RTL.H). */

/ *这个函数被调用时,说明系统运行时检测到一个错误。错误代码在参数’err_code ‘中。(定义在RTL.H中)。* /

/* HERE: include optional code to be executed on runtime error. */

/ *:包括可选的执行的代码在运行时错误。* /

//【注:此错误为系统错误,若程序运行到此处请查询err_code的值。很有可能是任务堆栈溢出。所以说还是公有堆栈好,不会溢出。不过私有堆栈的话,切换速度要快的多。】

for (;;);

}

 

 

/*—————————————————————————-

* RTX Configuration Functions

*—————————————————————————*/

 

#include <RTX_lib.c>

 

/*—————————————————————————-

* end of file

*—————————————————————————*/

转载请注明:徐自远的乱七八糟小站 » 【原创】RL-ARM-RTX的配置文件翻译

喜欢 (0)

您必须 登录 才能发表评论!

苏ICP备18041234号-1 bei_an 苏公网安备 32021402001397号