In our system, the USB host is used to read and write the USB flash disk. Therefore, the design and architecture fully focus on this purpose. The entire system involves a lot of content. According to the general principles of embedded system development, a hierarchical architecture is adopted to divide the system into several levels by function, and each layer completes the corresponding functions. According to the business needs of the system, the overall architecture of the system is as follows:
9 |
Business Application Layer |
8 |
File operation API Layer |
7 |
File System Layer |
6 |
USB flash disk operation command interface layer |
5 |
UFI command Layer |
4 |
USB device management layer |
3 |
OHCI Software Interface Layer |
2 |
Register read/write Interface Layer |
1 |
Hardware Layer |
This is a layered structure. Each layer completes its own functions. Both layers are completed through interfaces. Basically, upper-layer applications only depend on the next layer, for the function implementation of individual layers, it is convenient to consider the implementation. The functions of each layer are described below: 1. hardware is the underlying layer of the system and the hardware part for USB protocol processing is directly completed. 2. The register read/write interface AM9200 supports standard OHCI interfaces and provides pointers to OHCI registers.
PUhp) And data exchange zone HCCA). This layer encapsulates the access to the pointer and data exchange zone, shielding the details of register read/write. If it is transplanted to a non-OHCI system in the future, it can be reencoded without changing the interface. 3. The OHCI software interface is based on the OHCI standard. data transmission is completed through the two data structures: the endpoint descriptor ED) and the transmission descriptor TD, before transmission, you need to set ED and TD to ensure the correctness of data transmission. At this layer, operations on ED and TD are encapsulated, provides an OHCI-based data transmission interface. For more information about ED and TD, see OHCI Open Host Controller Interface Specification for USB. 4. USB device management according to USB standards, USB devices must provide device descriptors, configuration descriptors, interface descriptors, and Endpoint descriptors. This layer of Code provides commands for obtaining These descriptors. In addition, this layer also combines the commands for obtaining descriptors to complete the enumeration and detection of USB devices. 5. The UFI Command completes the UFI Command of the BulkOnly protocol in accordance with the specifications of Universal Serial Bus Mass Storage Class Bulk-Only Transport and Universal Serial Bus Mass Storage Class UFI Command Specification, provides the sector read/write command to the upper layer. 6. the USB flash drive operation command interface encapsulates the UFI command layer and provides disk read/write commands in units of sectors, such as diskRead () and diskWrite, call the UFI command to complete the USB flash disk enumeration and detection, and determine the number of the logical 0-sector, laying the foundation for building a file system. 7. The file system initializes the file system, obtains relevant parameters, and provides Directory Search, cluster operations, and other interfaces to the upper layer. 8. The file operation library function is modeled by the C language standard file library function. It provides a set of API function libraries for upper-layer business applications, including opening, closing, reading, writing, and locating files. 9. The business application is the business logic layer, that is, the corresponding file operation library function is called Based on the received billing information to save the ticket. With this hierarchical structure, the system has good maintainability and scalability. As long as the CPU supports the OHCI standard, the system can be directly used without modification. If the CPU does not support the OHCI standard, the code at the OHCI layer needs to be modified to ensure that the upper-layer Calling Interface remains unchanged, so that the system can be transplanted. If you need to expand to support more USB devices, keep the OHCI layer unchanged or properly extend the current OHCI Layer Code to support only control and batch transmission, but not synchronization and interrupted transmission ), you can add new drivers and upper-layer applications. In this article, I will give a general description of our system. This is to avoid elaborate on various technical details as soon as possible, leading to a blind eye. In this series of articles, all the code is written according to this framework principle. Remembering this architecture will be of great help for understanding the code.
This article is from the "rainman" blog, please be sure to keep this source http://lancelot.blog.51cto.com/393579/228153