CN111913783B - Single-chip microcomputer USB software development system and method based on objectification - Google Patents

Single-chip microcomputer USB software development system and method based on objectification Download PDF

Info

Publication number
CN111913783B
CN111913783B CN202011092431.7A CN202011092431A CN111913783B CN 111913783 B CN111913783 B CN 111913783B CN 202011092431 A CN202011092431 A CN 202011092431A CN 111913783 B CN111913783 B CN 111913783B
Authority
CN
China
Prior art keywords
usb
interface
equipment
virtual
interrupt
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011092431.7A
Other languages
Chinese (zh)
Other versions
CN111913783A (en
Inventor
樊驰舟
周红卫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Runhe Technology Investment Group Co Ltd
Jiangsu Hoperun Software Co ltd
Original Assignee
Jiangsu Runhe Technology Investment Group Co Ltd
Jiangsu Hoperun Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu Runhe Technology Investment Group Co Ltd, Jiangsu Hoperun Software Co ltd filed Critical Jiangsu Runhe Technology Investment Group Co Ltd
Priority to CN202011092431.7A priority Critical patent/CN111913783B/en
Publication of CN111913783A publication Critical patent/CN111913783A/en
Application granted granted Critical
Publication of CN111913783B publication Critical patent/CN111913783B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Abstract

The invention provides a system and a method for developing USB software based on an objectification-oriented singlechip, which comprises STM32 interrupt service, a USB HAL library, a virtual USB equipment object and a USB equipment registration module, wherein the STM32 interrupt service provides an inlet for responding USB interrupt; the USB HAL library provides a standard function interface for realizing USB data interrupt callback, control interrupt callback and API call of the operations; the virtual USB equipment object is associated with a standard function interface of a USB HAL library and is used for realizing USB data transmission, event response, functional operation and basic configuration of the virtual USB equipment object; the USB equipment registration module is used for setting respective operation methods of the USB equipment and is associated with function operation in the virtual USB equipment. The invention associates the device object function operation module with the USB device, thereby facilitating the switching of different USB devices.

Description

Single-chip microcomputer USB software development system and method based on objectification
Technical Field
The invention relates to a program processing method based on objectification and a single-chip microcomputer USB software development method, in particular to a single-chip microcomputer USB software development method based on objectification.
Background
The intelligent fusion terminal in the national power grid adopts the design of combining the CPU and the MCU at present, and the communication between the CPU and the MCU adopts the USB bus communication, so the USB bus communication is particularly important in the intelligent fusion terminal. The USB bus is used as a high-speed serial bus, the application environment requirement of high-speed data transmission can be met due to the extremely high transmission speed, a plurality of peripherals can be hung, four transmission modes are supported, the compatibility is good, and the requirement of intelligent fusion terminal equipment on the real-time property is met.
However, in the actual development of the single chip USB, the general chip SDK does not support the multifunctional configuration and function switching of the USB device, and the enumeration process is complex, and different MCUs have different USB drivers, and the USB interfaces are also divided into high-speed, full-speed and low-speed interfaces, which greatly increase the work difficulty and workload of development, are not favorable for the stability of the system and the requirements of transplantable communication, and may ultimately affect the requirements of real-time performance and stability of the internal communication of the device.
Disclosure of Invention
The invention aims to provide a USB software development method based on an objectification-oriented single chip microcomputer.
The technical solution for realizing the purpose of the invention is as follows: a USB software development system based on an objectification-oriented single chip microcomputer comprises an STM32 interrupt service, a USB HAL library, a virtual USB device object and a USB device registration module, wherein the STM32 interrupt service is used for providing an inlet for responding USB interrupt; the USB HAL library is used for providing a standard function interface for realizing operations of USB data interrupt callback, control interrupt callback and API call; the virtual USB equipment object is associated with a standard function interface of the USB HAL library and is used for realizing USB data transmission, event response, functional operation and basic configuration of the virtual USB equipment object; the USB equipment registration module is used for registering information of the USB equipment, comprises respective operation methods of the USB equipment and is associated with function operation in the virtual USB equipment, and when the USB equipment needs to be operated, the operation method of the USB equipment registration module is directly used for calling an API (application programming interface) of a USB HAL (advanced peripheral interface) library to operate, or the virtual USB equipment is called for carrying out function configuration, and an API corresponding to the configuration function is switched to complete function switching.
The USB HAL library comprises a USB data interrupt callback interface, a USB control interrupt callback interface and a USB API (application program interface) interface, wherein the USB data interrupt interface is used for processing enumerated USB data transceiving and comprises USB data transmission input and output and response completion; the USB control interrupt callback interface is used for realizing an enumeration process of the USB, and comprises control operations of setting, resetting and connecting in the USB enumeration process; the API interface of the USB includes endpoint operations to the USB.
The virtual USB equipment object comprises an equipment object management module, a USB data processing module, a USB event processing module and an equipment object function operation module, wherein the equipment object management module comprises basic operations of initializing, starting and stopping the virtual USB equipment; the USB data processing module is associated with a USB data interrupt callback interface to realize the transmission of USB data; the USB event processing module is associated with the control interrupt callback interface to realize the setting, resetting and connection of the event processing in the enumeration process; the device object function operation module is associated with the API interface of the USB to realize the function operation of all endpoints.
The USB device registration module comprises basic information of a device descriptor, an interface descriptor and an operation method of the device, wherein the operation method of the device is associated with the device object function operation module.
An object-oriented single-chip microcomputer USB software development method is based on any one of the systems to carry out object-oriented single-chip microcomputer USB software development.
Compared with the prior art, the invention has the following remarkable advantages: the virtual USB device object may include all function operations, and the device object function operation module is associated with the USB device, so that the USB device has a whole set of USB function operations, and the USB device may perform configuration operations on the virtual USB object management to switch different USB devices.
Drawings
Fig. 1 is a block diagram of a USB software development system based on an object-oriented single chip microcomputer according to the present invention.
FIG. 2 is a flow chart of the development method of USB software based on an object-oriented single chip microcomputer.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The invention is based on the single chip microcomputer USB software development system and the method thereof which are oriented to objectification, and further development is carried out on the basis of the HAL library based on STM32, so that the USB software development is modularized, abstract and has better expansibility, and the internal communication of the intelligent fusion terminal equipment is more stable and high-speed.
As shown in fig. 1, an object-oriented single-chip microcomputer USB software development system includes an STM32 interrupt service, a USB HAL library, a virtual USB device object, and a USB device registration module, wherein:
(1) STM32 interrupt service
The interrupt service of STM32 is the entry of STM32 to respond to USB interrupts. The interruption is actually when the CPU executes a program, the CPU temporarily interrupts the running program due to the occurrence of a random event (external or internal), and then goes to execute a special service program (an interruption service subroutine or an interruption handler) to process the event, and after the event is processed, the CPU returns to the interrupted program to continue execution, which is called interruption, and the interruption is called an interruption source. Such as: when watching television, the door ring suddenly rings, and the ring is equivalent to an interrupt source. Some interrupts can also be interrupted by other high priority interrupts, and this situation is called nesting of interrupts. The Crotex-M3 kernel supports 256 interrupts, including 16 kernel interrupts and 240 external interrupts. STM32 does not use all of the M3 core, but only a portion of it. For example, an STM32F10x chip has 84 interrupt channels including 16 core interrupts and 68 maskable interrupts, and for an STM32F103 series chip there are only 60 maskable interrupts and 68 in the STM32F107 series. The priority of other exceptions is programmable, except for the priority of individual exceptions being killed. The interrupt channels are fixedly allocated to corresponding external devices according to different priority orders.
(2) USB HAL library
The HAL library is a standard function interface provided by STM32 officially, and includes a USB data interrupt callback interface, a USB control interrupt callback interface, and a USB API interface. The interrupt interface of the USB data is used for processing the enumerated USB data receiving and sending, and mainly comprises the input and output of the USB data transmission and the completion response. The control interrupt callback interface of the USB is used for realizing some operations in the enumeration process of the USB, and mainly comprises some control operations such as SETUP, RESET and the like in the enumeration process of the USB. The API interface of USB primarily contains some operations on the endpoints of USB.
(3) Virtual USB device
The virtual USB device object comprises a device object management module, a USB data processing module, a USB event processing module and a device object function operation module. The virtual USB device object management module contains basic operations such as initialization, START, STOP, etc. of the virtual USB device. The USB data processing module is associated with OUT, IN and Complete interrupts of the HAL library, and is mainly used for enumerated data transmission. The virtual USB event processing module comprises a complete set of event processing of enumeration process, including SETUP, RESTART, CONNECT, etc., and is associated with the control interrupt callback interface of the HAL library. The device object function operations module contains all endpoint function operations supported by the device, associated with the USB API interface of the HAL library. Associating the virtual USB device object with the HAL library, the virtual USB device object has all response callbacks and endpoint operations for USB interrupts.
(4) USB device registration module
The USB device registration module is used to register information of the USB device, and mainly includes a device descriptor, an interface descriptor, and an operation method of the device itself. Generally, an interface descriptor represents a USB device, and a plurality of USB devices can be built according to different interface descriptors, each device includes its own operation method, and these operation methods are associated with some functional interfaces in the virtual USB device, so that each USB device has complete USB device information and functional operations.
In the invention, the virtual USB device object discards the basic information of the specific USB devices such as the configuration descriptor, the endpoint descriptor and the interface descriptor of the USB device, but contains the data transmission, all event responses and all functional operations of the USB. The USB device may switch between different USB devices by performing a SET Configuration operation on the virtual USB object management.
As shown in fig. 2, the process example of the development method based on the object-oriented single chip microcomputer software of the present invention includes the following steps:
STM32 devices are turned on by first initializing the USB HAL library and hardware ports. Then registering a virtual USB device object, constructing device object management, data processing, event processing and device function operation, processing USB data interrupt callback associated data of the HAL library, processing USB control interrupt callback associated events, and operating API interface associated device functions, thus finishing abstract USB device objects with complete USB functions, all response callbacks and endpoint operations of interrupts with USB. Then registering a real USB device with a configuration descriptor and an interface descriptor, and associating the operation method of the device with the functional interface of the virtual USB device object, thereby completing the complete construction of the USB device. Starting the USB device, completing enumeration, namely USB communication can be carried out, and HOST can also call the operation method of the USB device to switch the API interface through an instruction, thereby switching the function.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (3)

1. A single chip microcomputer USB software development system based on objectification is characterized by comprising an STM32 interrupt service, a USB HAL library, a virtual USB device object and a USB device registration module, wherein the STM32 interrupt service is used for providing an inlet for responding USB interrupt; the USB HAL library is used for providing a standard function interface for realizing operations of USB data interrupt callback, USB control interrupt callback and API call; the virtual USB equipment object is associated with a standard function interface of the USB HAL library and is used for realizing USB data transmission, event response, functional operation and basic configuration of the virtual USB equipment object; the USB equipment registration module is used for setting respective operation methods of the USB equipment, is associated with function operation in a virtual USB equipment object, and directly uses the operation method of the USB equipment registration module to call an API (application programming interface) of a USB HAL (advanced Serial bus HAL) library to operate or call the virtual USB equipment to perform function configuration when the USB equipment needs to be operated, and switches the API corresponding to the configuration function to complete function switching;
the USB HAL library comprises a USB data interrupt callback interface, a USB control interrupt callback interface and a USB API (application program interface) interface, wherein the USB data interrupt callback interface is used for processing enumerated USB data transceiving and comprises USB data transmission input and output and response completion; the USB control interrupt callback interface is used for realizing an enumeration process of the USB, and comprises control operations of setting, resetting and connecting in the USB enumeration process; the API interface of the USB includes endpoint operations to the USB;
the virtual USB equipment object comprises an equipment object management module, a USB data processing module, a USB event processing module and an equipment object function operation module, wherein the equipment object management module comprises basic operations of initializing, starting and stopping the virtual USB equipment; the USB data processing module is associated with a USB data interrupt callback interface to realize the transmission of USB data; the USB event processing module is associated with a USB control interrupt callback interface to realize the setting, resetting and connecting of the event processing in the enumeration process; the device object function operation module is associated with the API interface of the USB to realize the function operation of all endpoints.
2. The USB software development system based on the object-oriented single chip microcomputer according to claim 1, wherein the USB device registration module includes basic information of device descriptors, interface descriptors and operation methods of the USB devices, and the operation methods of the USB devices are associated with the device object function operation module.
3. An object-oriented single-chip microcomputer USB software development method is characterized in that the object-oriented single-chip microcomputer USB software development is carried out based on the system of any one of claims 1-2.
CN202011092431.7A 2020-10-13 2020-10-13 Single-chip microcomputer USB software development system and method based on objectification Active CN111913783B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011092431.7A CN111913783B (en) 2020-10-13 2020-10-13 Single-chip microcomputer USB software development system and method based on objectification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011092431.7A CN111913783B (en) 2020-10-13 2020-10-13 Single-chip microcomputer USB software development system and method based on objectification

Publications (2)

Publication Number Publication Date
CN111913783A CN111913783A (en) 2020-11-10
CN111913783B true CN111913783B (en) 2021-02-02

Family

ID=73265236

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011092431.7A Active CN111913783B (en) 2020-10-13 2020-10-13 Single-chip microcomputer USB software development system and method based on objectification

Country Status (1)

Country Link
CN (1) CN111913783B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853177A (en) * 2010-05-05 2010-10-06 四川九洲电器集团有限责任公司 Driving device of M2M (machine to machine) module with USB (Universal Serial Bus) interface

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6618387B1 (en) * 1999-03-04 2003-09-09 Webtv Networks, Inc. Interface for abstracting control of a cable modem
CN107403573B (en) * 2017-07-20 2018-12-14 湖北工业大学 A kind of USB experimental system and method based on STM32F7

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853177A (en) * 2010-05-05 2010-10-06 四川九洲电器集团有限责任公司 Driving device of M2M (machine to machine) module with USB (Universal Serial Bus) interface

Also Published As

Publication number Publication date
CN111913783A (en) 2020-11-10

Similar Documents

Publication Publication Date Title
DE69727407T2 (en) Distributed execution of mode-unsuitable instructions in multiprocessor systems
CN103150279B (en) Method allowing host and baseboard management controller to share device
CN105183698B (en) A kind of control processing system and method based on multi-core DSP
US10831539B2 (en) Hardware thread switching for scheduling policy in a processor
CN109522099B (en) Method and system for improving instantaneity of non-instantaneity operating system
CN103377081A (en) Implementation method for interrupt mechanism between embedded numerical control system dual-core chip and peripheral
US20220414052A1 (en) Multi-Core Processor, Multi-Core Processor Processing Method, and Related Device
WO2022134358A1 (en) Microservice data processing method, apparatus, microservice processing platform, and medium
CN102541616A (en) Embedded operating system virtual machine and implementation method thereof
US20120278814A1 (en) Shared Drivers in Multi-Core Processor
EP2761483B1 (en) Protocol neutral fabric
CN111913783B (en) Single-chip microcomputer USB software development system and method based on objectification
WO2019143749A1 (en) Direct memory access adapter
CN110401939B (en) Low-power consumption bluetooth controller link layer device
CN104951346A (en) Process management method for embedded system as well as system
CN102736908A (en) System, device and method for remotely setting CMOS (Complementary Metal-Oxide-Semiconductor Transistor) parameters
CN111195919B (en) Robot teaching platform and construction method thereof
Sakamura ITRON: An overview
CN110519390A (en) A kind of low-power consumption bluetooth controller link layer implementation method
CN103197959A (en) Switching method of multi-core CPUs (Central Processing Unit)
CN111459620A (en) Information scheduling method from security container operating system to virtual machine monitor
RU158939U1 (en) PERIPHERAL INTERFACE CONTROLLER (KPI-2)
CN112799800B (en) Lightweight low-voltage protection device platform development method
CN115237475B (en) Forth multi-core stack processor and instruction set
Ma et al. Construction of RISC-V lightweight trusted execution environment based on hardware extension

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant