CN115129268A - 一种打印机软硬件配合切换模式的双usb接口实现方法 - Google Patents

一种打印机软硬件配合切换模式的双usb接口实现方法 Download PDF

Info

Publication number
CN115129268A
CN115129268A CN202110312550.7A CN202110312550A CN115129268A CN 115129268 A CN115129268 A CN 115129268A CN 202110312550 A CN202110312550 A CN 202110312550A CN 115129268 A CN115129268 A CN 115129268A
Authority
CN
China
Prior art keywords
usb
mode
interface
hardware
printer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110312550.7A
Other languages
English (en)
Inventor
王伶刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ingenic Semiconductor Co Ltd
Original Assignee
Beijing Ingenic Semiconductor Co Ltd
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 Beijing Ingenic Semiconductor Co Ltd filed Critical Beijing Ingenic Semiconductor Co Ltd
Priority to CN202110312550.7A priority Critical patent/CN115129268A/zh
Publication of CN115129268A publication Critical patent/CN115129268A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1203Improving or facilitating administration, e.g. print management
    • 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/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4072Drivers or receivers
    • 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/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4081Live connection to bus, e.g. hot-plugging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1229Printer resources management or printer maintenance, e.g. device status, power levels
    • G06F3/1231Device related settings, e.g. IP address, Name, Identification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1236Connection management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1278Dedicated interfaces to print systems specifically adapted to adopt a particular infrastructure
    • G06F3/1279Controller construction, e.g. aspects of the interface hardware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1278Dedicated interfaces to print systems specifically adapted to adopt a particular infrastructure
    • G06F3/128Direct printing, e.g. sending document file, using memory stick, printing from a camera
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Systems (AREA)

Abstract

本发明提供一种打印机软硬件配合切换模式的双usb接口实现方法,所述方法包括以下步骤:S1.进行硬件设置:采用两个usb接口:一个device接口,一个host接口;通过device接口的插拔硬件事件自动切换两种模式,即插入device时设备能够切换到device模式,拔出device时设备能够切换到host模式;S2.对应进行软件配置:根据device插拔事件的状态,强制把设备配置成device only和host only模式,分别对应device接口和host接口。通过硬件和软件设计相结合的方法实现了打印机客户的特殊usb切换定制需求。

Description

