特别说明:
1. 本教程是安富莱电子原创。
2. 安富莱STM32F407开发板资料已经全部开源,开源地址:地址链接
3. 当前共配套300多个实例,4套用户手册。
本期教程主要教大家如何移植μ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的链接:
点击进入后,在网页的最下面可以看到源代码的下载地址:

大家可能已经注意到了左侧是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's Manual
2)
Computation of CPU usage has now a resolution of 1/100th of a
percent
3) Added
OSTaskRegGetID() to assign task register IDs
dynamically
4) Now able
to Suspend and Resume tasks from ISRs
5) Added
option 'OS_OPT_TASK_NO_TLS' to OSTaskCreate() to specify that a
task will not require TLS
6) Added and
changed some error codes
7) Removed
OSMsgPoolExtend() since it was not documented and not
used.
8) Added
global OSStatTaskCPUUsageMax to keep track of peak CPU
usage.
This value is reset by OSStatReset()
9) Added per
task .CPUUsageMax which tracks the peak CPU usage of each
task.
--------------------------------------------------------------------------------------------------------
Release V3.02.00
(2011/08/01):
--------------------------------------------------------------------------------------------------------
1) Corrected
pointer to integer cast in OSMemCreate.
2) Corrected
invalid typecast on constant 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 adding Tmr object into middle of spoke
linked-list.
5) Corrected
OS_TmrResetPeak() reset maximum number of entries
(NbrEntriesMax).
6) Added note
to clarify use of OS_OPT_LINK_DLY option on OS_TmrLink() at
OSTmrStart().
7) Adjusted
order of operation on Tick Wheel during insert (OS_TickListInsert)
to first set link pointers
on new object, then add it to the linked-list.
8) Corrected
OS_OPT_POST_NO_SCHED option for OSFlagPost and
OSFlagPendAbort.
9) Initialize
Interrupt Queue Handler Task before any other task to prevent usage
of OSIntQNbrEntries
uninitialized.
10) Corrected
use of disabled variable 'OSCfg_ISRStk'.
11) Changed
default OS_CYCLES to 32-bits.
12) Corrected
per task CPU usage statistics computation.
13) Adjusted
version to new format Vx.yy.zz.
14) Removed
OS_TMR_TICK datatype; converted OSTmrTickCtr to OS_TICK to be
consistent with other OS_TMR
structure fields.
15) Prevent
OSSchedLock/Unlock() to be called from ISR.
16)
Re-arranged order of data structure members on OS_TCB to keep
non-optional items at the beginning of
the structure.
17) Changed
error codes to enum.
18) Converted
OS object types to use CPU_TYPE_CREATE.
19) Reworked
check to not allow to create multiple tasks at idle task
priority.
20) Corrected
alignment check on OSMemCreate() to handle cases where sizeof(void
*) == 1.
21) Added
changes to priority handling to allow word addressable
architectures.
22) Adjusted
copyright in file headers for source available
distribution.
--------------------------------------------------------------------------------------------------------
Release V3.01.2
(2010/05/14):
--------------------------------------------------------------------------------------------------------
1) Added
error checking for time stamp configuration
#defines.
2) Removal of
some MISRA C 2004 errors.
3) Corrected
OS_MEM structure definition for field
FreeListPtr.
4) Moved
OSInitHook() to beginning of OSInit() to be consistent with
documentation section about
differences between uC/OS-II and uC/OS-III port
functions.
5) Removed
duplicate call to OS_TickListRemove() in
OS_TickListUpdate().
6) Corrected
OS_TmrLink() where number of entries in spoke was incremented twice
for a particular
case, and timer previous pointer was alwyas being cleared before
exit the function.
7) Corrected
OSTaskChangePrio() to update task priority if task is pending on
Task Queue, Task Sem,
or Flag.
8) Corrected
OSTaskDel() TCB clean up where it could potentially be skipped if
context switch happened
before OSSched().
9) Corrected
sections of code conditional on OS_CFG_Q_EN &
OS_CFG_TASK_Q_EN.
10) Corrected
DbgListRemove procedures where it did not clear the DbgPrevPtr of
the first object when
the head of the list was removed.
11) Removed
sections where TimeQuantaCtr was incorrectly
reset.
12) Corrected
NULL pointer de-reference on OSMutexDel() with OS_OPT_DEL_ALWAYS
option when Mutex created
and deleted right away.
13) Added
OSStatResetFlag into OS_StatTask to force reset of the computed
statistics.
14) Added
OSIntQMaxNbrEntries into computed statistics.
15) Reordered
DbgListAdd/Remove to prevent a still linked object from being
cleared.
16) Corrected
DbgList removal in OSTmrDel().
17) Added
critical section in OSMemCreate().
18) Removed
access to uninitialized kernel objects
(p_obj->Type).
19) Corrected
port's OSTaskSwHook where OSSchedLockTimeMaxCur was not always
cleared between context switch.
20) Corrected
NULL pointer de-reference of p_tcb on OS_SchedRoundRobin(), if no
TCB in the ready list.
21) Adjusted
check for nesting interrupts on OSSched() by removing conditional
compilation based
on OS_CFG_CALLED_FROM_ISR_CHK_EN.
22) Adjusted
formatting & function descriptions.
--------------------------------------------------------------------------------------------------------
Release V3.01.1
(2010/01/11):
--------------------------------------------------------------------------------------------------------
1) Added
PERIODIC and MATCH modes to OSTimeDlyHMSM().
2) Improved
the performance of the scheduler lock time
measurement.
3) Added
OS_CFG_TS_EN in OS_CFG.H which is used to enable/disable time
stamping.
4)
OSTaskStkChk() now returns the number of free and used 'ELEMENTS'
instead of 'BYTES'.
This is done for consistency.
5) Fixed a bug
with OS_PendListRemove1() which removes a task from a wait
list.
6) Fixed a bug
when pend-aborting a object where a task has multi-pended on the
same object
multiple times.
7) Fixed a bug
when posting to an event flag group where there are no task(s)
pending on the
event flag group.
--------------------------------------------------------------------------------------------------------
Release V3.01.0
(2009/12/07):
--------------------------------------------------------------------------------------------------------
1) The API for
OSTaskCreate()
changed. The
seventh argument changed from:
CPU_STK
*p_stk_limit;
to
CPU_STK_SIZE
stk_limit;
This argument now represents the number of CPU_STK elements left
before the stack is empty.
This is used when the CPU supports stack limit
checking.
2) As shown
above, OS_STK_SIZE has been changed to CPU_STK_SIZE and thus, this
data type is declared in uC/CPU
instead of uC/OS-III.
3) We removed
OS_AppInitHookPtr because it was impossible to initialize this
pointer prior to dereferncing it.
OSInit() set the pointer to NULL and didn't allow the user to
change its value before using it.
4) Added a new
operating mode to OSTimeDly(), i.e.
OS_OPT_TIME_PERIODIC
5) Added the
function OSSafetyCriticalStart() which, when called will prevent
further kernel objects from being created.
In other words, after calling this function, you will no longer be
allowed to create tasks, semaphores, mutexes, etc.
In some safety critical systems, it's not allowed to create kernel
objects once initialization has completed.
6) Fixed a bug
when an object was pend aborted when using
OSPendMulti().
7) Fixed a bug
when an object was deleted when using
OSPendMulti().
8)
Replaced:
for (;;)
to
while (DEF_ON)
for tasks to represent that the loop runs while power is
applied.
9) Fixed a bug
in OSPendMulti().
The scheduler was locked during a critical region that should have
been protected by disabling/enabling interrupts.
10) The timestamp is now read
when a task is created to determine when the task
starts.
This is used to compute the per task CPU usage.
11) Statistics are reset after
determining CPU usage capacity.
12) Changed the copyright
notice.
其余的四个文件,大家打开看一下就行,下面还会继续的介绍。关于源代码的下载就说这多,下面说一下如何下载建立好的工程文件:
l
打开官网进入主界面以后看到下面的Download标记后,点击进入

