Transplantation of UCOS-II on lpc2210 -- OS _cpu.h
CPU: Philips ARM7 lpc2210
OS: uC/OS-II 2.52
IDE: ADS 1.2
Porting an operating system to a CPU architecture requires the following:
1. Have a deep understanding of the target architecture-arm Architecture Reference Manual
2. Have a deep understanding of the operating system principle -- embedded real-time operating system uC/OS-II
3. Have a deep understanding of the compilers used-the analyticdb compiler and connector Manual
4. Have a good understanding of the operating system to be transplanted-embedded real-time operating system uC/OS-II
5. Have a certain understanding of the specific chip used-the chip data manual
Write OS _cpu.h
/*************************************** **************************************** **************************
** Start of File
**************************************** **************************************** ************************/
# Ifdef OS _cpu_globals
# Define OS _cpu_ext
# Else
# Define OS _cpu_ext extern
# Endif
/*************************************** **************************************** ***************************
* Define data types irrelevant to the Compiler
**************************************** **************************************** **************************/
Typedef unsigned char Boolean;/* Boolean variable */
Typedef unsigned char int8u;/* unsigned 8-bit integer variable */
Typedef signed Char int8s;/* signed 8-bit integer variable */
Typedef unsigned short int16u;/* unsigned 16-bit integer variable */
Typedef signed short int16s;/* signed 16-bit integer variable */
Typedef unsigned int int32u;/* unsigned 32-bit integer variable */
Typedef signed int int32s;/* signed 32-bit integer variable */
Typedef float fp32;/* single-precision floating point number (32-bit length )*/
Typedef double fp64;/* double-precision floating point number (64-bit length )*/
Typedef int32u OS _stk;/* the stack is a 32-Bit Width */
/* The following data types are compatible with uC/OS v1.xx and are not used in UC/OS-II */
# Define byte int8s
# Define ubyte int8u
# Define word int16s
# Define uword int16u
# Define long int32s
# Define ulong int32u
/*************************************** **************************************** ***************************
* Some definitions related to the ARM7 architecture
**************************************** **************************************** **************************/
# Define OS _critical_method 2/* select the on/off mode */
// A keyword _ SWI of ADS is used here to declare a function that does not exist. Then, to call this function, insert
// SWI command, and the function number can be specified. At the same time, its transfer rules are the same as general functions.
_ SWI (0x00) void OS _task_sw (void);/* task-level task switching function */
_ SWI (0x01) void _ osstarthighrdy (void);/* run the task with the highest priority */
_ SWI (0x02) void OS _enter_critical (void);/* Guanzhong disconnection */
_ SWI (0x03) void OS _exit_critical (void);/* Open interrupt */
_ SWI (0x40) void * getosfunctionaddr (INT index);/* Get system service function entry */
_ SWI (0x41) void * getusrfunctionaddr (INT index);/* Get the UDF entry */
_ SWI (0x42) void osisrbegin (void);/* start to process the interrupt */
_ SWI (0x43) int osisrneedswap (void);/* determine whether to switch the interrupt */
_ SWI (0x80) void changetosysmode (void);/* switch the task to system mode */
_ SWI (0x81) void changetousrmode (void);/* switch the task to user mode */
_ SWI (0x82) void taskisarm (int8u PRIO);/* The task code is the arm Code */
_ SWI (0x83) void taskisthumb (int8u PRIO);/* The task code is thumb */
# Define OS _stk_growth 1/* the stack is long from top to bottom */
# Define usr32mode 0x10/* User Mode */
# Define sys32mode 0x1f/* system mode */
# Define noint 0x80/* 0x80 = 10000000 set IRQ */
# Ifndef user_using_mode
# Define user_using_mode usr32mode/* default Task Mode --- user mode */
# Endif
# Ifndef OS _self_en
# Define OS _self_en 0/* allow the returned OS and tasks to be compiled and solidified separately */
# Endif
OS _cpu_ext int32u osentersum;/* Guanzhong disconnection counter (semaphore for switch interruption )*/
// Osentersum is a global variable defined by the author. It is mainly used to save the number of Guanzhong disconnections, so that the switch interrupt can be nested.
/*************************************** **************************************** **************************
** End of File
**************************************** **************************************** ************************/