JP2007140813A - Usb device - Google Patents

Usb device Download PDF

Info

Publication number
JP2007140813A
JP2007140813A JP2005332512A JP2005332512A JP2007140813A JP 2007140813 A JP2007140813 A JP 2007140813A JP 2005332512 A JP2005332512 A JP 2005332512A JP 2005332512 A JP2005332512 A JP 2005332512A JP 2007140813 A JP2007140813 A JP 2007140813A
Authority
JP
Japan
Prior art keywords
request
usb device
setting
usb
packet
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
JP2005332512A
Other languages
Japanese (ja)
Other versions
JP4666369B2 (en
Inventor
Hideyo Nakano
秀世 中野
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.)
Kawasaki Microelectronics Inc
Original Assignee
Kawasaki Microelectronics Inc
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 Kawasaki Microelectronics Inc filed Critical Kawasaki Microelectronics Inc
Priority to JP2005332512A priority Critical patent/JP4666369B2/en
Publication of JP2007140813A publication Critical patent/JP2007140813A/en
Application granted granted Critical
Publication of JP4666369B2 publication Critical patent/JP4666369B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To prevent malfunctions from occurring when a transfer error is generated in a status stage during control transfer from a USB host. <P>SOLUTION: When the USB device automatically responds to the request of the control transfer received from the USB host, setting required by the request is performed at a timing (steps S3, S5 and S8) specified by the contents of the request. For the request of Set_Address, an address is set to the USB device in the step S5 or S8. <P>COPYRIGHT: (C)2007,JPO&INPIT

Description

本発明は、USBホストから受信したコントロール転送のリクエストに対して自動応答を行うUSBデバイスにかかわり、特にそのコントロール転送時に発生した転送エラーによる誤動作を防止したUSBデバイスに関するものである。   The present invention relates to a USB device that automatically responds to a control transfer request received from a USB host, and more particularly to a USB device that prevents malfunction due to a transfer error that occurred during the control transfer.

まず、USBについて簡単に説明する。USBで転送されるデータは、トークンパケット、データパケット、ハンドシェークパケットで構成され、これら3つのパケットで構成される1回のデータ転送はトランザクションと呼ばれる。   First, USB will be briefly described. Data transferred by USB is composed of a token packet, a data packet, and a handshake packet, and one data transfer composed of these three packets is called a transaction.

トークンパケットには、トランザクションの種類を示すPID(識別子)やデータ転送の相手方となるUSBデバイスのアドレスおよびエンドポイントが格納されており、このトークンパケットの情報に適合したUSBデバイスとUSBホストとの間でデータ転送が可能になる。データパケットには転送データが格納されている。ハンドシェークパケットにはデータ転送が正常に完了したか否かを示す情報が格納されている。   The token packet stores the PID (identifier) indicating the type of transaction, the address of the USB device that is the counterpart of the data transfer, and the end point, and between the USB device and the USB host that conform to the information of the token packet. Data transfer becomes possible. Transfer data is stored in the data packet. The handshake packet stores information indicating whether or not the data transfer has been normally completed.

トランザクションには、INトランザクション、OUTトランザクション、SETUPトランザクションの3種類がある。INトランザクションではUSBデバイスからUSBホストへデータが転送される。OUTトランザクションではその反対にUSBホストからUSBデバイスへデータが転送される。SETUPトランザクションはUSBホストからUSBデバイスに対して規格で規定されたコマンドの転送を行うとき使用される。これら3つのトランザクションで、バルク転送、コントロール転送、アイソクロナス転送、あるいはインタラプト転送と呼ばれる転送が構成される。   There are three types of transactions: IN transactions, OUT transactions, and SETUP transactions. In the IN transaction, data is transferred from the USB device to the USB host. Conversely, in the OUT transaction, data is transferred from the USB host to the USB device. The SETUP transaction is used when a command specified by the standard is transferred from the USB host to the USB device. These three transactions constitute a transfer called bulk transfer, control transfer, isochronous transfer, or interrupt transfer.