进入后看到各IC厂商的地址链接:
我们点击进入意法半导体的链接,可以看到很多已经建立好的工程模板(这里只贴了部分工程):

咱们要下载的是下面的这个工程:

下载好以后,打开此路径:\Micrium\Software,内容如下:
这几个文件就是咱们移植要用到的,本期教程移植代码是使用的这个里面的文件,而没有使用上面下载的源码,主要是因为现在的源码和uC-CPU,uC-LIB有一定的关联性,咱们主要移植的也是uC-OSIII,uC-CPU,uC-LIB这三个文件。
8.2
源代码移植-MDK
下面开始讲解源代码的移植,这里咱们不一步一步的建立工程了,显得太罗嗦。咱们直接在一个现成的MDK和IAR工程上面建立。工程就使用V5开发板基础篇中的例子:V5-001a_GPIO实验_跑马灯。MDK使用4.54版本,其它高版本的也可以,不过要注意这个问题:http://bbs.armfly.com/read.php?tid=2567
现在开始移植讲解:
l
第一步:在跑马灯工程里面建立文件夹uCOS-III。
并将下面四个文件复制到uCOS-III文件夹里面:

l
第二步:把官方工程此路径下Micrium\Software\EvalBoards\ST\STM3240G-EVAL\uCOS-III的8个文件

