201107991 六、發明說明: 【發明所屬之技術領域】 [0001]本發明涉及一種USB電子裝置,特別涉及一種可自動切換 USB主從設備模式的電子裝置。 【先前技術】 _2]自從USB標準在1994年由inte卜麗、Micr〇s〇ft等多 家公司聯合提出後,經過多年的發展,USB介面已大量應 用於電子裝置中,成為電子設備的標準介面之一。 [0003]眾所周知,目前’不少電子裝置通過哪介面和不同外部 電子設備進行連搔以交換數據時,需要根據所接入的外 部電子裝置的類型選擇工作在肋^ (主設備模式)或 DEVICE (從設備模式)狀態,以電子相框為例當電子 相框通過USB介面與電腦連接時,該電子相框作為電滕的 從設備被電腦控制’而與U盤連接時又作為主設備控⑽ 盤。這樣’當電子裝置與外部電子裝置通卿8介面連接 時,例如電子相棍與電腦或U盤連帛時,電子裝置就需要 根據所連接的外部電作置來自動選擇處於主設備模式 或從設備模式。 國⑽,目前’已有的USB的主狀備模式切換電路結構較 為祕’個電子元H件比鮮1子元將的過多不 但造成製造成本增加而且增加電量的消耗。 【發明内容】 [0005] 有鑒於此,有必要提供_ 種具有簡早USB主從設備模式切 換電路的電子裝置,可根據不同外部裝置類型,電子裝 098128644 置自動、仃從叹備松式的切換,該主從設備模式切換 表單編號騰1 S 4 _ 18胃 ' 胃 0982049184-0 201107991 [0006] [0007] Ο [0008] Ο [0009] [0010] 電路簡單有效,減少了電子元器件的使用,從而減少製 造成本。 為解決本發明問題的技術問題,本發明公共開一種可自 動切換USB主從設備模式的電子裝置,用於一電子裝置主 從設備模式的切換,該電子裝置包括一USB介面、一處理 單元以及一電源,該USB介面包括一 USB電源引腳、一 USB數據引腳。 該可自動切換USB主從設備模式還包括一主從選擇觸發電 路、一開關電路、一控制單元以及一選擇電路。 該主從選擇觸發電路,包括一輸入端、一第一輸出端以 及一第二輸出端,該輸入端與該USB電源引腳連接,該第 一輸出端與控制單元連接以及該第二輸出端與選擇電路 連接。該主從選擇觸發電路用於偵測通過USB介面與該電 子裝置的連接的外部電子裝置類型,當偵測該外部電子 裝置為主設備時,則通過第一、第二輸出端發出從觸發 信號,當偵測該外部電子裝置為從設備時,則通過第一 、第二輸出端發出主觸發信號》 該開關電路連接與該電子裝置電源與該USB電源引腳之間 〇 該控制單元還與該開關電路連接,用於接收第一輸出端 輸出的觸發信號,當該觸發信號為從觸發信號時,則該 開關控制單元控制該開關單元截止,切斷該電子裝置電 源與該USB電源引腳的連接,當該處觸發信號為主觸發信 號時,則該開關控制單元控制該開關單元導通,該電子 098128644 表單編號A0101 第5頁/共18頁 0982049184-0 201107991 裝置電源對該USB電源引腳供電。 [0011] [0012] [0013] 098128644 該選擇電路用於根據接收來自第二輸出端的觸發信號來 選擇處理單元的主從設備模式,當該觸發信號為從觸發 信號時,該處理單元的從設備引腳與該USB數據引腳連接 ,该處理單元控制該電子裝置工作在從設備模式,當該 觸發信號為主觸發信號時,該處理單元控制的主設備引 腳與該USB數據引腳連接,該處理單元控制該電子裝置工 作在主設備模式。 與現有技術相比,本發明主從選擇觸發電路結構簡單, 減少電子器件的使用,減少USB主從設備摸式切換電路的 製造成本,減少USB主從設備模式切換:電路的功耗。 【實施方式】 如圖1所示’為可自動切換USB主從設備模式的電子裝置 的功能模組圖。該電子裝置i包括一USB主從模式切換電 路10、一USB介面20,其中,在本實施方式中,該uSB介 面20可為Mini USB介面或類型A或類型B的USB介面。當 該電子裝置1通過該USB介面20與外部電子裝置2連接時, 該USB主從模式切換電路1〇判斷外部電子裝置2的類型, 並當外部裝置2為主設備例如電腦時,USB主從模式切換 電路10切換該電子裝置!工作在從設備模式,當該USB主 從模式切換電路1〇判斷該外部電子裝置2為從設備例如U 盤時’該USB主從模式切換電路1〇〇切換該電子裝置1工作 在主設備模式。 該USB主從模式切換電路1〇包括一主從選擇觸發電路1〇1 、一控制單元102、一選擇電路103以及一開關電路1〇4 表單編號A0101 第6頁/共18頁 0982049184-0 [0014] 201107991 [0015] Ο [0016]201107991 VI. Description of the Invention: [Technical Field] The present invention relates to a USB electronic device, and more particularly to an electronic device capable of automatically switching a mode of a USB master-slave device. [Prior Art] _2] Since the USB standard was jointly proposed by inte Bu Li, Micr〇s〇ft and other companies in 1994, after years of development, the USB interface has been widely used in electronic devices, becoming the standard for electronic devices. One of the interfaces. [0003] It is well known that at present, when many electronic devices are connected to different external electronic devices to exchange data, it is necessary to select working in the ribs (main device mode) or DEVICE according to the type of external electronic devices that are connected. (From the device mode) state, taking the electronic photo frame as an example, when the electronic photo frame is connected to the computer through the USB interface, the electronic photo frame is controlled by the computer as the slave device of the electric device, and is also used as the main device control (10) disk when connected with the U disk. Thus, when the electronic device is connected to the external electronic device, for example, when the electronic phase stick is connected to the computer or the USB flash drive, the electronic device needs to automatically select the master device mode according to the connected external power. Device mode. In the country (10), the existing USB main mode switching circuit structure is more secretive. The number of electronic components H is higher than that of the fresh one, which not only increases the manufacturing cost but also increases the consumption of power. SUMMARY OF THE INVENTION [0005] In view of this, it is necessary to provide an electronic device with a simple USB master-slave mode switching circuit, which can be automatically switched according to different external device types. , the master-slave mode switch form number 腾 1 S 4 _ 18 stomach ' stomach 0982049184-0 201107991 [0006] [0007] Ο [0008] Ο [0009] [0010] The circuit is simple and effective, reducing the use of electronic components , thereby reducing manufacturing costs. In order to solve the technical problem of the present invention, the present invention generally provides an electronic device capable of automatically switching a USB master-slave mode for switching an electronic device master-slave mode, the electronic device including a USB interface, a processing unit, and A power supply, the USB interface includes a USB power pin and a USB data pin. The automatically switchable USB master-slave mode further includes a master-slave selection trigger circuit, a switch circuit, a control unit, and a selection circuit. The master-slave selection trigger circuit includes an input terminal, a first output terminal and a second output terminal, the input terminal being connected to the USB power supply pin, the first output terminal being connected to the control unit and the second output terminal Connect to the selection circuit. The master-slave selection trigger circuit is configured to detect an external electronic device type connected to the electronic device through the USB interface. When the external electronic device is detected as the main device, the slave trigger signal is sent through the first and second output terminals. When detecting that the external electronic device is a slave device, sending a main trigger signal through the first and second output terminals, the switch circuit is connected between the power supply of the electronic device and the USB power pin, and the control unit is further The switch circuit is connected to receive a trigger signal outputted by the first output end. When the trigger signal is a slave trigger signal, the switch control unit controls the switch unit to be turned off, and the power of the electronic device and the USB power pin are cut off. Connection, when the trigger signal is the main trigger signal, then the switch control unit controls the switch unit to be turned on, the electronic 098128644 Form No. A0101 Page 5 / 18 pages 0992049184-0 201107991 Device power supply to the USB power pin powered by. [0013] 00128644 The selection circuit is configured to select a master-slave mode of the processing unit according to the trigger signal received from the second output terminal, and when the trigger signal is a slave trigger signal, the slave device of the processing unit a pin is connected to the USB data pin, the processing unit controls the electronic device to operate in a slave mode, and when the trigger signal is a main trigger signal, the master device pin controlled by the processing unit is connected to the USB data pin, The processing unit controls the electronic device to operate in a master mode. Compared with the prior art, the master-slave selection trigger circuit of the invention has a simple structure, reduces the use of the electronic device, reduces the manufacturing cost of the USB master-slave mode switching circuit, and reduces the USB master-slave mode switching: the power consumption of the circuit. [Embodiment] As shown in Fig. 1, a functional module diagram of an electronic device capable of automatically switching a USB master-slave mode is shown. The electronic device i includes a USB master-slave mode switching circuit 10 and a USB interface 20. In this embodiment, the uSB interface 20 can be a Mini USB interface or a Type A or Type B USB interface. When the electronic device 1 is connected to the external electronic device 2 through the USB interface 20, the USB master-slave mode switching circuit 1 determines the type of the external electronic device 2, and when the external device 2 is a main device such as a computer, the USB master-slave The mode switching circuit 10 switches the electronic device! Working in the slave mode, when the USB master-slave mode switching circuit 1 determines that the external electronic device 2 is a slave device such as a USB flash drive, the USB master-slave mode switching circuit 1 switches the electronic device 1 to operate in the master device mode. . The USB master-slave mode switching circuit 1 includes a master-slave selection trigger circuit 1〇1, a control unit 102, a selection circuit 103, and a switch circuit 1〇4 form number A0101 page 6/18 pages 0982049184-0 [ 0014] 201107991 [0015] Ο [0016]
GG
[0017] 。該USB介面20包括一電源引腳201以及數據引腳202。 該主從選擇觸發電路1〇1包括一輸入端1〇11、一第一輸出 端1012、一第二輸出端1〇13,該輸入端1〇11與該USB介 面20的電源引腳201連接。該第一輸出端1〇12與該控制 單元102連接’該第二輸出端1〇13與該選擇電路103連接 該電子裝置1還包括一處理單元30以及一電源4〇。該處理 單元40包括一從設僙控制引腳3〇1以及一主設備控制引腳 302 〇[0017]. The USB interface 20 includes a power pin 201 and a data pin 202. The master-slave selection trigger circuit 1〇1 includes an input terminal 11〇, a first output terminal 1012, and a second output terminal 1〇13. The input terminal 1〇11 is connected to the power pin 201 of the USB interface 20. . The first output terminal 〇12 is connected to the control unit 102. The second output terminal 〇13 is connected to the selection circuit 103. The electronic device 1 further includes a processing unit 30 and a power supply unit 〇. The processing unit 40 includes a slave control pin 3〇1 and a master device control pin 302.
該主從選擇觸發電路101用於侦測與該電子裝置丨通過USB ,. ^ , 介面20連接的外部電子裝置2的類型。當該主從選擇觸發 電路101偵測到與該輪入填1011連接的電源引腳2〇1為高 電平時’該主從選擇觸發電路101判斷該外部電子裝置2 為主設備,通過第_、第二輸出端發出從觸發信號。當 該主從選擇觸發電路101偵測到與該輸入端1〇丨丨連接的電 源引腳201為低電平時,該主從選擇觸發電路1〇1判斷該 外部電子裝置2為.從設.備’通過第一、第二輸出端發出主 觸發信號。 該控制單元102同時還與該開關電路1〇4連接,該開關電 路104同時連接於該電源40與USB電源引腳2〇1之間。當 該控制單元102接收到第一輸出端發出的從觸發信號時, β玄控制早元1 〇 2控制該開關電路1 〇 4截止,切斷該電源4 〇 與該USB電源引腳201的連接。當該控制單元102接收到 第一輸出端發出的主觸發信號時,該控制單元102控制該 開關電路104導通,該電源40對該USB電源引腳2〇1供電 098128644 表單編號A0101 第7頁/共18頁 0982049184-0 201107991 [0018] 該選擇電路103,與該第二輸出端1〇13連接,用於根據接 收來自第二輸出端發出的觸發信號來選擇該處理單元3〇 的從設備控制引腳3〇1或主設備控制引腳302與USB介面 20的數據引腳202連接。當該選擇電路1〇3接收到該第二 輸出端1013發出的從觸發信號時,該選擇電路1〇3控制將 該處理單元30的從設備控制引腳3〇1與該USB介面20的數 據引腳202連接。當該選擇電路1〇3接收到該第二輸出端 1013發出的主觸發信號時,該選擇電路控制將該處理單 . ... ....... 元30的主設備控制弓丨腳302與面㈣的數據引腳 202連接。 :$ 广 [0019] 從而,當與該電子裝置1的USB介面20連接的外部電子裝 置為主設備時,該電子裝置1不對該USB介面20的電源引 腳201供電,同時該處理單元30的從設備控制引腳301與 該USB介面20的數據引腳202的連接,該電子裝置1工作 ... 在從設備模式。當與該電子裝置1的介面20連接的外 部電子裝置為從設備時’該電子裝置1對該USB介面30的 電源引腳201供電,同時該處理單元40的主設備控制引腳 302與該USB介面20的數據引腳202的連接,該電子裝置1 工作在主設備模式。 [0020] 如圖2所示,為可自動切換USB主從設備模式的電子裝置 的具體電路圖。在本實施方式中’該主從選擇觸發電路 101包括第一電阻R1、第二電阻R2以及一第三電阻R3 ’ 該第一電阻R1與該第二電阻R2的連接節點a構成該主從選 擇觸發電路101的輸入端1011 ’該第—電阻R1遠離該第 098128644 表單編號A0101 第8頁/共18頁 0982049184-0 201107991 [0021] Ο [0022] [0023] Ο [0024] [0025] 二電阻R2端Β構成該主從選擇觸發電路101的第一輸出端 1012,第二電阻R2與該第 > 電阻Μ的連接點C構成該主 從選擇觸發電路10的第二輸出端1013 ° 該控制單元102為一高電屮導通開關’包括一控制端,一 第一導通端以及一第二導通端。在本實施方式中,該控 制開關102以一ΝΡΝ三極管Q1為例進行說明,其中該控制 端 '第一導通端以及第二導通端分別對應該ΝΡΝ三極管Qi 的基極、發射極以及集電極。在其他實施方式中,該控 制單元10 2可為NMOS管。 該NPN三極管的基極與該第一輸出端1012連接,發射極接 地,集電極與開關電路104的一控制端連接> 在本實施方式中,該開關電路104為一高電平導通開關電 路’包括該控制端、一第一導通端以及_一第二導通端。 該控制端與該控制單元1〇2的第二導通端連接,該第—導 通端與該電源60連接,該第二導通端與該:USB電源引腳 201連接。在本實施方式中,該開關電路1〇4為NMOS管, 在其他實施方式中,該開關電路104可為NPN三極管。 在本實施方式中’該處理單元30的從設備控制引腳301包 括Device D+、Device D—兩個引腳’主設備控制引腳 302包括Host D+、Host D—兩個引腳。該USB介面20的 數據引腳202包括— j)+以及一 ρ 一引腳。 該選擇電路103具體為一雙刀雙擲開關,包括一控制端與 該第二輸入端1013連接,兩個公共端分別與USB介面20 的數據引腳D+以及])—連接,四個接觸端分別與處理單元 098128644 表單編號A0101 第9頁/共18頁 0982049184-0 201107991 30的從設備引腳301中的Device D+、Device D —引腳 以及主設備引腳302中的Host D+、Host D 一引腳連接 〇 [0026] 當該電子裝置1通過該USB介面20與作為主設備的外部電 子裝置2連接時。該USB介面20的USB電源引腳2〇1從該外 部電子裝置2獲得一高電平,從而與該電源引腳2〇1連 接的輸入端1011也處於高電平◦該第一輸出端1012通過 電阻R1與該輸入端1011連接而處於高電平,該NPN三極 管Q1的控制端接收到該高電平信號後,使得該N P N三極管 Q1導通。該開關電路ί 04的控制端通過該導通的N P N三極 管Q1而處於低電平,從而該開關電路1〇4截北,該電源4〇 至電源引腳201的電流路徑被切斷。 [0027] 當該輸入端1011處於高電平時,該第二輪出端1〇13也通 過該電阻R2、R3的分壓作用而處於高電平,該選擇電路 103選擇該處理單元3〇的Device D+、Device D—引腳 分別與該USB介面2〇的d+、D—引腳進行連接。 [0028] 從而該USB介面20外接主設備時,該電子裝置丨不對該 USB介面20的電源引腳201供電而選擇由外部主機設備供 電’同時將處理單元30的Device D+、Device D—引腳 分別與該USB介面20的D+、D—引腳連接,該電子裝置i 處於從設備模式。 當5亥電子裝置1通過该USB介面20與作為從設備的外部電 子裝置連接時。該USB介面20的USB電源引腳2〇丨處於一 低電平’從而與該USB電源引腳201連接的輸入端1〇11也 098128644 表單編號A0101 第10頁/共18頁 0982049184-0 [0029] 201107991 處於低電平。該第—輸出端1012通過電阻R1與該輸入端 】〇11連接而處於低電平,該ΝΡΝ三極管Q1的控制端接收 到該低電平後,使得該NPN三級管Q1截止。從而開關電路 104的控制端處於高電平,開關電路1〇4導通,該電源4〇 與電源引腳201連接。 [0030] Ο [0031] [0032] 〇 [0033] 當該輸入端1011處於低電平時’該第二輸出端1〇13也通 過該電阻R2、R3的分壓作用而處於低電平,該選擇電路 1〇3選擇該處理單元3〇的Host D+、Host D—引腳與該 USB介面的D+、D—引腳進行連揍。 從而該USB介面20外接從設備時’該電子裝置1對電源引 腳201供電,同時該選擇電路103選擇該處理單元3〇的 Host D+ ' Host D一引腳與5玄USB引腳的.D+、D —~引腳進 行連接,該電子設備處於主設備模式。^ 【圖式簡單說明】 圖1為可自動切換USB主從設備模式的電子裝置的功能模 組圖。 卜 圖2為圖1所示可自動切換USB主從設備模式的電子裝置的 具體電路圖。 【主要元件符號說明】 _ [0034] USB主從模式 切換電路 10 USB介面 — 20 ~ 處理單元 30 電源 40 主從選擇觸發 101 控制單元 102 電路 _ .表單編號A0101 第11頁/共18頁 0982049184-0 098128644 201107991 選擇電路 103 開關電路 104 電源引腳 201 數據?丨腳 202 主設備控制引 302 從設備控制引 301 腳 腳 外部電子裝置 2 輸入端 1011 第一輸出端 1012 第二輸出端 1013 電阻 R1/R2/R3/R4 NPN三極管 Q1 從設備控制引 Device D+/ 主設備控制引 Host D+/ 腳 Device D— 腳 Host D — 098128644 表單編號A0101 第12頁/共18頁 0982049184-0The master-slave selection trigger circuit 101 is configured to detect the type of the external electronic device 2 connected to the electronic device via the USB, . . . , interface 20. When the master-slave selection trigger circuit 101 detects that the power pin 2〇1 connected to the wheelfill 1011 is at a high level, the master-slave selection trigger circuit 101 determines that the external electronic device 2 is the master device, and passes the The second output sends a slave trigger signal. When the master-slave selection trigger circuit 101 detects that the power pin 201 connected to the input terminal 1 is low level, the master-slave selection trigger circuit 1〇1 determines that the external electronic device 2 is a slave device. The device sends a main trigger signal through the first and second outputs. The control unit 102 is also connected to the switch circuit 1〇4, and the switch circuit 104 is simultaneously connected between the power source 40 and the USB power pin 2〇1. When the control unit 102 receives the slave trigger signal sent by the first output terminal, the β-axis control early element 1 〇 2 controls the switch circuit 1 〇 4 to be turned off, and the connection of the power source 4 〇 to the USB power pin 201 is cut off. . When the control unit 102 receives the main trigger signal sent by the first output terminal, the control unit 102 controls the switch circuit 104 to be turned on, and the power source 40 supplies power to the USB power pin 2〇1 098128644 Form No. A0101 Page 7/ A total of 18 pages 0992049184-0 201107991 [0018] The selection circuit 103 is connected to the second output terminal 13 13 for selecting the slave device control of the processing unit 3 according to receiving a trigger signal from the second output terminal. Pin 3.1 or the master control pin 302 is coupled to the data pin 202 of the USB interface 20. When the selection circuit 1〇3 receives the slave trigger signal from the second output terminal 1013, the selection circuit 1〇3 controls the data of the slave device control pin 3〇1 of the processing unit 30 and the USB interface 20. Pin 202 is connected. When the selection circuit 1〇3 receives the main trigger signal sent by the second output terminal 1013, the selection circuit controls the master device of the processing unit 30. 302 is connected to the data pin 202 of the face (four). Therefore, when the external electronic device connected to the USB interface 20 of the electronic device 1 is the main device, the electronic device 1 does not supply power to the power pin 201 of the USB interface 20, and the processing unit 30 From the connection of the device control pin 301 to the data pin 202 of the USB interface 20, the electronic device 1 operates... in the slave device mode. When the external electronic device connected to the interface 20 of the electronic device 1 is a slave device, the electronic device 1 supplies power to the power pin 201 of the USB interface 30, and the master device control pin 302 of the processing unit 40 and the USB device The data pin 202 of the interface 20 is connected, and the electronic device 1 operates in the master mode. [0020] As shown in FIG. 2, it is a specific circuit diagram of an electronic device that can automatically switch the USB master-slave mode. In the present embodiment, the master-slave selection trigger circuit 101 includes a first resistor R1, a second resistor R2, and a third resistor R3'. The connection node a of the first resistor R1 and the second resistor R2 constitutes the master-slave selection. Input terminal 1011 of trigger circuit 101 'The first resistor R1 is away from the 098128644 Form No. A0101 Page 8 / 18 pages 0992049184-0 201107991 [0021] Ο [0022] [0024] [0025] [0025] The R2 terminal Β constitutes the first output terminal 1012 of the master-slave selection trigger circuit 101, and the connection point C of the second resistor R2 and the second resistor Μ constitutes the second output terminal 1013 of the master-slave selection trigger circuit 10 The unit 102 is a high-voltage turn-on switch 'including a control terminal, a first conductive terminal and a second conductive terminal. In the present embodiment, the control switch 102 is described by taking a triode Q1 as an example. The control terminal 'the first conduction end and the second conduction end respectively correspond to the base, the emitter and the collector of the triode Qi. In other embodiments, the control unit 102 can be an NMOS transistor. The base of the NPN transistor is connected to the first output terminal 1012, the emitter is grounded, and the collector is connected to a control terminal of the switch circuit 104. In the embodiment, the switch circuit 104 is a high-level switch circuit. 'Includes the control terminal, a first conduction terminal, and a second conduction terminal. The control terminal is connected to the second conductive terminal of the control unit 102, and the first conductive terminal is connected to the power supply 60, and the second conductive terminal is connected to the USB power supply pin 201. In the present embodiment, the switch circuit 1〇4 is an NMOS transistor. In other embodiments, the switch circuit 104 can be an NPN transistor. In the present embodiment, the slave device control pin 301 of the processing unit 30 includes Device D+, Device D - two pins. The master device control pin 302 includes two pins, Host D+ and Host D. The data pin 202 of the USB interface 20 includes -j)+ and a ρ-pin. The selection circuit 103 is specifically a double-pole double-throw switch, and includes a control terminal connected to the second input terminal 1013. The two common terminals are respectively connected to the data pins D+ and ]) of the USB interface 20, and the four contact terminals are respectively connected. Device D+, Device D — pin in slave pin 301 and master D+, Host D in master device pin 302 of processing unit 098128644 Form number A0101 page 9/18 page 0982049184-0 201107991 30 Pin Connection [0026] When the electronic device 1 is connected to the external electronic device 2 as a master device through the USB interface 20. The USB power pin 2〇1 of the USB interface 20 obtains a high level from the external electronic device 2, so that the input terminal 1011 connected to the power pin 2〇1 is also at a high level, the first output terminal 1012. The resistor R1 is connected to the input terminal 1011 to be at a high level. After receiving the high level signal, the control terminal of the NPN transistor Q1 turns on the NPN transistor Q1. The control terminal of the switching circuit ί 04 is at a low level through the turned-on N P N transistor Q1, so that the switching circuit 1〇4 is cut off, and the current path of the power supply 4 to the power supply pin 201 is cut off. [0027] When the input terminal 1011 is at a high level, the second wheel terminal 1〇13 is also at a high level by the voltage dividing action of the resistors R2 and R3, and the selection circuit 103 selects the processing unit 3〇. The Device D+ and Device D- pins are respectively connected to the d+ and D- pins of the USB interface. [0028] When the USB interface 20 is externally connected to the host device, the electronic device does not supply power to the power pin 201 of the USB interface 20 and is selected to be powered by the external host device. Meanwhile, the Device D+, Device D-pin of the processing unit 30 is selected. Connected to the D+, D- pins of the USB interface 20, respectively, the electronic device i is in the slave mode. When the 5H electronic device 1 is connected through the USB interface 20 to an external electronic device as a slave device. The USB power pin 2 of the USB interface 20 is at a low level, so that the input terminal connected to the USB power pin 201 is also 098128644. Form number A0101 Page 10/18 pages 0982049184-0 [0029 ] 201107991 is at a low level. The first output terminal 1012 is connected to the input terminal 〇11 through the resistor R1 and is at a low level. After the control terminal of the ΝΡΝ transistor Q1 receives the low level, the NPN tertiary tube Q1 is turned off. Therefore, the control terminal of the switch circuit 104 is at a high level, the switch circuit 1〇4 is turned on, and the power source 4〇 is connected to the power pin 201. [0033] [0033] When the input terminal 1011 is at a low level, the second output terminal 1〇13 is also at a low level by the voltage division of the resistors R2 and R3. The selection circuit 1〇3 selects the Host D+ and Host D− pins of the processing unit 3〇 to be connected to the D+ and D− pins of the USB interface. Therefore, when the USB interface 20 is externally connected to the slave device, the electronic device 1 supplies power to the power pin 201, and the selection circuit 103 selects the Host D+ 'Host D pin of the processing unit 3〇 and the .D+ of the 5 Xuan USB pin. The D —~ pin is connected and the electronic device is in master mode. ^ [Simple description of the diagram] Figure 1 is a functional block diagram of an electronic device that can automatically switch between USB master and slave modes. FIG. 2 is a specific circuit diagram of the electronic device capable of automatically switching the USB master-slave mode shown in FIG. 1. [Main component symbol description] _ [0034] USB master-slave mode switching circuit 10 USB interface - 20 ~ Processing unit 30 Power supply 40 Master-slave selection trigger 101 Control unit 102 Circuit_. Form No. A0101 Page 11 of 18 0982049184- 0 098128644 201107991 Select Circuit 103 Switch Circuit 104 Power Pin 201 Data?丨 202 202 Master device control reference 302 Slave device control 301 pin External electronic device 2 Input terminal 1011 First output terminal 1012 Second output terminal 1013 Resistor R1/R2/R3/R4 NPN transistor Q1 Slave device control Device D+/ Master device control Host D+/ Foot Device D—Foot Host D — 098128644 Form No. A0101 Page 12 of 18 0982049184-0