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

Universal serial bus device and access method Download PDF

Info

Publication number
CN113127399A
CN113127399A CN202011564719.XA CN202011564719A CN113127399A CN 113127399 A CN113127399 A CN 113127399A CN 202011564719 A CN202011564719 A CN 202011564719A CN 113127399 A CN113127399 A CN 113127399A
Authority
CN
China
Prior art keywords
buffer
data
host
endpoint
usb device
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.)
Granted
Application number
CN202011564719.XA
Other languages
Chinese (zh)
Other versions
CN113127399B (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

Images

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]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Systems (AREA)

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 being coupled with a host. When the host issues a bulk-in request, the endpoint reads the first or second buffer according to a buffer conversion flag. The usb is mainly used to connect the computer system and the external device. When different external devices are coupled to the computer system by the USB, the computer can automatically identify the external devices and match with proper drivers without requiring a user to set or install the drivers.

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 usb device and an access method thereof.
Background
The Universal Serial Bus (USB) is mainly used to connect the computer system and the external device. When different external devices are coupled to the computer system by the USB, the computer can automatically identify the external devices and match with proper drivers without requiring a user to set or install the drivers.
Disclosure of Invention
The invention provides a universal serial bus device, which comprises a data buffer memory, a terminal and a connecting port. The data buffer memory comprises a first buffer area and a second buffer area. The first buffer is used for storing a first data. The second buffer is used for storing a second data. The endpoints correspond to the first and second buffers. The connection port is used for coupling a host. When the host issues a bulk input request, the endpoint reads the first or second buffer according to a buffer conversion flag.
In one embodiment, when the buffer conversion flag is a first value, the endpoint reads the first buffer to provide a first data to the host. When the buffer conversion 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 conversion flag is set to the second value when the endpoint starts to provide the first data to the host. The buffer conversion flag is set to the first value when the endpoint starts providing the host with the second data.
The invention also provides an access method which is suitable for the 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 an endpoint corresponding to the first buffer area and the second buffer area; receiving an external instruction; when the external instruction is a bulk input request, the first or second buffer is read according to a buffer conversion flag.
In one embodiment, when the buffer conversion 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 conversion flag is changed from the first value to the second value when the endpoint starts providing the first data to the external host. The buffer conversion flag is changed from the second value to the first value when the endpoint starts providing the external host with the second data.
The access method of the present invention can be implemented by the usb device of the present invention, and the usb device is hardware capable of executing a specific function, or can be stored in a storage medium in the form of a program code and implemented by combining with 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 present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram of an operating system of the present invention.
FIG. 2 is a schematic flow chart of an accessing 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-124: an endpoint;
125: a data buffer memory;
126. 127: a buffer area;
130: a connecting wire;
BUFTOG: the conversion flag is buffered.
S211 to S216: and (5) carrying out the following steps.
Detailed Description
In order to make the objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below. The present description provides various examples to illustrate the technical features of various embodiments of the present invention. The configuration of the elements in the embodiments is for illustration only and not for limiting the invention. In addition, the reference numerals in the embodiments are partially repeated to simplify the description, and do not indicate the relationship between the different 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 with a usb device 120. In the present embodiment, the connection port 111 is a USB 2.0 connection port. The present invention does not limit 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 end points (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 up to 12 Mbps.
The connection port 128 is for coupling to the host 110. In one embodiment, the connection port 128 is coupled to the host 110 via a connection line 130. In another possible embodiment, connection port 128 plugs directly into connection port 111 of host 110. In this example, the connection port 128 is also a USB 2.0 connection port.
The terminals 121-124 are coupled between the connection port 128 and the data buffer memory 125. The endpoints 121-124 correspond to different types of transmissions. In the present embodiment, the endpoints 121-124 share a data buffer 125. In one embodiment, each endpoint communicates with the host 110 through a corresponding virtual pipe (virtual pipe). The number of endpoints is not limited by the invention. In other embodiments, the usb device 120 may have more terminals.
The host 110 enables a corresponding function 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 utilize a first specific endpoint inside the usb device 120 to perform an interrupt transfer (interrupt transfer) for activating the mouse function. IN this example, the first particular endpoint makes an interrupt IN (interrupt IN) transmission. In addition, the host 110 may utilize a second specific endpoint and a third specific endpoint within the usb device 120 to perform a bulk transfer (bulk transfer) for reading data or writing data. IN this case, the second specific endpoint performs a bulk-IN (bulk-IN) transfer, and the third specific endpoint performs a bulk-OUT (bulk-OUT) transfer. 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 to use the function of the usb device 120.
In this embodiment, the endpoints 121 and 122 perform a control transfer (control transfer) for controlling the transfer command and status operations, such as setting up the USB device, obtaining information about the USB device, sending commands to the USB device, etc. IN one embodiment, the endpoint 121 performs a control IN transfer to provide data from the data buffer memory 125 to the host 110, and the endpoint 122 performs a control OUT transfer to write output data from the host 110 to the data buffer memory 125. In addition, endpoints 123 and 124 perform a Bulk transfer (Bulk Transfers) for Bulk data Transfers. In this embodiment, the endpoint 123 performs a bulk-in transfer for providing data from the data buffer memory 125 to the host 110, and the endpoint 124 performs a bulk-out transfer for writing output data from the host 110 to the data buffer memory 125. In the present embodiment, the endpoint 123 corresponds to the buffers 126 and 127 of the data buffer 125. In other embodiments, the usb device 120 may have other terminals for interrupt transmission. In this example, the endpoint performing the interrupt transmission transmits a small amount of data with a fixed speed.
The present invention is not limited to the type of data buffer memory 125. In one embodiment, the data buffer 125 is a Volatile Memory (Volatile Memory), such as a Dynamic Random Access Memory (DRAM) or a Static Random Access Memory (SRAM). In one possible embodiment, the storage space of the data buffer memory 125 is 512 Bytes.
In addition, the present invention is not limited to the size of the buffers 126 and 127. In one embodiment, the storage space of the buffer 126 is the same as the storage space of the buffer 127. For example, the storage space of the buffers 126 and 127 are 64 Bytes. In this embodiment, the start address of the buffer 126 is 0108 and the end address thereof is 0147, and 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 ending address of buffer 126 is 0147, and the starting address of buffer 127 is 0148.
IN the present embodiment, when the host 110 issues a Bulk input request (Bulk IN transfer), the endpoint 123 reads the buffer 126 or the buffer 127 according to a buffer toggle flag (buffer toggle flag). In one possible embodiment, the initial value of the buffer switch flag BUFTOG is a value of 0. Since the buffer conversion flag BUFTOG is 0, a write circuit (not shown) writes a data DT1 in the buffer 126. At this time, if the host 110 issues a bulk-in request, the endpoint 123 reads the buffer 126 to provide the data DT1 to the host 110 since the buffer conversion flag BUFTOG is 0.
When the endpoint 123 starts to provide the data DT1 to the host 110, a hardware configuration (not shown) changes the buffer conversion flag BUFTOG to a value of 1. Since the buffer conversion 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 large input request again, the endpoint 123 reads the buffer 127 to provide the data DT2 to the host 110 since the buffer conversion flag BUFTOG is 1.
When the endpoint 123 starts to provide data DT2 to the host 110, the hardware configuration changes the buffer conversion flag BUFTOG to a value of 0. Accordingly, a write circuit (not shown) writes a data DT3 in the buffer 126. At this point, if the host 110 issues a large input request again, the endpoint 123 reads the buffer 126 to provide the data DT3 to the host 110 since the buffer conversion flag BUFTOG is 0.
When the endpoint 123 starts providing data DT3 to the host 110, the hardware configuration (not shown) changes the buffer conversion flag BUFTOG to a value of 1. Since the buffer conversion flag BUFTOG is 1, a write circuit (not shown) writes a data DT4 in the buffer 127. Therefore, when the host 110 issues a large input request again, the endpoint 123 reads the buffer 127 to provide the data DT4 to the host 110 since the buffer conversion flag BUFTOG is 1.
Because 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 does not need to read the data of the two buffers through the two endpoints, it can avoid the situation that the multiple functions of the composite device cannot be realized simultaneously due to the shortage of the endpoints, thereby reducing the number of the endpoints used when a function is realized in the usb device 120. 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 determining the value of the buffer conversion flag BUFTOG, the data can be automatically switched between the two buffers to write the data into the free buffer in advance, thereby increasing the access speed.
FIG. 2 is a schematic flow chart of an accessing method according to the present invention. The access method of the invention is suitable for the 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 present invention does not limit the type and size of the data buffer. In one embodiment, the data buffer is a static random access memory with 512Bytes of storage space.
First, an endpoint in the usb device is set to correspond to the first and second buffers (step S211). In one embodiment, the endpoint is configured to perform a bulk-in transfer. The present invention does not limit the location of the first and second buffers in the data buffer memory. In one possible embodiment, the first buffer area is adjacent to or not adjacent to the second buffer area. In other embodiments, the storage space of the first buffer and the storage space of the second buffer may be the same or different.
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 provides data to the USB device through an external command. When the external instruction is a bulk input request, the first or second buffer is read according to a buffer conversion flag (step S213).
In the present embodiment, step S213 includes steps S214 to S216. In step S214, it is determined whether the buffer status flag is a first value (e.g., 0). When the buffer conversion flag is the first value, the first buffer is read to provide the host with a first data (step S215). In one embodiment, the buffer conversion 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 example, if there is new data (e.g., third data) to be written, the first buffer is written preferentially.
When the buffer conversion flag is not the first value (e.g., the value 1), the second buffer is read (step S216) to provide the host with a second data. At this time, since the buffer conversion flag is not the first value, a third data is written into the first buffer. In addition, the buffer conversion flag is changed to the first value when the second data is provided to the host. At this time, the writing priority of the second buffer is higher than that of the first buffer. Therefore, if new data (e.g., fourth data) is to be written, the data is written preferentially in the second buffer.
The access methods of the present invention, or certain aspects or portions thereof, may exist in the form of program code. The program code may be stored in a storage medium, such as a floppy disk, a compact disk, a hard disk, or any other machine-readable (e.g., computer-readable) storage medium, or is a computer program product, which is not limited to external forms, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes a universal serial bus (usb) device for practicing the invention.
The program code may also be transmitted over some transmission medium, such as over 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 are to be interpreted as commonly understood by one of ordinary skill in the art to which this invention belongs. Moreover, unless expressly stated otherwise, the definition of a term in a general dictionary shall be construed as being consistent with its meaning in the context of the relevant art and shall not be construed as an idealized or overly formal meaning.
Although the present invention has been described with reference to the above preferred embodiments, it should be understood that various changes and modifications can be made by those skilled in the art without departing from the spirit and scope of the invention. For example, the systems, devices, or methods described in the embodiments of the present invention may be implemented in hardware, software, or a combination of hardware and software. Therefore, the protection scope of the present invention is subject to the protection scope defined by the claims.

Claims (10)

1. A universal serial bus device, comprising:
a data buffer memory comprising:
a first buffer for storing a first data; and
a second buffer for storing a second data;
an end point corresponding to the first buffer area and the second buffer area; and
a connection port for coupling with a host;
when the host issues a bulk input request, the endpoint reads the first buffer or the second buffer according to a buffer conversion flag.
2. The USB device according to claim 1, wherein the endpoint reads the first buffer to provide the first data to the host when the buffer status flag is a first value.
3. The USB device according to claim 2, wherein the buffering transition flag is a second value when the endpoint provides the first data to the host.
4. The USB device according to claim 3, wherein the endpoint reads the second buffer to provide the second data to the host when the buffer conversion flag is the second value.
5. The USB device according to claim 4, wherein the first buffer stores a third data when the buffering transition flag is the second value.
6. The USB device according to claim 3, wherein the buffering transition flag is the first value when the endpoint provides the second data to the host.
7. The USB device according to claim 6, wherein the second buffer stores a fourth data when the buffering transition flag is the first value.
8. The usb device according to claim 1, wherein the first buffer has the same storage space as the second buffer.
9. The usb device of claim 1, wherein the second buffer is adjacent to the first buffer.
10. An access method for a universal serial bus device, the universal serial bus 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 an end point corresponding to the first buffer area and the second buffer area;
receiving an external instruction; and
when the external instruction is a bulk input request, the first buffer or the second buffer is read according to a buffer conversion flag.
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 true CN113127399A (en) 2021-07-16
CN113127399B 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 (8)

* 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
US20010056513A1 (en) * 2000-06-21 2001-12-27 Nec Corporation Data transfer control method and controller for universal serial bus interface
JP2004070423A (en) * 2002-08-01 2004-03-04 Ricoh Co Ltd Usb controller and method of controlling data transfer thereof
US20060020721A1 (en) * 2004-05-26 2006-01-26 Microchip Technology Incorporated Configurable ping-pong buffers for USB buffer descriptor tables
US20090157913A1 (en) * 2007-12-18 2009-06-18 Bellows Gregory H Method for Toggling Non-Adjacent Channel Identifiers During DMA Double Buffering Operations
US20110099305A1 (en) * 2009-10-23 2011-04-28 Via Technologies, Inc. Universal Serial Bus Host Control Methods and Universal Serial Bus Host Controllers
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 (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008082530A1 (en) * 2006-12-31 2008-07-10 Sandisk Corporation Method and apparatus for performing full transfer automation in a usb 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 (8)

* 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
US20010056513A1 (en) * 2000-06-21 2001-12-27 Nec Corporation Data transfer control method and controller for universal serial bus interface
JP2004070423A (en) * 2002-08-01 2004-03-04 Ricoh Co Ltd Usb controller and method of controlling data transfer thereof
US20060020721A1 (en) * 2004-05-26 2006-01-26 Microchip Technology Incorporated Configurable ping-pong buffers for USB buffer descriptor tables
US20090157913A1 (en) * 2007-12-18 2009-06-18 Bellows Gregory H Method for Toggling Non-Adjacent Channel Identifiers During DMA Double Buffering Operations
US20110099305A1 (en) * 2009-10-23 2011-04-28 Via Technologies, Inc. Universal Serial Bus Host Control Methods and Universal Serial Bus Host Controllers
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
TW202127265A (en) 2021-07-16
CN113127399B (en) 2024-02-20
TWI736092B (en) 2021-08-11

Similar Documents

Publication Publication Date Title
USRE48736E1 (en) Memory system having high data transfer efficiency and host controller
US10002085B2 (en) Peripheral component interconnect (PCI) device and system including the PCI
US9135190B1 (en) Multi-profile memory controller for computing devices
US8583842B2 (en) Data transfer device and data transfer system
US10860507B2 (en) Electronic systems having serial system bus interfaces and direct memory access controllers and methods of operating the same
US7409486B2 (en) Storage system, and storage control method
CN110795373B (en) I2C bus-to-parallel bus conversion method, terminal and storage medium
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
US20070005847A1 (en) Data transfer control device and electronic instrument
CN113127399B (en) Universal serial bus device and access method
CN116486868A (en) Computing high speed nonvolatile memory (NVMe) over high speed link (CXL)
CN112732176B (en) SSD (solid State disk) access method and device based on FPGA (field programmable Gate array), storage system and storage medium
CN109992560B (en) Communication method and communication system
CN116601616A (en) Data processing device, method and related equipment
US20040186949A1 (en) XIP system and method for serial memory
US7921238B2 (en) USB host system and method for transferring transfer data
US8547985B2 (en) Network interface controller capable of sharing buffers and buffer sharing method
CN112732166A (en) Method and device for accessing solid state disk
KR20200143922A (en) Memory card and method for processing data using the card
CN110399322B (en) Data transmission method and ping-pong DMA framework
CN110489359B (en) Data transmission control method and system
CN107562658B (en) CPU finger picking system and finger picking method
CN116955228A (en) Accelerator for processing write command
US7730233B2 (en) Data transfer control device and electronic instrument

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