CN113127399B - Universal serial bus device and access method - Google Patents

Universal serial bus device and access method Download PDF

Info

Publication number
CN113127399B
CN113127399B CN202011564719.XA CN202011564719A CN113127399B CN 113127399 B CN113127399 B CN 113127399B CN 202011564719 A CN202011564719 A CN 202011564719A CN 113127399 B CN113127399 B CN 113127399B
Authority
CN
China
Prior art keywords
buffer
data
host
value
buffer area
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
CN202011564719.XA
Other languages
Chinese (zh)
Other versions
CN113127399A (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.)
Nuvoton Technology Corp
Original Assignee
Nuvoton Technology Corp
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 Nuvoton Technology Corp filed Critical Nuvoton Technology Corp
Publication of CN113127399A publication Critical patent/CN113127399A/en
Application granted granted Critical
Publication of CN113127399B publication Critical patent/CN113127399B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • 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/14Handling requests for interconnection or transfer
    • G06F13/16Handling requests for interconnection or transfer for access to memory bus
    • G06F13/1668Details of memory controller
    • G06F13/1673Details of memory controller using buffers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]

Abstract

The invention provides a universal serial bus device and an access method. The data buffer memory comprises a first buffer area and a second buffer area. The first buffer is used for storing first data. The second buffer is used for storing second data. The endpoints correspond to the first and second buffers. The connection port is used for coupling with a host. When the host issues a huge input request, the endpoint reads the first or second buffer area according to a buffer conversion flag. The USB is used to connect the computer system and the external device. When different external devices are coupled to the computer system by using the universal serial bus, the computer can automatically identify the external devices and match with proper driving programs without setting or installing the driving programs separately by a user.

Description

