Adopt the data transmission and the control system of USB (universal serial bus)
Technical field
The present invention relates to a kind of data transmission and control system, specifically, relate to the system that a kind of employing USB (universal serial bus) (USB) mode is carried out data transmission and control.
Background technology
The English full name of USB is Universal Serial Bus, the Chinese implication is a USB (universal serial bus), wherein the data of being transmitted are to follow the USB specification data, and the USB standard is to be to simplify interconnection between PC and the peripheral hardware and a kind of free data transmission standard of joint research exploitation by companies such as Conpaq, DEC, IBM, Inter, Microsoft, NEC and Northen Telecom.If relevant data are had between the electronic equipment of CPU when transmitting by the USB standard, the software that meets the USB standard accordingly must be set in these electronic equipments, and adopt special-purpose USB circuit that these electronic equipments are coupled together, thereby constitute the usb bus system.In a word, a complete usb bus system can be divided into three parts: the main frame of usb bus (to call the USB main equipment in the following text), the equipment of usb bus (to call the USB slave unit in the following text) and the USB circuit that USB main equipment and USB slave unit are coupled together.Couple by the USB circuit between USB main equipment and the USB slave unit.Be provided with USB main equipment software in the USB main equipment, be provided with the USB configuration information in the USB slave unit.After the start of USB main equipment, the USB main equipment is powered to the USB slave unit by the power lead of USB circuit, and by pulse of pull-up resistor generation, this pulse signal is back to the USB main equipment by the data line of USB circuit, thereby the USB main equipment is learnt the existence of this USB slave unit, and be that this USB slave unit distributes unique USB address, mark is come by the address register of USB main equipment in this address, to guarantee that packet can not be transferred to other USB slave unit.Simultaneously at first set up a message channel that is called Endpoint 0 between USB main equipment and USB slave unit, the USB main equipment brings into use Endpoint 0 channel to read the cell configuration tagged word of being stored in the USB slave unit ROM (read-only memory) as the USB configuration information.Based on the cell configuration tagged word, the USB main equipment is that this USB slave unit is specified a Configuration Values, and at this moment, the USB slave unit promptly has been in configuration status, thereby also just set up communication contact between USB main equipment and USB slave unit, this process of setting up communication contact is called " USB enumerates ".In any usb bus system, a USB main equipment can only be arranged, this can have 1 to 127 the USB slave unit, when slave unit quantity more for a long time, can adopt the mode of cascade USB main equipment and USB slave unit to be coupled together with usb hub and USB circuit.
It should be noted that above-mentioned " coupling " speech, only be not interpreted as directly to limitation to link to each other.Like this, sentence " device A couples with equipment B " should not be limited to device A wherein an output directly and an equipment or a system that input links to each other of equipment B.Its meaning is, have a path between the input of the output of device A and equipment B, and this path may comprise miscellaneous equipment or parts.
Fig. 1 has provided the circuit block diagram of a kind of usb bus of the prior art system.This usb bus system has a USB main equipment 131 and a USB slave unit 132, interconnects by USB circuit 121 between USB main equipment 131 and the USB slave unit 132, and has set up communication contact each other.USB main equipment 131 among the figure comprises a USB host device processor 111 and a data use device 114, and USB slave unit 132 comprises a USB slave unit processor 112 and a data storer 115.USB host device processor 111 can connect another one U SB slave unit by USB circuit 124.During this usb bus system works, USB main equipment 131 sends instruction by USB host device processor 111 and gives USB slave unit processor 112, USB slave unit processor 112 can respond this instruction, data memory device 115 is carried out read-write operations, USB slave unit processor 112 is given USB host device processor 111 with result transmission, and USB host device processor 111 uses device 114 to use for data after handling data.
Fig. 2 has provided the circuit block diagram of another kind of usb bus of the prior art system.The main equipment 331 of this usb bus system is a DVD player that has USB host device processor 311, and its data use device 314 to comprise a figure and audio process is used for carrying out the Voice ﹠ Video decoding.USB slave unit 332 is card reader of the band USB slave unit processor 312 of a static state, it can be controlled data storer 315, data-carrier store 315 can be selected in a lot of storage mediums, for example SmartMedia, MemoryStick, CompactFlash, SD card etc.DVD player 331 links to each other with card reader 332 by USB circuit 321, and DVD player also can be set up communication contact by USB circuit 324 and other USB slave unit processor.
In the usb bus system, data transmission between USB main equipment and the USB slave unit is a synchronous transmission, its speed is tens of times of standard serial port, when the USB main equipment is connected with the USB slave unit, can carry out Hot insertion hot swapping, the USB main equipment in the usb bus system can also directly provide power supply to some USB slave units simultaneously.At full speed the high transmission rates of USB interface can reach 12Mb/s, faster whole 100 times than serial ports, and the hi-speed USB interface speed of carrying out the USB2.0 standard has reached 480Mb/s especially, along with formally coming into operation of USB2.0, what all kinds of memory devices of USB interface developed allows the people too plenty for the eye to take it all in soon, not only Cheng Shu USB hard disk is accompanied by that bandwidth one action breakthrough bottleneck up to 480Mbps of USB2.0 becomes the focus that people attract attention, and portable CD writer, flash memory disk storer are also accepted by people because of the raising of speed.Simultaneously this makes the real-time Transmission of high capacity image of high resolving power, true color become possibility.But usb bus of the prior art system only has the data transmission in the storer in the USB slave unit is handled the function that the back uses device to use for the data in the USB main equipment in the USB main equipment, and its function ratio is more single.
Summary of the invention
The purpose of this invention is to provide a kind of data transmission and control system that adopts USB (universal serial bus), this system can realize delivering to after the USB main equipment is read the data in the data-carrier store of USB main equipment the USB slave unit, use device to use by the data of USB slave unit again.
Realize that a kind of data transmission of USB (universal serial bus) and the technical scheme of control system of adopting that provide in the object of the invention is: native system has a USB main equipment and a USB slave unit, the USB main equipment has a USB host device processor, the USB slave unit has a USB slave unit processor, couples by the USB circuit between USB host device processor and the USB slave unit processor; Its design feature is: the USB main equipment also has a data-carrier store that links to each other with the USB host device processor; The USB slave unit also has data that link to each other with USB slave unit processor and uses device; USB host device processor and USB slave unit processor in use set up a kind of have can make USB slave unit processor call and handle the communication contact of the function of the data in the data-carrier store of USB main equipment by the USB host device processor.
The present invention has positive effect: (1) the present invention adopts the data transmission of USB (universal serial bus) (USB) and control system to realize the data in the data-carrier store of USB main equipment are read by the USB host device processor, be transferred to the USB slave unit by the USB circuit, the data that are transferred to the USB slave unit after these data processes USB slave unit processor processing again use device to use, concerning the usb bus system, realized a kind of new transmission mode of data, thereby be original innovation and creation.(2) system of the present invention is an a kind of usb bus system, but the characteristics that oneself is arranged again, because general usb bus system is when carrying out the transmission of data, just use to the USB main equipment data transmission of USB slave unit, the present invention has not only changed the pattern of the data transmission of usb bus system in the past from structure, and in USB main equipment and USB slave unit, new program is set, thereby can carry out smoothly by the USB main equipment the data of storage medium (hard disk drive for example, the CDROM CD, the DVDROM CD, data on static memory devices or other storage medium) be transferred to the transmission mode of USB slave unit.(3) system and method for the present invention can be applied to vehicle GPS.Vehicle GPS mainly comprises GPS and receive to handle integral machine and mobile computing, PDA palm PC, CARPC vehicle-mounted computer etc.The GPS receiver is commonly called as G-MOUSE, is to be handled after satellite-signal is received, and the form that converts standard to is transferred to computing machine by cable or slot, and the interface mode of employing generally is RS232; Mobile computing, PDA palm PC, CARPC vehicle-mounted computer etc., effect are that signals such as position that G-MOUSE is sent here, speed, height are handled and combined with electronic chart, demonstrate current position and other information.The present invention can be arranged to the USB main equipment with the DVD video disc player that has LCDs, the synthesising pattern USB slave unit of function singleness is set, signals such as the position that the USB slave unit is sent the GPS receiver here, speed, height are handled and are combined with the electronic chart that the DVD video disc player is sent here, to synthesize good figure again and on the LCDs of DVD video disc player, show, even DVD video disc player and synthesising pattern can be fabricated to all-in-one with the USB slave unit.Like this, not only transmission speed is very fast to adopt vehicle GPS of the present invention, and cost is lower.
Description of drawings
Fig. 1 is the electric theory diagram of system of the data transmission of existing employing USB (universal serial bus) (USB).
Fig. 2 is a kind of electric theory diagram of application apparatus of system of the data transmission of existing employing USB (universal serial bus) (USB), and wherein the USB main equipment is a DVD player, and the USB slave unit is a card reader.
Fig. 3 is the electric theory diagram of the data transmission and the control system of employing USB (universal serial bus) of the present invention (USB).
Fig. 4 is the flow chart in USB main equipment when work among Fig. 3.
Fig. 5 is the block diagram of the subroutine of the inquiry main equipment memory state among Fig. 4.
Fig. 6 is the block diagram of data processing subroutine among Fig. 4.
Flow chart when Fig. 7 works for the USB slave unit.
Embodiment
(embodiment 1)
See Fig. 3, the data transmission of employing USB (universal serial bus) of the present invention and control system have a USB main equipment 231 and a USB slave unit 232.USB main equipment 231 has a USB host device processor 211 and a data-carrier store 214 that links to each other with USB host device processor 211.USB slave unit 232 has a USB slave unit processor 212 and uses device 215 with data that link to each other with USB slave unit processor 212.Couple by USB circuit 221 between USB host device processor 211 and the USB slave unit processor 212.USB host device processor 211 can also connect another one USB slave unit by USB circuit 224.
See Fig. 4, after the system start-up of the present invention, USB main equipment 231 and USB slave unit 232 all carry out initialization; After initialization is finished, USB host device processor 211 is sought possible USB slave unit, after finding possible USB slave unit, carrying out USB each other with this possible USB slave unit enumerates, if enumeration succeeds determines that then this possible USB slave unit is the USB slave unit, and sets up the mutual communication contact that meets the USB standard.
The detailed process that this USB enumerates is: USB host device processor 211 detects the existence of USB slave unit processor 212, and be that USB slave unit 232 distributes unique USB address, and make it be in the Addressed state, mark is come by address register (ADDR) in this address, to guarantee that packet can not be transferred to other USB peripheral hardware; Simultaneously at first set up a message channel that is called Endpoint 0 between the protocol layer of USB main equipment 231 and slave unit 232, the USB main equipment brings into use the Endpoint0 channel to read the cell configuration tagged word of being stored in USB slave unit 232 ROM (read-only memory); Based on the cell configuration tagged word, USB main equipment 231 is that this USB slave unit 232 is specified a Configuration Values, at this moment USB slave unit 232 promptly has been in configuration (Configured) state, and its all end points (Endpoint) at this moment also is in the described state of Configuration Values, and USB enumerates end.
Afterwards, 211 pairs of USB host device processor are judged with the USB slave unit that its foundation meets the communication relation of USB standard each other, when if this USB slave unit is not provided with required characteristic indication, then USB host device processor 211 is back to the state that continues to seek possible USB slave unit, if this USB slave unit is when being provided with required characteristic indication, then USB host device processor 211 is promptly carried out once the inquiry of the order of whether oriented USB host device processor 211 service of filing a request at set intervals to USB slave unit processor 212.After USB host device processor 211 inquires that USB slave unit processor 212 has proposed the order of request service, judge then whether this order is the order of request msg service, if not, the status information of reading of data storer 214 then, again the status information that is read is transferred to USB slave unit processor 212 through USB circuit 221, and is stored in the buffer of USB slave unit processor 212 (Fig. 5); If the order of request msg service, then according to the start address of the desired data that is comprised in the order and the information of length, the data message of appropriate address in the reading of data storer 214 is transferred to USB slave unit processor 212 (Fig. 6) with the status information that is read through USB circuit 221 again.
See Fig. 7, USB slave unit of the present invention 232 and USB main equipment 231 carry out after USB enumerates jointly, determined the communication standard between USB main equipment 231 and the USB slave unit 232, as the host-host protocol, port number, data transmission and the both sides' that adopt state etc., finally make this USB slave unit 232 be in spendable state.USB slave unit processor 212 is waited for the I/O order (input/output commands) from the input media of USB slave unit 232 afterwards, and this I/O order also can be produced when moving other application program by USB slave unit processor 212; If there is not the I/O order, then USB slave unit processor 212 continues to wait for.
If the I/O order is arranged, then USB slave unit processor 212 will judge whether this order is the order of request msg service.
If not data request command, 212 one side of USB slave unit processor are status service order and depositing to first register as the order of request service with this Command Flags, on the other hand this are ordered to the information of status service order and deposit in second register; Because USB host device processor 211 is promptly carried out once the inquiry of the order of whether oriented USB host device processor 211 service of filing a request at set intervals to USB slave unit processor 212, when USB host device processor 211 is got the order of request service and is judged that this order is not the order of request msg service in first register of USB slave unit processor 212 after, the status information of reading of data storer 214 then, again the status information that is read is transferred to USB slave unit processor 212 through USB circuit 221,212 of USB slave unit processors are according to the mark of being put down in writing in second register, resulting status information are stored in the corresponding zone of buffer of USB slave unit processor 212.
If the order of data, services (this data, services order by USB slave unit processor 212 according to the status information of the data-carrier store in its buffer 214 and move other program and draw, thereby comprise desired data) in the start address of data-carrier store 214 and the information of length, 212 one side of USB slave unit processor are data, services order and depositing to first register as the order of request service with this Command Flags, on the other hand this are ordered to the information of data, services order and deposit in second register; Because USB host device processor 211 is promptly carried out once the inquiry of the order of whether oriented USB host device processor 211 service of filing a request at set intervals to USB slave unit processor 212, when USB host device processor 211 is got the order of request service and is judged that this order is the order of request msg service in first register of USB slave unit processor 212 after, the data message of appropriate address in the reading of data storer 214, again the data message that is read is transferred to USB slave unit processor 212 through USB circuit 221,212 of USB slave unit processors are according to the mark of being put down in writing in second register, resulting status information are stored in the corresponding zone of buffer of USB slave unit processor 212.Again by USB slave unit processor 212 to these data carry out data check, rearrange etc. handle after, deliver to data and use device 215 to use.