|
本帖最后由 baiyongbin2009 于 2014-12-20 17:44 编辑 & o) J. I# Q, ]4 A2 k6 L 特别说明:2 y8 z) R1 |& X( N, l! p 1. 本教程是安富莱电子原创。' M. o2 z8 Y% ^$ }6 f; s 2. 安富莱STM32F407开发板资料已经全部开源,开源地址:地址链接 3. 当前共配套300多个实例,4套用户手册。 ; ] h) H1 F% M+ {. W, a1 | 第8章 μCOS-III系统移植过程详解 本期教程主要教大家如何移植μCOS-III系统,μCOS-III的移植并不难,因为官方已经帮我们把移植代码写好了,我们要做的只是将工程建立起来,编译、链接、运行。如果有什么错误参考官方已经建立好的代码即可。下面就跟大家详细的讲解一下移植过程。 8.1 源代码下载 8.2 源代码移植-MDK 8.3 源代码移植-IAR 8.4 总结 8.1 源代码下载 移植前要从官网下载相关的源代码,一般官方会为IC厂商新推出的评估板配套相应的移植工程,比如去年(2013年)ST公司推出的STM32F429 探索套件。推出后不久Micrium公司就为其配套了自己的μCOS-III工程文件。其实不光Micrium会为其移植相应的工程,其它的RTOS厂商也会移植的,比如SEGGER公司为STM32F429探索套件移植的embOS工程文件。还有一点要和大家说的是,这些RTOS厂商倾向于使用IAR开发环境。为什么使用IAR开发环境?主要是因为IAR中集成了多款RTOS的调试组件。如下图所示:
考虑到初学μCOS-III的同学中使用MDK的比较多,而且μCOS-III有相关的调试工具μC/Probe,功能也比较的强大。我们今后的教程以使用MDK为主,IAR相关的知识也会跟大家讲解。 下面开始说一下如何从官网下载μCOS-III源码代码以及为STM32配套好的工程代码。先说如何下载源代码: l 打开Micrium的官方网站:www.micrium.com,并点击下面的图标:
l 进入分版块以后,在最上面会有Download的链接:
1 W* J$ K( n7 j8 v 点击进入后,在网页的最下面可以看到源代码的下载地址:
大家可能已经注意到了左侧是Login,这个的意思是大家需要注册一个账号才可以下载,注册很简单,点击Login弹出下面的界面注册就行。
注册并登陆后上面的截图就会变成下面这样:
这种情况下就可以下载源码了,咱们要下载的是最下面的那个,不过日期有点早,是2012年的了。将这个源码下载下来解压后会看到里面的文件如下(路径:\Micrium\Software\uCOS-III):
这里咱们重点看一下Release文件,这个文件比较的重要,主要记录着μCOS-III的更新内容。内容如下(建议初学的同学把下面的内容读完,脑子里有个印象): -------------------------------------------------------------------------------------------------------- Release V3.03.00 (2012/02/14): -------------------------------------------------------------------------------------------------------- 1) Added Thread Local Storage(TLS) support See chapter 20 of the User'sManual 2) Computation of CPU usage hasnow a resolution of 1/100th of a percent * K6 C. x. @# a 3) Added OSTaskRegGetID() toassign task register IDs dynamically 4) Now able to Suspend and Resumetasks from ISRs 5) Added option'OS_OPT_TASK_NO_TLS' to OSTaskCreate() to specify that a task will not requireTLS 6) Added and changed some errorcodes ( d" c# ?) Q/ H 7) Removed OSMsgPoolExtend() sinceit was not documented and not used. 8) Added globalOSStatTaskCPUUsageMax to keep track of peak CPU usage. This value is reset byOSStatReset() . G- A$ B2 E1 q/ J/ A 9) Added per task .CPUUsageMaxwhich tracks the peak CPU usage of each task. " T( Z0 \$ t7 n& v% z: [; c" Q( P* K% P7 | -------------------------------------------------------------------------------------------------------- Release V3.02.00 (2011/08/01): -------------------------------------------------------------------------------------------------------- 1) Corrected pointer to integercast in OSMemCreate. " N* n' T3 |$ p9 e w2 t% c$ i! z0 E3 S 2) Corrected invalid typecast onconstant initialization on os_cfg_app.c. 3) Added a "return"statement after each invocation of the OS_SAFETY_CRITICAL_EXCEPTION() macro. 4) Fixed OS_TmrLink() while addingTmr object into middle of spoke linked-list. 5) Corrected OS_TmrResetPeak()reset maximum number of entries (NbrEntriesMax). 3 x1 K# R: q e, e; I 6) Added note to clarify use ofOS_OPT_LINK_DLY option on OS_TmrLink() at OSTmrStart(). % }) H- Y: j- M% M8 K: U 7) Adjusted order of operation onTick Wheel during insert (OS_TickListInsert) to first set link pointers on new object, then add it tothe linked-list. 8) Corrected OS_OPT_POST_NO_SCHEDoption for OSFlagPost and OSFlagPendAbort. # n4 M C, s6 I- w# f6 k 9) Initialize Interrupt QueueHandler Task before any other task to prevent usage of OSIntQNbrEntries uninitialized. 10) Corrected use of disabledvariable 'OSCfg_ISRStk'. ) a9 X5 l$ \. L5 u3 x$ e- W K 11) Changed default OS_CYCLES to32-bits. 9 b5 B% R: ^3 E! \ 12) Corrected per task CPU usagestatistics computation. 2 _- f+ d# e- N 13) Adjusted version to new formatVx.yy.zz. 4 E6 @+ s5 O' O, O 14) Removed OS_TMR_TICK datatype;converted OSTmrTickCtr to OS_TICK to be consistent with other OS_TMR structure fields. : f' c- K( { Y+ b0 n% w 15) Prevent OSSchedLock/Unlock() tobe called from ISR. & k. A# @: k- a) o9 l( o1 B 16) Re-arranged order of datastructure members on OS_TCB to keep non-optional items at the beginning of the structure. 0 P* [6 ?8 N3 A8 S9 K/ [$ }3 i 17) Changed error codes to enum. , `* _) F. O5 V" R5 W6 M 18) Converted OS object types touse CPU_TYPE_CREATE. : X* B g+ N1 A: P 19) Reworked check to not allow tocreate multiple tasks at idle task priority. 20) Corrected alignment check onOSMemCreate() to handle cases where sizeof(void *) == 1. 21) Added changes to priorityhandling to allow word addressable architectures. , F+ F# f: n- G, }( l( R# V& M 22) Adjusted copyright in fileheaders for source available distribution. -------------------------------------------------------------------------------------------------------- , Q/ v: H7 L, v8 H) A6 h$ c$ g% A" p% ^, A+ k# M) j |
【福利三:雨露均沾·逢7狂欢】之四:用一个定时器同步另外两个定时器输出PWM
【逢7发帖赢大礼】STM32开发之WIFI实时时钟
【逢7发帖赢大礼】STM32开发之指纹识别!
【逢7发帖赢大礼】STM32开发之环境空气质量监测
【逢7发帖赢大礼】STM32开发之人体实时运动信息监测!
【逢7发帖赢大礼】STM32开发之IC门禁卡UID读取方法!
【逢7发帖赢大礼】全网最简单的Arduino_STM32开发环境搭建教程!
STM32F4中文用户手册
STM32F400、STM32F402 Cortex-M4超值单片机
SPI 高温读错最后一位?STM32F42xx 官方根治方案
微信公众号
手机版
; I. b! D& {/ s8 x7 G* {
# ]: f x8 j& i, f& O8 A1 T- d
# [6 f* J- V/ r
5 t# H& d+ W& x; p- B
( \! K" F) Q/ ~8 G+ d4 i
8.2.2 文件修改
" l8 U# L. F$ d( U- g
2 j- W2 l3 \& a, q) u( H0 p
* [" D% R+ x- r2 @! q7 M0 @
(续)8.2.2 文件修改
上面这几步完成后,编译,链接,下载程序到开发板上,可以看到4个LED闪烁。至此μCOS-III的简单移植就完成了。
3 ]/ A1 M( U& \* ~# ]. D: H* l
7 o8 Y$ i M, \8 A/ [ {
' J, l8 S6 _8 m, ` n: `. E
谢谢支持