一种打印机软硬件配合切换模式的双usb接口实现方法
技术领域
本发明涉及打印机技术领域,特别涉及一种打印机软硬件配合切换模式的双usb接口实现方法。
背景技术
热敏小票打印机是一种常见的打印机设备,通常基于单片机来控制打印头来实现打印功能。例如北京君正的X2000芯片是针对物联网领域的一款芯片,针对热敏打印机市场,例如,北京君正开发了一套基于君正芯片的打印机驱动。Mini USB A、B连接器及其触点(未按比例绘制)Mini USB连接器触点功能:
1 VBUS(4.4–5.25V)
2 D-
3 D+
4 ID
5 接地
其中ID脚在otg功能中才使用。由于mini usb接口分mini-A、B和AB接口。如果系统仅仅是用做slave,那么就使用B接口,系统控制器会判断ID脚的电平判断是什么样的设备插入,如果是高平,则是B接头插入,此时系统就做从模式,如果ID为低,则是A接口插入,然后系统就会使用HNP对话协议来决定哪个做Master,哪个做slave。mini USB除了第4针外,其他接口功能皆与标准USB相同。第4针成为ID,在mini-A上连接到第5针,在mini-B可以悬空亦可连接到第5针。
然而现有技术中的打印机更多的为了兼容性采用的是标准usb接口,因此缺少如君正芯片中的第4针的ID pin,所以无法判断插入的设备是Master还是slave,但是打印机客户的需求是两种模式都要支持且可以切换。即可以支持插入u盘读取文件的Master功能,又需要作为usb打印机连接到电脑上打印的slave功能。
现有技术中常用的技术术语包括:
X2000:这里是指例如北京君正推出的一款针对物联网的双核(大小核)嵌入式芯片。
CPU:这里是指例如君正芯片X2000的主cpu,简称”大核”。
Usb协议:USB(Universal Serial Bus)总线协议是以Intel为主,并有Compaq,Microsoft,IBM,DEC,Northern Telecom以及日本NEC等共七家公司共同制定的串行接口标准。USB总线属于一种轮询式总线,主机控制端口初始化所有的数据传输。每一总线动作最多传送三个数据包,包括令牌(Token)、数据(Data)、联络(HandShake)。
Usb device(Slave)模式:把x2000配置成一个类似u盘的设备,连接到电脑上。
Usb host(Master)模式:把x2000配置成一个类似pc主机的设备,可以识别插入的u盘设备。
OTG(On-The-Go):主要应用于不同的设备或移动设备间的联接,进行数据交换。手机只有一个外接usb口,为了方便用户使用,如otg上插上一条可以支持U盘插入的线,手机就可以直接访问U盘的内容,不需要经过PC,手机给外设供电。若手机连上PC,PC上的usb口基本为host端,为方便使用,手机端作为device端比较方便合理。因此手机端的usb支持host、device模式的自动切换。OTG即是增加了host、device协商机制的usb口。
ID pin脚:系统控制器会判断ID脚的电平判断是什么样的设备插入。
Gpio(General-purpose input/output):通用输入输出的简称,其接脚可以供使用者由程控自由使用,PIN脚依现实考量可作为通用输入(GPI)或通用输出(GPO)或通用输入与输出(GPIO)。
Usb PHY负责最底层的信号转换,作用类似于网口的PHY。
发明内容
为了解决上述问题,本发明的目的在于:通过硬件和软件设计相结合的方法实现了打印机客户的特殊usb切换定制需求。
具体地,本发明提供一种打印机软硬件配合切换模式的双usb接口实现方法,所述方法包括以下步骤:
S1.进行硬件设置:采用两个usb接口:一个device接口,一个host接口;通过device接口的插拔硬件事件自动切换两种模式,即插入device时设备能够切换到device模式,拔出device时设备能够切换到host模式;
S2.对应进行软件配置:根据device插拔事件的状态,强制把设备配置成deviceonly和host only模式,分别对应device接口和host接口。
所述S1中所述的自动切换两种模式是通过采用usb高速切换开关,判断S端口的高低切换不同的通路,即(1)S=0时,HSD1通路打开,(2)S=1时,HSD2通路打开;这样就把usbotg的usb device和usb host功能分成两个相互独立的电路。
所述S2中,在usb驱动中把usb id pin脚的检测集成到usb phy检测。
综上,本发明能够实现的优势在于:通过软硬件的配合设计,实现了双usb口分别实现主从功能并相互切换的技术实现,既可以实现支持插入u盘读取文件的Master功能,又能够实现作为usb打印机连接到电脑上打印的slave功能。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,并不构成对本发明的限定。
图1是本发明方法的流程示意图。
图2是采用SGM7227的usb高速切换开关的电路示意图。
具体实施方式
为了能够更清楚地理解本发明的技术内容及优点,现结合附图对本发明进行进一步的详细说明。
如图1所示,本发明是一种打印机软硬件配合切换模式的双usb接口实现方法,所述方法包括以下步骤:
S1.进行硬件设置:采用两个usb接口:一个device接口,一个host接口;通过device接口的插拔硬件事件自动切换两种模式,即插入device时设备能够切换到device模式,拔出device时设备能够切换到host模式;这样可以弥补缺少ID pin脚导致两种模式无法切换的缺陷;
S2.对应进行软件配置:根据device插拔事件的状态,强制把设备配置成deviceonly和host only模式,分别对应device接口和host接口。
所述S1中所述的自动切换两种模式是通过采用usb高速切换开关,判断S端口的高低切换不同的通路,即(1)S=0时,HSD1通路打开,(2)S=1时,HSD2通路打开;这样就把usbotg的usb device和usb host功能分成两个相互独立的电路。
所述usb高速切换开关采用SGM7227的usb切换开关。
所述S2中,在usb驱动中把usb id pin脚的检测集成到usb phy检测。
所述方法进一步包括:
如果插入usb线,usb phy层检测到插入事件,忽略usb id pin电平高低信号,强制把双usb口的当前插入usb口配置成usb device从设备模式;
如果拔出usb线,usb phy层检测到拔出事件,忽略usb id pin电平高低信号,强制把双usb口的另外一个usb口配置成usb host主设备模式。
当拨出usb线时,实现u盘读取文件的Master功能,当插入usb线时,实现作为usb打印机连接到电脑上打印的slave功能。
具体地,硬件方面:如图2所示采用SGM7227的usb高速切换开关,通过判断S端口的高低切换不同的通路,即(1)S=0时,HSD1通路打开,(2)S=1时,HSD2打开。
这样就把usb otg的usb device和usb host功能分成两个相互独立的电路。
软件方面:根据device插拔事件的状态,代替原来的ID pin脚检测。来强制把设备配置成device only和host only模式。
具体地,软件方面:技术要点:usb驱动相关修改主要思路是把usb id pin脚的检测集成到usb phy检测。
修改前,具有id pin的驱动层的代码流程是:插入usb线---〉usb phy层检测到插入事件---〉usb dwc驱动层判断usb id pin电平高低信号,---〉切换主从模式。
修改后的驱动层代码流程:
1.插入usb线,usb phy层检测到插入事件,忽略usb id pin电平高低信号,强制把双usb口的当前插入usb口配置成usb device从设备模式。
2.拔出usb线,usb phy层检测到拔出事件,忽略usb id pin电平高低信号,强制把双usb口的另外一个usb口配置成usb host主设备模式。
通过以上软硬件的配合设计,实现了双usb口分别实现主从功能并相互切换的技术实现。
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明实施例可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (6)