以及此路径下Micrium\Software\EvalBoards\ST\STM3240G-EVAL\uCOS-III\KeilMDK的两个文件
复制到跑马灯工程里面的此路径下:V5-001a_GPIO实验_跑马灯\User。
工程中需要的文件已经都复制到工程中了,下一步就是将这些文件添加到工程里面,并添加头文件路径。
l
第三步:在工程的左侧再建立四个组用于添加相应文件。
Ø
uC/CPU中添加如下6个文件,这6个文件位于路径:V5-001a_GPIO实验_跑马灯\uCOS-III\uC-LIB和路径V5-001a_GPIO实验_跑马灯\uCOS-III\uC-LIB\Ports\ARM-Cortex-M4\RealView
下面
Ø
uC/Lib中添加如下10个文件,这10个文件位于路径V5-001a_GPIO实验_跑马灯\uCOS-III\uC-CPU和路径V5-001a_GPIO实验_跑马灯\uCOS-III\uC-CPU\ARM-Cortex-M4\RealView
下面

Ø
uC/OS-III
Source中添加如下20个文件,这20个文件位于路径:V5-001a_GPIO实验_跑马灯\uCOS-III\uCOS-III\Source
下面

Ø
uC/OS-III
Port中添加如下3个文件,这3个文件位于路径:V5-001a_GPIO实验_跑马灯\uCOS-III\uCOS-III\Ports\ARM-Cortex-M4\Generic\RealView
下面
Ø
User中添加如下8个文件,这8个文件位于路径:V5-001a_GPIO实验_跑马灯\User
下面

上面这些文件添加完以后,一个完整的工程就算建立了,下面需要添加一下头文件的路径:

