Porting UCOS II
To run μC/OS-ⅱ properly, the processor must meet the following requirements:
1. The C compiler of the processor can generate reusable code.
2. enable or disable the interrupt in C.
3. The processor supports interruption and can generate scheduled interruption (usually between 10 to Hz ).
4. The processor supports a hardware stack that can hold a certain amount of data (may be several thousand bytes ).
5. The processor reads and stores the stack pointer and other CPU registers into the stack or memory.
Baidu click "reentrant code ". Reentry code is also called pure code. It is a code that allows multiple processes to access at the same time.
Ucos ii is a preemptible kernel. It is understandable to have such requirements. If this task calls this code, it is complete. When the next task calls it, it becomes incomplete. What should I do next? This reminds me of the first time a girl was writing.
According to the above requirements, in fact, in practice, there are very few microprocessor compatible with ucos ii. Therefore, you can use ucos ii with confidence, boldness, and arrogance.
In general, to port ucos ii to a chip, you only need to modify the following three files: OS _cpu.h, OS _cpu_c.c, OS _cpu_a.asm.
Specifically, porting mainly includes the following items:
(1). OS _cpu.h: Use # define to set some constant values, declare 10 data types, and use # define to declare three macros.
(2). OS _cpu_c.c: Write six simple functions in C language.
(3). OS _cpu_a.asm: Compile four assembly language functions.
At first glance, the workload and difficulty of porting ucos ii are very small. But it is not easy for a beginner. It requires familiarity with microprocessor, assembly, and ucos ii.
In the mc21's project, mc21's students carried forward the spirit of the doctrine and directly referred to the template provided by Zhou ligong.