USB接口信號(hào)發(fā)生器
USB接口信號(hào)發(fā)生器,usb,接口,信號(hào)發(fā)生器
英文資料及中文翻譯
PDIUSBD12----USB interface device with parallel bus
The PDIUSBD12 is a cost and feature optimized USB device. It is normally used in microcontroller based systems and communicates with the system microcontroller over the high-speed general purpose parallel interface. It also supports local DMA transfer.This modular approach to implementing a USB interface allows the designer to choose the optimum system microcontroller from the available wide variety. This flexibility cuts down the development time, risks, and costs by allowing the use of the existing architecture and minimize firmware investments.This results in the fastest way to develop the most cost effective USB peripheral solution.The PDIUSBD12 fully conforms to the USB specification Rev. 2.0 (basic speed). It is also designed to be compliant with most device class specifications: Imaging Class, Mass Storage Devices, Communication Devices, Printing Devices, and Human Interface Devices.Assuch, the PDIUSBD 12 is ideally suited for many peripherals like Printer, Scanner, External Mass Storage (Zip Drive), Digital Still Camera, etc. It offers an immediate cost reduction for applications that currently use SCSI implementations.The PDIUSBD12 low suspend power consumption along with the Lazy Clock output allowsfor easy implementation of equipment that is compliant to the ACPI(TM),OnNOW(TM), and USB power management requirements. The low operating power allows the implementation of bus powered peripherals. In addition; it also incorporates features like SoftConnect(TM), GoodLink(TM), programmable clock output, low frequency crystal oscillator, and integration of termination resistors. All of these features contribute to significant cost savings in the system implementation and at the same time ease the implementation of advanced USB functionality into the peripherals.
1. DMA transfer
Direct Memory Address (DMA) allows an efficient transfer of a block of data between thehostandlocalsharedmemory.UsingaDMAcontroller, data transfer between the
PDIUSBD12’s main endpoint (endpoint 2) and local shared memory can happen autonomously without local CPU intervention.
Preceding any DMA transfer, the local CPU receives from the host the necessary setup information and programs the DMA controller accordingly. Typically, the DMA controller is set up for demand transfer mode and the byte count register and the address counter are programmed with the right values. In this mode, transfers occur only when the PDIUSBD12 requests them and are terminated when the byte count register reaches zero. After the DMA controller has been programmed, the DMA enable bit of the PDIUSBD12 is set by the local CPU to initiate the transfer.
The PDIUSBD12 can be programmed for single-cycle DMA or burst mode DMA. In single-cycle DMA, the DMREQ pin is deactivated for every single acknowledgement by the DMACK_N before being re-asserted. In burst mode DMA, the DMREQ pin is kept active for the number of bursts programmed in the device before going inactive.This process continues until the PDIUSBD12 receives a DMA termination notice through pin EOT_N. This will generate an interrupt to notify the local CPU that DMA operation is completed.
For DMA read operation,the DMREQ pin will only be activated whenever the buffer is full, signalling that the host has successfully transferred a packet to the PDIUSBD12.With the double buffering scheme, the host can start filling up the second buffer while the first buffer is being read out. This parallel processing increases the effective throughput.When the host does not fill up the buffer completely (lessthan64 bytesor 128 bytes for single direction ISO configuration), the DMREQ pin will be deactivatedat the last byte of the buffer regardless of the current DMA burst count. It will be re-asserted on the next packet with a refreshed DMA burst count.
Similarly, for DMA write operations, the DMREQ pin remains active whenever the buffer is not full. When the buffer is filled up, the packet is sent over to the host on the next IN token and DMREQ will be reactivated if the transfer was successful. Also, the double buffering scheme here will improve throughput. For non-isochronous transfer (bulk and interrupt), the buffer needs to be completely filled up by the DMA writeoperation before the data is sent to the host. The only exception is at the end of DMA transfer, when the reception of pin EOT_N will stop DMA write operation and the buffer content will be sent to the host on the next IN token.
For isochronous transfers, the local CPU and DMA controller have to guarantee that they are able to sink or source the maximum packet size in one USB frame (1 ms).
The assertion of pin DMACK_Nautomatically selects the main endpoint (endpoint 2), regardless of the current selected endpoint. The DMA operation of the PDIUSBD12 can be interleaved with normal I/O access to other endpoints.
DMA operation can be terminated by resetting the DMA enable register bit or the assertion of EOT_N together with DMACK_N and either RD_N or WR_N.
The PDIUSBD12 supports DMA transfer in single address mode and it can also work in dual address mode of the DMA controller. In the single address mode, DMA transfer is done via the DREQ, DMACK_N, EOT_N, WR_N and RD_N control lines.
In the dual address mode, pins DMREQ, DMACK_N and EOT_N are not used; instead CS_N, WR_N and RD_N control signals are used. The I/O mode Transfer
Protocol of PDIUSBD12 needs to be followed. The source of the DMAC is accessed during the read cycle and the destination during the write cycle. Transfer needs to be done in two separate bus cycles, storing the data temporarily in the DMAC.
Command description
2. Command procedure
There are three basic types of commands: Initialization, Data Flow and General Commands. Respectively, these are used to initialize the function; for data flow between the function and the host; and some general commands.
2.1 Initialization commands
Initialization commands are used during the enumeration process of the USB network. These commands are used to enable the function endpoints. They are also used to set the USB assigned address.
⑴ Set Address/Enable
Code (Hex):D0
Transaction: write 1 byte
This command is used to set the USB assigned address and enable the function.
⑵ Set endpoint enable
Code (Hex):D8
Transaction: write 1 byte
Thegeneric/Isochronous endpoints can only been abled when the function is enabled via the Set Address/Enable command.
⑶ Set mode
Code (Hex):F3
Transaction: write 2 bytes
The Set mode command is followed by two data writes. The first byte contains the configuration bits. The second byte is the clock division factor byte.
⑷ CLOCK DIVISION
The value indicates the clock division factor for CLKOUT. The FACTOR output frequency is 48 MHz/(N+1) where N is the Clock Division Factor. The reset value is 11. This will produce the output frequency of 4 MHz which can then be programmed up or down by the user. The minimum value is 1 giving the range of frequency from 4 to 24 MHz. The minimum value of N is 0, giving a maximum frequency of 48 MHz.The maximum value of N is 11 giving a minimum frequency of 4 MHz.The PDIUSBD12 design ensures no glitching during frequency change. The programmed value will not be changed by a bus reset.
⑸ Set DMA
Code (Hex): FB
Transaction: read/write 1 byte
The set DMA command is followed by one data write/read to/from the DMA configuration register.DMA Configuration register: During DMA operation, the two-byte buffer header (status and byte length information) is not transferred to/from the local CPU. This allows DMA data to be continuous and not interleaved by chunks of this headers.For DMA read operations, the header will be skipped by the PDIUSBD12. For DMA write operations, the header will be automatically added by the PDIUSBD12. This provides for a clean and simple DMA data transfer.
2.2 Data flow commands
Data flow commands are used to manage the data transmission between the USB endpoints and the external microcontroller. Much of the data flow is initiated via an interrupt to the microcontroller. The microcontroller utilizes these commands to access and determine whether the endpoint FIFOs have valid data.
⑴ Read interrupt register
Code (Hex):F4
Transaction: read 2 bytes
This command indicates the origin of an interrupt. The endpoint interrupt bits (bits 0 to 5) are cleared by reading the endpoint last transaction status register through Read Last Transaction Status command. The other bits are cleared after reading the interrupt registers.
⑵ Select Endpoint
Code (Hex):00 to 05
Transaction: read 1 byte (optional)
The Select Endpoint command initializes an internal pointer to the start of the selected buffer. Optionally, this command can be followed by a data read, which returns this byte.
FULL/EMPTY: A ‘1’ indicates the buffer is full, ‘0’ indicates an empty buffer.
STALL: A ‘1’ indicates the selected endpoint is in the stall state.
Fig 11. Select Endpoint command: bit allocation.
⑶ Read Endpoint status
Code (Hex):80 to 85
Transaction: read 1 byte
⑷ Read last transaction status register
Code (Hex):40 to 45
Transaction: read 1 byte
The Read Last Transaction Status command is followed by one data read that returns the status of the last transaction of the endpoint. This command also resets the corresponding interrupt flag in the interrupt register, and clears the status, indicating that it was read.This command is useful for debugging purposes. Since it keeps track of every transaction, the status information is overwritten for each new transaction.
⑸ Read buffer
Code (Hex):F0
Transaction: read multiple bytes (max. 130)
The Read Buffer command is followed by a number of data reads, which returns the contents of the selected endpoint data buffer. After each read, the internal buffer pointer is incremented by 1.The buffer pointer is not reset to the top of the buffer by the Read Buffer command.This means that reading or writing a buffer can be interrupted by any other command (except for Select Endpoint).
The data in the buffer are organized as follows:
* byte 0: reserved; can have any value
* byte 1: number/length of data bytes
* byte 2: data byte 1
* byte 3: data byte 2
* etc.
The first two bytes will be skipped in the DMA read operation. Thus, the first read will get Data byte 1, the second read will get Data byte 2, etc. The PDIUSBD12 can determine the last byte of this packet through the EOP termination of the USB packet.
⑹ Write buffer
Code (Hex):F0
Transaction: write multiple bytes (max. 130)
The Write Buffer command is followed by a number of data writes, which load the endpoints buffer. The data must be organized in the same way as described in the Read Buffer command. The first byte (reserved) should always be ‘0’.During DMA writes operation, the first two bytes will be bypassed. Thus, the first write will write into Data byte 1, the second write will write into Data byte 2, etc.
For non-isochronous transfer(bulk or interrupt), the buffer should be completely filled before the data is sent to the host and a switch to the next buffer occurs. The exception is at the end of DMA transfer indicated by activation of EOT_N, when the current buffer content (completely full or not) will be sent to the host.
Remark: There is no protection against writing or reading over a buffer’s boundary or against writing into an OUT buffer or reading from an IN buffer. Any of these actions could cause an incorrect operation.Data in an OUT buffer are only meaningful after asuccessful transaction.The exception is during DMA operation on the main endpoint (endpoint 2), in which case the pointer is automatically pointed to the second buffer after reaching the boundary (double buffering scheme).
⑺ Clear buffer
Code (Hex):F2
Transaction: none
When a packet is received completely, an internal endpoint buffer full flag is set. All Subsequent packets will be refused by returning a NAK.When the microcontroller has read the data, it should free the buffer by the Clear Buffer command. When the buffer
is cleared, new packets will be accepted.
⑻ Validate buffer
Code (Hex): FA
Transaction: none
When the microprocessor has written data into an IN buffer, it should set the buffer full flag by the Validate Buffer command. This indicates that the data in the buffer are valid and can be sent to the host when the next IN token is received.
⑼ Set endpoint status
Code (Hex):40 to 45
Transaction: write 1 byte
A stalled control endpoint is automatically unstalled when it receives a SETUP token, regardless of the content of the packet. If the endpoint should stay in its stalled state, the microcontroller can re-stall it.When a stalled endpoint is unstalled (either by the Set Endpoint Status command or by receiving a SETUP token), it is also re-initialized. This flushes the buffer and if it is an OUT buffer it waits for a DATA 0 PID, if it is an IN buffer it writes a DATA 0 PID.Even when unstalled, writing Set Endpoint Status to ‘0’ initializes the endpoint.
2.3 General commands
Send resume
Code (Hex):F6
Transaction:none
Sends an upstream resume signal for 10 ms.This command is normally issued when the device is in suspend. The RESUME command is not followed by a data read or write.
Read current frame number
Code (Hex):F5
Transaction:read 1 or 2 bytes
This command is followed by one or two data reads and returns the frame number of the last successfully received SOF. The frame number is returned Least Significant byte first.
PDIUSBD12帶并行總線的USB接口器件
PDIUSBD12是一款性價(jià)比很高的USB器件,它通常用作微控制器系統(tǒng)中實(shí)現(xiàn)與微控制器進(jìn)行通信的高速通用并行接口,它還支持本地的DMA傳輸。這種實(shí)現(xiàn)USB接口的標(biāo)準(zhǔn)組件使得設(shè)計(jì)者可以在各種不同類型微控制器中選擇出最合適的微控制器。這種靈活性減小了開發(fā)的時(shí)間,風(fēng)險(xiǎn)以及費(fèi)用(通過使用已有的結(jié)構(gòu)和減少固件上的投資),從而用最快捷的方法實(shí)現(xiàn)最經(jīng)濟(jì)的USB外設(shè)的解決方案。PDIUSBD12完全符合USB1.1版的規(guī)范,它還符合大多數(shù)器件的分類規(guī)格,成像類海量存儲(chǔ)器件,通信器件,打印設(shè)備以及人機(jī)接口設(shè)備。同樣地,PDIUSBD12理想地適用于許多外設(shè)。例如,打印機(jī),掃描儀,外部的存儲(chǔ)設(shè)備(Zip驅(qū)動(dòng)器)和數(shù)碼相機(jī)等等。它使得當(dāng)前使用SCSI的系統(tǒng)可以立即降低成本。PDIUSBD12所具有的低掛起功耗連同LazyClock輸出可以滿足使用ACPI,OnNOW和USB電源管理的要求,低的操作功耗可以應(yīng)用于使用總線供電的外設(shè)。此外它還集成了許多特性,包括SoftConnetTM,GoodLinkTM,可編程時(shí)鐘輸出,低頻晶振和終止寄存器集合。所有這些特性都為系統(tǒng)顯著節(jié)約了成本,同時(shí)使USB功能在外設(shè)上的應(yīng)用變得容易。
1. DMA傳輸
直接存儲(chǔ)器尋址(DMA)允許在主端點(diǎn)和本地共享存儲(chǔ)器間實(shí)現(xiàn)數(shù)據(jù)塊的有效傳輸。使用DMA控制器,PDIUSBD12的主端點(diǎn)和本地共享存儲(chǔ)器間的數(shù)據(jù)傳輸可自主進(jìn)行而不需要本地CPU的干預(yù)。要處理任何DMA傳輸,本地CPU從主機(jī)接收必要的SETUP信息并對(duì) DMA控制器進(jìn)行相應(yīng)的編程,典型的對(duì)DMA控制器的傳輸模式,字節(jié)計(jì)數(shù)寄存器和地址計(jì)數(shù)器進(jìn)行正確的編程。在該模式下,PDIUSBD12發(fā)出請(qǐng)求時(shí)開始傳輸。當(dāng)字節(jié)計(jì)數(shù)器減少為零時(shí)終止。在DMA控制器編程之后,本地CPU在初始化傳輸時(shí)將PDIUSBD12中的DMA使能位置位。
PDIUSBD12可編程為單周期DMA或突發(fā)模式DMA。在單周期DMA中,DMREQ在每單個(gè)應(yīng)答后直到被DMACK_N重新激活之前保持無效。在突發(fā)模式DMA中,DMREQ在器件中突發(fā)編程時(shí)一直保持有效。該過程持續(xù)到PDIUSBD12通過EOT_N接收到一個(gè)DMA終止信息。這時(shí)產(chǎn)生一個(gè)中斷指示本地CPU DMA操作已經(jīng)完成。
在DMA讀操作時(shí)DMREQ僅當(dāng)緩沖區(qū)完全表示主機(jī)成功的發(fā)送了一個(gè)信息包到PDIUSBD12時(shí)才有效。由于具有雙緩沖配置,主機(jī)可以在第一個(gè)緩沖區(qū)被讀出時(shí)對(duì)第二個(gè)緩沖區(qū)進(jìn)行填充,這種并行的處理有效的增加了數(shù)據(jù)吞吐量。當(dāng)主機(jī)沒有完全填滿緩沖區(qū)的情況下(單向ISO配置時(shí)小于64或128字節(jié)),DMREQ會(huì)在緩沖區(qū)的最后一個(gè)字節(jié)時(shí)無效 而不管當(dāng)前的DMA突發(fā)計(jì)數(shù)。在更新了DMA突發(fā)計(jì)數(shù)的下一個(gè)包發(fā)送時(shí),DMREQ再次被激活。
DMA的寫操作與之相似,當(dāng)緩沖區(qū)未裝滿時(shí),DMREQ一直有效。當(dāng)緩沖區(qū)填滿時(shí),在下一個(gè)IN標(biāo)志將信息包送入主機(jī)。當(dāng)傳輸完成之后,DMREQ變?yōu)闊o效。同樣的,雙緩沖配置在這也改善了數(shù)據(jù)的吞吐量。在非同步傳輸中,批量模式和中斷。在數(shù)據(jù)被發(fā)送到主機(jī)之前,緩沖區(qū)需要通過DMA寫操作完全裝滿。唯一的例外是,在DMA傳輸結(jié)束時(shí),EOT_N接收的信號(hào)將會(huì)停止DMA寫操作并且在下一個(gè)IN標(biāo)志置位時(shí)將緩沖區(qū)的內(nèi)容傳送到主機(jī)。
在同步模式中,本地CPU和DMA控制器必須保證它們在一個(gè)USB幀(1ms)中能夠吞吐的最大信息包的規(guī)模。DMACK_N的激活將自動(dòng)選擇主端點(diǎn)(端點(diǎn)2)而不管當(dāng)前選擇的端點(diǎn)。PDIUSBD12的DMA操作可通過普通的I/O對(duì)其它端點(diǎn)的存取實(shí)現(xiàn)交叉存取。DMA操作可通過以下方式終止:復(fù)位DMA使能寄存器位或EOT_N加上DMACK_N以及 RD_N/WR_N的激活。
PDIUSBD12支持單地址模式中的DMA傳輸,也可以在DMA控制器的雙地址模式中工作。在單地址模式中DMA通過DREQ DMACK_N,EOT_N,WR_N和RD_N控制線實(shí)現(xiàn)傳輸。在雙地址模式中DMREQ,DMACK_N和EOT_N未用,取而代之的是CS_N,WR_N和RD_N控制信號(hào)。需要遵循PDIUSBD12的I/O模式傳輸協(xié)議。在讀周期中對(duì)DMAC信號(hào)源進(jìn)行訪問,在寫周期對(duì)目標(biāo)進(jìn)行訪問,傳輸需要兩個(gè)單獨(dú)的總線周期來儲(chǔ)存暫存在DMAC中的數(shù)據(jù)。
2. 命令描述
有3種基本的類型的命令:初始化,數(shù)據(jù)流和通用命令。
2.1 初始化命令
初始化命令在USB網(wǎng)絡(luò)進(jìn)行枚舉處理時(shí)使用,這些命令用于使能端點(diǎn)的功能,還可用來設(shè)置USB配的地址。
⑴設(shè)置地址/使能
命令:D0h
處理:寫1字節(jié)
該命令用于設(shè)置USB分配的地址和使能功能。
地址 寫入的值即為地址
使能 置1使能該功能
⑵設(shè)置端點(diǎn)使能
命令:D8h
處理:寫1字節(jié)
通過設(shè)置設(shè)置地址/使能命令后才可使能普通/同步端點(diǎn)
普通/同步
端點(diǎn) 值1表示普通/同步端點(diǎn)使能
⑶設(shè)置模式
命令:F3h
處理:寫2字節(jié)
設(shè)置模式命令后跟2個(gè)寫入的數(shù)據(jù),第一個(gè)字節(jié)包含配置字節(jié)信息,第二個(gè)字節(jié)是時(shí)鐘分頻因素字節(jié)。
配置字節(jié)
無LazyClock:1 表示CLKOUT不會(huì)切換到LazyClock,0表示CLKOUT在Suspend腳變高之后切換到LazyClock,LazyClock頻率是30KHz±40%,編程值將不過會(huì)被總線復(fù)位所改變。
時(shí)鐘運(yùn)行:1表示內(nèi)部時(shí)鐘和PLL即使在掛起狀態(tài)下仍然運(yùn)行,0表示只要不需要時(shí),內(nèi)部時(shí)鐘晶振和PLL就停止運(yùn)行,為了滿足嚴(yán)格的掛起電流要求,該位需要設(shè)置為0,已編程的值不會(huì)被總線復(fù)位所改變。
中斷模式:1表示報(bào)告所有的錯(cuò)誤和“NAKing”并產(chǎn)生一個(gè)中斷。0表示只有OK被報(bào)告。編程值不會(huì)被總線復(fù)位所改變。
SoftConnect:1表示如果VBUS可用,上行數(shù)據(jù)上拉電阻就被連接,0表示不連接。已編程的值不會(huì)被總線復(fù)位所改變。
端點(diǎn)配置:該2位設(shè)置端點(diǎn)配置如下:
模式 0 非同步模式
模式 1 同步輸出模式
模式 2 同步輸入模式
模式 3 同步輸入/輸出模式
⑷時(shí)鐘分頻系數(shù)字節(jié)
時(shí)鐘分頻系數(shù):該值用來表示CLKOUT的時(shí)鐘分頻系數(shù),用N表示分頻系數(shù),那么輸出頻率就為48MHz/(N+1),復(fù)位值為11。這產(chǎn)生4MHz的輸出頻率,然后可由用戶自行調(diào)節(jié)。當(dāng)N為0時(shí),得到最大頻率48MHz,當(dāng)N取最大11時(shí),得到最小頻率4MHz。PDIUSBD12的設(shè)計(jì)確保了在改變頻率時(shí)不會(huì)出現(xiàn)干擾,已編程的值不會(huì)被總線復(fù)位所改變。
SET_TO_ONE:該位需要在任何DMA讀或?qū)懖僮髦爸脼?。該位在上電復(fù)位值為0。復(fù)位后可將其一直設(shè)為1。
僅有SOF中斷模式:將該位置1后,僅當(dāng)幀時(shí)鐘的起始(SOF)時(shí)刻引起中斷的產(chǎn)生 而不管引腳中斷模式的設(shè)置狀態(tài)設(shè)置(DMA位5)
⑸設(shè)置 DMA
命令:FBh
處理:讀/寫1字節(jié)
設(shè)置DMA命令后跟1個(gè)字節(jié)數(shù)據(jù)寫入/讀出 DMA配置寄存器
DMA配置寄存器
在DMA操作中,兩字節(jié)的緩沖區(qū)頭(狀態(tài)和字節(jié)長度信息)不參與傳送。這就允許了DMA數(shù)據(jù)的連續(xù)性,不插入信息頭。DMA讀操作時(shí),信息頭被PDIUSBD12跳過,在DMA寫操作時(shí),信息頭由PDIUSBD12自動(dòng)添加,這就提供了一個(gè)簡潔的DMA數(shù)據(jù)傳輸。
DMA突發(fā)串:選擇DMA操作的突發(fā)串長度
00 單周期 DMA
01 突發(fā)串 4 周期 DMA
10 突發(fā)串 8 周期 DMA
11 突發(fā)串 16 周期 DMA
DMA使能:向該位寫入1會(huì)通過激活DMREQ啟動(dòng)DMA操作,在激活DMREQ之前需要裝滿(DMA讀操作)或清空(DMA寫操作)主端點(diǎn)緩沖區(qū)。在單周期DMA模式中,DMREQ在突發(fā)串?dāng)?shù)目耗盡后無效,然后下一個(gè)突發(fā)串時(shí)重新激活,這個(gè)過程一直持續(xù)到EOT_N和DMACK_N以及RD_N或WR_N一起被激活。此時(shí)將該位置0并終止DMA操作,DMA操作也可通過直接向該位寫入0來終止。
DMA方向:該位決定了DMA傳輸時(shí)數(shù)據(jù)流的方向,1表示從外部共享存儲(chǔ)器到PDIUSBD12(DMA寫操作),0表示從PDIUSBD12到外部共享存儲(chǔ)器(DMA讀操作)。
自動(dòng)重裝:當(dāng)該位設(shè)為1,DMA操作會(huì)自動(dòng)重新啟動(dòng)。
中斷腳模式:0表示正常的中斷腳模式,中斷寄存器所有位的邏輯或產(chǎn)生中斷,當(dāng)該位寫入1時(shí)表示中斷會(huì)在USB總線上行數(shù)據(jù)流出現(xiàn)幀時(shí)鐘(SOF)起始位時(shí)產(chǎn)生中斷。其它中斷仍然有效。
端點(diǎn)索引4中斷使能:該位為1表示只要端點(diǎn)緩沖區(qū)包含一個(gè)有效的信息包就會(huì)產(chǎn)生中斷,通常在DMA操作時(shí)關(guān)閉以減少不必要的CPU響應(yīng)。
端點(diǎn)索引5中斷使能:該位為1表示只要端點(diǎn)緩沖區(qū)有效,見緩沖區(qū)生效命令,就會(huì)產(chǎn)生中斷,通常在DMA操作時(shí)關(guān)閉以減少不必要的CPU響應(yīng)。
2.2 數(shù)據(jù)流命令
數(shù)據(jù)流命令用于管理USB端點(diǎn)和外部微控制器之間的數(shù)據(jù)傳輸,通過微控制器中斷初始化大量的數(shù)據(jù)流。微控制器利用這些命令訪問和決定端點(diǎn)的FIFO是否含有有效的數(shù)據(jù)。
⑴讀中斷寄存器
命令:F4h
處理:讀2字節(jié)
中斷寄存器字節(jié)1
中斷寄存器字節(jié) 2
該命令指示中斷的來源,通過讀端點(diǎn)最后處理狀態(tài)寄存器將端點(diǎn)中斷位(位0~5)清零,其它位在讀中斷寄存器后被清零。
總線復(fù)位:在總線復(fù)位后將產(chǎn)生一個(gè)中斷將該位置1??偩€復(fù)位與通過RESET_N腳的硬件
復(fù)位基本相同,有一點(diǎn)除外,就是總線復(fù)位產(chǎn)生一個(gè)中斷并且器件在默認(rèn)地址0處使能。
掛起改變:當(dāng)PDIUSBD12沒有收到3個(gè)SOF時(shí),將會(huì)進(jìn)入掛起狀態(tài)并將掛起改變位置位。任何掛起或喚醒狀態(tài)的改變都會(huì)將該位置位并產(chǎn)生中斷。
DMA EOT:該位表示DMA操作已結(jié)束。
⑵選擇端點(diǎn)
命令:00-05h
處理:可選讀1字節(jié)
選擇端點(diǎn)命令將內(nèi)部指針初始化到選擇的緩沖區(qū)起始位置。可選的該命令可跟一個(gè)返回的讀出字節(jié)。
滿/空 1表示緩沖區(qū)已滿,0 表示緩沖區(qū)為空。
停止 1表示選擇的端點(diǎn)處于停止?fàn)顟B(tài)。
⑶讀端點(diǎn)狀態(tài)
命令:80-85h
處理:讀1字節(jié)
⑷讀最后處理狀態(tài)寄存器
命令:40-45h
處理:讀1字節(jié)
讀最后處理狀態(tài)寄存器命令后跟一個(gè)數(shù)據(jù)返回端點(diǎn)最后處理的狀態(tài),該命令同時(shí)復(fù)位中斷寄存器中的相應(yīng)位并將狀態(tài)清零表示已經(jīng)讀取,由于它保留了每次處理的記錄,所以該命令在以調(diào)試為目的時(shí)很有用。在每次新的處理之后會(huì)將原來的狀態(tài)信息覆蓋。
數(shù)據(jù)接收/發(fā)送成功:1表示數(shù)據(jù)已經(jīng)成功地接收或發(fā)送。
SETUP信息包:1表示最后成功接收的信息包有一個(gè)SETUP標(biāo)志,對(duì)IN緩沖區(qū)進(jìn)行讀總為0。
數(shù)據(jù)0/1包:1表示最后成功接收/發(fā)送包含有一個(gè)DATA1 PID。
前一狀態(tài)未讀:1表示在前一狀態(tài)被讀出之前發(fā)生了第二個(gè)事件。
⑸讀緩沖區(qū)
命令:F0h
處理:讀多個(gè)字節(jié),最大130
讀緩沖區(qū)命令后,返回一系列從選擇的端點(diǎn)數(shù)據(jù)緩沖區(qū)讀出的數(shù)據(jù),每讀一個(gè)字節(jié),內(nèi)部緩沖區(qū)指針自動(dòng)加一,讀緩沖區(qū)命令不會(huì)將緩沖區(qū)指針復(fù)位到緩沖區(qū)起始端,這意味著可被其它的命令所中斷(選擇端點(diǎn)命令除外)。
緩沖區(qū)數(shù)據(jù)結(jié)構(gòu)如下
字節(jié)1:保留;可為任意值
字節(jié)2:數(shù)據(jù)字節(jié)的數(shù)目/長度
字節(jié)3:數(shù)據(jù)字節(jié)1
字節(jié)4:數(shù)據(jù)字節(jié)2
……
頭兩個(gè)字節(jié)在DMA讀操作中可跳過。因此第一個(gè)讀出的字節(jié)是數(shù)據(jù)字節(jié)1。第二個(gè)讀出的是數(shù)據(jù)字節(jié)2等等。PDIUSBD12可通過USB信息包的EOP終止來決定包的最后一個(gè)字節(jié)。
⑹寫緩沖區(qū)
命令:F0h
處理:寫多個(gè)字節(jié),最大130
寫緩沖區(qū)命令后跟一系列需要寫入端點(diǎn)緩沖區(qū)的數(shù)據(jù),數(shù)據(jù)的結(jié)構(gòu)必須與前面描述的讀緩沖區(qū)命令一樣。第一個(gè)字節(jié)(保留)總為0。在DMA寫操作中,頭兩個(gè)字節(jié)會(huì)被繞過,因此,第一個(gè)寫入的字節(jié)是數(shù)據(jù)字節(jié)1。第二個(gè)寫入的是數(shù)據(jù)字節(jié)2等等。在非同步傳輸(批量或中斷)中,數(shù)據(jù)被發(fā)送到主機(jī)之前緩沖區(qū)必須被完全填滿并切換到下一個(gè)緩沖區(qū)。例外的情況是,當(dāng)前的緩沖區(qū)內(nèi)容將要被發(fā)送到主機(jī)時(shí),由有效的EOT_N指示DMA傳輸?shù)慕Y(jié)束。
⑺清緩沖區(qū)
命令:F2h
處理:無
當(dāng)一個(gè)信息包完全接收之后,內(nèi)部端點(diǎn)緩沖區(qū)滿標(biāo)志置位,所有后續(xù)的包將被返回的NAK拒絕,當(dāng)微控制器已讀取數(shù)據(jù),它應(yīng)當(dāng)通過清緩沖區(qū)命令來釋放緩沖區(qū),當(dāng)緩沖區(qū)清空之后新的信息包就可被接受了。
⑻使緩沖區(qū)有效
命令:Fah
處理:無
當(dāng)微控制器已將數(shù)據(jù)寫入IN緩沖區(qū),它應(yīng)當(dāng)通過使緩沖區(qū)有效命令設(shè)置緩沖區(qū)滿標(biāo)志,這表示緩沖區(qū)內(nèi)的數(shù)據(jù)有效并可在接收到下一個(gè)IN標(biāo)志時(shí)將其送入主機(jī)。
⑼設(shè)置端點(diǎn)狀態(tài)
命令:40-45h
處理:寫1字節(jié)
當(dāng)一個(gè)停止控制的端點(diǎn)接收到SETUP標(biāo)志時(shí)自動(dòng)解除停止,而不管信息包的內(nèi)容如何,如果端點(diǎn)應(yīng)當(dāng)停在停止?fàn)顟B(tài),微控制器可以重新停止它。
當(dāng)一個(gè)停止的端點(diǎn)解除了停止,設(shè)置端點(diǎn)命令或接收到一個(gè)SETUP標(biāo)志,它同時(shí)被重新初始化將緩沖區(qū)刷新,如果是OUT緩沖區(qū)就等待一個(gè)DATA 0 PID,如果是IN緩沖區(qū)就寫入一個(gè)DATA 0 PID,即使在解除停止時(shí),將設(shè)置端點(diǎn)狀態(tài)寫為0,也將初始化端點(diǎn)。
停止 1 表示端點(diǎn)處于停止?fàn)顟B(tài)
2.3普通命令
發(fā)送恢復(fù)
命令:F6h
處理:無
發(fā)送一個(gè)上行數(shù)據(jù)流恢復(fù)信號(hào)10ms,該命令通常用于器件處于掛起狀態(tài)時(shí),恢復(fù)命令后不跟讀出或?qū)懭氲臄?shù)據(jù)
讀當(dāng)前幀數(shù)目
該命令后跟1到2個(gè)讀出的字節(jié)并返回最后成功接收的SOF幀數(shù)目,幀數(shù)目為返回的低位字節(jié)。
12
收藏