上面的工程建立好以后,修改部分文件后就可以下载到V5开发板运行了,需要修改的主要有以下几个文件:
l
main.c文件,用下面的内容覆盖原有内容,这里主要是建立4个LED闪烁的任务。
#include
static
OS_TCB
AppTaskStartTCB;
static
CPU_STK
AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE];
static
OS_TCB
AppTaskUpdateTCB;
static
CPU_STK
AppTaskUpdateStk[APP_CFG_TASK_UPDATE_STK_SIZE];
static
OS_TCB
AppTaskCOMTCB;
static
CPU_STK
AppTaskCOMStk[APP_CFG_TASK_COM_STK_SIZE];
static
OS_TCB
AppTaskUserIFTCB;
static
CPU_STK
AppTaskUserIFStk[APP_CFG_TASK_USER_IF_STK_SIZE];
static
void
AppTaskCreate
(void);
static
void
AppTaskStart
(void
*p_arg);
static
void
AppTaskUserIF
(void
*p_arg);
static
void
AppTaskCOM
(void
*p_arg);
int main(void)
{
OS_ERR err;
//
BSP_IntDisAll();
OSInit(&err);
OSTaskCreate((OS_TCB
*)&AppTaskStartTCB,
(CPU_CHAR
*)"App Task Start",
(OS_TASK_PTR
)AppTaskStart,
(void
*)0,
(OS_PRIO
)APP_CFG_TASK_START_PRIO,
(CPU_STK
*)&AppTaskStartStk[0],
(CPU_STK_SIZE
)APP_CFG_TASK_START_STK_SIZE / 10,
(CPU_STK_SIZE
)APP_CFG_TASK_START_STK_SIZE,
(OS_MSG_QTY
)0,
(OS_TICK
)0,
(void
*)0,
(OS_OPT
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR
*)&err);
OSStart(&err);
(void)&err;
return (0);
}
static
void AppTaskStart (void *p_arg)
{
OS_ERR
err;
(void)p_arg;
bsp_Init();
CPU_Init();
BSP_Tick_Init();
//
Mem_Init();
//
Math_Init();
#if OS_CFG_STAT_TASK_EN >
0u
OSStatTaskCPUUsageInit(&err);
#endif
#ifdef
CPU_CFG_INT_DIS_MEAS_EN
CPU_IntDisMeasMaxCurReset();
#endif
AppTaskCreate();
while (1)
{
bsp_LedToggle(1);
OSTimeDly(100, OS_OPT_TIME_DLY, &err);
}
}
static void
AppTaskGUIUpdate(void *p_arg)
{
OS_ERR
err;
(void)p_arg;
while(1)
{
bsp_LedToggle(2);
OSTimeDly(200, OS_OPT_TIME_DLY,
&err);
}
}
static void AppTaskCOM(void
*p_arg)
{
OS_ERR
err;
(void)p_arg;
while(1)
{
bsp_LedToggle(3);
OSTimeDly(300, OS_OPT_TIME_DLY,
&err);
}
}
static void AppTaskUserIF(void
*p_arg)
{
OS_ERR
err;
while (1)
{
bsp_LedToggle(4);
OSTimeDly(100, OS_OPT_TIME_DLY,
&err);
}
}
static
void AppTaskCreate (void)
{
OS_ERR
err;
OSTaskCreate((OS_TCB
*)&AppTaskUpdateTCB,
(CPU_CHAR
*)"App Task Update",
(OS_TASK_PTR
)AppTaskGUIUpdate,
(void
*)0,
(OS_PRIO
)APP_CFG_TASK_UPDATE_PRIO,
(CPU_STK
*)&AppTaskUpdateStk[0],
(CPU_STK_SIZE )APP_CFG_TASK_UPDATE_STK_SIZE /
10,
(CPU_STK_SIZE
)APP_CFG_TASK_UPDATE_STK_SIZE,
(OS_MSG_QTY
)1,
(OS_TICK
)0,
(void
*)0,
(OS_OPT
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR
*)&err);
OSTaskCreate((OS_TCB
*)&AppTaskCOMTCB,
(CPU_CHAR
*)"App Task COM",
(OS_TASK_PTR
)AppTaskCOM,
(void
*)0,
(OS_PRIO
)APP_CFG_TASK_COM_PRIO,
(CPU_STK
*)&AppTaskCOMStk[0],
(CPU_STK_SIZE )APP_CFG_TASK_COM_STK_SIZE /
10,
(CPU_STK_SIZE
)APP_CFG_TASK_COM_STK_SIZE,
(OS_MSG_QTY
)2,
(OS_TICK
)0,
(void
*)0,
(OS_OPT
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR
*)&err);
OSTaskCreate((OS_TCB
*)&AppTaskUserIFTCB,
(CPU_CHAR
*)"App Task UserIF",
(OS_TASK_PTR
)AppTaskUserIF,
(void
*)0,
(OS_PRIO
)APP_CFG_TASK_USER_IF_PRIO,
(CPU_STK
*)&AppTaskUserIFStk[0],
(CPU_STK_SIZE )APP_CFG_TASK_USER_IF_STK_SIZE /
10,
(CPU_STK_SIZE
)APP_CFG_TASK_USER_IF_STK_SIZE,
(OS_MSG_QTY
)0,
(OS_TICK
)0,
(void
*)0,
(OS_OPT
)(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR
*)&err);
}
l
includes文件,主要是添加必要的头文件,用下面的内容覆盖原有内容
#ifndef
INCLUDES_PRESENT
#define
INCLUDES_PRESENT
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
"app_cfg.h"
#if (APP_CFG_SERIAL_EN ==
DEF_ENABLED)
#include
#endif
#endif
l
修改bps.c和bsp.h文件。这个文件主要是初始化相关的驱动,用下面的内容覆盖原有内容
#include
void
NVIC_Configuration(void);
#define
BSP_REG_DEM_CR
(*(CPU_REG32 *)0xE000EDFC)
#define
BSP_REG_DWT_CR
(*(CPU_REG32 *)0xE0001000)
#define
BSP_REG_DWT_CYCCNT
(*(CPU_REG32 *)0xE0001004)
#define
BSP_REG_DBGMCU_CR
(*(CPU_REG32 *)0xE0042004)
#define
BSP_DBGMCU_CR_TRACE_IOEN_MASK
0x10
#define
BSP_DBGMCU_CR_TRACE_MODE_ASYNC
0x00
#define
BSP_DBGMCU_CR_TRACE_MODE_SYNC_01
0x40
#define
BSP_DBGMCU_CR_TRACE_MODE_SYNC_02
0x80
#define
BSP_DBGMCU_CR_TRACE_MODE_SYNC_04
0xC0
#define
BSP_DBGMCU_CR_TRACE_MODE_MASK
0xC0
#define
BSP_BIT_DEM_CR_TRCENA
DEF_BIT_24
#define
BSP_BIT_DWT_CR_CYCCNTENA
DEF_BIT_00
void bsp_Init(void)
{
NVIC_Configuration();
bsp_InitUart();
bsp_InitLed();
//
bsp_InitKey();
#ifdef
TRACE_EN
BSP_CPU_REG_DBGMCU_CR |=
BSP_DBGMCU_CR_TRACE_IOEN_MASK;
BSP_CPU_REG_DBGMCU_CR &=
~BSP_DBGMCU_CR_TRACE_MODE_MASK;
BSP_CPU_REG_DBGMCU_CR |=
BSP_DBGMCU_CR_TRACE_MODE_SYNC_04;
#endif
}
void
NVIC_Configuration(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
}
CPU_INT32U
BSP_CPU_ClkFreq (void)
{
RCC_ClocksTypeDef rcc_clocks;
RCC_GetClocksFreq(&rcc_clocks);
return ((CPU_INT32U)rcc_clocks.HCLK_Frequency);
}
void BSP_Tick_Init
(void)
{
CPU_INT32U cpu_clk_freq;
CPU_INT32U cnts;
cpu_clk_freq =
BSP_CPU_ClkFreq();
#if (OS_VERSION >=
30000u)
cnts = cpu_clk_freq /
(CPU_INT32U)OSCfg_TickRate_Hz;
#else
cnts = cpu_clk_freq /
(CPU_INT32U)OS_TICKS_PER_SEC;
#endif
OS_CPU_SysTickInit(cnts);
//
SysTick_Config(cnts);
//这里默认的是最低优先级
}
#if (CPU_CFG_TS_TMR_EN ==
DEF_ENABLED)
void
CPU_TS_TmrInit (void)
{
CPU_INT32U fclk_freq;
fclk_freq = BSP_CPU_ClkFreq();
BSP_REG_DEM_CR
|=
(CPU_INT32U)BSP_BIT_DEM_CR_TRCENA;
BSP_REG_DWT_CYCCNT = (CPU_INT32U)0u;
BSP_REG_DWT_CR
|= (CPU_INT32U)BSP_BIT_DWT_CR_CYCCNTENA;
CPU_TS_TmrFreqSet((CPU_TS_TMR_FREQ)fclk_freq);
}
#endif
#if (CPU_CFG_TS_TMR_EN ==
DEF_ENABLED)
CPU_TS_TMR
CPU_TS_TmrRd (void)
{
CPU_TS_TMR ts_tmr_cnts;
ts_tmr_cnts = (CPU_TS_TMR)BSP_REG_DWT_CYCCNT;
return (ts_tmr_cnts);
}
#endif
#if (CPU_CFG_TS_32_EN ==
DEF_ENABLED)
CPU_INT64U
CPU_TS32_to_uSec (CPU_TS32 ts_cnts)
{
CPU_INT64U ts_us;
CPU_INT64U fclk_freq;
fclk_freq =
BSP_CPU_ClkFreq();
ts_us
= ts_cnts / (fclk_freq / DEF_TIME_NBR_uS_PER_SEC);
return (ts_us);
}
#endif
#if (CPU_CFG_TS_64_EN ==
DEF_ENABLED)
CPU_INT64U
CPU_TS64_to_uSec (CPU_TS64 ts_cnts)
{
CPU_INT64U ts_us;
CPU_INT64U fclk_freq;
fclk_freq =
BSP_CPU_ClkFreq();
ts_us
= ts_cnts / (fclk_freq / DEF_TIME_NBR_uS_PER_SEC);
return (ts_us);
}
#endif
#ifndef _BSP_H_
#define _BSP_H
#define STM32_V5
//#define STM32_X3
#if !defined (STM32_V5)
&& !defined (STM32_X3)
#error "Please define the board model : STM32_X3 or
STM32_V5"
#endif
#define
__STM32F1_BSP_VERSION
"1.1"
#define
ENABLE_INT()
__set_PRIMASK(0)
#define
DISABLE_INT()
__set_PRIMASK(1)
#define
BSP_Printf
printf
//#define
BSP_Printf(...)
#include
"stm32f4xx.h"
#include
#include
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#include
"bsp_uart_fifo.h"
#include "bsp_led.h"
#include
"bsp_timer.h"
#include "bsp_key.h"
#include "bsp_dwt.h"
//#include
"bsp_spi_flash.h"
//#include
"bsp_cpu_flash.h"
//#include
"bsp_sdio_sd.h"
//#include
"bsp_i2c_gpio.h"
//#include
"bsp_eeprom_24xx.h"
//#include
"bsp_si4730.h"
//#include
"bsp_hmc5883l.h"
//#include
"bsp_mpu6050.h"
//#include
"bsp_bh1750.h"
//#include
"bsp_bmp085.h"
//#include
"bsp_wm8978.h"
//#include
"bsp_fsmc_sram.h"
//#include
"bsp_nand_flash.h"
//#include
"bsp_nor_flash.h"
//#include
"LCD_RA8875.h"
//#include
"LCD_SPFD5420.h"
//#include
"bsp_touch.h"
//#include
"bsp_camera.h"
//#include
"bsp_ad7606.h"
//#include
"bsp_gps.h"
//#include
"bsp_oled.h"
//#include
"bsp_mg323.h"
void bsp_Init(void);
void bsp_Idle(void);
void BSP_Tick_Init
(void);
#endif
l
startup_stm32f40_41xxx.s文件,修改这个文件中Systick和PendSV中断入口名,以便于和μCOS-III中命名统一。
DCD
OS_CPU_PendSVHandler
DCD
OS_CPU_SysTickHandler
OS_CPU_PendSVHandler
PROC
EXPORT
OS_CPU_PendSVHandler
[WEAK]
B
.
ENDP
OS_CPU_SysTickHandler
PROC
EXPORT
OS_CPU_SysTickHandler
[WEAK]
B
.
ENDP
l
最后一步是去掉BSP文件组中的bsp_timer.c文件,因为这个文件是SysTick的驱动和μCOS-III中的驱动冲突了。同时要关闭FPU,因为咱们移植的port文件里面没有做FPU的支持。

上面这几步完成后,编译,链接,下载程序到开发板上,可以看到4个LED闪烁。至此μCOS-III的简单移植就完成了。
加载中,请稍候......