Universal serial bus device and access method
Technical Field
The present invention relates to the field of data access, and more particularly, to a universal serial bus device and an access method.
Background
The Universal Serial Bus (USB) is mainly used for connecting a computer system and an external device. When different external devices are coupled to the computer system by using the universal serial bus, the computer can automatically identify the external devices and match with proper driving programs without setting or installing the driving programs separately by a user.
Disclosure of Invention
The invention provides a universal serial bus device, which comprises a data buffer memory, a terminal and a connection port. The data buffer memory comprises a first buffer area and a second buffer area. The first buffer is used for storing first data. The second buffer is used for storing second data. The end points correspond to the first buffer area and the second buffer area. The connection port is used for coupling with a host. When the host issues a large number of input requests, the endpoint reads the first or second buffer according to a buffer transition flag.
In one possible embodiment, when the buffer transition flag is a first value, the endpoint reads the first buffer to provide a first data to the host. When the buffer transition flag is a second value, the endpoint reads the second buffer to provide a second data to the host.
In another possible embodiment, the buffer transition flag is a second value when the endpoint begins to provide the first data to the host. The buffer transition flag is a first value when the endpoint begins providing second data to the host.
The invention also provides an access method which is suitable for a universal serial bus device. The USB device has a data buffer memory. The data buffer memory comprises a first buffer area and a second buffer area. The access method of the invention comprises the following steps: setting a first buffer area and a second buffer area corresponding to an endpoint; receiving an external instruction; when the external instruction is a huge input request, the first buffer area or the second buffer area is read according to a buffer conversion flag.
In one possible embodiment, when the buffer transition flag is a first value, the first buffer is read to provide a first data to an external host. When the buffer conversion flag is a second value, the second buffer is read to provide a second data to an external host.
In another possible embodiment, the buffer transition flag is changed from the first value to the second value when the endpoint begins to provide the first data to the external host. The buffer transition flag is changed from the second value to the first value when the endpoint begins to provide the external host with the second data.
The access method of the present invention may be implemented by the usb device of the present invention, which is hardware capable of performing a specific function, or may be implemented by storing the usb device in a storage medium in the form of program codes and combining the usb device with the specific hardware. When the program code is loaded into and executed by an electronic device, processor, computer, or machine, the electronic device, processor, computer, or machine becomes a universal serial bus device for practicing the invention.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an operating system of the present invention.
FIG. 2 is a schematic flow chart of an access method according to the present invention.
Reference numerals:
100: an operating system;
110: a host;
111: a connection port;
120: a universal serial bus device;
128: a connection port;
121 to 124: an endpoint;
125: a data buffer memory;
126. 127: a buffer area;
130: a connecting wire;
BUFTOG: the transition flag is buffered.
S211 to S216: and (3) step (c).
Detailed Description
The present invention will be described in more detail with reference to the following examples, which are provided for the purpose of understanding the present invention. The present description provides various examples to illustrate the features of various embodiments of the present invention. The arrangement of the elements in the embodiments is merely for illustration, and is not intended to limit the invention. In addition, the repetition of the reference numerals in the embodiments is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments.
FIG. 1 is a schematic diagram of an operating system of the present invention. As shown, the operating system 100 includes a host 110 and a Universal Serial Bus (USB) device 120. The host 110 includes a connection port 111 for coupling to the USB device 120. In this embodiment, the connection port 111 is a USB 2.0 connection port. The present invention is not limited to the number of usb devices. In other embodiments, the host 110 may be coupled to more USB devices. In this example, the host 110 assigns different addresses to different USB devices.
The USB device 120 includes endpoints 121-124, a data buffer 125, and a connection port 128. In one possible embodiment, the USB Device 120 is a Full-Speed Device (Full-Speed Device) with a transmission rate of up to 12Mbps.
The connection port 128 is used for coupling with the host 110. In one possible embodiment, the connection port 128 is coupled to the host 110 through a connection line 130. In another possible embodiment, connection port 128 is plugged directly into connection port 111 of host 110. In this example, the connection port 128 is also a USB 2.0 connection port.
Endpoints 121-124 are coupled between connection port 128 and data buffer 125. Endpoints 121-124 correspond to different types of transmissions. In this embodiment, endpoints 121-124 share data buffer 125. In one possible embodiment, each endpoint communicates with host 110 through a corresponding virtual pipe (virtual pipe). The invention is not limited to the number of endpoints. In other embodiments, the USB device 120 may have more endpoints.
The host 110 enables a corresponding function by using at least one endpoint in the USB device 120. For example, if the usb device 120 has both mouse and usb functions, the host 110 may perform an interrupt transmission (interrupt transfer) by using a first specific endpoint inside the usb device 120 to activate the mouse function. IN this example, the first specific endpoint performs an interrupt input (interrupt IN) transmission. In addition, the host 110 may use a second specific endpoint and a third specific endpoint inside the usb device 120 to perform a bulk transfer (bulk transfer) for reading data or writing data. IN this example, the second specific endpoint performs a bulk IN (bulk IN) transmission and the third specific endpoint performs a bulk OUT (bulk OUT) transmission. Therefore, when the host 110 wants to use a specific function of the usb device 120, the host 110 only needs to designate the corresponding endpoint, so that the function of the usb device 120 can be used.
In this embodiment, the endpoints 121 and 122 perform a control transfer (control transfers) for controlling transfer commands and status operations, such as setting the USB device, obtaining information about the USB device, sending commands to the USB device, etc. IN one possible embodiment, endpoint 121 performs a control IN (control IN) transfer to provide data from data buffer 125 to host 110, and endpoint 122 performs a control OUT (control OUT) transfer to write output data from host 110 to data buffer 125. In addition, endpoints 123 and 124 perform a batch transfer (Bulk Transfers) for Bulk data transfer. In this embodiment, the endpoint 123 performs a bulk input transfer to provide the data of the data buffer 125 to the host 110, and the endpoint 124 performs a bulk output transfer to write the output data from the host 110 into the data buffer 125. In this embodiment, endpoint 123 corresponds to buffers 126 and 127 of data buffer 125. In other embodiments, the USB device 120 may have other terminals for interrupt transmission. In this example, the endpoint that is performing the interrupt transmission transmits a small amount of data with a fixed speed.
The present invention is not limited to the type of the data buffer 125. In one possible embodiment, the data buffer 125 is a Volatile Memory (Volatile Memory), such as a dynamic random access Memory (Dynamic Random Access Memory; DRAM) or a static random access Memory (Static Random Access Memory; SRAM). In one possible embodiment, the storage space of the data buffer 125 is 512Bytes.
In addition, the size of buffers 126 and 127 is not limited by the present invention. In one possible embodiment, the memory space of buffer 126 is the same as the memory space of buffer 127. For example, the storage space of buffers 126 and 127 is 64Bytes. In this embodiment, the start address of the buffer 126 is 0108, the end address thereof is 0147, the start address of the buffer 127 is 01C8, and the end address thereof is 0207. Thus, buffer 127 is not adjacent to buffer 126. In other examples, buffer 127 may be adjacent to buffer 126. In this example, the end address of buffer 126 is 0147 and the start address of buffer 127 is 0148.
IN this embodiment, when host 110 issues a Bulk IN transfer request, endpoint 123 reads buffer 126 or buffer 127 according to a buffer transition flag (buffer toggle flag) BUFTOG. In one possible embodiment, the initial value of the buffer transition flag BUFTOG is a value of 0. Since the buffer switch flag BUFTOG is a value of 0, a write circuit (not shown) writes a data DT1 in the buffer 126. At this time, if the host 110 issues a bulk input request, the endpoint 123 reads the buffer 126 to provide the data DT1 to the host 110 since the buffer transition flag BUFTOG is set to a value of 0.
When endpoint 123 begins providing data DT1 to host 110, a hardware architecture (not shown) changes the buffer transition flag BUFTOG to a value of 1. Since the buffer switch flag BUFTOG is a value of 1, a write circuit (not shown) writes a data DT2 in the buffer 127. Therefore, when the host 110 issues a huge input request again, the buffer flag BUFTOG is set to be 1, so that the endpoint 123 reads the buffer 127 to provide the data DT2 to the host 110.
When endpoint 123 begins providing data DT2 to host 110, the hardware architecture changes the buffer transition flag BUFTOG to a value of 0. Thus, a write circuit (not shown) writes a data DT3 in the buffer 126. At this time, if the host 110 issues a huge input request again, the buffer 126 is read by the endpoint 123 for providing the data DT3 to the host 110 since the buffer transition flag BUFTOG is set to be 0.
When endpoint 123 begins providing data DT3 to host 110, the hardware architecture (not shown) changes the buffer transition flag BUFTOG to a value of 1. Since the buffer switch flag BUFTOG is a value of 1, a write circuit (not shown) writes a data DT4 in the buffer 127. Therefore, when the host 110 issues a huge input request again, the buffer 127 is read by the endpoint 123 to provide the data DT4 to the host 110 since the buffer transition flag BUFTOG is a value of 1.
Since the host 110 can read the data of the two buffers only through a single endpoint (e.g. 123) in the usb device 120, and the data of the two buffers is not required to be read through the two endpoints, the situation that the multiple functions of the composite device cannot be realized due to the shortage of the endpoints can be avoided, and the number of endpoints used when a function is realized in the usb device 120 is reduced. In addition, by using two buffers, the occurrence of the situation that the usb device 120 temporarily has no data to transmit to the host 110 or cannot receive data from the host 110 can be reduced, thereby improving the efficiency of the usb device 120. In addition, by judging the value of the buffer conversion flag BUFTOG, the data can be automatically switched between two buffer intervals and written into the idle buffer area in advance, so that the access speed is improved.
FIG. 2 is a schematic flow chart of an access method according to the present invention. The access method is suitable for the universal serial bus device. The universal serial bus device is provided with a data buffer memory. The data buffer memory comprises a first buffer area and a second buffer area. The present invention is not limited to the type and size of the data buffer memory. In one possible embodiment, the data buffer memory is a static random access memory having a memory space of 512Bytes.
First, a terminal in the usb device is set to correspond to the first and second buffers (step S211). In one possible embodiment, the endpoint is configured to perform a bulk-in transmission. The present invention is not limited to the locations of the first and second buffers in the data buffer memory. In one possible embodiment, the first buffer is adjacent or not adjacent to the second buffer. In other embodiments, the storage space of the first buffer may be the same as or different from the storage space of the second buffer.
Then, an external command is received (step S212). In this embodiment, the external command is provided by a host. The host requests the USB device to output data or provide data to the USB device through an external command. When the external command is a huge input request, the first or second buffer is read according to a buffer transition flag (step S213).
In the present embodiment, step S213 includes steps S214 to S216. Step S214 is to determine whether the buffer status flag is a first value (e.g. 0). When the buffer transition flag is the first value, the first buffer is read to provide a first data to the host (step S215). In one possible embodiment, the buffer transition flag is changed to a second value (e.g., 1) after the first data is initially provided to the host. At this time, the write priority of the first buffer is higher than the write priority of the second buffer. In this case, if there is new data (e.g., third data) to be written, the first buffer is written preferentially.
When the buffer transition flag is not the first value (e.g., 1), the second buffer is read (step S216) to provide a second data to the host. At this time, since the buffer transition flag is not the first value, a third data is written into the first buffer. In addition, the buffer transition flag is changed to the first value when the second data is provided to the host. At this time, the write priority of the second buffer is higher than the write priority of the first buffer. Therefore, if new data (e.g., fourth data) is to be written, it is preferable to write in the second buffer.
The access method of the present invention, or a specific type or portion thereof, may exist in the form of program code. The program code may be stored on a storage medium, such as a floppy disk, an optical disk, a hard disk, or any other machine-readable (e.g., computer-readable) storage medium, or it may be a computer program product in a form other than an external form, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes an universal serial bus device for practicing the invention.
Program code may also be transmitted over some transmission medium, such as electrical wiring or cabling, through fiber optics, or via any other form of transmission, wherein, when the program code is received and loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention. When implemented in a general-purpose processing unit, the program code combines with the processing unit to provide a unique apparatus that operates analogously to specific logic circuits.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. Furthermore, unless explicitly indicated otherwise, the definition of a term in a general dictionary should be construed as consistent with its meaning in the context of the relevant art and should not be interpreted in an idealized or overly formal sense.
Although the present invention has been described with reference to the preferred embodiments, it should be understood by those skilled in the art that various changes, modifications and alterations can be made without departing from the spirit and scope of the invention. For example, the system, apparatus or method according to the embodiments of the present invention may be implemented in hardware, software or a combination of hardware and software. The protection scope of the invention is therefore subject to the protection scope defined by the claims.

Claims (4)

1. A universal serial bus device, comprising:
a data buffer memory, comprising:
a first buffer area for storing a first data; and
a second buffer area for storing a second data;
an endpoint corresponding to the first buffer area and the second buffer area; and
a connection port for coupling with a host;
wherein:
when the host sends a first huge input request and a buffer conversion flag is a first value, the endpoint reads the first buffer area and outputs the first data to the host;
when the endpoint outputs the first data to the host, the buffer transition flag is changed to a second value, and the second buffer stores a second data;
when the host sends a second huge amount of input request and the buffer conversion flag is the second value, the endpoint reads the second buffer area and outputs the second data to the host;
while the endpoint outputs the second data to the host, the buffer transition flag is changed to the first value, and the first buffer stores a third data;
when the host sends a third huge amount of input request and the buffer conversion flag is the first value, the endpoint reads the first buffer area and outputs the third data to the host;
while the endpoint outputs the third data to the host, the buffer transition flag is changed to the second value, and the second buffer stores a fourth data;
when the host sends a fourth huge amount of input request and the buffer conversion flag is the second value, the endpoint reads the second buffer area and outputs the fourth data to the host.
2. The usb device of claim 1, wherein the first buffer is the same as the second buffer.
3. The universal serial bus device of claim 1, wherein the second buffer is adjacent to the first buffer.
4. An access method, suitable for a usb device, the usb device having a data buffer memory, the data buffer memory including a first buffer area and a second buffer area, the access method comprising:
setting a terminal point to correspond to the first buffer area and the second buffer area;
receiving an external instruction; and
when the external instruction is a first huge input request and a buffer conversion flag is a first value, reading the first buffer area and outputting the data stored in the first buffer area;
changing the buffer conversion flag to a second value while outputting the data stored in the first buffer, and writing the data into the second buffer;
when the external instruction is a second huge input request and the buffer conversion flag is the second value, reading the second buffer area and outputting the data stored in the second buffer area;
changing the buffer conversion flag to the first value while outputting the data stored in the second buffer, and writing the data into the first buffer;
when the external instruction is a third huge input request and the buffer conversion flag is the first value, reading the first buffer area and outputting the data stored in the first buffer area;
changing the buffer conversion flag to the second value while outputting the data stored in the first buffer, and writing the data into the second buffer;
when the external instruction is a fourth huge input request and the buffer conversion flag is the second value, reading the second buffer area and outputting the data stored in the second buffer area;
and changing the buffer conversion flag to the first value while outputting the data stored in the second buffer, and writing the data into the first buffer.
CN202011564719.XA 2019-12-31 2020-12-25 Universal serial bus device and access method Active CN113127399B (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
TW108148543 2019-12-31
TW108148543A TWI736092B (en) 2019-12-31 2019-12-31 Usb device and accessing method thereof

Publications (2)

Publication Number Publication Date
CN113127399A CN113127399A (en) 2021-07-16
CN113127399B true CN113127399B (en) 2024-02-20

Family

ID=76772212

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011564719.XA Active CN113127399B (en) 2019-12-31 2020-12-25 Universal serial bus device and access method

Country Status (2)

Country Link
CN (1) CN113127399B (en)
TW (1) TWI736092B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1266515A (en) * 1997-08-12 2000-09-13 爱特梅尔股份有限公司 Universal serial bus device controller
JP2004070423A (en) * 2002-08-01 2004-03-04 Ricoh Co Ltd Usb controller and method of controlling data transfer thereof
US8996772B1 (en) * 2012-02-15 2015-03-31 Cypress Semiconductor Corporation Host communication device and method with data transfer scheduler
CN110096461A (en) * 2019-04-16 2019-08-06 中国科学院国家空间科学中心 A kind of real-time and high-speed data transmission method and system based on USB3.0 aided protocol

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3415567B2 (en) * 2000-06-21 2003-06-09 エヌイーシーマイクロシステム株式会社 USB transfer control method and USB controller
US20060020721A1 (en) * 2004-05-26 2006-01-26 Microchip Technology Incorporated Configurable ping-pong buffers for USB buffer descriptor tables
WO2008082530A1 (en) * 2006-12-31 2008-07-10 Sandisk Corporation Method and apparatus for performing full transfer automation in a usb controller
US7689734B2 (en) * 2007-12-18 2010-03-30 International Business Machines Corporation Method for toggling non-adjacent channel identifiers during DMA double buffering operations
CN101692213B (en) * 2009-10-23 2012-06-27 威盛电子股份有限公司 Universal serial bus (USB) host control method and universal serial bus host controller
TWI488043B (en) * 2009-10-27 2015-06-11 Genesys Logic Inc Accelerated access apparatus and reading and writing methods thereof
CN101968779A (en) * 2010-09-30 2011-02-09 威盛电子股份有限公司 Universal serial bus transmission transaction translator and microframe synchronous method
TWM525481U (en) * 2015-10-21 2016-07-11 宏正自動科技股份有限公司 System and apparatus for communication between different interfaces

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1266515A (en) * 1997-08-12 2000-09-13 爱特梅尔股份有限公司 Universal serial bus device controller
JP2004070423A (en) * 2002-08-01 2004-03-04 Ricoh Co Ltd Usb controller and method of controlling data transfer thereof
US8996772B1 (en) * 2012-02-15 2015-03-31 Cypress Semiconductor Corporation Host communication device and method with data transfer scheduler
CN110096461A (en) * 2019-04-16 2019-08-06 中国科学院国家空间科学中心 A kind of real-time and high-speed data transmission method and system based on USB3.0 aided protocol

Also Published As

Publication number Publication date
TWI736092B (en) 2021-08-11
TW202127265A (en) 2021-07-16
CN113127399A (en) 2021-07-16

Similar Documents

Publication Publication Date Title
US9135190B1 (en) Multi-profile memory controller for computing devices
WO2021244194A1 (en) Register reading/writing method, chip, subsystem, register group, and terminal
US10860507B2 (en) Electronic systems having serial system bus interfaces and direct memory access controllers and methods of operating the same
CN113485672B (en) Information generation method, device, equipment and medium based on FIFO memory
CN111124985A (en) Read-only control method and device for mobile terminal
US7409486B2 (en) Storage system, and storage control method
JP2963426B2 (en) Bus bridge device and transaction forward method
CN109992556A (en) A kind of I2C driving method and device
CN104461977A (en) memory card access device, control method thereof and memory card access system
US7822040B2 (en) Method for increasing network transmission efficiency by increasing a data updating rate of a memory
TW201344444A (en) Motherboard and data processing method thereof
US10852991B1 (en) Memory controller and memory controlling method where number of commands (executed by the memory controller prior to releasing host memory) is adjusted based on transmission speed of interface to host
US10853255B2 (en) Apparatus and method of optimizing memory transactions to persistent memory using an architectural data mover
CN113127399B (en) Universal serial bus device and access method
US20090138673A1 (en) Internal memory mapped external memory interface
CN110795373B (en) I2C bus-to-parallel bus conversion method, terminal and storage medium
CN112564924B (en) Computer expansion card and block chain terminal equipment
US20040186949A1 (en) XIP system and method for serial memory
CN109992560B (en) Communication method and communication system
CN116601616A (en) Data processing device, method and related equipment
US7921238B2 (en) USB host system and method for transferring transfer data
US20080222385A1 (en) Parameter setting method and apparatus for network controller
CN110489359B (en) Data transmission control method and system
CN107911414B (en) Data access system
US7272680B2 (en) Method of transferring data between computer peripherals

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