1.一种打印机软硬件配合切换模式的双usb接口实现方法,其特征在于,所述方法包括以下步骤:
S1.进行硬件设置:采用两个usb接口:一个device接口,一个host接口;通过device接口的插拔硬件事件自动切换两种模式,即插入device时设备能够切换到device模式,拔出device时设备能够切换到host模式;
S2.对应进行软件配置:根据device插拔事件的状态,强制把设备配置成device only和host only模式,分别对应device接口和host接口。
2.根据权利要求1所述的一种打印机软硬件配合切换模式的双usb接口实现方法,其特征在于,所述S1中所述的自动切换两种模式是通过采用usb高速切换开关,判断S端口的高低切换不同的通路,即(1)S=0时,HSD1通路打开,(2)S=1时,HSD2通路打开;这样就把usbotg的usb device和usb host功能分成两个相互独立的电路。
3.根据权利要求2所述的一种打印机软硬件配合切换模式的双usb接口实现方法,其特征在于,所述usb高速切换开关采用SGM7227的usb切换开关。
4.根据权利要求1所述的一种打印机软硬件配合切换模式的双usb接口实现方法,其特征在于,所述S2中,在usb驱动中把usb id pin脚的检测集成到usb phy检测。
5.根据权利要求4所述的一种打印机软硬件配合切换模式的双usb接口实现方法,其特征在于,所述方法进一步包括:
如果插入usb线,usb phy层检测到插入事件,忽略usb id pin电平高低信号,强制把双usb口的当前插入usb口配置成usb device从设备模式;
如果拔出usb线,usb phy层检测到拔出事件,忽略usb id pin电平高低信号,强制把双usb口的另外一个usb口配置成usb host主设备模式。
6.根据权利要求5所述的一种打印机软硬件配合切换模式的双usb接口实现方法,其特征在于,当拨出usb线时,实现u盘读取文件的Master功能,当插入usb线时,实现作为usb打印机连接到电脑上打印的slave功能。
CN202110312550.7A 2021-03-24 2021-03-24 一种打印机软硬件配合切换模式的双usb接口实现方法 Pending CN115129268A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110312550.7A CN115129268A (zh) 2021-03-24 2021-03-24 一种打印机软硬件配合切换模式的双usb接口实现方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110312550.7A CN115129268A (zh) 2021-03-24 2021-03-24 一种打印机软硬件配合切换模式的双usb接口实现方法

Publications (1)

Publication Number Publication Date
CN115129268A true CN115129268A (zh) 2022-09-30

Family

ID=83374076

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110312550.7A Pending CN115129268A (zh) 2021-03-24 2021-03-24 一种打印机软硬件配合切换模式的双usb接口实现方法

Country Status (1)

Country Link
CN (1) CN115129268A (zh)

Similar Documents

Publication Publication Date Title
US7085876B2 (en) USB controlling apparatus for data transfer between computers and method for the same
US8832329B2 (en) USB peripheral device comprising limited function USB host controller
CN108885601B (zh) Usb多主机端点反射器集线器
US20110191503A1 (en) Motherboard Compatible with Multiple Versions of Universal Serial Bus (USB) and Related Method
US7293118B1 (en) Apparatus and method for dynamically providing hub or host operations
US7069347B1 (en) Device and method for adapting speed of a USB device based on available power
EP1771020B1 (en) Communication interface for an electric device
US7921244B2 (en) Data sharing and transfer systems and methods
US20060106962A1 (en) USB On-The-Go implementation
JP3610424B2 (ja) 電子機器及びインタフェース回路
US20090198861A1 (en) Device With A USB Interface Which Can Be Used As A Time-Sharing Standard I/O Interface And A Method Thereof
EP1181638B1 (en) Method and apparatus for maintaining load balance on a graphics bus when an upgrade device is installed
CN112799985B (zh) Usb接口控制方法、usb控制电路及智能网联设备主板
CN213365380U (zh) 一种服务器主板及服务器
CN109062846B (zh) 通用串行总线装置及其操作方法
CN105868140A (zh) 一种移动设备
CN212112455U (zh) Type-c接口电路、芯片及电子设备
CN101599050B (zh) 可适配的pci-e控制器核及其方法
JP2008065364A (ja) 拡張システム、アドインカード及び外部装置
CN115129268A (zh) 一种打印机软硬件配合切换模式的双usb接口实现方法
CN213365381U (zh) 主板
CN107391405A (zh) Usb接口电路及usb设备
US20090185559A1 (en) Integration module for universal serial bus
JP2002202835A (ja) 電子機器、および、電子機器の接続方法
CN101094464A (zh) 利用手机管理u盘中文件的装置及方法

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination