QP transplant

 To the STM32 platform, for example, the microcontroller core ARM Cortex-M series is what the QP long-term support, so QP on the ARM Cortex-M series kernel have a long-proven.

  Routine matching books PSICC2 in the most primitive version QP 4.0.00 (IAR routine only, of course, you can modify the assembly file qk_port.s applicable to other compilers), the latest version of the current (2017/04/01) is 5.8.2 (direct support gnu, iar, arm compiler), the following are the latest version, for example. (Seen from 4.0.00 to version 5.8.2 Revision History, an official fix a lot of bug).

qpc5.8.2 folders and files:

qpc\

| + -3rd_party \ - related hardware, stm32f4, stm32f7, tms and other mcu drivers generally do not need transplants, with our common past (including the CMSIS standard (ARM Cortex), related to the specific type of MCU lib of .c /. h)

| + -Source \ -qp framework of the source file (src.c), copied directly transplant

| + -Include \ -qp frame header file (src.h), copied directly transplant

| + -Ports \ - the store with mcu core, qp scheduling, compiler interface-related functions, need to select the appropriate folder

| | + -Arm7-9 \

| | + -Arm-cm \ - for example, to select MCU our common core Cortex-M Series

| | | + -Qk \ - for example, with preemptive kernel qp framework qk

| | | | + -Arm \ - for example establishing engineering keil (ARMCC compiler)

| | | | + -And \

|     |     |     |     +-...\

|     |     |     +-qv\

| | | + -Qxk \

|     |     +-msp430\

|     |     +-...\

| + -Examples \ - official routine: Store official routine application layer (state machine), hardware abstraction layer (bsp.c), do not need transplants, can refer to write your own programs.

| | + -Arm-cm \ -Cortex-M series MCU routine

| | | + -Game_efm32-slstk3401a \ -PSICC books about flying and shooting game

| | | | + -Bsp.c - hardware abstraction function, this file can copy and modify according to their needs

| | | | + -Main.c - the main function, the main function to establish their own reference works contain qp framework initialization

| | | | + -... - reference to other state machine functions to get started writing your own state machine

| | | + -... \ other routine functions

| | + -... \ other MCU routines

Transplant finished first attempt to establish a state machine, a simple switch the state to produce an event, the event dispatcher, event subscription / distribution, event handling, scheduled tasks, delay tasks, you can test out the framework document has not missed transplantation.

After the migration is complete use need to pay attention to:

1, QS are not necessary, is a debugger, print the information needs to occupy a serial port.

2, Q_onAssert () is asserted, in many qp framework is used to assist in prompt, when there is a problem (such as queue overflow, overflow memory pool, the event dispatcher failure, etc.) assertion is triggered when (the official routine is triggered into while () loop, led flashing can be modified to operate we need, such as printing an error message), this is used to debug, product lines need to turn this feature off.

3, the frame recovery event qp QF_gc () function during recovery event, the event will not clear the contents of the memory block corresponding to the event, only the pointer link memory block free block list for future use (the global memory pool event, survival of the entire program is run), if you create an event carrying the parameters, but not every parameter of the event to create a completely refilled, this may cause garbage data reuse.

4, QtimeEvt time event list for each event unique time, for example, sending a time event A: 2s post processing task B. If 2s does not arrive and they want to create a time event A, this time will trigger assertion. You can modify QTimeEvt_armX () function, there are two commonly used approach to the start time, whichever is first created, whichever is the last time you created.

5, with preemptive kernel qk frame, longer if a high priority state machine processing time is present, more frequent tasks, note the low priority state machine prone message queue overflows, the corresponding memory pool overflow event, because of the low priority state machine is preempted, the event no response.

6, see the book mentioned on the need to avoid mistakes PSICC2

7, please add ...

Third, learning materials and accessories

1, the official website home page, download page: https: //state-machine.com/ (fully open source, official information provided quite complete)

2、官方Revision History:http://www.state-machine.com/qpc/blinky.html

3, http: //www.cnblogs.com/hyper99/archive/2015/11/01/QP-zhiQF-yuan-li.html

4, AN_ARM-Cortex-M_Interrupt-Priorities.pdf (interrupt priority!), PSiCC2-CN.pdf (textbooks, English has official under)

Guess you like

Origin www.cnblogs.com/water-sea/p/12059394.html