But if the device is on a chip peripherals, ADC, for example, if you define hal_adc_init (), then the application layer directly call HAL layer, or put the initialization ADC driver layer, if on the driver layer, it is an initialization function, feel no sense,
CodePudding user response:
On the record about the consideration of software layers,USES the object-oriented thought, whether on a chip peripherals or other devices, each as a separate device, such as on-chip ADC1, ADC2 this is two devices, each device has its own driver, because here on equipment, it will drive layer to equipment, some equipment need on-chip peripherals support, such as IO operations, a HAL layer in the layer, so the equipment for on-chip peripherals, HAL layer,
Emphasize that the HAL layer belong to equipment, is part of the device driver, transplantation, modify the HAL layer can,
CodePudding user response:
In the design of software framework, and met a problem: how equipment layer and application layer data interaction?CodePudding user response:
Although data from equipment, need what kind of data, how to deal with data depends on the application layer, different applications might require different data, so will all of the data defined in the application layer,Data interaction function return value or by parameter manner, parameter can be a value to pass or address, specific choose which kind of, in practice to consider,
The main principle: only defined in the application layer data,
CodePudding user response:
Embedded system software layer is targeted, based on the model of programming and scheduler (freertos, ucos, etc.) and special VxWorks, Linux, wince stratified not exactlyIn general, like most of control software, the interface is not too much and portability requirements, not excessive packaging, such as voltage acquisition into adc operation and the output voltage calculation,
You might say, can have on a chip ADC and SPI/IIC ADC, but at the moment can rewrite voltage acquisition corresponding files directly, because usually small embedded system software, or simply as a failure, or write a driver directly, such as Linux system can realize the dynamic loading,
CodePudding user response:
Thank upstairs comments, I hope we will make a lot of point of view, people there are always unexpected places, all firewood high flame,Upstairs said stratification based on the operating system, which conforms to the traditional principle of operating system, because the most basic principle, hardware and operating system management, provide the interface, but I don't intend to here with the operating system as the core, but going to equipment as the core, there are two reasons, because of the embedded mainly to deal with a variety of hardware, 2 it is equipment is relatively independent, naturally can be cut, and the function of the operating system, only keep task scheduling and management, and is included in the way of service, and semaphores, message queues, timer, etc., and all kinds of software functions, such as FIFO, CRC, such as PID are provided in separate service way,
About rewriting it, tell me about my real experience, because as the upstairs said, basically different project, program is written again, I tell the truth, is not big, is not difficult to read, so to each program, even if the same function, implementation is different also, of course, unless the copy and paste, if really rewrite, this year and last year's idea will be a little different, this is also I want to design an application framework, the main reasons for because if use a framework, even if the idea has changed, can be classified as framework of upgrade, this is an ongoing process, not like in each program, the change of clutter is unable to continue,