Changsha BSL Info. Tech. CO.,Ltd.

Honesty is the foundation, Dare to innovate

+86-13913227693

+86-13632930703

Column

Free Hotline

8613913227693

The birth of embedded micro system MSOs

In order to solve the problem of multi person cooperation, multi demand product development and long-term maintenance, we must extract the commonness of these products.


1. No low power design is required.


2. Sensor class and driver class belong to a single function of the device, the traditional front background architecture of MS3 can be.


3. Power supply and control equipment are complex, high real-time requirements, with screen display, external expansion of multi-channel sensors or drivers. These two types can be unified into one type, which is the focus of design, and need to establish a new platform.


So what should this new platform look like? I still have no idea in my mind. I just know that in the design of high frequency machine, the traditional menu interface programming mode of state machine or function pointer mode needs to be improved. Although I have worked in a mobile phone company for nearly two years in mobile phone driver development, I have been working in hardware since then. Later, I started a business, so the level of embedded software has remained at MS3 level without improvement. For the design of this new platform, first of all, I need to consult software experts. Especially in the past so many years, software development has changed greatly.


Fortunately, our company's foundation is to make mobile phones, and the mainstream is MTK mobile phone solution. In addition, we have made an industrial handset based on WinCE, so we have all kinds of professional software personnel, who are very familiar with C, Java and C #. Among many software personnel, Su Peng is especially grateful. He is good at Linux, and then he is responsible for the maintenance of MTK mobile phone development platform, and also needs to develop java applications. At that time, he also happened to participate in the development of infrared temperature sensor based on MS3, so he has a certain concept of embedded, and is very good at large-scale software programming, so when I  put forward my requirements, He knows exactly what I want to do.


Su Peng thinks that MS3 is a good thing, simple and easy to use, and can't be easily abandoned. So the first step is to refactor MS3 and introduce the current mainstream idea of object-oriented menu interface programming. This refactoring took nearly a month, because MS3 is front-end and back-end, with only one big cycle. Based on the message mechanism, many events are processed in a big cycle, When the menu interface is parsed in a large loop, because the display of the menu interface is a low-speed event, which will seriously affect the high-speed event and make the message mechanism in MS3 invalid, the object-oriented menu interface programming can not be realized, but some functions are formally realized without using this code, But it also laid the foundation for the later real implementation of object-oriented menu interface programming, and realized that MS3, which has only one big loop architecture, can't realize the real object-oriented menu interface programming. It must introduce preemptive multitasking operating system, put the menu interface in the lowest priority task, and other message event processing (message event processing, It's also called business logic processing, which is expressed by business logic in the future. In this way, at least two tasks are required. So the next thing is to select RTOS and understand it deeply.


The first thing to consider is UC / OS-II, because it has the most information, a wide range of users, and has been in touch with a little before. Although it is not in-depth, it is emotionally preferred. In addition, some colleagues recommended FreeRTOS and RT thread in China. FreeRTOS is similar to UC / OS-II, but its popularity is too low, and its information and customer base are very few. Although it is free, it still gives up. RT thread programming style is Linux. I don't like Linux style. It's not good-looking and elegant. Secondly, its popularity is far less than that of UC / OS-II, and its reliability and stability are questionable. Its GUI is suitable for color screen, relatively complex, and not suitable for black-and-white industrial occasions, so I gave it up.


After selecting UC / OS-II, we must deeply understand every detail of it. The first thing we encounter is that UC / OS-II has too many macro definitions, because it needs to be tailorable and configurable, but there are actually a lot of functions that can't be used. So I start with simplification, and keep the functions that may be used in the new platform, and remove all the others. In this way, there will be no annoying macro definitions, Many netizens also complain that these macro definitions seriously interfere with the code reading of UC / OS-II.


By streamlining UC / OS-II, we have a deep grasp of its principle. At this time, the requirements of the new platform are becoming more and more clear. Most of the requirements only need two tasks, one is menu interface task, and the other is business logic task. There are no 64 tasks at all. Therefore, we have greatly modified and reconstructed UC / OS-II, eliminating idle tasks and statistical tasks, In this way, only two tasks are needed.


In order to consider the expansibility of tasks in the future, the task table is retained, but it is simplified to support 8 tasks. In order to reduce the memory consumption of OS and further simplify the OS kernel, the original task block based on linked list structure is changed to array structure. Such a very simple UC / OS-II came out, just two files.


The simplified and reconstructed kernel only retains the task switching function of UC / OS-II, and all RTOS have this function, and they are similar, so it has been separated from UC / OS-II. It's just that the kernel starts to originate from UC / OS-II with the same style, so it still retains its name, but it doesn't belong to UC / OS-II in essence, so there is no copyright problem, If you only need to use two tasks, the new platform also provides a way of soft interrupt to achieve dual tasks, which does not need RTOS at all.


After the introduction of RTOS to achieve multitasking, the architecture of the new platform has emerged. The next thing to do is to determine the software architecture, which must be found from the modern mature software architecture. After communicating with colleagues, they all mentioned object-oriented design, but this needs to use C + +, but C + + in embedded system is not popular, and I can't, so it's impossible to choose C + +. Later, I thought of using the conventional C language to write an object-oriented style similar to C + +, but after referring to the online code, I felt that the C language was more complicated, very awkward, and became four unlike. After that, I learned about Java, but I didn't feel that this style was very suitable. Until Hou Deping, a colleague in charge of C #, suggested using C #, and showed me the advantages of C #, he let my eyes shine. This is what I want.


1. Elegant programming style, simple and easy to use long naming rules are easily accepted by developers, abandoning the complicated Hungarian naming method.


2. System, the concept of namespace, can encapsulate the whole system layer and separate the application layer, which can improve the reusability and stability of the code.


3. C # is object-oriented, but it is much simpler than C + +. We can use the structure of C language to simulate the namespace and class, and write C language in C # style.


4. Microsoft's programming environment is especially suitable for the industrial industry, whether PC or wince embedded devices, C #, can be universal. In this way, after the embedded end is developed with the new platform, it is C # style, and it is easy to master the C # programming of PC end.


At this point, the whole framework is basically formed, but how to further subdivide the system layer? At this time, Su Peng suggested to refer to arm's CMSIS standard.


In order to improve the portability, the device layer is introduced into the hardware driver layer, OS, GUI and other middleware layers. So far, the framework of the whole software architecture is basically established.


Previous: How does embedded chip connect with development platform? Next: 2024 Laser World of Photonics China——Waiting For You
Tips: This website needs to enter a password to access
wrong password,try again