バルク転送は非周期的に大量データを扱う転送に用いられ、INトランザクション、またはOUTトランザクションの繰り返しで行われる。コントロール転送はUSBデバイスの制御などに必要な情報のやりとりについて使用される転送であり、セットアップトランザクション(セットアップステージ)で始まりINトランザクション又はOUTトランザクションからなるデータトランザクション(データステージ)が続き、ステータストランザクション(ステータスステージ)で終わる。ただし、データトランザクションは無い場合がある。アイソクロナス転送は連続的で周期的な通信に使用され、ハンドシェークパケットの無いINトランザクションまたはOUTトランザクションの並びである。インタラプト転送は周期的でバンド幅が低いデータ転送に使用される1つのINトランザクションである。   Bulk transfer is used for transferring a large amount of data aperiodically, and is performed by repeating an IN transaction or an OUT transaction. The control transfer is a transfer used for exchanging information necessary for USB device control, etc., and starts with a setup transaction (setup stage), followed by a data transaction (data stage) consisting of an IN transaction or OUT transaction, and a status transaction (status End with stage. However, there may be no data transaction. Isochronous transfer is used for continuous and periodic communication, and is a sequence of IN or OUT transactions without handshake packets. An interrupt transfer is a single IN transaction used for periodic and low bandwidth data transfers.

これらの各種転送は、フレームと呼ばれる一定期間(フルスピードモードでは1ms、ハイスピードモードでは125μs)に並べられて、1フレーム単位で転送される。フレームの開始は、SOF(Start of Frame)パケットと呼ばれる特殊なパケットで通知される。   These various transfers are arranged in a certain period called a frame (1 ms in the full speed mode, 125 μs in the high speed mode) and transferred in units of one frame. The start of the frame is notified by a special packet called an SOF (Start of Frame) packet.

図3にUSBシステムの構成を示す。1個のUSBホスト1(パーソナルコンピュータ)に複数のUSBデバイスが接続される。例えば、3台のUSBデバイス2A,2B,2Cが接続された場合では、個々のUSBデバイス2A,2B,2CにはUSBホスト1によりアドレス「1」,「2」,「3」が割り当てられる。そして、各USBデバイス2A,2B,2Cは、USBホスト1から転送されたトークンパケットに含まれるアドレスを確認し、自己のUSBデバイス宛に送信されたパケットか、他のUSBデバイス宛に送信されたパケットかを判断する。   FIG. 3 shows the configuration of the USB system. A plurality of USB devices are connected to one USB host 1 (personal computer). For example, when three USB devices 2A, 2B, and 2C are connected, addresses “1”, “2”, and “3” are assigned by the USB host 1 to the individual USB devices 2A, 2B, and 2C. Then, each USB device 2A, 2B, 2C confirms the address included in the token packet transferred from the USB host 1, and is sent to its own USB device or to another USB device. Determine if it is a packet.

図4はこの処理の概要を示す図で、USBホスト1からUSBデバイス2A→2B→2Cの順にトークンパケットが転送されている場合を示す。例えば、USBデバイス2Aでは、アドレス「1」のトークンパケットに対してはデータDATA_Aを返す。これに対して、USBホスト1はハンドシェークパケットACKを返す。しかし、USBデバイス2Aは他のアドレス「2」,「3」のトークンパケットに対してはデータを返さず、送信されてきたトークンパケットを無視する。また、USBデバイス2Aは、他のUSBデバイス2B,2CからのデータDATA_B、DATA_Cに対してUSBホスト1が返したACKも無視する。   FIG. 4 is a diagram showing an outline of this process, and shows a case where token packets are transferred from the USB host 1 in the order of the USB devices 2A → 2B → 2C. For example, the USB device 2A returns data DATA_A to the token packet with the address “1”. In response to this, the USB host 1 returns a handshake packet ACK. However, the USB device 2A does not return data to token packets of other addresses “2” and “3”, and ignores the transmitted token packet. The USB device 2A also ignores the ACK returned by the USB host 1 for the data DATA_B and DATA_C from the other USB devices 2B and 2C.

図5はUSBデバイスへのアドレスの設定の説明図である。個々のUSBデバイスのアドレスの初期値は「0」であり、接続後にコントロール転送のSet_Addressリクエストにより「0」以外のアドレス「1」〜「127」のうちの1つ値がセットされる。すなわち、セットアップステージにおいて、USBデバイスはUSBホストから送信されたSETUPトークンパケットと8バイトのデータパケットを受信すると、セットアップデータに含まれるアドレス(例えば「1」)を保持する。そして、ACKハンドシェークパケットをUSBホストに返信する。USBホストはACKハンドシェークパケットを受信すると、次に、ステータスステージにおいて、INトークンパケットを当該USBデバイスに送信する。これを受信した当該USBデバイスは、アドレス「1」の正常受信を知らせる長さ0バイトのデータパケットを送信する。これがUSBホストで受信されると、そのUSBホストからACKハンドシェークパケットがUSBデバイスに返信されるので、これを受信した時点でUSBデバイスはアドレス「1」をセットする。このようにして、USBデバイスは、コントロール転送のステータスステージの完了を示すACKハンドシェークパケットを受信したタイミングでアドレス設定を行う。   FIG. 5 is an explanatory diagram of address setting to the USB device. The initial value of the address of each USB device is “0”, and one of the addresses “1” to “127” other than “0” is set by a control transfer Set_Address request after connection. That is, in the setup stage, when receiving the SETUP token packet and the 8-byte data packet transmitted from the USB host, the USB device holds the address (for example, “1”) included in the setup data. Then, an ACK handshake packet is returned to the USB host. When receiving the ACK handshake packet, the USB host next transmits an IN token packet to the USB device in the status stage. The USB device that has received this transmits a 0-byte data packet informing the normal reception of the address “1”. When this is received by the USB host, an ACK handshake packet is returned from the USB host to the USB device, and when this is received, the USB device sets the address “1”. In this way, the USB device performs address setting at the timing of receiving the ACK handshake packet indicating completion of the status stage of control transfer.

図6はUSBデバイス2の構成を示すブロック図である。USBデバイス2はUSBデバイスコントローラ21、USB動作を制御するMPU22、データ格納用のメモリ(RAM)23、そのメモリ23を制御するメモリコントローラ24、内部バス25を具備する。   FIG. 6 is a block diagram showing the configuration of the USB device 2. The USB device 2 includes a USB device controller 21, an MPU 22 that controls USB operation, a memory (RAM) 23 for storing data, a memory controller 24 that controls the memory 23, and an internal bus 25.

図7は図6に示したUSBデバイスコントローラ21の内部構成を示すブロック図である。USBデバイスコントローラ21は、パケットの入出力を制御するUSBPHY211、入出力するパケットを制御するパケット制御回路212、データ保持用のエンドポイントバッファ213、DMAコントローラ214、制御レジスタ215を具備する。   FIG. 7 is a block diagram showing an internal configuration of the USB device controller 21 shown in FIG. The USB device controller 21 includes a USBPHY 211 that controls input / output of packets, a packet control circuit 212 that controls packets to be input / output, an endpoint buffer 213 for holding data, a DMA controller 214, and a control register 215.

ところで、USBの規格では、転送エラーが発生した場合に、その後の通信が停止してしまわないようにエラー発生時のプロトコルが定義されている。コントロール転送のSet_Addressリクエストにおいて、USBホストがUSBデバイスからデータを受け取るIN転送では図8〜10の処理が行われる。   By the way, in the USB standard, when a transfer error occurs, a protocol at the time of the error occurrence is defined so that subsequent communication will not stop. In the IN transfer in which the USB host receives data from the USB device in the Set_Address request for the control transfer, the processes of FIGS. 8 to 10 are performed.

図8にケース1を示す。これは、USBデバイスが、USBホストから返信されるINトークンパケットを正常に受信できなかった場合である。このときは、USBデバイスから長さ0バイトのデータパケットの返信がないので、USBホストは再度INトークンパケットをUSBデバイスに対して送信(リトライ)して、USBデバイスからの長さ0バイトデータの返信を要求する。この2回目のINトークンパケットを受信したUSBデバイスが長さ0バイトのデータパケットを返信し、このデータパケットを受信したUSBホストがACKハンドシェークパケットを送信し、これがUSBデバイスで受信されると、その受信のタイミングでUSBデバイス内のアドレスセットが行われる。   Case 1 is shown in FIG. This is a case where the USB device cannot normally receive the IN token packet returned from the USB host. At this time, since there is no reply of a 0-byte data packet from the USB device, the USB host transmits (retrys) the IN token packet to the USB device again, and the 0-byte data from the USB device is returned. Request a reply. The USB device that has received this second IN token packet returns a 0-byte data packet, and the USB host that has received this data packet sends an ACK handshake packet. Address setting in the USB device is performed at the reception timing.

図9にケース2を示す。これは、USBホストが、USBデバイスから返信される0バイトのデータパケットを正常に受信できなかった場合である。データパケットを受信できないため、USBホストからACKハンドシェークパケットが返信されない。そして、USBホストは、再度INトークンパケットをUSBデバイスに対して送信(リトライ)する。USBデバイスはこれに応じて同じ0バイトのデータパケットを送信する。この後は、ケース1と同様に、2回目のINトークンパケットを受信したUSBデバイスが長さ0バイトのデータパケットを返信し、このデータパケットを受信したUSBホストがACKハンドシェークパケットを送信し、これがUSBデバイスで受信されると、その受信のタイミングでUSBデバイス内のアドレスセットが行われる。   FIG. 9 shows Case 2. This is a case where the USB host cannot normally receive the 0-byte data packet returned from the USB device. Since the data packet cannot be received, the ACK handshake packet is not returned from the USB host. Then, the USB host transmits (retrys) the IN token packet to the USB device again. In response to this, the USB device transmits the same 0-byte data packet. After this, as in Case 1, the USB device that received the second IN token packet returns a 0-byte data packet, and the USB host that received this data packet sends an ACK handshake packet. When received by the USB device, address setting in the USB device is performed at the reception timing.

INトークンパケットを用いるコントロール転送のステータスステージで、上記ケース1,2のような転送エラーが発生した場合には、USBホストからINトークンパケットを再送信(リトライ)することによってUSBデバイスのアドレスセットが正しく行われ、その後の通信が停止することはない。   If a transfer error such as in cases 1 and 2 above occurs in the status stage of control transfer using an IN token packet, the address set of the USB device is determined by retransmitting (retrying) the IN token packet from the USB host. It is done correctly and subsequent communication never stops.

ところが、図10に示すケース3の転送エラーが発生した場合は、USBデバイスにアドレスが正しくセットされず、誤動作を起こす。すなわち、図10のケース3はステータスステージにおいて、USBデバイスが、USBホストから返信されたACKハンドシェークパケットを正常に受信できなかった場合である。このとき、USBホストは、USBデバイスから0バイトのデータパケットを受信済みであるため、USBデバイス側でのアドレスセットが正常に行われたと判断して、ACKハンドシェークパケットを返信し、コントロール転送のステータスステージを終了する。そして、次のセットアップステージにおいては、セット済みのアドレス(図10においては「1」)を指定したSETUPトークンパケットを送信する。   However, when a transfer error in case 3 shown in FIG. 10 occurs, the address is not set correctly in the USB device, causing malfunction. That is, Case 3 in FIG. 10 is a case where the USB device cannot normally receive the ACK handshake packet returned from the USB host in the status stage. At this time, since the USB host has already received the 0-byte data packet from the USB device, the USB host determines that the address setting on the USB device has been performed normally, returns an ACK handshake packet, and returns the control transfer status. End the stage. In the next setup stage, a SETUP token packet designating a set address (“1” in FIG. 10) is transmitted.

しかし、USBデバイス側では、まだUSBホストからのACKハンドシェークパケットを受信できていないので、アドレスのセットが行われておらず、アドレスは初期値「0」のままである。このため、SETUPトークンパケットのアドレス不一致により応答できなくなり、誤動作を起こす。   However, since the USB device side has not yet received the ACK handshake packet from the USB host, the address is not set, and the address remains at the initial value “0”. For this reason, it becomes impossible to respond due to the address mismatch of the SETUP token packet, and malfunction occurs.

以上から、接続を再度確立するためには、USBホストのファームウエアで再リクエストを行う処理を予め用意しておくか、これが無い場合は人手によるUSBケーブルの抜き差しが必要になってくる。   From the above, in order to re-establish the connection, it is necessary to prepare in advance a process for performing a re-request with the firmware of the USB host, or when this is not available, the USB cable must be manually connected and disconnected.

本発明の目的は、USBホストからのコントロール転送時のステータスステージで転送エラーが発生した場合にも、誤動作が発生しないか、もしくは少なくとも、誤動作発生が抑制されたUSBデバイスを提供することである。   An object of the present invention is to provide a USB device in which a malfunction does not occur even when a transfer error occurs in a status stage during control transfer from a USB host, or at least the malfunction is suppressed.

上記課題を解決するために、請求項1にかかる発明は、USBホストから受信したコントロール転送のリクエストに対して自動応答を行うUSBデバイスであって、前記リクエストの内容により特定されるタイミングで前記リクエストにより要求された設定を行うようにした。
請求項2にかかる発明は、前記リクエストの内容が、前記設定を行った後に前記USBホストからIN転送要求のリトライを受信したときに該リトライに対して自動応答を行うことが可能なリクエストである場合に、該リクエストに対して前記USBデバイスが送信する応答を受信した前記USBホストが送信する、ACK信号の受信を待つことなく設定を行うようにした。
請求項3にかかる発明は、請求項2にかかる発明において、前記リクエストの内容が、前記USBデバイスが送信する応答を受信した前記USBホストが送信するACK信号の受信を待つことなく設定を行うと、前記USBホストからIN転送要求のリトライを受け取ったときに該リトライに対して自動応答を行うことが不可能である場合に、前記ACK信号の受信を待ってから前記設定を行うようにした。
請求項4にかかる発明は、請求項1乃至3のいずれかにかかる発明において、前記リクエストに対して前記USBデバイスが送信する応答を受信した前記USBホストが前記USBデバイスに対してACK信号に続いて送信する、次のパケットが特定できる場合に、該特定された次のパケットの受信を待ってから前記設定を行うようにした。
請求項5にかかる発明は、請求項4にかかる発明において、前記コントロール転送のセットアップステージにおいて前記USBホストから受信したデータを記憶するセットアップバッファを有するとともに、前記リクエストに対する応答を送信した後に前記USBホストから受信したデータを前記セットアップデータバッファに記憶したデータと比較して、前記特定された次のパケットの受信を識別するパケット識別回路を有するようにした。
請求項6にかかる発明は、請求項1、2、3、4又は5にかかる発明において、前記リクエストをデコードし、該リクエストの内容を判断するリクエストデコーダ回路を有するようにした。
In order to solve the above-described problem, the invention according to claim 1 is a USB device that automatically responds to a control transfer request received from a USB host, and the request is specified at a timing specified by the content of the request. The setting requested by was added.
According to a second aspect of the present invention, when the content of the request receives a retry of an IN transfer request from the USB host after performing the setting, the request can automatically respond to the retry. In this case, the setting is made without waiting for the reception of the ACK signal transmitted by the USB host that has received the response transmitted by the USB device in response to the request.
The invention according to claim 3 is the invention according to claim 2, wherein the content of the request is set without waiting for reception of an ACK signal transmitted by the USB host that has received a response transmitted by the USB device. When an IN transfer request retry is received from the USB host and it is impossible to automatically respond to the retry, the setting is performed after the reception of the ACK signal.
According to a fourth aspect of the present invention, in the invention according to any one of the first to third aspects, the USB host that has received a response transmitted by the USB device in response to the request follows the ACK signal to the USB device. When the next packet to be transmitted can be identified, the setting is performed after waiting for the reception of the identified next packet.
The invention according to claim 5 is the invention according to claim 4, further comprising a setup buffer for storing data received from the USB host in the setup stage of the control transfer, and the USB host after transmitting a response to the request. A packet identification circuit for comparing reception of the next packet identified is compared with data stored in the setup data buffer.
The invention according to claim 6 is the invention according to claim 1, 2, 3, 4 or 5, further comprising a request decoder circuit for decoding the request and judging the content of the request.

本発明のUSBデバイスによれば、USBホストから受信したコントロール転送のリクエストの内容により特定されるタイミングでそのリクエストにより要求された設定を行うので、転送エラーが発生しても、誤動作を防止することができる。   According to the USB device of the present invention, since the setting requested by the request is performed at the timing specified by the content of the control transfer request received from the USB host, even if a transfer error occurs, malfunction is prevented. Can do.

全てのUSBデバイスで標準対応が必要で、且つ、Set_Addressリクエストと同じ方式のコントロール転送を使用するリクエストは、他に何種類かある。例えば、Set_Feature、Clear_Feature、Set_Configuration、Set_Interface等である。本発明では、このような各種のコントロール転送のリクエスト内容に応じて特定のタイミングでリクエストにより要求された内容の設定を行い、転送エラーが発生しても誤動作を起こさないようにする。   There are several other types of requests that require standard support for all USB devices and that use the same type of control transfer as the Set_Address request. For example, Set_Feature, Clear_Feature, Set_Configuration, Set_Interface, etc. In the present invention, the contents requested by the request are set at a specific timing in accordance with the contents of the various control transfer requests, and no malfunction occurs even if a transfer error occurs.

図1は本発明の1つの実施例のUSBデバイスのデバイスコントローラ21の構成を示すブロック図である。図示の構成要素の内、セットアップデータバッファ2161、リクエストデコード回路2162、パケット識別回路2163、設定条件生成回路2164からなる設定回路216が、本実施例のデバイスコントローラ21において新たに追加したものである。その他は、図7で説明した従来のUSBデバイスコントローラ21に含まれていた要素である。   FIG. 1 is a block diagram showing a configuration of a device controller 21 of a USB device according to one embodiment of the present invention. Among the components shown in the figure, a setting circuit 216 including a setup data buffer 2161, a request decode circuit 2162, a packet identification circuit 2163, and a setting condition generation circuit 2164 is newly added in the device controller 21 of the present embodiment. The other elements are elements included in the conventional USB device controller 21 described with reference to FIG.

図1に示したUSBデバイスコントローラ21をもつUSBデバイスにおいては、パケット制御回路212によって受信されたリクエストに含まれるアドレスデータ等の設定データがセットアップデータバッファ2161に記憶される。また、受信されたリクエストは、リクエストデコード回路2162に送られ、そのリクエスト内容(種別)が判断される。さらに、パケット識別回路2163は、受信したパケットを識別する。そして、リクエストデコード回路2162によるデコード結果およびパケット識別回路2163によるパケット識別結果に基づいて、設定条件生成回路2164が設定タイミングを設定する。この設定結果に基づいた適切なタイミングで、パケット制御回路212が受信したパケットに含まれる設定データが制御レジスタ215に記憶され、設定が行われる。   In the USB device having the USB device controller 21 shown in FIG. 1, setting data such as address data included in the request received by the packet control circuit 212 is stored in the setup data buffer 2161. The received request is sent to the request decode circuit 2162, and the request content (type) is determined. Further, the packet identification circuit 2163 identifies the received packet. Based on the decoding result by the request decoding circuit 2162 and the packet identification result by the packet identification circuit 2163, the setting condition generation circuit 2164 sets the setting timing. At appropriate timing based on the setting result, setting data included in the packet received by the packet control circuit 212 is stored in the control register 215 and setting is performed.

本実施例のUSBデバイスでのステータスステップの処理のフローを図2に示す。本実施例では、ステータスステージの転送フローの3箇所に、リクエスト内容により選定される設定(1)〜(3)のステップS3,S5,S8を設けている。この設定(1)〜(3)の選定はUSBデバイスコントローラ21のリクエストデコード回路2162とパケット識別回路2163で行う。ただし、リクエストをUSBデバイスコントローラ21の外部でその都度判断してレジスタ215に書き込むことで切り替えてもよい。   FIG. 2 shows a flow of status step processing in the USB device of this embodiment. In the present embodiment, steps S3, S5, and S8 of settings (1) to (3) selected according to the request contents are provided at three locations in the status stage transfer flow. The settings (1) to (3) are selected by the request decode circuit 2162 and the packet identification circuit 2163 of the USB device controller 21. However, it may be switched by judging the request outside the USB device controller 21 each time and writing it in the register 215.

図2において、ステップS1はステータスステージで最初にUSBホストから転送されるINトークンパケットの受信の有無を判断する。ステップS2では該INトークンパケットを受信すると対応するデータをUSBホストに対して送信する。ステップS4は該対応するデータを受信したUSBホストからのACKハンドシェークパケットの受信の有無を判断する。ステップS6はリトライによりUSBホストから再転送されるINトークンパケットの受信の有無を判断する。ステップS7は、ステップS2でデータを送信した後に、このデータを受信したUSBホストがACKハンドシェークパケットに続いて送信する次のパケットの受信の有無を判断する。例えば、ステータスステージに先立つセットアップステージがSet_Addressリクエストであった場合は、セットアップステージで受信されたアドレスデータをセットアップデータバッファ2161に保存しておく。そして、ステップS7において、USBホスト1がそのアドレスヘ次のパケットを送信してきたか否かを判断する。   In FIG. 2, step S1 determines whether or not an IN token packet first transferred from the USB host is received in the status stage. In step S2, when the IN token packet is received, the corresponding data is transmitted to the USB host. In step S4, it is determined whether or not an ACK handshake packet is received from the USB host that has received the corresponding data. In step S6, it is determined whether or not an IN token packet re-transferred from the USB host by the retry is received. In step S7, after transmitting the data in step S2, it is determined whether or not the USB host that has received this data has received the next packet transmitted following the ACK handshake packet. For example, if the setup stage preceding the status stage is a Set_Address request, the address data received in the setup stage is stored in the setup data buffer 2161. In step S7, it is determined whether or not the USB host 1 has transmitted the next packet to the address.

図2において、ステップS3の設定(1)は、設定を行った後に転送エラーが発生した場合でもそのリトライ動作に影響しない(つまり、リトライに対してファームウエアもしくは人手による対応を必要とせず、自動応答を行うことが可能な)リクエストの内容に応じた設定を行う。例えば、Set_ConfigurationリクエストでConfiguration Valueを設定する場合は、設定後にステータスステージのINトークンパケット転送のリトライが発生してもそのリトライ動作に影響しないので、この設定(1)で設定する。これに対して、例えば、Set_FeatureリクエストでTEST_MODEを設定する場合は、設定(1)で設定してしまうとUSBデバイスが別のモードに移行するため、INトークンパケット転送のリトライが行われてもそれに応答できない。また、Set_Addressリクエストでデバイスアドレスを設定する場合は、設定(1)でアドレスを設定してしまうと、アドレス不一致によりINトークンパケット転送のリトライに応答できない。このようなリクエストの場合には、設定(1)での設定は行われない。   In FIG. 2, the setting (1) in step S3 does not affect the retry operation even if a transfer error occurs after the setting is made (that is, automatic operation is not required for the retry without requiring firmware or manual response). Set according to the content of the request (which can respond). For example, when the Configuration Value is set by the Set_Configuration request, even if a retry of IN token packet transfer in the status stage occurs after the setting, the retry operation is not affected, so this setting (1) is used. On the other hand, for example, when setting TEST_MODE with a Set_Feature request, the USB device moves to another mode if it is set in setting (1). I cannot respond. Also, when setting a device address with a Set_Address request, if an address is set in setting (1), it cannot respond to a retry of IN token packet transfer due to an address mismatch. In the case of such a request, the setting in the setting (1) is not performed.

この設定(1)では、リクエストデコード回路2162でデコードされたリクエストが当該ステップS3の設定(1)で行うべき内容である場合に、ステップS1で受信したINトークンパケットをパケット識別回路2163で識別した直後に、設定(1)のタイミングを設定条件生成回路2164で生成して、その設定を制御レジスタ215に対して行う。なお、この設定(1)はステップS2のデータ送信と同時又はそれより前であっても良い。   In this setting (1), when the request decoded by the request decoding circuit 2162 has contents to be made in the setting (1) of the step S3, the IN token packet received in step S1 is identified by the packet identification circuit 2163. Immediately after that, the timing of the setting (1) is generated by the setting condition generation circuit 2164 and the setting is made to the control register 215. This setting (1) may be performed simultaneously with or before the data transmission in step S2.

ステップS5における設定(2)は、設定(1)で設定を行ってしまうと、転送エラーによるステータスステージのINトークンパケット転送のリトライが発生した場合に、リトライ動作に影響を与えるリクエストである場合に行う。   The setting (2) in step S5 is a request that affects the retry operation when a retry of the IN stage packet transfer in the status stage due to a transfer error occurs if the setting is made in the setting (1). Do.

この設定(2)では、リクエストデコード回路2162でデコードされたリクエストが当該ステップS3の設定(1)で行うべきではない内容である場合に、ステップS4で受信したACKハンドシェークパケットをパケット識別回路2163で識別した直後に、設定(2)のタイミングを設定条件生成回路2164で生成して、その設定を制御レジスタ215に対して行う。このように設定(2)では、ステップS4でACKハンドシェークパケットの受信があるとき行うので、Set_Addressのリクエストに対して、前記した図5、図8、図9で説明した設定が可能である。しかし、図10で説明した転送エラーには対応できない。   In this setting (2), when the request decoded by the request decoding circuit 2162 has contents that should not be made in the setting (1) of step S3, the packet identification circuit 2163 receives the ACK handshake packet received in step S4. Immediately after the identification, the setting condition generation circuit 2164 generates the timing of setting (2), and the setting is performed on the control register 215. Since the setting (2) is performed when an ACK handshake packet is received in step S4, the setting described with reference to FIGS. 5, 8, and 9 can be performed for the Set_Address request. However, it cannot cope with the transfer error described in FIG.

ステップS8における設定(3)は、設定(1)で設定を行ってしまうと、転送エラーによりINトークンパケット転送のリトライが発生した場合にリトライ動作に影響を与えるリクエストであって、且つ、続くパケットが確定(想定)可能なリクエストの場合に実行される。つまり、USBの接続手順で次に実行されるリクエストが決まっていることが条件である。例えば、Set_AddressリクエストでUSBデバイスのアドレス設定が行われた場合、次には、Get_Descriptiorリクエストが実行されることが決まっている。   The setting (3) in step S8 is a request that affects the retry operation when an IN token packet transfer retry occurs due to a transfer error if the setting is made in the setting (1), and the subsequent packet It is executed when the request can be confirmed (assumed). That is, the condition is that the next request to be executed is determined in the USB connection procedure. For example, when the USB device address is set by the Set_Address request, it is determined that the Get_Descriptior request is executed next.

この設定(3)は、まずリクエストデコード回路2162でデコードされたリクエストが当該ステップS7の設定(3)で行うべき内容であることが条件である。そして、ACKハンドシェークパケットが受信できず(ステップS4)、リトライのINトークンパケットも受信できなかった(ステップS6)場合に、受信したパケットが特定の次のパケットであることをパケット識別回路2163で識別した(ステップS7)直後に、設定(3)のタイミングを設定条件生成回路2164で生成して、その設定を制御レジスタ215に対して行う。   This setting (3) is made on condition that the request decoded by the request decoding circuit 2162 is the contents to be made in the setting (3) of step S7. If the ACK handshake packet cannot be received (step S4) and the retry IN token packet cannot be received (step S6), the packet identification circuit 2163 identifies that the received packet is a specific next packet. Immediately after (step S7), the timing of setting (3) is generated by the setting condition generation circuit 2164, and the setting is performed on the control register 215.

この設定(3)は、例えば、Set_Addressのリクエストの場合は、具体的には以下のように行われる。まず、リクエストに含まれるセットアップステージのアドレスデータが、セットアップデータバッファ2161に記憶される。また、受信されたSet_Addressのリクエストは、リクエストデコード回路2162に送られ、その内容が判断される。その後、ステップS7において受信したパケットがパケット識別回路2163で識別されるとともに、該受信したパケットに含まれるアドレスとセットアップデータバッファ2161に記憶したアドレスとが比較される。そして、両アドレスが一致するときに該受信したパケットが特定の次のパケットであることが識別される。そして、リクエストデコード回路2162による判断結果がSet_Addressのリクエストであること、およびパケット識別回路2163による識別結果がステップS7の次パケットであることに基づいて、設定条件生成回路2164が設定(3)のタイミングを生成する。このタイミングでセットアップデータバッファ2161に記憶されたアドレスデータが制御レジスタ215に記憶され、アドレス設定が行われる。この設定(3)により、では前記図10で説明した転送エラーが発生しても、次のセットアップステージのSETUPトークンパケットの受信によりそのアドレス設定を行うことができる。従って、誤動作発生を防止できる。   For example, in the case of a Set_Address request, the setting (3) is specifically performed as follows. First, setup stage address data included in the request is stored in a setup data buffer 2161. The received Set_Address request is sent to the request decoding circuit 2162, and the contents thereof are determined. Thereafter, in step S7, the received packet is identified by the packet identification circuit 2163, and the address included in the received packet is compared with the address stored in the setup data buffer 2161. Then, when both addresses match, it is identified that the received packet is a specific next packet. Then, based on the determination result by the request decode circuit 2162 being a Set_Address request and the identification result by the packet identification circuit 2163 being the next packet of step S7, the setting condition generation circuit 2164 sets the timing of setting (3). Is generated. At this timing, the address data stored in the setup data buffer 2161 is stored in the control register 215, and address setting is performed. With this setting (3), even if the transfer error described in FIG. 10 occurs, the address can be set by receiving the SETUP token packet in the next setup stage. Therefore, the occurrence of malfunction can be prevented.

本実施例においては、設定(1)、(2)、(3)の3つの設定タイミングを設け、リクエストの内容に応じて、このいずれかのタイミングにおいて設定を行った。これにより、全ての場合に誤動作の発生を防止できるわけではないが、いずれか1つの設定タイミングしか設けなかった場合に比較すると、はるかに誤動作発生の頻度を低減することができる。ただし、これらの3つの設定タイミングの全てを設けることは必ずしも必須ではない。何れか2つの設定タイミングを設け、リクエストの内容に応じていずれかのタイミングにおいて設定を行うことによっても、いずれか1つの設定タイミングしか設けなかった場合に比較すると誤動作発生の頻度を低減することができる。   In this embodiment, three setting timings (1), (2), and (3) are provided, and the setting is performed at any one of these timings according to the content of the request. Thus, although it is not possible to prevent the occurrence of malfunctions in all cases, the frequency of malfunctions can be greatly reduced compared to the case where only one set timing is provided. However, it is not always necessary to provide all of these three setting timings. Even if any two setting timings are provided and the setting is performed at any timing according to the content of the request, the frequency of occurrence of malfunction can be reduced as compared with the case where only one setting timing is provided. it can.

例えば、設定(1)のタイミングを設けず、設定(2)、(3)の設定タイミングのみを設けることによっても、図10に示した転送エラーには対応できる。すなわち、Set_Addressリクエストに対する設定を行うためには、設定(1)のタイミングは不要である。この場合、上記の実施例においては設定(1)において設定したSet_ConfigurationリクエストでのConfiguration Value設定も、設定(2)において行う。   For example, it is possible to cope with the transfer error shown in FIG. 10 by providing only the setting timings of the settings (2) and (3) without providing the timing of the setting (1). In other words, the timing of the setting (1) is not necessary for setting for the Set_Address request. In this case, in the above embodiment, the Configuration Value setting in the Set_Configuration request set in the setting (1) is also performed in the setting (2).

本発明の実施例のUSBデバイスのUSBデバイスコントローラの構成のブロック図である。It is a block diagram of a structure of the USB device controller of the USB device of the Example of this invention. 本発明の実施例のUSBデバイスのステータスステージの処理のフローチャートである。It is a flowchart of the process of the status stage of the USB device of the Example of this invention. 従来のUSBシステムの構成のブロック図である。It is a block diagram of the structure of the conventional USB system. 図3のUSBデバイスへのデータ転送のタイミングチャートである。4 is a timing chart of data transfer to the USB device of FIG. 3. USBデバイスへのアドレス設定のタイミングチャートである。It is a timing chart of the address setting to a USB device. 従来のUSBホストとUSBデバイスの概略構成の説明用のブロック図である。It is a block diagram for demonstrating schematic structure of the conventional USB host and USB device. 従来のUSBデバイスコントローラの構成のブロック図である。It is a block diagram of the structure of the conventional USB device controller. USBデバイスへのアドレス設定の転送エラーがある場合のケース1のタイミングチャートである。10 is a timing chart of case 1 when there is an error in transferring an address setting to a USB device. USBデバイスへのアドレス設定の転送エラーがある場合のケース2のタイミングチャートである。12 is a timing chart of case 2 when there is an error in transferring an address setting to a USB device. USBデバイスへのアドレス設定の転送エラーがある場合のケース3のタイミングチャートである。12 is a timing chart of case 3 in the case where there is an address setting transfer error to the USB device.

符号の説明Explanation of symbols

1:USBホスト
2,2A,2B,2C:USBデバイス
21:USBデバイスコントローラ、211:USBPHY、212:パケット制御回路、213:エンドポイントバッファ、214:DMAコントローラ、215:制御レジスタ、216:設定回路
2161:セットアップデータバッファ、2162:リクエストデコード回路、2163:パケット識別回路、2164:設定条件生成回路
1: USB host 2, 2A, 2B, 2C: USB device 21: USB device controller, 211: USBPHY, 212: packet control circuit, 213: endpoint buffer, 214: DMA controller, 215: control register, 216: setting circuit 2161: Setup data buffer, 2162: Request decode circuit, 2163: Packet identification circuit, 2164: Setting condition generation circuit

Claims (6)

USBホストから受信したコントロール転送のリクエストに対して自動応答を行うUSBデバイスであって、前記リクエストの内容により特定されるタイミングで前記リクエストにより要求された設定を行うことを特徴とするUSBデバイス。   A USB device that automatically responds to a control transfer request received from a USB host, wherein the setting requested by the request is performed at a timing specified by the content of the request. 前記リクエストの内容が、前記設定を行った後に前記USBホストからIN転送要求のリトライを受信したときに該リトライに対して自動応答を行うことが可能なリクエストである場合に、該リクエストに対して前記USBデバイスが送信する応答を受信した前記USBホストが送信する、ACK信号の受信を待つことなく設定を行うことを特徴とする請求項1記載のUSBデバイス。   When the content of the request is a request that can automatically respond to the retry when receiving the retry of the IN transfer request from the USB host after performing the setting, The USB device according to claim 1, wherein the setting is performed without waiting for reception of an ACK signal transmitted by the USB host that has received a response transmitted by the USB device. 前記リクエストの内容が、前記USBデバイスが送信する応答を受信した前記USBホストが送信するACK信号の受信を待つことなく設定を行うと、前記USBホストからIN転送要求のリトライを受け取ったときに該リトライに対して自動応答を行うことが不可能である場合に、前記ACK信号の受信を待ってから前記設定を行うことを特徴とする請求項2に記載のUSBデバイス。   If the content of the request is set without waiting for the reception of the ACK signal transmitted by the USB host that has received the response transmitted by the USB device, the request is received when an IN transfer request retry is received from the USB host. The USB device according to claim 2, wherein when the automatic response to the retry is impossible, the setting is performed after the reception of the ACK signal. 前記リクエストの内容が、前記リクエストに対して前記USBデバイスが送信する応答を受信した前記USBホストが前記USBデバイスに対してACK信号に続いて送信する、次のパケットが特定できる場合に、該特定された次のパケットの受信を待ってから前記設定を行うことを特徴とする請求項1乃至3のいずれかに記載のUSBデバイス。   When the content of the request can identify the next packet that the USB host that has received the response transmitted by the USB device in response to the request transmits to the USB device following the ACK signal, the specification can be performed. The USB device according to claim 1, wherein the setting is performed after waiting for reception of the next packet. 前記コントロール転送のセットアップステージにおいて前記USBホストから受信したデータを記憶するセットアップバッファを有するとともに、前記リクエストに対する応答を送信した後に前記USBホストから受信したデータを前記セットアップデータバッファに記憶したデータと比較して、前記特定された次のパケットの受信を識別するパケット識別回路を有することを特徴とする請求項4記載のUSBデバイス。   A setup buffer for storing data received from the USB host in the setup stage of the control transfer, and comparing data received from the USB host after transmitting a response to the request with data stored in the setup data buffer; 5. The USB device according to claim 4, further comprising a packet identification circuit for identifying reception of the specified next packet. 前記リクエストをデコードし、該リクエストの内容を判断するリクエストデコーダ回路を有することを特徴とする請求項1、2、3、4又は5に記載のUSBデバイス。   6. The USB device according to claim 1, further comprising a request decoder circuit that decodes the request and determines contents of the request.
JP2005332512A 2005-11-17 2005-11-17 USB device Expired - Fee Related JP4666369B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005332512A JP4666369B2 (en) 2005-11-17 2005-11-17 USB device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005332512A JP4666369B2 (en) 2005-11-17 2005-11-17 USB device

Publications (2)

Publication Number Publication Date
JP2007140813A true JP2007140813A (en) 2007-06-07
JP4666369B2 JP4666369B2 (en) 2011-04-06

Family

ID=38203600

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005332512A Expired - Fee Related JP4666369B2 (en) 2005-11-17 2005-11-17 USB device

Country Status (1)

Country Link
JP (1) JP4666369B2 (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003337786A (en) * 2002-05-21 2003-11-28 Victor Co Of Japan Ltd Serial interface device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003337786A (en) * 2002-05-21 2003-11-28 Victor Co Of Japan Ltd Serial interface device

Also Published As

Publication number Publication date
JP4666369B2 (en) 2011-04-06

Similar Documents

Publication Publication Date Title
KR100456180B1 (en) A peripheral device and control method thereof
CN111857838B (en) Method and system for managing communication between UFS device and UFS host
JP3664664B2 (en) Bus system and bus arbitration method thereof
JPS639786B2 (en)
US11544132B2 (en) Communication apparatus, communication method, program, and communication system
CN110896372B (en) I2C link switching method, terminal and storage medium
US6889265B2 (en) Apparatus and method to allow and synchronize schedule changes in a USB enhanced host controller
JP4666369B2 (en) USB device
JP4104939B2 (en) Multiprocessor system
JP4098910B2 (en) Packet transfer control device and packet transfer method
CN112241279B (en) Self-adaptive electronic control unit software upgrading method and system and automobile
US7702838B2 (en) Method and apparatus for configuration space extension bus
JP3750467B2 (en) USB simulation apparatus and storage medium
JP2000269993A (en) Data transmission method and transmitter
JP2001325212A (en) Method and device for transmitting data block from source processor to destination processor in multiprocessor system
US6546019B1 (en) Duplex memory control apparatus
JP2006195607A (en) Method and circuit for determining bulk-out transfer end
JPH11252150A (en) Network connection device and network connection control method
WO2012093475A1 (en) Information transfer device and information transfer method of information transfer device
JP2001256171A (en) Data transfer method and module
JP2573790B2 (en) Transfer control device
JPH0378066A (en) Data processor
JP2022091361A (en) Communication device, communication method, and program
JP2003249978A (en) Serial forwarding device
JPWO2004107188A1 (en) Data processing apparatus and data communication method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20080924

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20110105

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110105

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20140121

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Ref document number: 4666369

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees