Design of embedded software programming interface library to support automotive electronics
2026-04-06 08:32:44··#1
Abstract: This paper introduces the content and design method of an embedded software platform programming interface library supporting automotive electronics. This interface library provides a basic programming interface library based on commonly used algorithms in the automotive electronics field, a dedicated programming interface library based on low-level hardware driver functions, and an API function library designed for specific systems. The system uses the MPC555 as the hardware platform, and users can perform calculations and hardware operations by calling the API functions provided by the interface library. This hierarchical design also facilitates the maintenance of the interface library and the porting of new platforms. Keywords: API; Embedded system; Application algorithm; Low-level driver Introduction In recent years, with the rapid development of electronic science and computer technology, the application of automotive electronic equipment has increased significantly. Currently, the level of domestic automotive electronics technology still lags far behind that of foreign automakers, especially in engine electronic control, where there are no independent development precedents in China. The diesel engine electronic control system embedded software platform introduced in this paper is an automotive electronics-oriented system platform that follows the OSEK standard and is applied to automotive powertrain control. The software platform consists of a microsystem kernel and an application programming interface library. The embedded operating system kernel is responsible for task scheduling and event handling, while the programming interface library encapsulates commonly used algorithms and driver functions for the MPC555 low-level hardware at the control level for user calls. In embedded systems, developers can implement common computational functions and routine hardware operations by calling existing API functions in the programming interface library. Figure 1 shows the hierarchical diagram of the engine electronic control system. The entire electronic control system comprises four layers: hardware platform, low-level driver, embedded software platform, and upper-level user. The relationships between these layers are shown in Figure 1. Hardware Platform Introduction The main control CPU of the engine electronic control system hardware platform is the MPC555, a high-performance 32-bit microcontroller designed specifically for high-end embedded control systems in automotive electronics, aerospace, and intelligent systems. Its unique feature is its floating-point arithmetic unit, supporting direct programming of floating-point code. Furthermore, the MPC555 has a programmable time processing module, which can be independently programmed to process complex periodic signals from the engine crankshaft and camshaft without requiring an external CPU, thus greatly simplifying software and hardware design. Figure 2 shows the hardware circuit structure of the engine electronic control system. The engine electronic control system, designed with the MPC555 as the core control unit and supplemented by corresponding input signal processing, output control, and communication units, is illustrated in Figure 2. Introduction to the Embedded Operating System Kernel This embedded operating system is an ultra-miniature, real-time, and secure embedded operating system kernel built using the MPC555/MPC556 microcontroller as the hardware platform and referencing the European OSEK standard. The system provides users with various task scheduling, event handling, and interrupt response mechanisms, and the operating system manages the switching and information transfer between tasks. To meet the system's real-time requirements, the operating system's task management adopts a preemptive task mechanism based on task priority. Tasks exchange variables and information through message mailboxes and message queues. Furthermore, the system kernel utilizes an open-source mechanism, and through customization and porting, it can support various mainstream international processors. Figure 3 shows the structure of the embedded operating system kernel supporting automotive electronics. The functional structure of this embedded operating system kernel is shown in Figure 3. Embedded Programming Interface Library Design The design of the application programming interface library encapsulates the common algorithms and basic hardware operations required by the engine electronic control system into function form, embedding them in the operating system to provide developers with a user-friendly and secure software platform. Figure 4 shows the structure of the embedded programming interface library supporting automotive electronics. Embedded Basic Programming Interface Library The embedded basic programming interface library refers to a programming interface library commonly used in various industries for electronic control. This library uses existing vehicle data as simulation data to verify control algorithms and linear interpolation algorithm library functions, and the data structure conforms to the ASAP2 standard. This interface library provides users with a complete set of commonly used algorithm functions and basic operations in development, encapsulating typical algorithms and operations at the control level, providing a complete and universal system call function library for applications. This function library mainly includes: 1. 2D and 3D linear interpolation algorithm interface library: In two-dimensional and three-dimensional tables, linear interpolation is used to obtain function values corresponding to the input quantities, used for engine control parameter lookup algorithms. 2. PID controller algorithm interface library: The PID controller is a type of linear controller. It uses the given value and the actual output value to form the control deviation, and combines the proportional, integral, and derivative of the deviation linearly to form the control quantity, mainly used to control the fuel injection output signal. 3. Smoothing and Filtering Algorithm Interface Library: Primarily used for smoothing and debouncing the acquired analog signals. 4. Interface libraries for commonly used control algorithms and signal processing functions in other automotive electronic control systems. The embedded basic programming interface library is designed for two purposes: first, to facilitate application calls, increasing program reliability and programming efficiency; second, to standardize processing methods, allowing programs to be ported to different hardware platforms without changing the program structure, eliminating the need for software developers to repeatedly program some typical algorithms and operations. Embedded Dedicated Programming Interface Library The embedded dedicated programming interface library refers to a system-specific programming interface library designed for the special hardware needs of specific diesel engines and ECUs. This interface library is designed in accordance with the OSEK operating system calling specifications, providing users with drivers for various functional modules of the underlying MPC555 hardware, and completing basic data processing work for automotive electronics, providing callable functions in the software aspect. The embedded dedicated programming interface library mainly includes: 1. Analog Input Detection and Processing Interface Library: Sensor signals such as engine temperature and pressure are acquired in voltage form by the analog channels of the ECU. Signal acquisition can be done by calling an acquisition function as needed, or by setting the QADC unit to automatically acquire signals sequentially according to the timer cycle. During system initialization, the user can set the acquisition method for each channel according to specific circumstances. 2. Digital Input/Output Interface Library: Used to acquire and debouncing digital signals such as clutch and brake signals, assigning the results to designated global variables for the user to read when needed. Digital outputs such as sensor power supply and turbocharger control are achieved by directly calling the corresponding functions to output high and low levels from the pins. The pin direction of the I/O ports is set according to the hardware design during system initialization. 3. Periodic Input Detection and Output Control Interface Library: The time processing unit (TPU) integrated within the MPC555 microcontroller has built-in crankshaft/camshaft signal detection and fuel injection signal output control functions. To facilitate user use, we have encapsulated each function as a low-level driver function, which users can call to set the TPU's operating mode. 4. Other driver function interface libraries related to microcontroller hardware. The low-level driver interface library serves as a bridge between automotive electronics developers and the underlying hardware system, allowing developers to focus on automotive control algorithm design while minimizing their reliance on the underlying hardware. Users can easily manipulate the MPC555 low-level hardware by calling the low-level driver interface functions. Embedded API Function Library Based on the aforementioned algorithms and low-level driver function libraries, and considering the specific needs and functions of this control system while maintaining versatility in the automotive electronics field, we have further encapsulated the functions, algorithms, and various operations, providing users with a more standardized API function library and greatly enhancing user convenience. The API function library includes input processing and output control functions for various engine signals, enabling more specific functionalities. For example, in the engine fuel injection control function, an interrupt is generated when the system detects a missing tooth position on the crankshaft signal. Based on the measured engine speed, various temperature and pressure parameters, and the states of idle speed, brakes, and other switches, the system sets the start time and pulse width of the fuel injection output signal, thereby controlling engine performance. Conclusion This paper introduces the content and design method of an embedded programming interface library supporting automotive electronics. The interface library provides various API functions that can be directly called by the system to implement common algorithms and hardware operations. The interface library is designed relatively independently, enabling parallel development with the hardware platform, operating system, and control algorithms, followed by unified debugging, significantly shortening development time. Simultaneously, this hierarchical design philosophy makes the interface library more universal and standardized, allowing for simple modifications and portability to new software and hardware platforms, improving code reusability and giving it high practical value. References: 1. MPC555 / MPC556 USER'S MANUAL, Motorola Corporation data; 2. Zhu Jun (ed.), Waveform Analysis of Electronic Control Engine Circuits, Machinery Industry Press, 2003.09; 3. Huangfu Jian (ed.), Modern Automotive Electronic Technology and Devices, Beijing Institute of Technology Press, 1999.09; 4. Wang Shangyong and Yang Qing (eds.), Diesel Engine Electronic Control Technology, Machinery Industry Press, 2005.01;