1. Knowledge preparation To have a deeper understanding of the UCOS-II porting, two aspects of knowledge are required: (1) Target chip. Here is the LPC17xx series chip. They are all based on the ARMv7 Cortex-M3 core. So the UCOS-II porting of this type of chip is almost the same. To understand the Cortex-M3 core, we recommend "ARM Cortex-M3 Authoritative Guide" (translated by Song Yan); (2) UCOS-II core principle. We recommend "Embedded Real-Time Operating System uC/OS-II (2nd Edition)" (translated by Shao Beibei). 2. Download files The ucos-ii porting process mainly involves three files: os_cpu.h, os_cpu_a.asm and os_cpu_c.c In fact, under normal circumstances, the target chip we want to port has already been successfully ported by our predecessors, and all we need to do is download it. You need to download two types of files: (1) LPC17xx chip startup/initialization code: LPC17xx.h, system_LPC17xx.h, core_cm3.h, core_cm3.c, startup_LPC17xx.s and system_LPC17xx.c. These files can be found in any project of LPC17xx series chips from the LPC official website; (2) UCOS-II porting code: The uCOS-II porting code on LPC17xx can be found on the Micrium official website (IAR platform). 3. Create a project (1) Create a folder UCOS_II_V289, and create sub-directories APP, lpc17xx, Output, uC-CPU, UCOS-II in this directory. Create obj and list sub-directories under Output, and then add the files downloaded in step 2 to the corresponding folders. The file topology is as follows: UCOS_II_V289 (1) Create a folder UCOS_II_V289, and create sub-directories APP, lpc17xx, Output, uC-CPU, UCOS-II in this directory. Create sub-directories obj and list under Output, and then add the files downloaded in step 2 to the corresponding folders. The file topology is as follows: UCOS_II_V289 (1) Create a folder UCOS_II_V289, and create sub-directories APP, lpc17xx, Output, uC-CPU, UCOS-II in this directory. Create sub-directories obj and list under Output, and then add the files downloaded in step 2 to the corresponding folders. The file topology is as follows: hello.c │ ├─lpc17xx │ core_cm3.c │ core_cm3.h │ LPC17xx.h │ startup_LPC17xx.s │ system_LPC17xx.c │ system_LPC17xx.h │ type.h[ /backcolor] │ ├─Output │ ├─list[/ backcolor] │ └─obj ├─uC-CPU │ os_cpu.h [color=#00000 0]│ os_cpu_a.asm
│ os_cpu_c.c
│ os_dbg.c
│
└─uCOS-II
app_cfg.h
os_cfg.h
os_core.c
os_flag.c
os_mbox.c
os_mem.c
os_mutex.c
os_q.c
os_sem.c
os_task.c
os_time.c
os_tmr.c
ucos_ii.h
其中,hello.c中的文件代码如下:
(2)Keil uVision4创建新工程,选择UCOS_II_V289作为工程目录,选择芯片型号,需要注意的是当提示“Copy NXP LPC17xx Startup Code to Project Folder and Add File to Project?”时,选择“否”,因为我们已经有这个文件了。创建组,添加相应文件到组.