WO2007088967A1 - 外部デバイス、電子機器システム及び制御方法 - Google Patents

外部デバイス、電子機器システム及び制御方法 Download PDF

Info

Publication number
WO2007088967A1
WO2007088967A1 PCT/JP2007/051788 JP2007051788W WO2007088967A1 WO 2007088967 A1 WO2007088967 A1 WO 2007088967A1 JP 2007051788 W JP2007051788 W JP 2007051788W WO 2007088967 A1 WO2007088967 A1 WO 2007088967A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
external device
control
electronic device
control signal
Prior art date
Application number
PCT/JP2007/051788
Other languages
English (en)
French (fr)
Inventor
Takashi Kohno
Original Assignee
Japan Science And Technology Agency
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 Japan Science And Technology Agency filed Critical Japan Science And Technology Agency
Priority to JP2007556929A priority Critical patent/JPWO2007088967A1/ja
Publication of WO2007088967A1 publication Critical patent/WO2007088967A1/ja

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices

Definitions

  • the present invention relates to an external device connected to an electronic device and receiving control from the electronic device, an electronic device system including the external device, and a control method in the external device and the electronic device system.
  • the present invention connects a device having a control function such as a measuring instrument and a data transfer function via a USB (Universal Serial Bus), and does not know the USB information.
  • the present invention relates to a novel method and apparatus for controlling a device such as the above equipment in conformity with the standard.
  • USB is a standard that is suitable for both control and high-speed data transfer.
  • OS Operating System
  • the present invention has been made to solve the above-described problems.
  • a control signal is input to the external device depending on the OS of the electronic device. It is an object of the present invention to provide an external device, an electronic device system, and a control method that do not require preparation of a device driver for each external device.
  • a device having a control function and a data transfer function such as a measuring instrument
  • a control function and a data transfer function can be programmed by a method compliant with an open standard without knowing USB-specific information.
  • a method to make it possible we propose to support USB Mass Storage Class.
  • an external device is an external device that is connected to an electronic device and receives control from the electronic device, and has an ID that identifies the type of the external device.
  • the ID storage means stored as its own ID, the input reception function of the external device whose type is specified by the ID stored in the ID storage means, and the execution function executed by itself are associated with each other Function storage means for storing the function and a control signal for executing the function are received from the electronic device, the function stored in the function storage means is referred to, and the function related to the control signal is input input function And a control means for executing the function for execution corresponding to the above.
  • an electronic device system includes an electronic device and an electronic device configured to include the electronic device and an external device that is connected to the electronic device and receives control from the electronic device.
  • an external device is an ID storage unit that stores an ID that identifies the type of external device as its own ID, and an external device whose type is specified by the ID stored in the ID storage unit
  • Function storage means for storing the input reception function and the execution function executed by itself in association with each other, and a control signal for executing the electronic device power function is received and stored in the function storage means. Execute the corresponding execution function when the function related to the control signal is set as the function for accepting input. And a control means.
  • a control method is connected to an electronic device to receive control of the electronic device force, and stores an ID for identifying the type of external device as its own ID.
  • the ID storage means, the input reception function of the external device that is stored in the ID storage means and whose type is specified by the ID, and the execution function that is executed by itself are stored in association with each other.
  • a function storage unit that receives a control signal for executing a function from an electronic device, refers to information stored in the function storage unit, and relates to the function related to the control signal.
  • a control method includes an electronic device, an ID connected to the electronic device and controlled by the electronic device, and identifying the type of external device Is stored as its own ID, the function for accepting input from an external device whose type is specified by the ID stored in the ID storage means, and the function for execution executed by itself And a function storage means for storing the information stored in the function storage means.
  • the control method is for an external device provided with the function storage means, and the external device receives a control signal for executing a function from the electronic device and stores the control signal. It includes a control step of referring to the information and operating the corresponding execution function when the function related to the control signal is the input reception function.
  • the control means when the control signal for executing the function of the external device of the type related to the ID stored in the ID storage means is input from the electronic device, the control means The information stored in the storage means is referred to, and the corresponding execution function is executed when the function related to the control signal is set as the input reception function. Therefore, if the ID of the external device that can input the control signal in advance is stored in the ID storage means, the control signal can be input to the external device depending on the OS of the electronic device. It is not necessary to prepare a device driver or the like for each external device.
  • the ID stored in the ID storage means is an ID that identifies an external device in which a device driver for performing control in advance in the electronic device is defined. According to this configuration, the ID stored in the ID storage means predicts the electronic device force control signal. Therefore, the ID of the external device that can be input is obtained, so that the effects of the present invention can be reliably achieved.
  • the ID stored in the ID storage means is preferably an ID that identifies an external device that is a block device. According to this configuration, it is possible to easily store the function correspondence in the function storage means, and it is possible to easily input the control signal from the electronic device to the external device according to the present invention.
  • a device control method according to the present invention is characterized in that a device is controlled using a standard called USB Mass Storage Class.
  • USB Mass Storage Class standard is preferably supported in the OS.
  • USB interface including the USB Mass Storage Class standard and to provide this USB interface independently of the device.
  • the device recognizes the USB Mass Storage Class standard as an external storage device having partitions for command / status and data transfer.
  • the control of the device is preferably performed using the input / output system calls openO, readO, write (), closeO defined by the POSIX standard in the control program.
  • the device virtually prepares storage areas (partitions) for control and data, and interprets and executes commands from the USB Mass Storage Class standard.
  • the device physically prepares storage areas (partitions) for control and data, and interprets and executes commands from the USB Mass Storage Class standard.
  • Control storage area (partition) is preferably interpreted as issuing a command.
  • the device control apparatus includes control means including a standard called USB Mass Storage Class, and controls the device by this control means.
  • the control means uses an OS that supports the USB Mass Storage Class standard. Is desirable.
  • the control means preferably includes a USB interface including the USB Mass Storage Class standard and is provided independently of the device.
  • USB Mass Storage Class as an external storage device having a partition for command / status and data transfer.
  • the control of the device is preferably performed using the input / output system calls openO, readO, write (), closeO defined by the POSIX standard in the control program.
  • the device virtually prepares storage areas (partitions) for control and data, and interprets and executes commands from the USB Mass Storage Class standard.
  • a device control method is characterized in that a device is controlled using a standard called USB Mass Storage Class.
  • the device control apparatus includes control means including a standard called USB Mass Storage Class, and the device is controlled by the control means.
  • Mass Storage Class is a standard for connecting a hard disk or floppy (registered trademark) disk to an external storage device via USB, and is a standard driver supported by many operating systems. Can be used without.
  • the device is recognized by the OS as an external storage device with partitions for command / status and data transfer.
  • the control program performs device control and data input / output using the input / output system calls openO, read (), writeO, and closeO defined in the POSIX standard.
  • the device is virtually! /, Physically has a storage area (partition) for control and data For that, it interprets and executes Mass Storage Class commands sent from the PC via USB.
  • Writing to the control partition is interpreted as issuing a command, and reading is interpreted as a status request. Reading / writing data partitions is interpreted as reading / writing data.
  • the ID storage means stores the ID of an external device of a type capable of inputting an electronic device force control signal in advance
  • the external device depends on the OS of the electronic device in the electronic device. It is not necessary to prepare device drivers for inputting control signals to each device.
  • FIG. 1 is a diagram showing a relationship between a device driver and a USB device in a PC.
  • FIG. 2 is a diagram showing a configuration of an external device according to an embodiment of the present invention.
  • FIG. 3 is a diagram showing an example of function correspondence in an external device.
  • FIG. 4 is a flowchart showing an operation of the external device according to the embodiment of the present invention.
  • FIG. 5 is a block diagram in the control method of the present invention.
  • FIG. 6 is a circuit diagram of the control device of the present invention.
  • FIG. 7 is a block diagram of software used in the control method of the present invention.
  • FIG. 8 is a block diagram showing an example of a control routine in the USBN9603 register. Explanation of symbols
  • FIG. 1 shows a state in which a USB device 30 that is an external device is connected to a PC 40 that is an electronic device by a cable 50.
  • a class ID that is an ID for specifying the type of the device according to the USB device 30 is set.
  • a device driver 41 is required according to the USB device 30 in the PC 40.
  • the device driver 41 is included in the OS 42 and functions as a link between the intermediate layer 42a and the USB host driver 42b.
  • the intermediate layer 42a is a part that transmits and receives information to and from the application 43 that generates a control signal
  • the USB host driver 42b is a USB host that is an interface with the USB device 30. 44 is used to send and receive signals.
  • the device driver 41 Since the transmission of the control signal from the PC 40 to the USB device 30 is performed for each function corresponding to the USB device 30 after the class ID is specified, the device driver 41 is usually set for each USB device 30. Necessary. Therefore, as described above, when a new USB device 30 is developed, it is necessary to create a device driver 41 for each USB device 30. In addition, since the intermediate layer 42a and the USB host driver 42b in the OS 42 have different formats depending on the OS, the device driver 41 has to be created for each OS 42.
  • the device driver 41 is usually prepared in common in many types of OS42 in order to omit development of individual device drivers for USB devices having frequently used functions such as storage devices and sound devices. There is something that has been.
  • a device driver 41 is called a USB class driver.
  • the mass storage class driver 41a shown in FIG. 1 is a device driver for storage equipment, and provides a control procedure for accessing the storage space. A control signal is input to the USB mass storage device 30a connected to the PC 40 using the mass storage class driver 41a.
  • the external device 10 and the PC 20 constitute an electronic device system according to this embodiment.
  • the external device 10 and the PC 20 are connected by a cable 25 or the like.
  • the external device 10 can also be removed from the PC 20.
  • the connection between the external device 10 and the PC 20 conforms to a predetermined data transmission path standard. As described above, according to the standard, transmission of the control signal to the external device 10 is performed by specifying the type of the external device 10 by ID and using a device driver corresponding to the type. In this embodiment, the standard will be described as USB.
  • the external device 10 is a device that realizes a predetermined function under the control of the PC 20.
  • the external device 10 corresponds to a peripheral device such as a storage device, a keyboard, a mouse, and a modem.
  • the external device 10 will be described as an AZD change that converts an analog value that is also input with an external force by a voltage or the like into a digital value.
  • the external device 10 includes a function unit 11, an interface unit 12, a function storage unit 13, and a control unit 14.
  • the function unit 11 is a means for executing the function of the external device 10. In the case of an AZD converter as in this embodiment, it is a means for executing a function of converting an analog value input by a voltage value or the like into a digital value. The execution of the function by the function unit 11 is performed under the control of the control unit 14 as described later.
  • the function unit 11 is realized by hardware corresponding to the function. For example, in the case of an AZD converter as in this embodiment, a circuit that performs AZD conversion is realized by a CPU or the like.
  • the interface unit 12 is a means for accepting input of a control signal compliant with USB input from the PC 20 via the cable 25 and for inputting / outputting data to / from the PC 20.
  • the interface unit 12 is also an ID storage unit that stores a class ID that identifies the type of external device as its own class ID.
  • the class ID stored in the interface unit 12 is a class ID of the type of external device in which a device driver for controlling in advance in the PC 40 (each OS) is defined.
  • the interface The type of external device related to the class ID stored in the ace unit 12 is a block type device.
  • the class ID stored in the interface unit 12 is desirably, for example, the class ID of the mass storage device described above.
  • the PC 20 recognizes that the external device 10 is a mass storage device regardless of the function of the external device 10, that is, the function of the functional unit 11. Therefore, a control signal for the mass storage device is input from the PC 20.
  • the interface unit 12 receives the control signal input from the PC 20 and inputs it to the control unit 14.
  • the interface unit 12 is realized by hardware such as an IC chip (USB device).
  • the function storage unit 13 associates the input reception function of the external device whose type is specified by the class ID stored in the interface unit with the execution function executed by its own function unit 11. It is a function storage means for storing. Specifically, the function storage unit 13 stores the function of the mass storage device (input reception function) and the function executed by the function unit 11 in association with each other. More specifically, as shown in FIG. 3, the function of the mass storage device “writes 0 or 1 to address 0 of the memory address” and the function AZD change function 11 starts or stops measurement. “Do” is stored in association with each other.
  • the control unit 14 receives a control signal for executing a function from the PC 20 via the interface unit 12, and inputs the function related to the control signal with reference to the information stored in the function storage unit 13. This is a control means for causing the function unit 11 to execute the execution function corresponding to the reception function. Specifically, for example, when a control signal “write 1 to address 0” is input from the PC 20 to the external device 10, the control unit 14 stores it in the function storage unit 13. The function unit 11 is controlled to “start measurement” with reference to the information indicating the correspondence between the functions as shown in FIG. As described above, it is desirable to write to the mass storage device as a command issue and to read from the mass storage device as a status (digital value in the above example) request.
  • the external device 10 is provided with storage means such as SRAM (Static Random Access Memory), and reads / writes on the memory address of the storage means based on the control signal input from the PC 20 like the mass storage device. May be performed (in conjunction with the execution of the function by the function part 11). The above is the function of the external device 10.
  • storage means such as SRAM (Static Random Access Memory)
  • SRAM Static Random Access Memory
  • the PC 20 is a device that controls the external device 10 by transmitting a control signal to the external device 10.
  • the PC 20 includes an interface unit 21 and a control signal transmission unit 22.
  • the PC 20 is realized by hardware such as a CPU and a memory.
  • the interface unit 21 is means for transmitting a control signal conforming to USB to the external device 10 in accordance with an instruction from the control signal transmitting unit 22 and inputting / outputting data to / from the external device 10.
  • the interface unit 21 is realized by hardware such as an IC chip (USB host).
  • the control signal transmission unit 22 is a unit that instructs the interface unit 21 to transmit a control signal to the external device 10 to the external device 10.
  • the control signal transmission unit 22 corresponds to the functions of the OS 42 and the application 43 of the PC 40 in FIG. That is, the control signal transmission unit 22 specifies the class ID using a device driver corresponding to the class ID of the external device 10 and then transmits the control signal to the external device 10 to the interface unit 21. Instruct.
  • the transmission of the control signal to the external device 10 is performed after the class ID of the external device 10 is set as the class ID of the mass storage device.
  • the device driver for the mass storage device is provided in the control signal transmission unit 22 regardless of the OS of the PC 20.
  • control signal transmission unit 22 application that realizes Transmits the control signal of the mass storage device so that the function of the functional unit 11 of the external device 10 is executed based on the correspondence relationship.
  • the input / output of the control signal to the application power OS in the control signal transmission unit 22 is an input / output system call defined by the OS portability standard POSIX (specifically, open (), read It is desirable to access using (), write (), close ()). This is to facilitate the development of applications for each OS.
  • POSIX the OS portability standard
  • the operation is started when a control signal is input from the PC 20 to the external device 10 via the mutual interface units 12 and 21.
  • the control signal is input by using a user operation or the like on the PC 20 as a trigger.
  • the control signal transmission unit 22 of the PC 20 uses the device driver of the mass storage device to identify the mass storage device class ID stored in the interface unit 12 of the external device 10. Is done.
  • control signal is received by the control unit 14 (S01, control step).
  • the function unit 11 corresponding to the input reception function related to the control signal input by referring to the information as shown in FIG. 3 stored in the function storage unit 13 by the control unit 14 should be executed.
  • An execution function is identified (S02, control step).
  • the control unit 14 controls the function unit 11 to execute the specified execution function, and the function unit 11 executes the execution function (S03, control step).
  • the PC 20 can control the external device 10 as an external device of a type related to the class ID stored in the interface unit 12 of the external device 10. Therefore, if the class ID stored in the interface unit 12 is the class ID of an external device of a type capable of inputting a control signal from the PC 20 in advance, that is, an external device for which a device driver or the like is prepared in advance, the PC 20 However, it is not necessary to prepare device drivers for each external device 10 depending on the operating system of the electronic device.
  • the ID stored in the interface unit 12 as in the present embodiment is an ID that specifies an external device for which a device driver for performing control in advance is specified on the PC 20. Is desirable. According to this configuration, the ID stored in the interface unit 12 becomes the ID of an external device that can input a control signal from the PC 20 in advance, so that the effects of the present invention can be reliably achieved.
  • the ID stored in the interface unit 12 as in the present embodiment is an ID that identifies an external device that is a block device.
  • the function storage unit 13 can easily store the function correspondence and the external device 10 according to the present invention. It is possible to easily input control signals for PC power. However, it may be a character type device that does not necessarily need to be a block type device! /.
  • the external device 10 can be used without depending on the OS of the PC 20 (in OS independent), that is, without requiring an OS-dependent source. it can.
  • the AZD variation is used as an example of the function of the external device 10 (the functional unit 11 thereof).
  • any instrument, power supply device, The present invention can be applied to arbitrary devices such as video equipment and audio devices.
  • the electronic device to which the external device 10 is connected is not limited to the PC 20.
  • the standard of connection between external devices and electronic devices is not limited to USB, and can be applied to devices having a similar framework.
  • the OS has a cache mechanism for the storage device.
  • FIG. 5 shows a block diagram of this machine. Increase the independence of the USB interface and device-specific operations (in this case, data acquisition of A / D converter power), and add functions to the USB interface (for example, data output to the D / A converter) In order to be able to achieve this, a memory partition was physically prepared using 64KB external SRAM.
  • USB physical layer is left to National Instruments USBN9603 (Full Speed compatible), and the protocol layer (USB transaction processing), device 'framework (USB device' request processing), and mass storage class processing are performed by software. . These software are called as ADuC7026 IRQ interrupts by USBN9603 interrupt request signal (INTRQ).
  • USBN9603 interrupt request signal INTRQ
  • Timerl has a sampling frequency set and checks the control / partition and interprets the command each time it is called.
  • data loading is instructed, the data is read from the A / D converter each time it is called and stored in the SRAM data 'partition.
  • the status is written to the control 'partition. Since this processing must be performed for each sampling frequency, it is called as a FIQ interrupt with a higher priority than the UBN9603 interrupt signal.
  • the 0th byte is a command to CH0
  • the 1st byte is a command to CH1
  • the 2nd byte is a command' queue.
  • the data import start command ('G') and stop command (' ⁇ ') are prepared.
  • the command 'queue' indicates that a valid command has been written in the command 'byte to CH0, CHI.
  • the device recognizes that '*' has been written to this byte, it clears it with '' (space character) and interprets and executes the CH0, CHI command 'byte.
  • '' space character
  • '#' is written as an operation completion mark in the corresponding command 'byte', and the process ends.
  • the PC can check the control 'partition periodically and wait for' # 'to be written to know the completion of data capture.
  • the data itself can be obtained by reading the partition corresponding to each channel.
  • FIG. 6 shows the circuit diagram of this machine.
  • a 'data multiplexed 16 / 8bit memory' bus can be used, and the memory space accessible via this bus is divided into four areas of 128KB each, and the enable signal (MS [3: 0960) USB9603 and external SRAM are connected to this bus, the former is assigned to area 0 and the latter is assigned to area 1 (GPIO data sheet (ANALOG DEVIC ES, “AduC7019 / 20/21/22/24/25/26/27 Data sheet, Rev. 0 ", Nov., 2005) p.59-60, same as p.78-81 for memory 'interface, same for detailed timing p.9-10, for the memory map, see p.33)).
  • ANALOG DEVIC ES “AduC7019 / 20/21/22/24/25/26/
  • W24257AK-15 made by Winbond was prepared for the external SRAM.
  • This is a general 8-bit wide 2 56KBit SRAM (Windbond, "W24257A Datasheet, Rev. A6, see"), which is pin-compatible with HM65256 and uP D43256.
  • the addresses are separated by the output and supplied to the SRAM BHE and BLE outputs are signals for accessing in 8-bit units on the 16-bit bus, and access to the upper byte and lower byte is required respectively. Since it is only write that needs to distinguish between 16-bit and 8-bit accesses, the logical product of the write 'strobe signal WS is supplied to the SRAM, and the read' strobe signal RS is connected as it is. .
  • the waiting time after writing requires about 10 cycles of the CPU clock.
  • the XMxPAR register cannot be set up to 1 CLK, so it may require programming considerations in some cases.
  • USBN9603 interrupt request signal (INTRQ) is sent to the ADuC7026 external interrupt input pin IRQ0.
  • a simple amplifier was prepared for each of CH0 and CHI.
  • the ADuC A / D converter input range is 0V to 2.5V, so this amplifier is used to adjust the range.
  • the amplitude of the input signal is first adjusted through an attenuator.
  • the operational amplifier TLC272 directly via a coupling capacitor and bias resistor for AC connection, or directly for DC connection.
  • the first stage of the operational amplifier constitutes a voltage follower and performs impedance conversion.
  • an LM158 or the like that can operate with a single power supply of 3.3V can be used.
  • Figure 7 shows the software block diagram.
  • interrupts in the ARM7TDMI series There are two types of interrupts in the ARM7TDMI series: IRQ and FI Q.
  • the latter limits the number of registers that can be used in the interrupt routine, thereby reducing the processing from interrupt signal detection to routine call, resulting in latency.
  • the ARM7TDMI interrupt disable flag is provided separately for IRQ (I bit) and FIQ (F bit) in the CPU register called CPSR. These disable flags are automatically set when the interrupt routine is called.
  • the processing around the USB may be complicated as FIQ interrupt processing, and it is implemented as IRQ interrupt processing because the time constraint is not so strong.
  • the data sampling interval is set in Timerl to generate an interrupt periodically. Specifically, set the count value in the T1LD register, the division ratio in the lower 4 bits of T1CON, and set T in bits 7 and 6. Set this interrupt signal to generate FIQ (FIQEN register (above ANALOG DEV ICES, "AduC7019 / 20/21/22/24/25/26/27 Data sheet, Rev. 0", Nov., 2005, p.73—74) is written 00000008h).
  • the INTRQ output of the USBN9603 is connected to the external interrupt input pin IRQ0, so set this to generate an IRQ interrupt (write 00008000h to the IRQEN register).
  • the IRQEN and FIQEN registers are newly set! /, Enabling bits can be added by writing only the bits. Conversely, if you want to clear the enable bit, write only the bit you want to clear in the IRQCLR and FIQ CLR registers.
  • the FIQSTA register is checked. This register informs which of the signals that enable interrupts in the FIQEN register is active. If the corresponding bit is T, it is active, so if this register and 00000008h are ANDed, T is determined to be an interrupt from Timerl (in this example, the FIQ interrupt is from Timerl) So it works even without this process).
  • T1CLRI register (above ANALOG DEVICES, "AduC7019 / 20/21/22/24/25/26 / 27 Data sheet, Rev. 0 ", Nov., 2005, p.75-76) and clear the interrupt input. If this is not done, the interrupt process will start immediately after the end of the interrupt process.
  • the command 'partition command' queue 'byte is checked.In this case, if is written, valid command power SCH0, CHI command' byte 'is set in each byte, so check the command contents If 'G', start collecting data for the corresponding channel, stop if 'N', otherwise do nothing, specifically, if data collection is started, start data collection is a variable.
  • Set ADC_CHx_EN (x 0, l) to T, and set it to '0' if it is interrupted.
  • USB interface 'routine first checks the IRQSTA register to confirm that it is an interrupt from external interrupt 0, and then executes the USBN9603 control routine (USBN960x_intO). To do.
  • the control routine is described in usbn 960x.c and corresponds to the USB protocol layer in the upper left in Figure 7.
  • USB communication programming technique "http: ⁇ .
  • each device has an “entrance / exit” for sending and receiving data called endpoints.
  • the PC can communicate directly with the functional block you want to use by selecting the endpoint and exchanging data.
  • the USBN9603 has seven endpoints EP0 to EP6.
  • EP0 is a USB standard (Compaq, Intel, Microsoft, a nd NEC, “Universal Serial Bus Specification, Rev. 1.1”) (USBN9603 is USB Rev. 1.1 compatible)
  • Control “endpoint” is required, and it has an 8-byte FIFO.
  • USB As specified by the USB standard, it is also used for input / output, FIFO is also used for input / output, and the direction is switched by the EPC0 register (only the control 'endpoint can be used for input / output).
  • EP1, EP3, and EP5 are transmission-only endpoints (corresponding to the USB IN direction) and have a 64-byte FIFO.
  • EP2, EP4, and EP6 are receive-only (corresponding to the USB OUT direction) and are equipped with a 64-byte FIFO!
  • the task of the control routine is to determine why the interrupt was strong and to give a corresponding command to the USBN9603.
  • Figure 8 shows the USBN9603 registers that are frequently used in control routines. In this case, all are 8 bits.
  • the NAK bit is received from the PC because the FIFO was empty at the transmission endpoint (EP1, EP3, EP5). T when the data read request cannot be met.
  • USB device In order to function as a USB device, at least respond to the command group called “standard device 'request” among various commands sent to the control' endpoint (EP0). Must be able to.
  • commands sent to the control' endpoint (EP0).
  • EP0 the control' endpoint
  • 9J iJSB Device Framework of Compaq, Intel, Microsoft, and NEC Universal 3 ⁇ 4enal Bus Specincation, Rev.1.1 above, and mainly device-specific information (function summary, number of endpoints, etc.) It has functions such as requesting, setting an address in the USB tree, and switching the operation mode.
  • the device holds its own unique information in the form of a data 'table group called standard USB descriptors. It consists of a combination of a standard device 'descriptor, standard configuration' descriptor, a standard interface 'descriptor, a standard endpoint' four types of data called tables descriptors' tables.
  • the standard device descriptor includes information on the entire device, such as which version of USB is supported, an outline of the device function (Class Code, etc.), manufacturer name, and device name.
  • the standard endpoint 'descriptor' contains the endpoint number, data transfer method and direction, maximum packet 'size, etc.
  • USB With USB, multiple independent functions can be implemented in one device. An interface that is a collection of endpoints is defined for each function.
  • the standard interface 'descriptor contains an outline of the function of the corresponding interface (Class Code, etc.).
  • USB also provides a mechanism for dynamically changing which functions (interfaces) are enabled. The combination of which function group is enabled It is called the configuration and is outlined in the standard configuration descriptor.
  • the PC will use the “Get Descriptor” standard device “request” to read all the configuration descriptors provided and select the desired configuration with the “Set Configuration” standard device request. .
  • the standard interface 'descriptor standard configuration' descriptor itself does not contain information on which endpoint and interface each belongs.
  • this descriptor is notified to the PC side by sending all the endpoints and interface descriptors to which it belongs.
  • multiple interfaces that are not enabled at the same time can have the same endpoint, and in such a case, the data transfer method and direction of the same endpoint may differ depending on the interface. ,.
  • the PC When the PC detects the connection of a USB device, it resets the bus, assigns a USB address to the device with a “Set Address” standard device request, and activates the interface with a “Set Configuration” standard device request. Take the device to an operational state.
  • USB-IF Universal Serial Mass St orage Class Specification Overview
  • Rev. 1.2 Mass Storage Class summary document of the USB- IF, "Universal Serial Mass St orage Class Specification Overview, Rev. 1.2
  • two types define the interface 1 ⁇ ⁇ full ace for Mass Storage Class These two types are Control / Bulk / Interrupt protocol (CBI) and Bulk-Only Transport, the former being used only for FuU-speed USB floppy disks and not for new designs.
  • CBI Control / Bulk / Interrupt protocol
  • USB-IF Universal Benai Bus Mass Storage Class Bulk-Only Transport, Rev. 1.0
  • USB-IF Universal Benai Bus Mass Storage Class Bulk-Only Transport
  • Rev. 1.2 defines six types, but two of them are UFI and SFF-8070i that are suitable for USB floppy disks.
  • USB-IF USB-IF Universal Serial Bus Storage and select lass UFI Command Specincation, Rev. IV.7.
  • Bulk-In Endpoint IN-direction endpoint communicating with Bulk transaction (Compaq, Intel, Microsoft, and NE, 'Universal Serial Bus Specification, Rev.1.1, 8.5.1, pl 3-164)
  • Each Bulk-Out endpoint consists of one each.
  • Descriptor 2 the only function that can be installed in this unit is the Mass Storage Class function, so there is only one interface for this function. Therefore, only one type of configuration is required.
  • Descriptors prepared for this unit are one standard device descriptor, one standard configuration descriptor, one standard interface descriptor, and two standard endpoint descriptors (one for Bulk-Out and one for Bulk-In). ).
  • the standard device 'descriptor 5th byte (bDeviceClass) must be 00h and the standard interface' descriptor 6th byte (blnterfaceClass) must be 08h. There is.
  • Bulk-Only Transport means that the 8th byte (blnterfaceProtocol) of the descriptor is 5 Oh, and that the UFI command system is adopted is that the 7th byte (blnterfaceSubClass) is 04h. (See USB—IF, 'Universal Serial Mass Storage Class Specification Overview, Rev. 1.2 ”, p.6-7).
  • the device requests in 3) are "Bulk-Only Mass Storage Reset” request and ⁇ Get Max LU N '' request.
  • the former is a reset of mass storage class interface-related functions, and the latter responds with the maximum value of the device's Logical Unit Number (LUN).
  • LUN is a mechanism for preparing multiple (sub) devices in one physical device (for example, LUN0 is a CD-ROM drive function, LUN1 is a DVD-RAM drive function, etc. in a multi-optical drive.
  • the CBW includes information such as the data transfer amount (dCBWDataTransferLength) and its direction (bit7 of bmCBWFlags) in addition to the command system command used (UFI command this time).
  • dCBWDataTransferLength data transfer amount
  • bit7 of bmCBWFlags bit7 of bmCBWFlags
  • Bus Mass storage Class Bulk See Omy Transport, Rev. 1.0 ").
  • the device side interprets this CBW and the UFI command included in the CBW, sends and receives data via Bulk-Out / In endpoints as needed, and finally sends a Command Status Wr apper (CSW). Send the called data block from the Bulk-In endpoint to the PC.
  • the command execution status (bCSWStatus) and the amount of data not processed (dCSWR esidue) S3 are stored in the C SW (upper three USB—IF, “Universal Serial Bus Mass Storage and lass Buk -Only Transport, Rev. 1.0 ", P.14-15). In Bulk-Only Transport, data must be exchanged in this order.
  • the PC issues CBW
  • the device returns CSW, and the PC resets with the "Bulk Only Mass Storage Reset" command. Until then, the next CBW will not be issued!
  • CSW There are three types of execution status included in CSW: normal completion, failure, and CBW inconsistency.
  • a CBW inconsistency is the data described in the CBW. Data transfer amount and transfer direction are inconsistent with those specified by the UFI command. For example, CBW specifies that data transfer is in the OUT direction, but the required data transfer in UFI is in the IN direction. This is defined in detail in USB-IF, “Universal Serial Bus Mass Storage Class Bulk-Only Transport, Rev. 1.0”, 6.7 The Thirteen Cases (p.l8-22).
  • host expectations transfer amount and direction expected by the host
  • device intent device transfer amount and direction intended
  • UFI Means the amount and direction of data.
  • a device judged to be CBW inconsistent stalls the Bulk-In endpoint if the data transfer direction specified by CBW is IN, and both endpoints if it is OUT.
  • the PC detects that the endpoint has stalled, it resets the endpoint with a “Clear Feature” standard device request and reads the CSW.
  • the CSW bCSWStatus describes that a CBW mismatch occurred.

Abstract

 本発明は、外部デバイスに接続される電子機器において、電子機器のOSに依存する、外部デバイスへ制御信号を入力するためのデバイスドライバ等を外部デバイス毎に用意することを不要とすることを目的とする。  本発明に係る外部デバイス10は、PC20に接続されてPC20から制御を受け、外部デバイスの種類を特定するIDを、自身のIDとして記憶したインターフェース部12と、インターフェース部12に記憶されているIDにより種類が特定される外部デバイスの入力受付用機能と、自身で実行される実行用機能と、を対応付けて記憶しておく機能記憶部13と、機能を実行させる制御信号をPC20から受け付けて、機能記憶部13に記憶された情報を参照して、当該制御信号に係る機能を入力受付用機能としたときに対応する実行用機能を機能部11に実行させる制御部14とを備える。

Description

明 細 書
外部デバイス、電子機器システム及び制御方法
技術分野
[0001] 本発明は、電子機器に接続されて当該電子機器カゝら制御を受ける外部デバイス、 当該外部デバイスを含む電子機器システム、並びに当該外部デバイス及び電子機 器システムにおける制御方法に関する。また、本発明は、計測機器ゃァクチユエータ などのコントロール機能とデータ転送機能とを具える機器を USB (Universal Serial Bus )経由で接続しながら、 USB情報を知らな 、場合にぉ 、てもオープンな規格に準拠し て、上記機器などのデバイスを制御するための新規な方法及び装置に関する。
背景技術
[0002] コンピュータシステム等の電子機器に必要な機能の一つは、外部デバイスとの接続 機能である。一昔前はシリアル (EIA-232)接続が主流であった。この規格はモデムと P C (Personal Computer)を接続するために制定されたものであり、リモート 'ホストとの キャラクタ 'ベースのデータ通信に最適化されている。汎用性が高く直感的に理解し やすいため、簡単に制御ソフトウェアを書くことができる。外部デバイスを PCから制御 するという用途では多くの場合これで十分であるが、転送速度が低いため、高い応答 性が必要だったり大量のデータを高速にやりとりするという用途には不向きである。 発明の開示
発明が解決しょうとする課題
[0003] 一方、 USBは制御にも高速データ転送にも適した規格である力 一部の規格化され た機能以外に対しては、外部デバイス毎に OS (Operating System)に依存した専用の デバイスドライバを用意する必要があり、開発に負担が力かるというペナルティがある
[0004] 即ち、 USB等の規格は、接続される外部デバイスの制御形式にまで立ち入った内 容となっており、 PC等の電子機器側においてカーネルモードで動作する OSに依存 したドライバを必要とする。外部デバイスの設計者は、接続バス規格に精通すると共 に、 PC等の電子機器側における各種 OSと接続バスのホストドライバに特有のドライ バ設計技術にも習熟しなければならない。これは設計者の負担増だけでなぐ必要 なソフトウェア部品の増加により必要なデバッグ量の増力 []、システム全体の安定性の 低下をもたらす原因となっている。
[0005] 本発明は、以上の問題点を解決するためになされたものであり、外部デバイスに接 続される電子機器において、電子機器の OSに依存する、外部デバイスへ制御信号 を入力するためのデバイスドライバ等を外部デバイス毎に用意することを不要とする 外部デバイス、電子機器システム及び制御方法を提供することを目的とする。
[0006] 本願においては、計測機器ゃァクチユエータなどコントロール機能とデータ転送機 能をもつ機器を USB経由で接続しながら、 USB固有の情報を知らなくてもオープンな 規格に準拠した方法でプログラムできるようにするための手法として、 USB Mass Stor age Classへの対応を提案するものである。
課題を解決するための手段
[0007] 上記目的を達成するために、本発明に係る外部デバイスは、電子機器に接続され て当該電子機器カゝら制御を受ける外部デバイスであって、外部デバイスの種類を特 定する IDを、自身の IDとして記憶した ID記憶手段と、 ID記憶手段に記憶されている IDにより種類が特定される外部デバイスの入力受付用機能と、自身で実行される実 行用機能と、を対応付けて記憶しておく機能記憶手段と、機能を実行させる制御信 号を前記電子機器から受け付けて、前記機能記憶手段に記憶された情報を参照し て、当該制御信号に係る機能を入力受付用機能としたときに対応する実行用機能を 実行させる制御手段と、を備えることを特徴とする。
[0008] 上記目的を達成するために、本発明に係る電子機器システムは、電子機器と、当 該電子機器に接続されて当該電子機器から制御を受ける外部デバイスとを含んで構 成される電子機器システムであって、外部デバイスは、外部デバイスの種類を特定す る IDを、自身の IDとして記憶した ID記憶手段と、 ID記憶手段に記憶されている IDに より種類が特定される外部デバイスの入力受付用機能と、自身で実行される実行用 機能と、を対応付けて記憶しておく機能記憶手段と、電子機器力 機能を実行させる 制御信号を受け付けて、前記機能記憶手段に記憶された情報を参照して、当該制 御信号に係る機能を入力受付用機能としたときに対応する実行用機能を動作させる 制御手段と、を備えることを特徴とする。
[0009] 上記目的を達成するために、本発明に係る制御方法は、電子機器に接続されて当 該電子機器力も制御を受けると共に、外部デバイスの種類を特定する IDを、自身の I Dとして記憶した ID記憶手段と、前記 ID記憶手段に記憶されて 、る IDにより種類が 特定される外部デバイスの入力受付用機能と、自身で実行される実行用機能と、を 対応付けて記憶しておく機能記憶手段と、を備える外部デバイスにおける制御方法 であって、電子機器から機能を実行させる制御信号を受け付けて、前記機能記憶手 段に記憶された情報を参照して、当該制御信号に係る機能を入力受付用機能とした ときに対応する実行用機能を動作させる制御ステップを含むことを特徴とする。
[0010] 上記目的を達成するために、本発明に係る制御方法は、電子機器と、当該電子機 器に接続されて当該電子機器カゝら制御を受けると共に、外部デバイスの種類を特定 する IDを、自身の IDとして記憶した ID記憶手段と、前記 ID記憶手段に記憶されてい る IDにより種類が特定される外部デバイスの入力受付用機能と、自身で実行される 実行用機能と、を対応付けて記憶しておく機能記憶手段と、を備える外部デバイスに おける制御方法であって、外部デバイスが、前記電子機器から機能を実行させる制 御信号を受け付けて、前記機能記憶手段に記憶された情報を参照して、当該制御 信号に係る機能を入力受付用機能としたときに対応する実行用機能を動作させる制 御ステップを含むことを特徴とする。
[0011] 本発明に係る外部デバイスでは、 ID記憶手段に記憶された IDに係る種類の外部 デバイスの機能を実行させる制御信号を電子機器カゝら入力されると、制御手段によ つて、機能記憶手段に記憶された情報が参照されて、当該制御信号に係る機能を入 力受付用機能としたときに対応する実行用機能が実行される。従って、電子機器カゝら 制御信号を予め入力可能な種類の外部デバイスの IDを ID記憶手段に記憶させて おけば、電子機器において、電子機器の OSに依存する、外部デバイスへ制御信号 を入力するためのデバイスドライバ等を外部デバイス毎に用意することが不要となる。
[0012] ID記憶手段に記憶されている IDは、前記電子機器において予め制御を行うため のデバイスドライバが規定されている外部デバイスを特定する IDであることが望まし い。この構成によれば、 ID記憶手段に記憶される IDが、電子機器力 制御信号を予 め入力可能な種類の外部デバイスの IDとなるので、確実に本発明の効果を奏するこ とがでさる。
[0013] ID記憶手段に記憶されている IDは、ブロック型デバイスである外部デバイスを特定 する IDであることが望ましい。この構成によれば、機能記憶手段において機能の対 応を容易に記憶させることができると共に、本発明に係る外部デバイスに対する電子 機器からの制御信号の入力を容易に行うことができる。
[0014] 本発明に係るデバイスの制御方法は、 USB Mass Storage Classなる規格を用いて、 デバイスを制御することを特徴とする。
[0015] 前記 USB Mass Storage Class規格は OS内にサポートされていることが望ましい。
[0016] 前記 USB Mass Storage Class規格を含む USBインターフェイスを設けるとともに、こ の USBインターフェイスを前記デバイスと独立に設けることが望ましい。
[0017] 前記デバイスは、前記 USB Mass Storage Class規格をコマンド/ステータス用及び データ転送用のパーティションをもつ外部記憶装置として認識することが望ましい。
[0018] 前記デバイスの制御は、制御プログラムにおける POSIX規格で定義されて 、る、入 出力システムコール openO, readO, write(), closeOを用いて行うことが望ましい。
[0019] 前記デバイスは、仮想的にコントロール用及びデータ用の記憶領域 (パーティショ ン)を用意し、前記 USB Mass Storage Class規格からのコマンドを解釈し、実行するこ とが望ましい。
[0020] 前記デバイスは、物理的にコントロール用及びデータ用の記憶領域 (パーティショ ン)を用意し、前記 USB Mass Storage Class規格からのコマンドを解釈し、実行するこ とが望ましい。
[0021] 前記コントロール用記憶領域 (パーティション)への書き込みはコマンド発行として 解釈することが望ましい。
[0022] 前記コントロール用記憶領域 (パーティション)力もの読み出しはステータス要求とし て解釈することが望ましい。
[0023] 本発明に係るデバイスの制御装置は、 USB Mass Storage Classなる規格を含む制 御手段を具え、この制御手段によってデバイスを制御することを特徴とする。
[0024] 前記制御手段は、前記 USB Mass Storage Class規格をサポートした OSを用いること が望ましい。
[0025] 前記制御手段は、前記 USB Mass Storage Class規格を含む USBインターフェイスを 含み、デバイスと独立に設けたことが望ましい。
[0026] 前記デバイスは、前記 USB Mass Storage Class規格をコマンド/ステータス用及び データ転送用のパーティションをもつ外部記憶装置として認識することが望ましい。
[0027] 前記デバイスの制御は、制御プログラムにおける POSIX規格で定義されて 、る、入 出力システムコール openO, readO, write(), closeOを用いて行うことが望ましい。
[0028] 前記デバイスは、仮想的にコントロール用及びデータ用の記憶領域 (パーティショ ン)を用意し、前記 USB Mass Storage Class規格からのコマンドを解釈し、実行するこ とが望ましい。
[0029] 前記 USB Mass Storage Class規格からのコマンドを解釈し、実行するための、物理 的にコントロール用及びデータ用の記憶領域 (パーティション)を具えることが望まし い。
[0030] 前記コントロール用記憶領域 (パーティション)への書き込みはコマンド発行として 解釈することが望ましい。
[0031] 前記コントロール用記憶領域 (パーティション)力もの読み出しはステータス要求とし て解釈することが望ましい。
[0032] 上記目的を達成すべく、本発明に係るデバイスの制御方法は、 USB Mass Storage Classなる規格を用いて、デバイスを制御することを特徴とする。
[0033] また、本発明に係るデバイスの制御装置は、 USB Mass Storage Classなる規格を含 む制御手段を具え、この制御手段によってデバイスを制御することを特徴とする。
[0034] Mass Storage Classは USB経由でハードディスクやフロッピ(登録商標)ディスクと!/ヽ つた外部記憶装置を接続するための規格で、多くの OSで標準的にサポートされてお り、特別なドライバなしで利用することができる。デバイスは OSから、コマンド/ステータ ス用及びデータ転送用のパーティションをもつ外部記憶装置として認識される。
[0035] 制御用プログラムは POSIX規格で定義されている入出力システムコール openO, rea d(), writeO, closeOを用いてデバイスの制御、データ入出力を行う。デバイスは仮想 的にある!/、は物理的にコントロール用、データ用の記憶領域 (パーティション)を用意 し、それらに対して PCが USB経由で送ってくる Mass Storage Classのコマンドを解釈、 実行する。コントロール用パーティションに対する書き込みはコマンド発行、読み出し はステータス要求として解釈する。また、データ用パーティションに対する読み書きは データの読み書きと解釈する。
発明の効果
[0036] 本発明によれば、電子機器力 制御信号を予め入力可能な種類の外部デバイスの IDを ID記憶手段に記憶させておけば、電子機器において、電子機器の OSに依存 する、外部デバイスへ制御信号を入力するためのデバイスドライバ等をデバイス毎に 用意することが不要となる。
図面の簡単な説明
[0037] [図 1]PCにおけるデバイスドライバと USBデバイスとの関係を示す図である。
[図 2]本発明の実施形態に係る外部デバイスの構成を示す図である。
[図 3]外部デバイスにおける機能の対応の例を示した図である。
[図 4]本発明の実施形態に係る外部デバイスの動作を示すフローチャートである。
[図 5]本発明の制御方法におけるブロック図である。
[図 6]本発明の制御装置における回路図である。
[図 7]本発明の制御方法で用いるソフトウェアのブロック図である。
[図 8]USBN9603レジスタにおける制御ルーチンの一例を示すブロック図である。 符号の説明
[0038] 10· ··外部デバイス、 11· ··機能部、 12· ··インターフェース部、 13· ··機能記憶部、 1 4…制御部、 20"'PC、 21· ··インターフェース部、 22· ··制御信号送信部、 25· ··ケー ブル、 30· ··外部デバイス、 30a…マスストレージデバイス、 31 "'USBインターフエ一 ス、 40- --PC, 41· ··デノ イスドライノく、 41a' ··マスストレージクラスドライノく、 42- --OS, 42a…中間層、 42b- "USBホス卜ド、ライノく、 43· ··アプリケーション、 44- USBホス卜、 50…ケーブル。
発明を実施するための最良の形態
[0039] 以下、図面とともに本発明に係る外部デバイス、当該外部デバイスを含む電子機器 システム及び当該外部デバイスにおける制御方法の好適な実施形態について詳細 に説明する。なお、図面の説明においては同一要素には同一符号を付し、重複する 説明を省略する。
[0040] まず、図 1を用いて、本発明の背景を改めて説明する。図 1は、外部デバイスである USBデバイス 30が、電子機器である PC40にケーブル 50により接続されている状態 を示す。 USBデバイス 30では、 USBインターフェース 31において、 USBデバイス 3 0に応じてデバイスの種類を特定する IDである、クラス IDが設定されている。 PC40 力も USBデバイス 30に対して、機能を実行させる制御信号を送信するためには、 P C40において USBデバイス 30に応じてデバイスドライバ 41が必要となる。デバイスド ライノく 41は、 OS42に含まれており、 OS42内にお!ヽて、中間層 42aと、 USBホストド ライバ 42bとを繋ぐ役割を果たす。ここで、図 1に示すように、中間層 42aは、制御信 号を生成するアプリケーション 43と情報の送受信を行う部分であり、 USBホストドライ ノ 42bは、 USBデバイス 30とのインターフェースである USBホスト 44と信号の送受 信を行うものである。
[0041] PC40から USBデバイス 30への制御信号の送信は、クラス IDが特定された上で U SBデバイス 30に応じた機能毎に行われるため、デバイスドライバ 41は、通常、 USB デバイス 30毎に必要となる。従って、上述したように、 USBデバイス 30を新たに開発 する場合は、その USBデバイス 30毎にデバイスドライバ 41を作成する必要があった 。また、 OS42における上記の中間層 42aや USBホストドライバ 42bは、 OSにより形 式が異なるので、デバイスドライバ 41は、 OS42毎に作成する必要があった。
[0042] ところで、デバイスドライバ 41には、ストレージゃサウンドデバイス等のよく使われる 機能の USBデバイスのための個々のデバイスドライバ開発を省略するために、通常 、多くの種類の OS42において共通的に用意されているものがある。このようなデバイ スドライバ 41は USBクラスドライバと呼ばれる。例えば、図 1に示すマスストレージクラ スドライバ 41aは、ストレージ機器のためのデバイスドライバであり、ストレージ空間へ のアクセスのための制御手順を提供して 、る。 PC40に接続された USBマスストレー ジデバイス 30aには、マスストレージクラスドライバ 41aが用いられて制御信号が入力 される。 [0043] 以上を踏まえて、本発明に係る外部デバイス、当該外部デバイスを含む電子機器 システム及び当該外部デバイスにおける制御方法の好適な実施形態を説明する。図 2に本実施形態に係る外部デバイス 10、及び当該外部デバイス 10の接続対象であ る PC20の機能構成を示す。外部デバイス 10と PC20とは、本実施形態に係る電子 機器システムを構成している。外部デバイス 10と PC20とは、ケーブル 25等により接 続されている。なお、外部デバイス 10は、 PC20から取り外すこともできるようになって いる。外部デバイス 10と PC20との接続は、所定のデータ伝送路の規格に準じている 。上述したように、当該規格では、外部デバイス 10への制御信号の送信は、外部デ バイス 10の種類を IDにより特定した上で、当該種類に応じたデバイスドライバが用い られて行われる。本実施形態では、当該規格を USBとして説明する。
[0044] 外部デバイス 10は、 PC20からの制御を受けて所定の機能を実現するデバイスで ある。外部デバイス 10としては、具体的には、ストレージ機器、キーボード、マウス及 びモデム等の周辺機器に相当する。本実施形態では、外部デバイス 10は、電圧等 により外部力も入力されるアナログ値を、デジタル値に変換する AZD変 として 説明する。図 2に示すように、外部デバイス 10は、機能部 11と、インターフェース部 1 2と、機能記憶部 13と、制御部 14とを備えて構成される。
[0045] 機能部 11は、外部デバイス 10の機能を実行する手段である。本実施形態のように AZD変換器であれば電圧値等により入力されたアナログ値をデジタル値に変換す る機能を実行する手段である。機能部 11による機能の実行は、後述するように、制御 部 14の制御を受けて行われる。機能部 11は、機能に応じたハードウ アによって実 現される。例えば、本実施形態のように AZD変換器であれば、 AZD変換を行う回 路ゃ CPU等によって実現される。
[0046] インターフェース部 12は、 PC20からケーブル 25を経由して入力される USBに準 拠した制御信号の入力を受け付けつけ、また、 PC20との間でデータの入出力を行う 手段である。また、インターフェース部 12は、外部デバイスの種類を特定するクラス I Dを、自身のクラス IDとして記憶した ID記憶手段でもある。インターフェース部 12に 記憶されているクラス IDは、 PC40 (の各 OS)において予め制御を行うためのデバィ スドライバが規定されている外部デバイスの種類のクラス IDである。また、インターフ エース部 12に記憶されているクラス IDに係る外部デバイスの種類は、ブロック型デバ イスである。インターフェース部 12に記憶されているクラス IDは、具体的には例えば、 上述したマスストレージデバイスのクラス IDであることが望ましい。
[0047] これによつて、 PC20からは、外部デバイス 10の機能、即ち機能部 11の機能にかか わらず、外部デバイス 10がマスストレージデバイスであると認識される。従って、 PC2 0からは、マスストレージデバイスに対する制御信号が入力される。インターフェース 部 12は、 PC20から入力された制御信号を受信して、制御部 14に入力する。
[0048] インターフェース部 12は、 ICチップ(USBデバイス)等のハードウェアによって実現 される。
[0049] 機能記憶部 13は、インターフェース部に記憶されているクラス IDにより種類が特定 される外部デバイスの入力受付用機能と、 自身の機能部 11で実行される実行用機 能とを対応付けて記憶しておく機能記憶手段である。機能記憶部 13は、具体的には 、マスストレージデバイスの機能 (入力受付用機能)と、機能部 11で実行される機能と を対応付けて記憶する。更に具体的には、図 3に示すように、マスストレージデバイス の機能として"メモリアドレスの 0番地に 0又は 1を書き込む"ことと、機能部 11の AZD 変 の機能として"計測をスタート又はストップする"こととを対応付けて記憶する。 また、マスストレージデバイスの機能として"メモリアドレスの 1番地に数値を書き込む" ことと、機能部 11の AZD変 の機能として"当該数値を計測間隔とする"こととを 対応付けて記憶する。また、マスストレージデバイスの"メモリアドレスの 2番地の数値 "と、機能部 11の AZD変換器の "計測された値"とを対応付けて記憶する(PC20か らメモリアドレス 2番地にアクセスする制御信号が入力されることにより計測された値が 読み出される)。これらの情報は、制御部 14によって参照される。機能記憶部 13は、 メモリや回路のハードウェア等により上記の情報を記憶することにより実現される。
[0050] 制御部 14は、機能を実行させる制御信号を、 PC20からインターフェース部 12を介 して受け付けて、機能記憶部 13に記憶された情報を参照して、当該制御信号に係る 機能を入力受付用機能としたときに対応する実行用機能を機能部 11に実行させる 制御手段である。具体的には例えば、 PC20から外部デバイス 10に、 "0番地に 1を 書き込む"という旨の制御信号が入力されると、制御部 14は、機能記憶部 13に記憶 された図 3に示すような機能の対応関係を示す情報を参照して、機能部 11に対して" 計測をスタートさせる"制御を行う。上記のように、マスストレージデバイスへの書き込 みはコマンド発行として、マスストレージデバイスからの読み出しはステータス(上記の 例ではデジタル値)要求とすることが望ま 、。
[0051] なお、外部デバイス 10に、 SRAM (Static Random Access Memory)等のストレージ 手段を設けておき、マスストレージデバイスと同様に PC20から入力された制御信号 に基づきストレージ手段のメモリアドレス上での読み書きが (機能部 11による機能の 実行と合わせて)行われることとしてもよ ヽ。以上が外部デバイス 10の機能である。
[0052] 引き続いて、電子機器である PC20の構成について説明する。 PC20は、外部デバ イス 10に制御信号を送信して、外部デバイス 10を制御する装置である。 PC20は、 図 2に示すように、インターフェース部 21と、制御信号送信部 22とを備えて構成され る。 PC20は、 CPU及びメモリ等のハードウェアにより実現される。
[0053] インターフェース部 21は、制御信号送信部 22からの指示に従い USBに準拠した 制御信号を外部デバイス 10に送信し、外部デバイス 10との間でデータの入出力を 行う手段である。インターフェース部 21は、 ICチップ (USBホスト)等のハードウェア によって実現される。
[0054] 制御信号送信部 22は、外部デバイス 10への制御信号を外部デバイス 10へ送信 するように、インターフェース部 21に指示を行う手段である。制御信号送信部 22は、 図 1における PC40の OS42及びアプリケーション 43の機能に相当する。即ち、制御 信号送信部 22は、外部デバイス 10のクラス IDに対応したデバイスドライバを用いて クラス IDを特定した上で、外部デバイス 10に対して制御信号を送信するようにインタ 一フェース部 21に指示する。
[0055] 本実施形態に係る外部デバイス 10への制御信号の送信は、外部デバイス 10のク ラス IDをマスストレージデバイスのクラス IDとした上で行われる。なお、通常、マススト レージデバイスのデバイスドライバは PC20の OSにかかわらず、制御信号送信部 22 に備えられている。なお、制御信号送信部 22の指示により送信された制御信号は、 上述したように外部デバイス 10においては、機能記憶部 13に記憶された対応付けさ れた機能が実行される。従って、制御信号送信部 22 (を実現するアプリケーション) は、その対応関係に基づいて、外部デバイス 10の機能部 11の機能が実行されるよう に、マスストレージデバイスの制御信号を送信する。
[0056] なお、制御信号送信部 22における、アプリケーション力 OSへの制御信号の入出 力は、 OSのポータビリティ規格 POSIXで定義されている入出力システムコール (具 体的には、 open ()、 read ()、 write ()、 close () )を用いてアクセスすることが望まし い。 OS毎のアプリケーションの開発を容易にするためである。以上が PC20の機能 である。
[0057] 引き続いて、図 4のフローチャートを用いて、本実施形態に係る外部デバイス 10の 動作 (外部デバイス 10における制御方法)を説明する。
[0058] PC20から外部デバイス 10に互いのインターフェース部 12, 21を介して制御信号 が入力されることにより、動作が開始される。なお、制御信号の入力は、 PC20におけ るユーザの操作等をトリガとして行われる。また、この制御信号の入力の際、 PC20の 制御信号送信部 22では、マスストレージデバイスのデバイスドライバが用いられて、 外部デバイス 10のインターフェース部 12に記憶されたマスストレージデバイスのクラ ス IDが特定される。
[0059] 外部デバイス 10では、制御部 14によって制御信号が受け付けられる(S01、制御 ステップ)。続いて、制御部 14によって、機能記憶部 13に記憶された図 3に示すよう な情報が参照されて入力された制御信号に係る入力受付用機能に対応する、機能 部 11で実行されるべき実行用機能が特定される(S02、制御ステップ)。続いて、制 御部 14によって、機能部 11に対して特定された実行用機能が実行されるように制御 されて、機能部 11によって当該実行用機能が実行される(S03、制御ステップ)。
[0060] 上述したように本実施形態では、 PC20は、外部デバイス 10のインターフェース部 1 2に記憶されたクラス IDに係る種類の外部デバイスとして、外部デバイス 10を制御す ることができる。従って、インターフェース部 12に記憶されたクラス IDを、 PC20から制 御信号を予め入力可能な種類の外部デバイス、即ち、デバイスドライバ等が予め用 意されている外部デバイスのクラス IDとすれば、 PC20において、電子機器の OSに 依存する、外部デバイスへ制御信号を入力するためのデバイスドライバ等を外部デ バイス 10毎に用意することが不要となる。 [0061] また、本実施形態のようにインターフェース部 12に記憶されている IDを、 PC20に お ヽて予め制御を行うためのデバイスドライバが規定されて ヽる外部デバイスを特定 する IDであることとするのが望ましい。この構成によれば、インターフェース部 12に記 憶される IDが、 PC20から制御信号を予め入力可能な種類の外部デバイスの IDとな るので、確実に本発明の効果を奏することができる。
[0062] また、本実施形態のようにインターフェース部 12に記憶されている IDは、ブロック型 デバイスである外部デバイスを特定する IDであることが望ま ヽ。この構成によれば、 アドレスと機能の内容とを容易に対応付けることができるため、機能記憶部 13にお ヽ て機能の対応を容易に記憶させることができると共に、本発明に係る外部デバイス 1 0に対する PC力もの制御信号の入力を容易に行うことができる。但し、必ずしもブロッ ク型デバイスである必要はなぐキャラクタ型デバイスであってもよ!/、。
[0063] 上記のような本発明の特徴により、外部デバイス 10を PC20の OSによらずに (OS インデペンデントに)、即ち、 OSに依存したソースを必要とせずに利用可能とすること ができる。なお、上記の実施形態では、外部デバイス 10 (の機能部 11)の機能の例と して、 AZD変 を説明に用いたが、外部デバイスとして実現できる機能であれば 、計測器、電源装置、映像機器及びオーディオ装置等の任意のデバイスに本発明を 適用することができる。また、外部デバイス 10が接続される電子機器も PC20に限ら れない。更に、外部デバイスと電子機器との接続の規格についても、 USB〖こ限られ ず、同様の枠組みを有するものに適用することができる。
[0064] 実装例として、 ADuC7026内蔵の ADコンバータ (2チャンネル)からアナログデータを キヤプチヤして PCへ転送するシステムを作製した。
[0065] OSはストレージ機器に対してキャッシュ機構を持っている。 open()システムコールで オープンする限りオプション ·フラグ (0_DIRECTと 0_SYNC)を設定することでキヤッシ ュを回避することができる力 アクセス方法の選択肢を広げ、あらゆる環境下で OSの キャッシュ機構を避けることを意図して、メディアロック機構のな 、USBフロッピディスク をエミュレートする。これによつて、ディレイは避けられなくても、ライト'キャッシュを自 動的に回避することができる。
[0066] (システム) 本機のブロックダイアグラムを図 5に示す。 USBインターフェースとデバイス固有の動 作 (今回は A/Dコンバータ力 のデータ取り込み)の独立性を高め、機能追加 (例えば D/Aコンバータへのデータ出力など)を USBインターフェースに手をカ卩えることなく実 現できるようにするために、 64KBの外付け SRAMを用 、て物理的にメモリ ·パーティシ ヨンを用意した。
[0067] 図の右側には、 USBインターフェースの構成を示している。 USB物理層は National I nstruments製の USBN9603(Full Speed対応)にまかせ、プロトコル層 (USBトランザクショ ンの処理)、デバイス 'フレームワーク (USBデバイス 'リクエストの処理)、 Mass Storage Classの処理をソフトウェアで行う。これらのソフトウェアは USBN9603の割り込み要求 信号 (INTRQ)によって ADuC7026の IRQ割り込みとして呼び出される。
[0068] 図の左側には、デバイス固有の動作 (A/Dコンバータからのデータ取り込み)を示し ている。このソフトウェアは ADuC内蔵のタイマ (Timerl)の割り込みによって呼び出さ れる。 Timerlにはサンプリング周波数がセットされており、呼び出される度にコント口 ール.パーティションをチェック、コマンドの解釈を行う。データの取り込みが指示され れば呼び出される度に A/Dコンバータからデータを読み出して SRAMのデータ'パー テイシヨンに格納する。
[0069] また、必要のある場合にはステータスをコントロール 'パーティションに書き込む。こ の処理は確実にサンプリング周波数ごとに行わなければならないため、 UBN9603の 割り込み信号よりも優先度の高い FIQ割り込みとして呼び出している。
[0070] 具体的には、コントロール 'パーティションは 0バイト目が CH0へのコマンド、 1バイト 目が CH1へのコマンド、 2バイト目がコマンド 'キューとなっている。今回は簡単のため 、データ取り込み開始コマンド ('G')と、中止コマンド ('Ν')だけを用意した。
[0071] コマンド 'キューは、 CH0、 CHIへのコマンド 'バイトに有効なコマンドが書き込まれた ことを示すためのものである。デバイス側は、このバイトに' *'が書き込まれたことを認 識すると、これを' '(スペース文字)でクリアすると同時に、 CH0、 CHIのコマンド 'バイト を解釈し、実行する。データ'パーティションとしては CH0、 CHI用にそれぞれ 16KBず つのパーティションを用意した。 'G'コマンドが与えられると、対応するチャネルのパー テイシヨンの先頭力も順次 A/Dコンバータ力ものデータを格納していき、末尾に到達 すると対応するコマンド 'バイトに動作完了のマークとして' # 'を書き込み、終了する。
[0072] PC側はコマンド発行後、定期的にコントロール 'パーティションをチェックし、 '# 'が書 き込まれるのを待つことでデータ取り込みの完了を知ることができる。
[0073] データ自体は、それぞれのチャネルに対応するパーティションを読み出すことによ つて得ることがでさる。
[0074] (ハードウェア)
本機の回路図を図 6に示す。 ADuC7026は GPIOの P0.1, P0.2, P2.1〜7、 P3、 P4をコ ンフィギユレーシヨン 2に設定 (GPxCONレジスタ (x=0,2,3,4》することで、アドレス'デー タ多重の 16/8bitのメモリ'バスを使用することができる。このバス経由でアクセスできる メモリ空間は 128KBずつの 4領域に分けられており、各領域ごとにィネーブル信号 (M S[3:0])が用意されている。 USB9603及び外付け SRAMをこのバスに接続し、前者を領 域 0に、後者を領域 1に割り当てた(GPIOについてはデータ'シート (ANALOG DEVIC ES, "AduC7019/20/21/22/24/25/26/27 Data sheet, Rev. 0", Nov., 2005)p.59- 60 、メモリ'インターフェースについては同 p.78-81、詳細なタイミングについては同 p.9-1 0、メモリ'マップについては同 p.33参照))。
[0075] USBN9603は 8bitのアドレス多重バスをサポート (MODE1='0,, MODE0='l 'に設定)し ています (National Semiconductor, USBN9603/USBN9604 Universal Serial Bus Full Speed Node Controller with Enhanced DMA Support, Rev.l.3,,参照)のでADuC7026 のメモリ'バスに直結することができます。 ADuC7026側では XM0CONの bitlを' 0'とす ることで領域 0のアクセス ·モードを 8bitに設定することができる。
[0076] 外付け SRAMには Winbond製 W24257AK- 15を準備した。これは一般的な 8bit幅の 2 56KBit SRAM (Windbond, "W24257A Datasheet, Rev. A6,,参照)で、 HM65256や uP D43256とピン配置互換である。アドレス 'ラッチとして 74HC573を 2個使用し、 ALE出 力によってアドレスを分離し、 SRAMに供給している。 BHE, BLE出力は 16bitバス上で 8bit単位でのアクセスを行うための信号で、それぞれ、上位バイト、下位バイトへのァ クセスが必要となる時にアクティブになる。 16bitと 8bitのアクセスを区別する必要があ るのは書き込みのみであるから、ライト'ストローブ信号 WSとの論理積を SRAMに供給 し、リード'ストローブ信号 RSはそのまま接続する。 [0077] メモリ'バスのアクセス 'タイミングを設定するレジスタ力メモリ領域ごとに用意されて いる (XMxPAR, x=0, 1,2,3)。 ADuCのメモリ'タイミング 'チャートと USBN9603、 SRAMの タイミングチャートを比較してタイミング設定を決定し、実機でチェックしながら調整し たところ、 USBN9603については 0109h、 SRAMについては 0201hが最速の設定であつ た。 USBN9603のアクセスタイミングは、アドレス関連のアクセスタイムは早いものの、リ ードでは読み出し時間力 ライトでは書き込み後次のアドレス設定が可能になるまで の時間力 ¾50nsと長いことに注意が必要である(上記 Windbond, "W24257A Datashee t, Rev. A6"参照)。
[0078] 特に、ライト後の待ち時間は CPUクロックで約 10サイクル必要である力 XMxPARレ ジスタでは 1CLKまでしカゝ設定できな 、ため、場合によってはプログラミング上の配慮 が必要となる。
[0079] また、 USBN9603の割り込み要求信号 (INTRQ)を ADuC7026の外部割り込み入力ピ ン IRQ0
に接続し、 USBN9603からの割り込みを受け付けられるようにしておく。
[0080] アナログ入力については、 CH0、 CHIそれぞれに簡単なアンプを用意した。 ADuC の A/Dコンバータの入力範囲は 0V〜2.5Vであるので、このアンプによりレンジ調節を 行う。入力信号はまずアツテネータを通って振幅調整される。次に、 AC接続の場合 はカップリング'コンデンサとバイアス抵抗を経由、 DC接続の場合は直接、オペアン プ (TLC272)に入力する。オペアンプの一段目はボルテージ ·フォロワを構成しており 、インピーダンス変換を行う。二段目は反転増幅器で、 1.25V(Rx2, χ=0,1の分圧比で 決定される電圧)を中心として Rxl/3K倍 (χ=0,1)に増幅する。すべて単電源で構成さ れて 、るので、負の電圧を計測した!/、場合は AC接続にしなければならな 、。
[0081] また、オペアンプとしては単電源 3.3Vで動作するものであればよぐ LM158なども使 用できる。
[0082] (ソフトウェア)
ソフトウェアのブロック図を図 7に示す。 ARM7TDMIシリーズの割り込みには IRQと FI Qとの二種類がある。後者は割り込みルーチンで使用できるレジスタ数などに制限を 加えることで割り込み信号検出からルーチンコールまでの処理を軽減し、レイテンシ を抑えている (上記 ANALOG DEVICES, "AduC7019/20/21/22/24/25/26/27 Data sheet, Rev. 0", Nov., 2005、 p.31- 32参照)。また、 ARM7TDMIの割り込み禁止フラグ は CPSRという CPUレジスタに IRQ用 (Iビット)と FIQ用 (Fビット)とが別々に用意されてい る。これらの禁止フラグは割り込みルーチンが呼ばれる時に自動的にセットされる力 IRQ割り込み時は Iビットのみセットされ、 FIQ割り込み時には Iビットと Fビットとの両方 がセットされる。つまり、 IRQ割り込み処理中でも FIQ割り込み処理を受け付けることが できる。従って、 IRQと FIQとを使い分けることで CPSRにアクセスすることなぐ割り込 み処理中により優先度の高 、割り込みを受け付けることができる。
[0083] データのサンプリング処理は必ずサンプリング周波数ごとに必要な処理であるので FIQ割り込み処理として、 USBまわりは処理が複雑になる場合もあり、それほど時間の 制約も強くないため IRQ割り込み処理として実装した。前述のように、 Timerlにデータ のサンプリング間隔を設定して周期的に割り込みを発生させる。具体的には T1LDレ ジスタにカウント値、 T1CONの下位 4ビットに分周比、 bit7と 6に Tをセットする。この割 り込み信号で FIQを発生させられるよう設定する (FIQENレジスタ (上記 ANALOG DEV ICES, "AduC7019/20/21/22/24/25/26/27 Data sheet, Rev. 0", Nov., 2005、 p.73— 74)に 00000008hを書き込む)。
[0084] USBN9603の INTRQ出力は外部割り込み入力ピン IRQ0に接続してあるので、これ によって IRQ割り込みを発生させられるよう設定する (IRQENレジスタに 00008000hを 書き込む)。 IRQENや FIQENレジスタは新たにセットした!/、ビットのみを立てて書き込 むことで許可ビットを追加できる。逆に許可ビットをクリアしたい場合は IRQCLR、 FIQ CLRレジスタにクリアしたいビットのみを立てて書き込むことになる。
[0085] A/Dコンバータ制御ルーチンではまず、 FIQSTAレジスタをチェックする。このレジス タは FIQENレジスタで割り込みを許可している信号のうちどの信号がアクティブになつ ているかを知らせてくれる。対応するビットが Tになっていればアクティブになってい るので、このレジスタと 00000008hとの論理積をとつて Tならば Timerlからの割り込み と判断する (本例では、 FIQ割り込みは Timerlからのものだけなので、この処理はなく ても動作する)。
[0086] 次に T1CLRIレジスタ (上記 ANALOG DEVICES, "AduC7019/20/21/22/24/25/26/ 27 Data sheet, Rev. 0", Nov., 2005、 p.75-76)に書き込みを行い、割り込み入力をク リアする。これを行わないと、割り込み処理終了後またすぐ割り込み処理が始まってし まう。次にコマンド 'パーティションのコマンド'キュ一'バイトをチェックする。この場合、 が書き込まれていれば、有効なコマンド力 SCH0、 CHIのコマンド 'バイトそれぞれに セットされているのでコマンド内容をチェックする。 'G'ならば該当チャネルのデータ収 集を開始、 'N'ならば中止する。これら以外ならばなにもしない。具体的には、データ 収集開始の場合はデータ収集の開始は変数 ADC_CHx_EN(x=0,l)に Tをセット、中 止の場合は' 0'をセットする。
[0087] 同時に、データ収集開始の場合はデータ'メモリへのポインタ (変数 adcChxCurrent( x=0,l》をメモリ領域の先頭 (ADC_CHx_BUFHEAD(x=0,l》にセットする。そして、 ADC_ CHx_ENが Tの場合は該当チャネル力ものデータを読み込み、メモリへ格納、ポイン タをインクリメントする。ポインタ力 Sメモリ領域の最後 (ADC_CHx_BUFTAIL - 1 (χ=0,1)) まで達したらデータ収集を完了し、該当コマンド 'バイトに' # '(完了ステータス)を書き 込む。
[0088] USBインターフェース 'ルーチンでは、 A/Dコンバータ制御ルーチンの場合と同様、 まず IRQSTAレジスタをチェックして外部割り込み 0からの割り込みであることを確認し てから USBN9603の制御ルーチン (USBN960x_intO)を実行する。制御ルーチンは usbn 960x.cに記述されており、図 7では左上の USBプロトコル ·レイヤに相当する。 USBN96 03の制御方法については、上述したデータ'シート以外にも、例えば、 USB通信プロ グラミングテクニック" http:〃. picfon.com/usbframe.html; 桑野雅彦" USBコントローラ USBN9602を使った USBターゲット機器の開発" in TECHI USBハード &ソフト開発の すべて" TECHI Vol.8, pp.43- 54); 桑野雅彦" USBコントローラ USBN9602/9603/960 4の使 、方")などを参照して用いることができる。
[0089] これらの方法を用いた制御方法について以下に簡単に説明する。
[0090] USBでは、一つのデバイスがエンドポイントというデータを送受信するための「出入り 口」を機能ごとに用意する。 PCはエンドポイントを選んでデータをやりとりすることで使 用したい機能ブロックと直接通信することができる。 USBN9603には EP0〜EP6の 7個 のエンドポイントが用意されている。 EP0は USB規格(上記 Compaq, Intel, Microsoft, a nd NEC, "Universal Serial Bus Specification, Rev.1.1"参照)(USBN9603は USB Rev. 1.1対応)で必須とされているコントロール 'エンドポイントで、 8バイトの FIFOを備えて いる。 USB規格で指定されている通り入出力兼用で、 FIFOも入出力兼用、 EPC0レジ スタによって方向を切り替えて使用する (入出力兼用なのはコントロール 'エンドポイン トのみ)。 EP1, EP3, EP5は送信専用 (USBの IN方向に対応)のエンドポイントで、 64バイ トの FIFOを備えている。 EP2, EP4, EP6は受信専用 (USBの OUT方向に対応)で、同じ く 64バイトの FIFOを備えて!/ヽる。
[0091] 制御ルーチンの仕事はなぜ割り込みが力かったのかを判定し、それに対応した指 令を USBN9603に与えることである。図 8に USBN9603のレジスタのうち制御ルーチン でよく使うものを示す。この場合、すべて 8ビットである。 MAEVレジスタには、割り込み 発生の理由がおおまかに示されているので、最初にこれをチェックする。 RX_EVビット が立っていればデータの受信に関係する状態が変化した、ということである。どのチ ャネルで、何が起こったのか (受信が成功した、エラーが発生したなど)を知るために R XEVレジスタ、さらに RXSx(x=0,l, 2,3)レジスタをチェックすることになる。 TX_EVビット が立っていればデータ送信の完了 (あるいは未完了)を意味するので、 TXEVレジスタ や TXSx(x=0,l,2,3)レジスタをチェックする。 NAKビットは、受信エンドポイント (EP2, EP 4, EP6)において FIFOがいつぱいであり、データを受け取ることができなかった場合、 送信エンドポイント (EP1, EP3, EP5)において FIFOが空だったため PCからのデータ読 み出し要求に応えられな力つた場合に Tになる。
[0092] どのチャネルで発生したかは NAKEVレジスタによって知ることができる。基本的にこ のレジスタで重要なのは OUT0(bit4)のみである。このビットは EP0の受信方向で NAK が発生したことを意味し、 PCからのコマンドが来て!/、るのに受け取れて!/ヽな ヽと!、うこ とであって、送信中でも中止して受信モードに切り替えてやる必要がある。 ALTビット が立っていた場合は、パワーマネジメント関連とバスリセット関連のレジスタ ALTEVレ ジスタをチェックする。本機のようにセルフパワーのデバイスの場合はパワーマネジメ ントが必須というわけではないので、バスリセット (bit6)のみをチェックすればよい。バス リセットが発生した場合は、電源投入時と同じ状態に戻らなければならない。 USBN96 03の制御ルーチンはこれらのレジスタを操作し、各エンドポイントでのデータ送受信 を行つ。これ【ま、 Compaq, Intel, Microsoft, and NEC, "Universal Serial Bus Specificat ion, Rev.1.1"の 8章 Protocol Layerに記載されている処理に相当し、ファイル usbn960 x.cに記述されている。
[0093] USBデバイスとして機能するためには少なくとも、コントロール 'エンドポイント (EP0) に対して PC力 送られてくる種々のコマンドのうち「標準デバイス 'リクエスト」と呼ばれ るコマンド群に対して応答することができなければならない。これらは、上記 Compaq, Intel, Microsoft, and NEC, Universal ¾enal Bus Specincation, Rev.1.1 の 9早 iJSB Device Frameworkに定義されており、主としてデバイス固有の情報 (機能の概要ゃェ ンドポイントの数など)を要求したり、 USBツリー内でのアドレスを設定したり、動作モー ドを切り替えたり、といった機能をもっている。
[0094] これらの処理は、図 7の左下、デバイス 'リクエスト処理に相当し、 usb.devicelayer.c, usb.descriptors.hに記述されている。これらのコマンド群はコントロール 'トランスファ( 上己し ompaq, Intel, Microsoft, and NEし, 'Universal Serial Bus specification, Rev.1. 1"、 8.5.2, p.164-168)と呼ばれるプロトコルに従って伝達、実行、ステータス報告が行 われる。コントロール 'トランスファの処理は usbn960x.cに記述されている。
[0095] デバイスは、自分の固有情報を標準 USBディスクリプタというデータ'テーブル群の 形で保持している。これは標準デバイス 'ディスクリプタ、標準コンフィギュレーション' ディスクリプタ、標準インターフェース 'ディスクリプタ、標準エンドポイント 'ディスクリブ タと呼ばれる 4種類のデータ'テーブルの組み合わせで構成されている。標準デバィ ス'ディスクリプタにはデバイス全体の情報、例えば USBのどのバージョンをサポートし ているか、デバイス機能の概略 (Class Codeなど)、製造者名、デバイス名などが記載 されている。標準エンドポイント 'ディスクリプタには該当エンドポイントの番号、データ 転送方式と方向、最大のパケット'サイズなどが記載されて 、る。
[0096] USBでは 1つのデバイスに複数の独立した機能を実装することができる。その機能 ごとにエンドポイントの集合体であるインターフェースが定義される。標準インターフエ ース 'ディスクリプタには該当インターフェースの機能の概略 (Class Codeなど)が記載 されている。また、 USBではどの機能 (インターフェース)を有効にするか動的に変更す るための機構が用意されている。どの機能群を有効にするか、という組み合わせをコ ンフィギユレーシヨンと呼び、標準コンフィギュレーション 'ディスクリプタにその概略が 記載されている。 PC側は〃 Get Descriptor〃標準デバイス 'リクエストを使用して、用意 されているコンフィギュレーションのディスクリプタをすベて読み出し、 "Set Configurati on"標準デバイス 'リクエストで希望のコンフィギュレーションを選択することになる。
[0097] なお、標準インターフェース 'ディスクリプタ、標準コンフィギュレーション 'ディスクリ プタ自身にはそれぞれどのエンドポイント、インターフェースが属するかという情報の 記載はない。また、 "Get Descriptor〃標準デバイス 'リクエストでディスクリプタを要求さ れたときに、所属するエンドポイント、インターフェースのディスクリプタをすべていつし よに送ることで、この情報を PC側に知らせることになる。
[0098] また、同時に有効にならない複数のインターフェースは同じエンドポイントを所有す ることができるし、そのような場合、インターフェースによって同一エンドポイントのデ ータ転送方式や方向が異なって 、ても良 、。
[0099] PCは USBデバイスの接続を検知すると、バス'リセットをかけ、 "Set Address"標準デ バイス'リクエストによりデバイスに USBアドレスを割り当て、 "Set Configuration"標準デ バイス'リクエストによりインターフェースをァクティペートし、デバイスを動作可能状態 に持っていく。
[0100] デバイスが Mass Storage Classとして機能するためには、 l)Mass Storage Class機能 専用のンターフェースを用意すること、 2)そのインターフェースのディスクリプタにデバ イスのサポートするデータ転送方法とコマンド 'コード体系を正しく記述しておくこと、 そして、 3)Mass Storage Class特有のデバイス 'リクエストをサポートすること、が必要で ある。
[0101] まず、 1)に関し、 Mass Storage Classの概要文書 USB- IF, "Universal Serial Mass St orage Class Specification Overview, Rev. 1.2,,では、 Mass Storage Class用インタ1 ~~フ エースを 2種類定義している。この 2種類とは、 Control/Bulk/Interrupt protocol(CBI) と Bulk- Only Transportとである。前者は FuU- speedの USBフロッピ 'ディスクのみで用 いること、新規設計には用いないことを推奨する、と書かれているので、本例では Bulk -Only Transport (USB— IF, Universal benai Bus Mass Storage Class Bulk-Only Tra nsport, Rev. 1.0"参照)を用いる。また、コマンド 'コード体系について、上記 USB-IF, "Universal Serial Mass Storage Class Specification Overview, Rev. 1.2"では、 6 種類定義されているが、そのうち USBフロッピに適したものは UFI、 SFF-8070iの 2つで ある。
[0102] 今回は正式な specificationを USB- IFから入手できる USB- IF, "Universal Serial Bus Storageし lass UFI Command Specincation, Rev.丄.2 を選択し 7こ。 Bulk— Only Transp ort用のインターフェースは Bulk-Inエンドポイント (Bulkトランザクション (上記 Compaq, I ntel, Microsoft, and NEし, 'Universal Serial Bus Specification, Rev.1.1 、 8.5.1, p.lり 3-164)により通信する IN方向のエンドポイント)、 Bulk-Outエンドポイントをそれぞれ一 つずつで構成される。
[0103] 2)のディスクリプタにつ!/ヽては、本機に搭載する機能は Mass Storage Class機能の みであるので、インターフェースはこの機能用のもの 1種類だけである。従って、コンフ ィギユレーシヨンも 1種類しか必要としない。本機に用意するディスクリプタは標準デバ イス'ディスクリプタ、標準コンフィギュレーション 'ディスクリプタ 1つ、標準インターフエ ース 'ディスクリプタ 1つ、標準エンドポイント 'ディスクリプタ 2つ (Bulk- Out、 Bulk- In用 1 つずつ)、となる。 Mass Storage Classに対応したデバイスであることを PCに知らせるた めには、標準デバイス 'ディスクリプタの 5バイト目(bDeviceClass)を 00h、標準インター フェース 'ディスクリプタの 6バイト目(blnterfaceClass)を 08hとする必要がある。さらに、 Bulk-Only Transportであることは同ディスクリプタの 8バイト目(blnterfaceProtocol)を 5 Ohに、 UFIコマンド体系を採用していることは 7バイト目(blnterfaceSubClass)を 04hとす ることで己述する (USB— IF, 'Universal Serial Mass Storage Class Specincation Overvi ew, Rev. 1.2"、 p.6- 7参照)。
[0104] 3)のデバイス ·リクエストは" Bulk— Only Mass Storage Reset"リクエストと〃 Get Max LU N' 'リクエストである。前者は Mass Storage Class用インターフェース関連の機能のリセ ットであり、後者はデバイスの Logical Unit Number(LUN)の最大値を応答する。 LUN は 1つの物理デバイスに複数の (サブ)デバイスを用意するための機構である (例えば、 マルチ光学ドライブで LUN0は CD- ROMドライブ機能、 LUN1は DVD- RAMドライブ機 能、など。データ用パーティションを沢山 (3個以上)用意したい場合には LUNを用いる 必要があるが、今回の設計では必要ないのでこのコマンドに対しては 0を返す。 ) 0 [0105] Mass Storage Classとしての機能は図 7の中程下の部分で処理して!/、る。コードは b oms.cbwhandler.c、 UFIの処¾は boms.ufiproc.cに 述して ヽる。 [後述のように、 Bulk- Only Transport用のインターフェースは Bulk- In/Outエンドポイント 1つずつで構成さ れる。 PC側はデバイスの Bulk- Outエンドポイントに対して (もちろん Bulk- Outトランザ クシヨンを用いて)、 Command Block Wrapper(CBW)と呼ばれるデータ.ブロックを送る 。 CBWには使用するコマンド体系のコマンド (今回は UFIコマンド)の他にデータ転送 量 (dCBWDataTransferLength)やその方向 (bmCBWFlagsの bit7)などの情報を含んで V、る (上己 USB— IF, Universal ¾enal Bus Mass storage Class Bulk— Omy Transport, Rev. 1.0"参照)。
[0106] デバイス側はこの CBW、及び CBWに含まれる UFIコマンドを解釈し、必要に応じて B ulk-Out/Inエンドポイント経由でデータの送受信を行い、最後に Command Status Wr apper(CSW)と呼ばれるデータ'ブロックを Bulk- Inエンドポイントから PCに送出する。 C SWにはコマンドの実行ステータス (bCSWStatus)と処理されなかったデータ量 (dCSWR esidue)力 S3 れてい (上 3己 USB— IF, "Universal Serial Bus Mass Storage し lass Buk -Only Transport, Rev. 1.0"、 p.14- 15参照)。 Bulk-Only Transportでは必ずこの順に データがやりとりされる必要があり、 、つたん PC側が CBWを発行すればデバイス側が CSWを返す力、、 PC側が" Bulk- Only Mass Storage Reset"コマンドでリセットをかけるま で次の CBWが発行されることはな!/、。
[0107] もしこの規則に従わないタイミングで CBWが発行されたり、 CBWの内容に不備 (上 gdUSB-IF, 'Universal Serial Bus Mass Storage し lass Bulk— unly Transport, Rev. 1. 0"、 P.17- 18で定義されている)のある場合、デバイスは Bulk- Out/In両方のエンドポィ ントをストールさせ、 "Bulk- Only Mass Storage Reset"デバイス 'リクエストを待つ。後 述のようにエンドポイントのストールを検知した PC側は、まず" Clear Feature"標準デ バイス'リクエストによってエンドポイントをリセットしょうとする力 この場合はこのデバ イス ·リクエストにはエラーを返す。これにより PC側は CBWのエラーであると認識し、〃 Bulk-Only Mass Storage Reset"デバイス 'リクエストを発行してくることになる。
[0108] CSWに含まれる実行ステータスは正常終了、失敗、 CBW不整合の三種類がある。
失敗は UFIコマンドの実行エラーを意味する。 CBW不整合は CBW内に記述されたデ ータ転送量と転送方向が UFIコマンドで指定されたものと矛盾することを意味する。例 えば、 CBWにはデータ転送が OUT方向と指定されているのに UFIで必要なデータ転 送が IN方向、というような場合である。これは、 USB-IF, "Universal Serial Bus Mass St orage Class Bulk-Only Transport, Rev. 1.0"の 6.7 The Thirteen Cases(p.l8— 22)に 詳細に定義されている。この資料中では" host expectations" (ホストが期待する転送 量、方向)が CBWで指定されたデータ量、方向を意味し、 "device intent" (デバイスの 意図する転送量、方向)が UFIで指定されたデータ量、方向を意味する。
[0109] CBW不整合の判定にはいくつかの選択枝がある力 本機ではデータ転送が必要 な場合で、 0方向が反対の場合、 ii)方向は一致するが、 CBWで指定されたデータ量 の方が UFIで指定されたデータ量よりも小さい場合、という基準で判定している。また 、方向が一致して CBWで指定されたデータ量が UFIで指定されたデータ量よりも多 ヽ 場合、デバイスは (USBでいう) IN方向なら足りない分だけ 0を追加し、 OUT方向なら余 分なデータを読み捨てる。そして、その量を CSWの未処理データ数 (dCSWResidue) にセットする。 CBW不整合と判断したデバイスは、 CBWで指定されたデータ転送方 向が IN方向の場合は Bulk-Inエンドポイントを、 OUT方向の場合は両方のエンドポィ ントをストールさせる。 PC側はエンドポイントがストールしたのを検知すると" Clear Fea ture"標準デバイス 'リクエストで該当エンドポイントをリセットし、 CSWを読み出します。 もちろん、この CSWの bCSWStatusには CBW不整合が発生したことが記述されている ことになる。
[0110] 留意すべき点は、 CBW不整合によるエラーを報告しない場合は必ず CBWに指定さ れている量のデータ送受信を行うことである。また、読み捨てたり 0を追カ卩した量は CS Wの dCSWResidueにセットする。これは UFIコマンドの実行に失敗した場合にもあては まる。たとえば、データやパラメータを読み出すような UFIコマンドに失敗し、送るべき データが用意できな力つた場合は CBWで指定された分だけ 0を送る。

Claims

請求の範囲
[1] 電子機器に接続されて当該電子機器カゝら制御を受ける外部デバイスであって、 外部デバイスの種類を特定する IDを、自身の IDとして記憶した ID記憶手段と、 前記 ID記憶手段に記憶されている IDにより種類が特定される外部デバイスの入力 受付用機能と、自身で実行される実行用機能と、を対応付けて記憶しておく機能記 憶手段と、
機能を実行させる制御信号を前記電子機器から受け付けて、前記機能記憶手段 に記憶された情報を参照して、当該制御信号に係る機能を入力受付用機能としたと きに対応する実行用機能を実行させる制御手段と、
を備える外部デバイス。
[2] 前記 ID記憶手段に記憶されて 、る IDは、前記電子機器にお!、て予め制御を行う ためのデバイスドライバが規定されている外部デバイスの種類を特定する IDであるこ とを特徴とする請求項 1に記載の外部デバイス。
[3] 前記 ID記憶手段に記憶されている IDは、ブロック型デバイスである外部デバイスの 種類を特定する IDであることを特徴とする請求項 1又は 2に記載の外部デバイス。
[4] 電子機器と、当該電子機器に接続されて当該電子機器から制御を受ける外部デバ イスとを含んで構成される電子機器システムであって、
前記外部デバイスは、
外部デバイスの種類を特定する IDを、自身の IDとして記憶した ID記憶手段と、 前記 ID記憶手段に記憶されている IDにより種類が特定される外部デバイスの入力 受付用機能と、自身で実行される実行用機能と、を対応付けて記憶しておく機能記 憶手段と、
前記電子機器から機能を実行させる制御信号を受け付けて、前記機能記憶手段 に記憶された情報を参照して、当該制御信号に係る機能を入力受付用機能としたと きに対応する実行用機能を動作させる制御手段と、
を備える電子機器システム。
[5] 電子機器に接続されて当該電子機器カゝら制御を受けると共に、外部デバイスの種 類を特定する IDを、自身の IDとして記憶した ID記憶手段と、前記 ID記憶手段に記 憶されて 、る IDにより種類が特定される外部デバイスの入力受付用機能と、自身で 実行される実行用機能と、を対応付けて記憶しておく機能記憶手段と、を備える外部 デバイスにおける制御方法であって、
前記電子機器から機能を実行させる制御信号を受け付けて、前記機能記憶手段 に記憶された情報を参照して、当該制御信号に係る機能を入力受付用機能としたと きに対応する実行用機能を動作させる制御ステップを含む制御方法。
[6] 前記 ID記憶手段に記憶されて 、る IDは、前記電子機器にお!、て予め制御を行う ためのデバイスドライバが規定されている外部デバイスを特定する IDであることを特 徴とする請求項 5に記載の制御方法。
[7] 前記 ID記憶手段に記憶されている IDは、ブロック型デバイスである外部デバイスを 特定する IDであることを特徴とする請求項 5又は 6に記載の制御方法。
[8] 電子機器と、当該電子機器に接続されて当該電子機器カゝら制御を受けると共に、 外部デバイスの種類を特定する IDを、自身の IDとして記憶した ID記憶手段と、前記 I D記憶手段に記憶されている IDにより種類が特定される外部デバイスの入力受付用 機能と、自身で実行される実行用機能と、を対応付けて記憶しておく機能記憶手段と 、を備える外部デバイスにおける制御方法であって、
前記外部デバイスが、前記電子機器カゝら機能を実行させる制御信号を受け付けて 、前記機能記憶手段に記憶された情報を参照して、当該制御信号に係る機能を入 力受付用機能としたときに対応する実行用機能を動作させる制御ステップを含む制 御方法。
PCT/JP2007/051788 2006-02-02 2007-02-02 外部デバイス、電子機器システム及び制御方法 WO2007088967A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2007556929A JPWO2007088967A1 (ja) 2006-02-02 2007-02-02 外部デバイス、電子機器システム及び制御方法

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2006-026065 2006-02-02
JP2006026065 2006-02-02

Publications (1)

Publication Number Publication Date
WO2007088967A1 true WO2007088967A1 (ja) 2007-08-09

Family

ID=38327535

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2007/051788 WO2007088967A1 (ja) 2006-02-02 2007-02-02 外部デバイス、電子機器システム及び制御方法

Country Status (2)

Country Link
JP (1) JPWO2007088967A1 (ja)
WO (1) WO2007088967A1 (ja)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011086126A (ja) * 2009-10-15 2011-04-28 Taida Electronic Ind Co Ltd ヒューマン・マシン・インターフェース装置がマスストレージクラス規格で実現するデータ伝送およびコピーガード方法
JP2013045464A (ja) * 2011-08-23 2013-03-04 ▲華▼▲為▼終端有限公司 データカードとホストとの間の通信異常、及びデータカードの異常の回復のための方法
JP2013513874A (ja) * 2009-12-24 2013-04-22 ▲華▼▲為▼▲終▼端有限公司 データカードのアップグレーディング方法およびデバイス
CN104469449A (zh) * 2013-09-18 2015-03-25 青岛海尔电子有限公司 家电设备及其功能扩展方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000112666A (ja) * 1998-10-01 2000-04-21 Hitachi Ltd ディスク制御装置
JP2002041247A (ja) * 2000-07-28 2002-02-08 Nec Corp コンピュータシステムおよびusbメモリ装置
JP2004302658A (ja) * 2003-03-28 2004-10-28 Brother Ind Ltd 情報処理装置、端末装置およびプログラム
JP2004318864A (ja) * 2003-03-31 2004-11-11 Matsushita Electric Ind Co Ltd ディジタル製品用インタフェース
JP2006011807A (ja) * 2004-06-25 2006-01-12 Oki Data Corp 情報処理装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000112666A (ja) * 1998-10-01 2000-04-21 Hitachi Ltd ディスク制御装置
JP2002041247A (ja) * 2000-07-28 2002-02-08 Nec Corp コンピュータシステムおよびusbメモリ装置
JP2004302658A (ja) * 2003-03-28 2004-10-28 Brother Ind Ltd 情報処理装置、端末装置およびプログラム
JP2004318864A (ja) * 2003-03-31 2004-11-11 Matsushita Electric Ind Co Ltd ディジタル製品用インタフェース
JP2006011807A (ja) * 2004-06-25 2006-01-12 Oki Data Corp 情報処理装置

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011086126A (ja) * 2009-10-15 2011-04-28 Taida Electronic Ind Co Ltd ヒューマン・マシン・インターフェース装置がマスストレージクラス規格で実現するデータ伝送およびコピーガード方法
JP2013513874A (ja) * 2009-12-24 2013-04-22 ▲華▼▲為▼▲終▼端有限公司 データカードのアップグレーディング方法およびデバイス
JP2013045464A (ja) * 2011-08-23 2013-03-04 ▲華▼▲為▼終端有限公司 データカードとホストとの間の通信異常、及びデータカードの異常の回復のための方法
US9058264B2 (en) 2011-08-23 2015-06-16 Huawei Device Co., Ltd. Method for repairing communication abnormality between data card and host and data card
CN104469449A (zh) * 2013-09-18 2015-03-25 青岛海尔电子有限公司 家电设备及其功能扩展方法
CN104469449B (zh) * 2013-09-18 2018-07-13 青岛海尔电子有限公司 家电设备及其功能扩展方法

Also Published As

Publication number Publication date
JPWO2007088967A1 (ja) 2009-06-25

Similar Documents

Publication Publication Date Title
US6928505B1 (en) USB device controller
US7058748B1 (en) ATA device control via a packet-based interface
US7185135B1 (en) USB to PCI bridge
JP5085334B2 (ja) Usb・otgコントローラ
US8521934B1 (en) Multi-port context-based host controller
JP3403284B2 (ja) 情報処理システム及びその制御方法
JP4799417B2 (ja) ホストコントローラ
US6067589A (en) USB legacy support system
US6131131A (en) Computer system including an enhanced communication interface for an ACPI-compliant controller
JP2853809B2 (ja) 周辺コントローラのためのバッファメモリサブシステムおよび方法
US10846254B2 (en) Management controller including virtual USB host controller
US20050246477A1 (en) Combined host interface controller for conducting communication between a host system and multiple devices in multiple protocols
WO1996000940A1 (en) Pci to isa interrupt protocol converter and selection mechanism
JP4837659B2 (ja) 分割トランザクションを処理するためのバス・コントローラ
US7159065B1 (en) Method for issuing vendor specific requests for accessing ASIC configuration and descriptor memory while still using a mass storage class driver
JP2541767B2 (ja) スマ―ト・バス制御ユニット
US6078742A (en) Hardware emulation
US11704263B2 (en) Configurable multi-function PCIe endpoint controller in an SoC
WO2007088967A1 (ja) 外部デバイス、電子機器システム及び制御方法
US6014717A (en) PCMCIA host adapter and method for variable data transfers
WO1998043173A1 (fr) Systeme d'emulation et processeur de donnees
US20090083021A1 (en) Emulation of ahci-based solid state drive using nand interface
US20160314086A1 (en) Secure digital host controller virtualization
US7162565B1 (en) Universal serial bus interface to mass storage device
CN115454902A (zh) 一种基于pcie接口的nvme通信系统及方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application
WWE Wipo information: entry into national phase

Ref document number: 2007556929

Country of ref document: JP

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 07707948

Country of ref document: EP

Kind code of ref document: A1