[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN116909474B - Device identification method and related device - Google Patents

Device identification method and related device Download PDF

Info

Publication number
CN116909474B
CN116909474B CN202310481771.6A CN202310481771A CN116909474B CN 116909474 B CN116909474 B CN 116909474B CN 202310481771 A CN202310481771 A CN 202310481771A CN 116909474 B CN116909474 B CN 116909474B
Authority
CN
China
Prior art keywords
slave device
value
register
addresses
master device
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.)
Active
Application number
CN202310481771.6A
Other languages
Chinese (zh)
Other versions
CN116909474A (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.)
Honor Device Co Ltd
Original Assignee
Honor Device 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 Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202310481771.6A priority Critical patent/CN116909474B/en
Publication of CN116909474A publication Critical patent/CN116909474A/en
Application granted granted Critical
Publication of CN116909474B publication Critical patent/CN116909474B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/24Resetting means
    • 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/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Systems (AREA)
  • Stored Programmes (AREA)

Abstract

本申请实施例提供器件识别方法和相关装置,应用于电子设备。电子设备包括存储有对应关系的主器件以及通过SPI总线与主器件连接的从器件,对应关系包括从器件型号、第一地址、第一预设值、第二地址和第二预设值之间的关系。方法包括:主器件基于从器件型号和对应关系读取从器件中寄存器的值得到第一从器件型号对应的第一值和第二值;若第一值和第二值分别与第一从器件型号对应的第一预设值和第二预设值相同,主器件基于第一从器件型号配置从器件;主器件配置从器件之前,从器件中第一从器件型号对应的第二地址对应的寄存器的值为定值。基于两个地址进行两次验证识别,减少同一地址的寄存器的值相同导致的器件型号误识别,减少配置失败。

The embodiment of the present application provides a device identification method and related apparatus, which are applied to electronic devices. The electronic device includes a master device storing a corresponding relationship and a slave device connected to the master device through an SPI bus, and the corresponding relationship includes the relationship between the slave device model, the first address, the first preset value, the second address and the second preset value. The method includes: the master device reads the value of the register in the slave device based on the slave device model and the corresponding relationship to obtain the first value and the second value corresponding to the first slave device model; if the first value and the second value are respectively the same as the first preset value and the second preset value corresponding to the first slave device model, the master device configures the slave device based on the first slave device model; before the master device configures the slave device, the value of the register corresponding to the second address corresponding to the first slave device model in the slave device is a fixed value. Two verification and identification are performed based on two addresses to reduce the misidentification of device models caused by the same value of the register at the same address, and reduce configuration failures.

Description

器件识别方法和相关装置Device identification method and related device

本申请是分案申请,原申请的申请号是202210380036.1,原申请日是2022年04月12日,原申请的全部内容通过引用结合在本申请中。This application is a divisional application. The application number of the original application is 202210380036.1, and the original application date is April 12, 2022. The entire contents of the original application are incorporated into this application by reference.

技术领域Technical Field

本申请涉及终端技术领域,尤其涉及一种器件识别方法和相关装置。The present application relates to the field of terminal technology, and in particular to a device identification method and related apparatus.

背景技术Background technique

串行外设接口(serial peripheral interface,SPI)总线系统是一种同步串行外设接口,广泛使用于集成电路和电子设备等产品中。示例性的,电子设备中的处理器(CPU)与外围器件可以通过SPI接口以串行方式进行通信以交换信息,进而从外围器件获取信息或控制外围器件,以实现电子设备的一种或多种功能。外围器件包括但不限于:触控面板、传感器或显示屏等。The serial peripheral interface (SPI) bus system is a synchronous serial peripheral interface, which is widely used in products such as integrated circuits and electronic devices. For example, the processor (CPU) in the electronic device can communicate with the peripheral devices in a serial manner through the SPI interface to exchange information, and then obtain information from the peripheral devices or control the peripheral devices to achieve one or more functions of the electronic device. The peripheral devices include but are not limited to: touch panels, sensors or displays, etc.

目前,在电子设备中处理器(CPU)通过一组SPI接口可以兼容连接多个型号的外围器件,以提高SPI接口的复用率。因此,处理器需要识别通过SPI接口连接的外围器件的型号,进而基于型号进行相应的初始化配置。At present, in electronic devices, the processor (CPU) can be compatible with multiple models of peripheral devices through a set of SPI interfaces to improve the multiplexing rate of the SPI interface. Therefore, the processor needs to identify the model of the peripheral device connected through the SPI interface, and then perform corresponding initialization configuration based on the model.

但是,在识别过程中,可能会出现误识别,导致从器件初始化配置有误,外围器件无法使用,恶化用户体验。However, during the identification process, misidentification may occur, resulting in incorrect initialization configuration of the slave device, making the peripheral device unusable, and worsening the user experience.

发明内容Summary of the invention

本申请实施例提供一种器件识别方法和相关装置,主器件可以基于标识寄存器地址及一个额外的寄存器地址读取从器件中两个不同的寄存器的数值,得到对应的两个值进行验证。当两次的值均符合预期时,器件识别成功。这样,进行二次识别,减少因不同型号从器件中的相同地址的寄存器对应的值相同,导致器件型号误识别,进而初始化配置从器件失败的情况,优化用户体验。此外,本申请实施例未改动电子设备的硬件结构,成本友好,提高系统设计灵活性,提高产品物料供应的稳定性。The embodiment of the present application provides a device identification method and related devices, and the master device can read the values of two different registers in the slave device based on the identification register address and an additional register address, and obtain the corresponding two values for verification. When the values of both times meet expectations, the device is successfully identified. In this way, a secondary identification is performed to reduce the situation where the device model is misidentified due to the same values corresponding to the registers of the same address in different models of slave devices, and then the initialization configuration of the slave device fails, thereby optimizing the user experience. In addition, the embodiment of the present application does not change the hardware structure of the electronic device, is cost-friendly, improves the flexibility of system design, and improves the stability of product material supply.

第一方面,本申请实施例提供一种器件识别方法。该方法应用于电子设备,电子设备包括主器件和从器件,主器件通过串行外设接口SPI总线与从器件连接,主器件存储有对应关系,对应关系包括从器件型号、第一地址、第一预设值、第二地址和第二预设值之间的关系,对应关系中任一从器件型号对应有一个第一地址、一个第一预设值、一个第二地址和一个第二预设值。In the first aspect, an embodiment of the present application provides a device identification method. The method is applied to an electronic device, the electronic device includes a master device and a slave device, the master device is connected to the slave device via a serial peripheral interface SPI bus, the master device stores a corresponding relationship, the corresponding relationship includes the relationship between the slave device model, the first address, the first preset value, the second address and the second preset value, and any slave device model in the corresponding relationship corresponds to a first address, a first preset value, a second address and a second preset value.

器件识别方法包括:主器件基于第一从器件型号和对应关系读取从器件中寄存器的数值,得到第一从器件型号对应的第一值和第一从器件型号对应的第二值;当主器件确定第一从器件型号对应的第一值与第一从器件型号对应的第一预设值相同,并且第一从器件型号对应的第二值与第一从器件型号对应的第二预设值相同时,主器件基于第一从器件型号配置从器件;在主器件基于第一从器件型号配置从器件之前,第三值为固定值,第三值为从器件中与第一从器件型号对应的第二类地址对应的寄存器的值寄存器的数值。The device identification method includes: the master device reads the value of the register in the slave device based on the first slave device model and the corresponding relationship to obtain the first value corresponding to the first slave device model and the second value corresponding to the first slave device model; when the master device determines that the first value corresponding to the first slave device model is the same as the first preset value corresponding to the first slave device model, and the second value corresponding to the first slave device model is the same as the second preset value corresponding to the first slave device model, the master device configures the slave device based on the first slave device model; before the master device configures the slave device based on the first slave device model, the third value is a fixed value, and the third value is the value of the register corresponding to the second type address corresponding to the first slave device model in the slave device.

第一地址可以为标识寄存器的地址,第二地址可以为复查寄存器的地址。这样,基于两个寄存器地址进行两次验证识别,可以减少因不同型号从器件中的相同地址的寄存器对应的值相同导致的器件型号误识别,减少从器件配置失败的情况,优化用户体验。此外,本申请实施例未改动电子设备的硬件结构,成本友好,提高系统设计灵活性,提高产品物料供应的稳定性。The first address may be the address of the identification register, and the second address may be the address of the review register. In this way, two verifications and identifications are performed based on the two register addresses, which can reduce the misidentification of device models caused by the same values corresponding to registers of the same address in different models of slave devices, reduce the failure of slave device configuration, and optimize user experience. In addition, the embodiment of the present application does not change the hardware structure of the electronic device, is cost-friendly, improves the flexibility of system design, and improves the stability of product material supply.

可选的,主器件基于第一从器件型号和对应关系读取从器件中寄存器的数值,得到第一从器件型号对应的第一值和第一从器件型号对应的第二值,包括:主器件基于第一从器件型号对应的第一地址读取从器件中寄存器的数值,得到第一值;主器件基于第一从器件型号对应的第二类地址读取从器件中寄存器的数值,得到第二值。Optionally, the master device reads the value of the register in the slave device based on the first slave device model and the corresponding relationship to obtain a first value corresponding to the first slave device model and a second value corresponding to the first slave device model, including: the master device reads the value of the register in the slave device based on a first address corresponding to the first slave device model to obtain the first value; the master device reads the value of the register in the slave device based on a second address corresponding to the first slave device model to obtain the second value.

可选的,主器件基于第一从器件型号对应的第二类地址读取从器件中寄存器的数值,得到第二值,包括:当主器件确定第一值与第一从器件型号对应的第一预设值相同时,主器件基于第一从器件型号对应的第二地址读取从器件中寄存器的数值,得到第二值。Optionally, the master device reads the value of the register in the slave device based on the second address corresponding to the first slave device model to obtain the second value, including: when the master device determines that the first value is the same as the first preset value corresponding to the first slave device model, the master device reads the value of the register in the slave device based on the second address corresponding to the first slave device model to obtain the second value.

在第一值与第一预设值相同时,主器件读取得到第二值。这样,第一值与第一预设值不同时,无需对第二值进行判断,节约计算资源。When the first value is the same as the first preset value, the master device reads and obtains the second value. In this way, when the first value is different from the first preset value, there is no need to judge the second value, thus saving computing resources.

可选的,方法还包括:当主器件确定第一值与第一从器件型号对应的第一预设值不一致,或者主器件确定第二值与第一从器件型号对应的第二预设值不一致时,主器件基于第二从器件型号和对应关系读取从器件中寄存器的数值。Optionally, the method also includes: when the master device determines that the first value is inconsistent with the first preset value corresponding to the first slave device model, or the master device determines that the second value is inconsistent with the second preset value corresponding to the first slave device model, the master device reads the value of the register in the slave device based on the second slave device model and the corresponding relationship.

这样,还可以基于第二从器件型号验证从器件的型号。In this way, the model of the slave device can also be verified based on the model of the second slave device.

可选的,当第二从器件型号为对应关系中最后一个型号且主器件未识别到从器件为第二从器件型号时,主器件基于预设型号配置从器件,预设型号为对应关系中任意一个从器件型号。Optionally, when the second slave device model is the last model in the corresponding relationship and the master device does not recognize that the slave device is the second slave device model, the master device configures the slave device based on a preset model, and the preset model is any slave device model in the corresponding relationship.

这样,主器件可能会基于预设型号成功配置从器件,使得从器件可以正常运行,提高主器件成功配置从器件的可能性。In this way, the master device may successfully configure the slave device based on the preset model, so that the slave device can operate normally, thereby increasing the possibility that the master device can successfully configure the slave device.

可选的,主器件基于第一从器件型号配置从器件,包括:主器件将第一从器件型号对应的调整参数写入从器件的寄存器中。Optionally, the master device configures the slave device based on the first slave device model, including: the master device writes an adjustment parameter corresponding to the first slave device model into a register of the slave device.

这样,将第一从器件型号对应的调整参数写入从器件的寄存器中,使得从器件基于调整参数运行。In this way, the adjustment parameters corresponding to the first slave device model are written into the register of the slave device, so that the slave device operates based on the adjustment parameters.

可选的,在主器件基于第一从器件型号对应的第二地址读取从器件中寄存器的数值之前,还包括:主器件控制从器件复位。Optionally, before the master device reads the value of the register in the slave device based on the second address corresponding to the first slave device model, the method further includes: the master device controls the slave device to reset.

这样,将从器件复位将从器件中寄存器的数值恢复至默认值,可以减少复查寄存器对应的值被改写等情况导致的识别失败或者误识别。In this way, resetting the slave device will restore the value of the register in the slave device to the default value, which can reduce the recognition failure or misrecognition caused by the value corresponding to the review register being rewritten.

可选的,固定值不为零。Optional, fixed non-zero value.

可以理解的是,多数寄存器上电复位后寄存器报值为0,以及寄存器异常时报值通常为0。这样,选择非零寄存器可以进一步减少误识别,提高本申请实施例稳定性。It is understandable that after most registers are powered on and reset, the register value reported is 0, and when the register is abnormal, the value reported is usually 0. In this way, selecting a non-zero register can further reduce misidentification and improve the stability of the embodiment of the present application.

可选的,第二类地址对应的寄存器包括:读值固定且未被读写操作过的控制寄存器。Optionally, the registers corresponding to the second type of addresses include: control registers whose reading values are fixed and have not been subjected to read or write operations.

这样,可以减少寄存器中的值被改变导致的识别失败的情况,提高识别的成功率。In this way, the situation of recognition failure caused by the change of the value in the register can be reduced, and the success rate of recognition can be improved.

可选的,主器件基于第一从器件型号和对应关系读取从器件中寄存器的数值之前,包括:主器件从第二状态切换为第一状态,第二状态为下电状态,第一状态为上电状态;或者,主器件检测到从器件从第二状态切换为第一状态。Optionally, before the master device reads the value of the register in the slave device based on the first slave device model and the corresponding relationship, the master device switches from the second state to the first state, the second state is the power-off state, and the first state is the power-on state; or, the master device detects that the slave device switches from the second state to the first state.

可选的,对应关系以表格的形式存储在主器件中。Optionally, the corresponding relationship is stored in the main device in the form of a table.

可选的,主器件包括但不限于:处理器CPU或系统级芯片SOC、微控制器MCU、微处理器MPU或可编程片上系统SOPC;从器件包括但不限于:传感器、电池、天线、移动通信模块,无线通信模块,音频模块、扬声器、受话器、麦克风、耳机、按键、马达、指示器、摄像头、显示屏,以及用户标识模块。Optionally, the main device includes but is not limited to: a processor CPU or a system-on-chip SOC, a microcontroller MCU, a microprocessor MPU or a programmable system on chip SOPC; the slave devices include but are not limited to: sensors, batteries, antennas, mobile communication modules, wireless communication modules, audio modules, speakers, receivers, microphones, headphones, buttons, motors, indicators, cameras, displays, and user identification modules.

器件识别方法可以适用于多种主器件和从器件之间,适用范围广。The device identification method can be applied between a variety of master devices and slave devices and has a wide application range.

可选的,预设型号可以为电子设备中使用次数最多从器件对应的型号。这样,提高主器件成功配置从器件的可能性。Optionally, the preset model may be the model corresponding to the slave device that is used most times in the electronic device, thereby increasing the possibility that the master device can successfully configure the slave device.

可选的,主器件多次基于第一类地址和/或第二类地址对从器件的型号进行验证。这样,可以进一步减少误识别情况。Optionally, the master device verifies the model of the slave device based on the first type address and/or the second type address for multiple times, thereby further reducing misidentification situations.

第二方面,本申请实施例提供一种电子设备,电子设备包括终端设备,终端设备可以为:手机、平板电脑、膝上型电脑、个人数字助理(personal digitalassistant,PDA)、移动上网装置(mobile internet device,MID)、可穿戴式设备、消费电子产品、笔记本电脑、台式电脑、汽车、工业控制机器人或工业电子装备等。In a second aspect, an embodiment of the present application provides an electronic device, which includes a terminal device, and the terminal device may be: a mobile phone, a tablet computer, a laptop, a personal digital assistant (PDA), a mobile internet device (MID), a wearable device, a consumer electronic product, a laptop computer, a desktop computer, a car, an industrial control robot or industrial electronic equipment, etc.

电子设备包括:处理器和存储器;存储器存储计算机执行指令;处理器执行存储器存储的计算机执行指令,使得处理器执行上述第一方面的方法。The electronic device comprises: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the method of the first aspect mentioned above.

上述第二方面以及上述第二方面的各可能的设计中所提供的电子设备,其有益效果可以参见上述第一方面和第一方面的各可能的结构所带来的有益效果,在此不再赘述。The beneficial effects of the electronic device provided in the second aspect and each possible design of the second aspect can refer to the beneficial effects brought about by the first aspect and each possible structure of the first aspect, which will not be repeated here.

第三方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序或指令,当计算机程序或指令被运行时,实现上述第一方面的方法。In a third aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions are executed, the method of the first aspect described above is implemented.

上述第三方面以及上述第三方面的各可能的设计中所提供的计算机可读存储介质,其有益效果可以参见上述第一方面和第一方面的各可能的结构所带来的有益效果,在此不再赘述。The beneficial effects of the computer-readable storage medium provided in the third aspect and each possible design of the third aspect can be referred to the beneficial effects brought about by the first aspect and each possible structure of the first aspect, which will not be repeated here.

第四方面,本申请实施例提供一种计算机程序产品,包括计算机程序或指令,计算机程序或指令被处理器执行时,实现上述第一方面的方法。In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the method of the first aspect.

上述第四方面以及上述第四方面的各可能的设计中所提供的计算机程序产品,其有益效果可以参见上述第一方面和第一方面的各可能的结构所带来的有益效果,在此不再赘述。The beneficial effects of the computer program product provided in the fourth aspect and each possible design of the fourth aspect can be referred to the beneficial effects brought about by the first aspect and each possible structure of the first aspect, which will not be repeated here.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本申请实施例提供的一种主器件和从器件连接示意图;FIG1 is a schematic diagram of a connection between a master device and a slave device provided in an embodiment of the present application;

图2为本申请实施例提供的一种应用场景示意图;FIG2 is a schematic diagram of an application scenario provided by an embodiment of the present application;

图3为本申请实施例提供的一种从器件结构示意图;FIG3 is a schematic diagram of a slave device structure provided in an embodiment of the present application;

图4为本申请实施例提供的一种电子设备的硬件结构示意图;FIG4 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

图5为可能的设计中一种器件识别方法的流程示意图;FIG5 is a schematic diagram of a flow chart of a device identification method in a possible design;

图6为可能的设计中一种器件识别方法的流程示意图;FIG6 is a schematic diagram of a flow chart of a device identification method in a possible design;

图7为可能的设计中一种器件误识别的流程示意图;FIG7 is a schematic diagram of a process flow of a device misidentification in a possible design;

图8为本申请实施例提供的一种器件识别方法的流程示意图;FIG8 is a schematic diagram of a flow chart of a device identification method provided in an embodiment of the present application;

图9为本申请实施例提供的一种器件识别方法的流程示意图。FIG. 9 is a schematic flow chart of a device identification method provided in an embodiment of the present application.

具体实施方式Detailed ways

为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。例如,第一设备和第二设备仅仅是为了区分不同的设备,并不对其先后顺序进行限定。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first" and "second" are used to distinguish the same items or similar items with basically the same functions and effects. For example, the first device and the second device are only used to distinguish different devices, and their order is not limited. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit them to be different.

需要说明的是,本申请中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其他实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

需要说明的是,本申请实施例描述的网络架构以及业务场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着网络架构的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。It should be noted that the network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

可以理解的是,本文中的术语“多个”是指两个或两个以上。本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系;在公式中,字符“/”,表示前后关联对象是一种“相除”的关系。It is understood that the term "plurality" in this article refers to two or more than two. The term "and/or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character "/" in this article generally indicates that the previous and next associated objects are in an "or" relationship; in a formula, the character "/" indicates that the previous and next associated objects are in a "division" relationship.

可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.

可以理解的是,在本申请的实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请的实施例的实施过程构成任何限定。It can be understood that in the embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

为了便于理解,示例的给出部分与本申请实施例相关概念的说明以供参考。To facilitate understanding, some of the examples given are provided for reference to the description of concepts related to the embodiments of the present application.

1、SPI总线:一种高速的全双工同步串行通信接口,SPI总线可以使处理器与各种外围器件以串行方式进行通信以交换数据。数据传输速度比其他串行接口,例如异步数据收发接口(universal asynchronous receiver/transmitter,UART)或者内部集成电路(inter-integrated circuit,I2C)总线要快,可以达到10兆比特每秒(megabits persecond,Mbps)左右。1. SPI bus: A high-speed full-duplex synchronous serial communication interface. The SPI bus enables the processor to communicate with various peripheral devices in a serial manner to exchange data. The data transmission speed is faster than other serial interfaces, such as the universal asynchronous receiver/transmitter (UART) or the inter-integrated circuit (I2C) bus, and can reach about 10 megabits per second (Mbps).

SPI总线以主从方式工作,主器件可以通过SPI总线与一个或多个从器件连接。示例性的,处理器可以通过SPI总线与传感器、触控面板、显示屏等中的一个或多个从器件连接。The SPI bus works in a master-slave mode, and the master device can be connected to one or more slave devices via the SPI bus. Exemplarily, the processor can be connected to one or more slave devices in a sensor, a touch panel, a display screen, etc. via the SPI bus.

需要说明的是,主器件和从器件在通过SPI总线进行通信的过程中,主器件和从器件之间没有应答机制。具体的,使能状态的从器件在接收到来自主器件的请求后,向主器件传输信息;从器件不会向主器件反馈用于指示接收到请求的消息。It should be noted that there is no response mechanism between the master device and the slave device during the communication process through the SPI bus. Specifically, after receiving a request from the master device, the enabled slave device transmits information to the master device; the slave device does not feed back a message to the master device indicating that the request has been received.

可能的设计一中,SPI总线包括4种传输线,分别为串行时钟线(serial clock,SCLK)、主机输入/从机输出数据线(master in/slave out,MISO)、主机输出/从机输入数据线(master out/slave in,MOSI)、低电平有效从机选择线(chip select,CS)。In possible design one, the SPI bus includes four transmission lines, namely, a serial clock line (SCLK), a master in/slave out data line (MISO), a master out/slave in data line (MOSI), and a low-level active slave select line (CS).

MISO为主器件数据输入,从器件数据输出;MISO也可以称为SOMI或SDO等。MOSI为主器件数据输出,从器件数据输入;MOSI也可以称为SIMO或SDO等。SCLK是时钟信号,由主器件产生;CS是从器件的使能信号,由主器件控制;CS也可以称为SS或SSEL等。本申请实施例对此不做限定。MISO is the data input of the master device and the data output of the slave device; MISO can also be called SOMI or SDO, etc. MOSI is the data output of the master device and the data input of the slave device; MOSI can also be called SIMO or SDO, etc. SCLK is the clock signal generated by the master device; CS is the enable signal of the slave device, which is controlled by the master device; CS can also be called SS or SSEL, etc. The embodiments of the present application do not limit this.

可能的设计二中,SPI总线包括3种传输线,分别为串行时钟线(serial clock,SCLK)、主机输出/主机输入数据线(master output/master input,MOMI)、低电平有效从机选择线(chip select,CS)。In the possible design 2, the SPI bus includes three transmission lines, namely, a serial clock line (serial clock, SCLK), a master output/master input data line (master output/master input, MOMI), and a low-level active slave select line (chip select, CS).

MOMI也可以称为SISO。SCLK是时钟信号,由主器件产生;CS是从器件的使能信号,由主器件控制;CS也可以称为SS或SSEL等。本申请实施例对此不做限定。MOMI can also be called SISO. SCLK is a clock signal generated by the master device; CS is an enable signal of the slave device, controlled by the master device; CS can also be called SS or SSEL, etc. This embodiment of the application does not limit this.

可以理解的是,上述两种可能的设计中,SPI总线可以省去CS传输线,将用于连接CS传输线的管脚接地。It is understandable that, in the above two possible designs, the SPI bus can omit the CS transmission line and ground the pin used to connect the CS transmission line.

本申请实施例中,主器件可以通过四线SPI接口连接从器件(如图1中的a和b所示),也可以通过三线SPI接口连接从器件(如图1中的c和d所示)。本申请实施例中,主器件还可以通过一组SPI接口连接一个或多个从器件(如图1中的e和f所示)。In the embodiment of the present application, the master device can be connected to the slave device through a four-wire SPI interface (as shown in a and b in Figure 1), or can be connected to the slave device through a three-wire SPI interface (as shown in c and d in Figure 1). In the embodiment of the present application, the master device can also be connected to one or more slave devices through a group of SPI interfaces (as shown in e and f in Figure 1).

需要说明的是,主器件通过一组SPI接口连接从器件时,主器件可以通过不同的CS信号选择性使能SPI接口连接的不同从器件。但是,同一时间中一组SPI接口对应连接的从器件中只有一个从器件处于使能状态,可以被启用。It should be noted that when the master device is connected to the slave device through a group of SPI interfaces, the master device can selectively enable different slave devices connected to the SPI interfaces through different CS signals. However, at the same time, only one slave device among the slave devices corresponding to a group of SPI interfaces is in an enabled state and can be enabled.

可以理解的是,一组SPI接口可以预留多个从器件位置连接多个从器件,也可以预留一个从器件位置连接一个从器件(可能有不同型号但封装相同的从器件贴在该位置)。It is understandable that a group of SPI interfaces can reserve multiple slave device positions to connect multiple slave devices, or reserve one slave device position to connect one slave device (slave devices of different models but the same package may be attached to this position).

需要说明的是,主器件可以通过SPI接口兼容相同类型不同型号的从器件连接,也可以兼容不同类型的从器件连接。这样,可以提高产品物料的可供应性,提高接口复用率。It should be noted that the master device can be compatible with slave devices of the same type and different models through the SPI interface, and can also be compatible with slave devices of different types. In this way, the supplyability of product materials can be improved and the interface reuse rate can be increased.

可以理解的是,由于不同型号的器件中器件原理、内部结构、软件实现等方面会有差异,当SPI接口可以兼容多个从器件连接时,主器件在对从器件进行配置前需要对SPI接口连接的从器件的类型、型号等进行识别,基于从器件的类型、型号等进行初始化配置。It is understandable that due to differences in device principles, internal structures, software implementations, etc. among devices of different models, when the SPI interface is compatible with multiple slave device connections, the master device needs to identify the type and model of the slave device connected to the SPI interface before configuring the slave device, and perform initialization configuration based on the type and model of the slave device.

2、轮询(polling):是一种主器件决策如何提供从器件服务的方式。具体的,由主器件发出询问,按照从器件可能的型号识别从器件;若主器件基于第一从器件型号识别到从器件,则基于第一从器件型号进行初始化配置;若未基于第一从器件型号识别到从器件,基于第二从器件型号识别从器件,接着不断周而复始,直至识别到从器件或者基于最后一个型号识别从器件。轮询也可以称为“程控输入输出”(programmed I/O)。2. Polling: It is a way for a master device to decide how to provide services to a slave device. Specifically, the master device sends out a query to identify the slave device according to the possible model of the slave device; if the master device identifies the slave device based on the first slave device model, it initializes the configuration based on the first slave device model; if the slave device is not identified based on the first slave device model, it identifies the slave device based on the second slave device model, and then repeats the process until the slave device is identified or the slave device is identified based on the last model. Polling can also be called "programmed I/O".

本申请实施例中,主器件按照预先存储的标识寄存器的顺序向从器件发出询问,当主器件读取的从器件的值与该器件标识对应的预设值一致时,主器件识别到该从器件,配置该从器件。In an embodiment of the present application, the master device sends inquiries to the slave device in the order of pre-stored identification registers. When the value of the slave device read by the master device is consistent with the preset value corresponding to the device identification, the master device identifies the slave device and configures the slave device.

3、复位(power on reset,por):是指器件第一次上电或者断电后上电时,器件中的寄存器都回到初始状态的过程。示例性的,当电子设备开机启动时,主器件和从器件均可能处于初始状态,从初态开始工作。3. Reset (power on reset, POR): refers to the process in which the registers in the device return to their initial state when the device is powered on for the first time or after power failure. For example, when an electronic device is turned on, both the master device and the slave device may be in the initial state and start working from the initial state.

下面结合附图对本申请实施例的应用场景进行说明。The application scenarios of the embodiments of the present application are described below with reference to the accompanying drawings.

示例性的,图2为本申请实施例提供的一种应用场景示意图。如图2所示,电子设备包括主器件101和从器件102。主器件101和从器件102通过SPI总线连接。For example, Fig. 2 is a schematic diagram of an application scenario provided by an embodiment of the present application. As shown in Fig. 2, the electronic device includes a master device 101 and a slave device 102. The master device 101 and the slave device 102 are connected via an SPI bus.

主器件101用于通过SPI总线获取从器件102的数据和/或控制从器件102等,进而实现电子设备的一种或多种功能。示例性的,以主器件为CPU,从器件为温度传感器为例,CPU通过SPI总线获取温度传感器检测的温度,并基于该温度执行温度处理策略。CPU还可以通过SPI总线调节温度传感器检测频率等。The master device 101 is used to obtain data from the slave device 102 and/or control the slave device 102 through the SPI bus, thereby realizing one or more functions of the electronic device. For example, taking the master device as a CPU and the slave device as a temperature sensor as an example, the CPU obtains the temperature detected by the temperature sensor through the SPI bus and executes a temperature processing strategy based on the temperature. The CPU can also adjust the detection frequency of the temperature sensor through the SPI bus.

本申请实施例中,主器件101通过SPI总线可以兼容多个型号的从器件连接。而不同型号的从器件对应的器件原理、内部结构、软件实现等方面会有差异。因此,在主器件上电或者从器件上电后,主器件需要对从器件的型号进行识别,以对从器件进行初始化配置,进而实现电子设备的一种或多种功能。In the embodiment of the present application, the master device 101 can be compatible with multiple models of slave devices through the SPI bus. However, the device principles, internal structures, software implementations, etc. corresponding to different models of slave devices may be different. Therefore, after the master device is powered on or the slave device is powered on, the master device needs to identify the model of the slave device to initialize and configure the slave device, thereby realizing one or more functions of the electronic device.

具体的,主器件101可以通过SPI总线读取或改写从器件102中寄存器的数值,以实现对从器件102型号的识别、数据的获取以及控制等。Specifically, the master device 101 can read or rewrite the value of the register in the slave device 102 through the SPI bus to achieve identification of the model of the slave device 102, acquisition and control of data, etc.

为方便理解,下面结合图3对从器件102的结构进行说明。For ease of understanding, the structure of the slave device 102 is described below in conjunction with FIG. 3 .

从器件102中包括多个寄存器。寄存器包括但不限于控制类寄存器、状态类寄存器、功能类寄存器和标识寄存器。The slave device 102 includes a plurality of registers, including but not limited to control registers, status registers, function registers and identification registers.

控制类寄存器,用于控制和确定从器件的运行模式以及从器件的工作的特性等。Control registers are used to control and determine the operating mode of the slave device and the working characteristics of the slave device.

状态类寄存器,用于存放两类信息:一类信息是体现指令执行结果的各种状态信息(条件码),如有无进位(CF位)、有无溢出(OV位)、结果正负(SF位)、结果是否为零(ZF位)、奇偶标志位(P位)等;另一类信息是控制信息,如允许中断(IF位)、跟踪标志(TF位)等。Status registers are used to store two types of information: one type of information is various status information (condition codes) that reflect the results of instruction execution, such as whether there is a carry (CF bit), whether there is an overflow (OV bit), whether the result is positive or negative (SF bit), whether the result is zero (ZF bit), parity flag (P bit), etc.; the other type of information is control information, such as enabling interrupts (IF bit), tracking flag (TF bit), etc.

功能类寄存器用于存放相应功能部件的控制命令,状态或数据。Functional registers are used to store control commands, status or data of corresponding functional components.

标识寄存器用于存储器件标识,以方便主器件区分从器件的类型。The identification register is used to store the device identification so that the master device can distinguish the type of slave device.

可以理解的是,从器件中的每个寄存器均对应有一个地址,不同地址对应的寄存器对应的功能不同。示例性的,如图3所示,从器件包括多个寄存器,分别为01寄存器、02寄存器、03寄存器等。以从器件为温度传感器为例,01寄存器可以为状态类寄存器,用于存放温度是否异常的状态信息;02寄存器可以为控制类寄存器,用于存放检测的频率;03寄存器可以为标识寄存器,用于存放器件标识。图3所示的从器件还可以包括功能类寄存器,用于存放检测的温度。It is understandable that each register in the slave device corresponds to an address, and registers corresponding to different addresses have different functions. Exemplarily, as shown in FIG3 , the slave device includes multiple registers, namely register 01, register 02, register 03, etc. Taking the slave device as a temperature sensor as an example, register 01 can be a status register for storing status information of whether the temperature is abnormal; register 02 can be a control register for storing the detected frequency; register 03 can be an identification register for storing the device identification. The slave device shown in FIG3 can also include a function register for storing the detected temperature.

此外,不同型号的从器件对应的寄存器数量可能不同。相同地址对应的寄存器可能不同。示例性的,图3中01寄存器可以为标识寄存器,用于存放器件标识。02寄存器可以为状态类寄存器,用于存放温度是否异常的状态信息;03寄存器可以为控制类寄存器,用于存放检测的频率。本申请实施例对于从器件中寄存器的具体功能和每个功能对应的寄存器的地址不做限定。In addition, the number of registers corresponding to different models of slave devices may be different. The registers corresponding to the same address may be different. For example, register 01 in Figure 3 can be an identification register for storing the device identification. Register 02 can be a status register for storing status information on whether the temperature is abnormal; register 03 can be a control register for storing the frequency of detection. The embodiment of the present application does not limit the specific functions of the registers in the slave device and the addresses of the registers corresponding to each function.

本申请实施例中,主器件101可以为电子设备中的处理器(central processingunit,CPU)、系统级芯片(system on chip,SOC)、微控制器(micro control unit,MCU)、微处理器(MPU)和可编程片上系统(system-on-a-programmable-chip,SOPC),等。In the embodiment of the present application, the main device 101 can be a processor (central processing unit, CPU), a system on chip (system on chip, SOC), a microcontroller (micro control unit, MCU), a microprocessor (MPU) and a programmable system on a chip (system-on-a-programmable-chip, SOPC), etc. in an electronic device.

从器件102可以为电子设备中的外围器件。外围器件具体可以参照下面图4中电子设备的硬件架构说明,此处不再赘述。The slave device 102 may be a peripheral device in an electronic device. The peripheral device may be specifically described in the hardware architecture of the electronic device in FIG. 4 below, and will not be described in detail here.

示例性的,图4为本申请实施例提供的一种电子设备的硬件结构示意图。如图4所示,电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriberidentification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。Exemplarily, Figure 4 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. As shown in Figure 4, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从存储器中调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C或IIC)接口,串行外设接口(serial peripheralinterface,SPI)、集成电路内置音频(inter-integrated circuitsound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universalasynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobileindustry processor interface,MIPI),通用输入输出(general-purposeinput/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C or IIC) interface, a serial peripheral interface (SPI), an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (SIM) interface, and/or a universal serial bus (USB) interface, etc.

I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

SPI接口是一种高速的同步串行通信总线,具体结构可以参照上述相关概念的说明。在一些实施例中,处理器110可以包含多组SPI总线。处理器110可以通过不同的SPI总线接口分别耦合温度传感器180J,充电器,闪光灯,摄像头193等外围器件。例如:处理器110可以通过SPI接口耦合温度传感器180J,使处理器110与温度传感器180J通过SPI总线接口通信,实现电子设备100基于温度传感器180J检测的温度,执行温度处理策略,实现温度调节功能。The SPI interface is a high-speed synchronous serial communication bus, and the specific structure can refer to the description of the above-mentioned related concepts. In some embodiments, the processor 110 may include multiple groups of SPI buses. The processor 110 can be coupled to peripheral devices such as the temperature sensor 180J, the charger, the flash, the camera 193, etc. through different SPI bus interfaces. For example: the processor 110 can be coupled to the temperature sensor 180J through the SPI interface, so that the processor 110 communicates with the temperature sensor 180J through the SPI bus interface, and the electronic device 100 executes a temperature processing strategy based on the temperature detected by the temperature sensor 180J to achieve a temperature adjustment function.

I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。I2S接口和PCM接口都可以用于音频通信。The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(displayserial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.

GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

可以理解的是,本申请实施例示意的各模块间的接口连接关系,是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。The charging management module 140 is used to receive charging input from a charger, where the charger can be a wireless charger or a wired charger.

电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

天线1和天线2用于发射和接收电磁波信号。电子设备100中的天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. The antennas in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas.

移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。The mobile communication module 150 can provide solutions for wireless communications including 2G/3G/4G/5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.

无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wirelesslocal area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。The wireless communication module 160 can provide wireless communication solutions for application in the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.

电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

显示屏194用于显示图像、显示视频和接收滑动操作等。显示屏194包括显示面板。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, display videos, and receive sliding operations, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将电信号传递给ISP处理,转化为肉眼可见的图像。些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted to the camera photosensitive element through the lens, and the light signal is converted into an electrical signal. The camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. In some embodiments, the ISP can be set in the camera 193.

摄像头193用于捕获静态图像或视频。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频。The video codec is used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record videos in multiple coding formats.

外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

内部存储器121可以用于存储计算机可执行程序代码,可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and/or instructions stored in a memory provided in the processor.

电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation based on the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions.

陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x、y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.

磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。在一些实施例中,当电子设备100是翻盖机时,电子设备100可以根据磁传感器180D检测翻盖的开合。进而根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.

加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别终端设备姿态,应用于横竖屏切换,计步器等应用程序。The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the terminal device and is applied to applications such as horizontal and vertical screen switching and pedometers.

距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.

接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外光。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。当检测到不充分的反射光时,电子设备100可以确定电子设备100附近没有物体。电子设备100可以利用接近光传感器180G检测用户手持电子设备100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。The ambient light sensor 180L is used to sense the brightness of the ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热,以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。在一些实施例中,骨传导传感器180M也可以设置于耳机中,结合成骨传导耳机。音频模块170可以基于骨传导传感器180M获取的声部振动骨块的振动信号,解析出语音信号,实现语音功能。应用处理器可以基于骨传导传感器180M获取的血压跳动信号解析心率信息,实现心率检测功能。The bone conduction sensor 180M can obtain a vibration signal. In some embodiments, the bone conduction sensor 180M can obtain a vibration signal of a vibrating bone block of the vocal part of the human body. The bone conduction sensor 180M can also contact the human pulse to receive a blood pressure beat signal. In some embodiments, the bone conduction sensor 180M can also be set in an earphone and combined into a bone conduction earphone. The audio module 170 can parse out a voice signal based on the vibration signal of the vibrating bone block of the vocal part obtained by the bone conduction sensor 180M to realize a voice function. The application processor can parse the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M to realize a heart rate detection function.

按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.

马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用程序(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 may be an indicator light, which may be used to indicate the charging status, power changes, messages, missed calls, notifications, etc.

SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

上述图4所示的电子设备中,主器件可以为处理器,从器件可以为外围器件,例如,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriberidentification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。In the electronic device shown in FIG. 4 above, the master device may be a processor, and the slave device may be a peripheral device, for example, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

本申请实施例提供的器件识别方法,可以应用具有SPI接口的电子设备中。电子设备包括终端设备。终端设备也可以称为终端(terminal)、用户设备(user equipment,UE)、移动台(mobile station,MS)、移动终端(mobile terminal,MT)等。终端设备可以是手机(mobile phone)、智能电视、穿戴式设备、平板电脑(Pad)、带无线收发功能的电脑、虚拟现实(virtual reality,VR)终端设备、增强现实(augmented reality,AR)终端设备、工业控制(industrial control)中的无线终端、无人驾驶(self-driving)中的无线终端、远程手术(remote medical surgery)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端、智慧家庭(smart home)中的无线终端等等。The device identification method provided in the embodiment of the present application can be applied to electronic devices with SPI interfaces. Electronic devices include terminal devices. Terminal devices can also be called terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. Terminal devices can be mobile phones, smart TVs, wearable devices, tablet computers (Pad), computers with wireless transceiver functions, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc.

作为示例而非限定,在本申请实施例中,该终端设备还可以是可穿戴设备。可穿戴设备也可以称为穿戴式智能设备,是应用穿戴式技术对日常穿戴进行智能化设计、开发出可以穿戴的设备的总称,如眼镜、手套、手表、服饰及鞋等。可穿戴设备即直接穿在身上,或是整合到用户的衣服或配件的一种便携式设备。可穿戴设备不仅仅是一种硬件设备,更是通过软件支持以及数据交互、云端交互来实现强大的功能。广义穿戴式智能设备包括功能全、尺寸大、可不依赖智能手机实现完整或者部分的功能,例如:智能手表或智能眼镜等,以及只专注于某一类应用功能,需要和其它设备如智能手机配合使用,如各类进行体征监测的智能手环、智能首饰等。As an example but not limitation, in the embodiments of the present application, the terminal device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.

此外,在本申请实施例中,终端设备还可以是物联网(internet of things,IoT)系统中的终端设备,IoT是未来信息技术发展的重要组成部分,其主要技术特点是将物品通过通信技术与网络连接,从而实现人机互连,物物互连的智能化网络。In addition, in the embodiments of the present application, the terminal device may also be a terminal device in an Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.

本申请的实施例对终端设备所采用的具体技术和具体设备形态不做限定。The embodiments of the present application do not limit the specific technology and specific device form adopted by the terminal device.

电子设备在接收到用于指示开机的操作时,电子设备中的处理器需要识别通过SPI总线连接的外围器件的型号,以基于器件型号等对外围器件进行相应的初始化配置,进而实现电子设备相应的功能。When an electronic device receives an operation for instructing power on, the processor in the electronic device needs to identify the model of the peripheral device connected via the SPI bus, so as to initialize and configure the peripheral device accordingly based on the device model, thereby realizing the corresponding function of the electronic device.

可能的设计中,处理器通过轮询的方式读取外围器件的器件标识(chip id)实现外围器件的型号识别,进而对外围器件做相应的初始化配置。具体的,当电子设备接收到用于指示开机的操作时,主器件轮询次序和对应关系读取从器件中相应寄存器存储的值。当主器件读取的值与预设值相同时,主器件识别到从器件。当主器件读取的值与预设值不同时,基于轮询次序读取下一类型对应从器件的寄存器,直至识别到从器件或者轮询至最后一个从器件。当轮询至最后一个从器件时,未识别到从器件,从器件识别失败。In a possible design, the processor reads the device identification (chip id) of the peripheral device by polling to realize the model identification of the peripheral device, and then performs corresponding initialization configuration on the peripheral device. Specifically, when the electronic device receives an operation for instructing power on, the master device reads the value stored in the corresponding register in the slave device according to the polling order and the corresponding relationship. When the value read by the master device is the same as the preset value, the master device identifies the slave device. When the value read by the master device is different from the preset value, the register of the next type of corresponding slave device is read based on the polling order until the slave device is identified or the last slave device is polled. When the last slave device is polled, the slave device is not identified, and the slave device identification fails.

示例性的,图5为可能的设计中器件识别方法的流程示意图。如图5所示,方法包括:Exemplarily, FIG5 is a flow chart of a possible method for identifying a device in a design. As shown in FIG5, the method includes:

S401、当电子设备接收到用于指示开机的操作时,主器件基于型号次序和对应关系读取从器件中寄存器的数值。S401: When the electronic device receives an operation for instructing power on, the master device reads the value of the register in the slave device based on the model sequence and the corresponding relationship.

可以理解的是,主器件通过SPI总线可能兼容多个从器件连接。主器件按照预先设置的型号的次序和对应关系读取从器件中相应寄存器的数值,以确认从器件的型号。It is understandable that the master device may be compatible with multiple slave devices via the SPI bus. The master device reads the values of the corresponding registers in the slave device according to the order and correspondence of the preset models to confirm the model of the slave device.

本申请实施例中,对应关系为从器件型号、标识(chip id)寄存器地址以及预设值之间的关系。轮询次序与从器件型号相对应。In the embodiment of the present application, the corresponding relationship is the relationship between the slave device model, the identification (chip id) register address and the preset value. The polling order corresponds to the slave device model.

可能的实现方式中,对应关系可以以表格的形式存储在主器件中。示例性的,从器件型号、标识寄存器地址以及预设值之间的对应关系如表1所示。In a possible implementation, the corresponding relationship may be stored in the master device in the form of a table. For example, the corresponding relationship between the slave device model, the identification register address, and the preset value is shown in Table 1.

表1对应关系表Table 1 Correspondence table

型号model 标识寄存器地址Identification register address 预设值default value AA 0×000×00 1111 BB 0×010×01 1212

从表1中可以看出,A型号对应的标识寄存器地址为0×00,即A型号对应的标识寄存器为0×00寄存器,预设值为11。可以理解的是,主器件基于从器件0×00寄存器对应的值和预设值可以识别从器件是否为A型号。当主器件基于从器件0×00寄存器对应的值为11时,识别从器件为A型号;当主器件基于从器件0×00寄存器对应的值不为11时,识别从器件不是A型号。As can be seen from Table 1, the identification register address corresponding to model A is 0×00, that is, the identification register corresponding to model A is register 0×00, and the preset value is 11. It can be understood that the master device can identify whether the slave device is model A based on the value corresponding to register 0×00 of the slave device and the preset value. When the master device identifies the slave device as model A based on the value corresponding to register 0×00 of the slave device is 11, the master device identifies the slave device as model A; when the master device identifies the slave device as not model A based on the value corresponding to register 0×00 of the slave device is not 11.

B型号对应的标识寄存器为0×01寄存器,即B型号对应的标识寄存器为0×01寄存器预设值为12。可以理解为,主器件基于从器件0×01寄存器对应的值和预设值可以识别从器件是否为B型号。当主器件基于从器件0×01寄存器对应的值为12时,识别从器件为B型号;当主器件基于从器件0×01寄存器对应的值不为12时,识别从器件不是B型号。The identification register corresponding to the B model is the 0×01 register, that is, the identification register corresponding to the B model is the 0×01 register preset value is 12. It can be understood that the master device can identify whether the slave device is a B model based on the value corresponding to the 0×01 register of the slave device and the preset value. When the master device identifies the slave device as a B model based on the value corresponding to the 0×01 register of the slave device is 12; when the master device identifies the slave device as not a B model based on the value corresponding to the 0×01 register of the slave device is not 12.

S402、当主器件读取的值与预设值相同时,主器件识别到从器件。S402: When the value read by the master device is the same as the preset value, the master device recognizes the slave device.

适应性的,主器件在识别到从器件后,对从器件进行初始化配置。Adaptively, after the master device recognizes the slave device, it initializes and configures the slave device.

示例性的,以从器件为温度传感器为例,主器件为温度传感器中的寄存器中配置新的值,例如,该值用于指示温度传感器采集环境中的温度的频率等。Exemplarily, taking the slave device as a temperature sensor as an example, the master device configures a new value in a register in the temperature sensor. For example, the value is used to indicate the frequency of the temperature sensor collecting the temperature in the environment.

S403、当主器件读取的从器件的值与预设值不同时,主器件确认轮询是否完成。S403: When the value of the slave device read by the master device is different from the preset value, the master device confirms whether the polling is completed.

当主器件未轮询至最后一个型号的从器件时,主器件执行S401。当主器件的轮询至最后一个型号的从器件时,主器件识别从器件失败。When the master device does not poll the last model of the slave device, the master device executes S401. When the master device polls the last model of the slave device, the master device fails to identify the slave device.

示例性的,以SPI接口兼容连接的从器件为A型号和B型号为例,如图6所示,识别流程如下:For example, taking the slave devices of type A and type B that are compatible with the SPI interface as an example, as shown in FIG6 , the identification process is as follows:

S501、当电子设备接收到用于指示开机的操作时,主器件基于A型号对应的寄存器地址读取从器件中寄存器的数值。S501: When the electronic device receives an operation for instructing power on, the master device reads the value of the register in the slave device based on the register address corresponding to model A.

示例性的,主器件读取A型号对应的标识寄存器,即0×00寄存器。Exemplarily, the master device reads the identification register corresponding to model A, that is, register 0×00.

S502、当主器件读取的值与A型号对应的预设值相同时,主器件识别从器件为A型号。S502: When the value read by the master device is the same as the preset value corresponding to model A, the master device identifies the slave device as model A.

适应性的,主器件基于A型号对从器件进行初始化设置。Adaptively, the master device initializes the slave device based on the A model.

S503、当主器件读取的值与A型号对应的预设值不同时,主器件基于B型号对应的寄存器地址读取从器件中寄存器的数值。S503: When the value read by the master device is different from the preset value corresponding to model A, the master device reads the value of the register in the slave device based on the register address corresponding to model B.

S504、当主器件读取的值与B型号对应的预设值相同时,主器件识别从器件为B型号。S504: When the value read by the master device is the same as the preset value corresponding to the B model, the master device identifies the slave device as the B model.

适应性的,主器件基于B型号对从器件进行初始化设置。Adaptively, the master device initializes the slave device based on the B model.

S505、当主器件读取的值与B型号对应的预设值不同时,主器件识别从器件失败。S505: When the value read by the master device is different from the preset value corresponding to model B, the master device fails to identify the slave device.

主器件基于第一从器件型号对应的标识寄存器地址读取从器件中相应寄存器的数值;当主器件读取的值与对应关系中的预设值相同时,主器件识别到从器件为第一从器件型号。当主器件读取值与对应关系中的预设值不同时,主器件基于下一型号对应的标识寄存器地址读取从器件中相应寄存器的数值,直至识别到从器件或者轮询至最后一个从器件。当轮询至最后一个型号的从器件时,主器件未识别到从器件,从器件识别失败。The master device reads the value of the corresponding register in the slave device based on the identification register address corresponding to the first slave device model; when the value read by the master device is the same as the preset value in the corresponding relationship, the master device identifies the slave device as the first slave device model. When the value read by the master device is different from the preset value in the corresponding relationship, the master device reads the value of the corresponding register in the slave device based on the identification register address corresponding to the next model until the slave device is identified or the last slave device is polled. When the last model of the slave device is polled, the master device does not identify the slave device, and the slave device identification fails.

但是,上述图5和图6所示的流程中,主器件在识别从器件时可能会出错,从而导致从器件无法使用,电子设备相应的功能无法使用,用户体验差。However, in the processes shown in FIG. 5 and FIG. 6 , the master device may make an error when identifying the slave device, thereby rendering the slave device unusable and the corresponding functions of the electronic device unusable, resulting in a poor user experience.

示例性的,以主器件通过SPI接口兼容连接A型号从器件和B型号从器件为例,主器件可能会将B型号从器件识别为A型号从器件。具体的,主器件基于A型号对应的寄存器地址读取从器件中寄存器的数值时,B型号从器件中相应寄存器对应的值与A型号对应的预设值相同。For example, taking the example of a master device being compatible with a model A slave device and a model B slave device through an SPI interface, the master device may identify the model B slave device as a model A slave device. Specifically, when the master device reads the value of the register in the slave device based on the register address corresponding to the model A, the value corresponding to the corresponding register in the model B slave device is the same as the preset value corresponding to the model A.

为方便理解,示例性的给出从器件中两个型号对应的寄存器列表。For ease of understanding, a register list corresponding to two models in the slave device is given as an example.

表2寄存器列表Table 2 Register List

型号model 寄存器地址Register Address value AA 0×000×00 1111 0×010×01 1313 BB 0×000×00 保留(reserved)reserved 0×010×01 1212

需要说明的是,从器件中有部分寄存器为保留(reserved)寄存器,可以理解为未被公开的寄存器。保留(reseverd)寄存器可能为仅在器件设计研发阶段调试使用的寄存器;还可能为器件在设计上有功能,但由于生产工艺等问题,对应的功能不能实现的寄存器等。It should be noted that some registers in the slave device are reserved registers, which can be understood as undisclosed registers. Reserved registers may be registers that are only used for debugging during the device design and development stage; they may also be registers that have functions in the device design, but the corresponding functions cannot be realized due to production process and other issues.

可以理解的是,保留寄存器对应的值可能为1个固定值,也可能为随机值,还可能对应于多个固定值。It is understandable that the value corresponding to the reserved register may be one fixed value, may be a random value, or may correspond to multiple fixed values.

下面结合表2和图7对误识别过程进行说明。示例性的,以从器件的型号为B型号,主器件按照A型号和B型号顺序识别从器件为例,识别流程包括:The misidentification process is described below in conjunction with Table 2 and Figure 7. For example, taking the slave device model as Model B and the master device identifying the slave device in the order of Model A and Model B, the identification process includes:

S601、当电子设备接收到用于指示开机的操作时,主器件基于A型号对应的寄存器地址读取从器件中寄存器的数值。S601: When the electronic device receives an operation for instructing power on, the master device reads the value of the register in the slave device based on the register address corresponding to model A.

示例性的,主器件读取A型号对应的标识寄存器,即0×00寄存器。Exemplarily, the master device reads the identification register corresponding to model A, that is, register 0×00.

S602、当从器件反馈的值与A型号对应的预设值相同时,主器件识别从器件为A型号。S602: When the value fed back by the slave device is the same as the preset value corresponding to model A, the master device identifies the slave device as model A.

适应性的,主器件基于A型号进行初始化设置。Adaptively, the master device is initialized based on model A.

示例性的,当从器件为B型号时,0×00寄存器为保留寄存器,其对应的值可能也为11,因此从器件反馈的值为11,与A型号对应的预设值相同,主器件将从器件误识别为A型号。For example, when the slave device is model B, the 0×00 register is a reserved register, and its corresponding value may also be 11. Therefore, the value fed back by the slave device is 11, which is the same as the preset value corresponding to model A. The master device mistakenly identifies the slave device as model A.

当主器件基于A型号进行初始化配置时,可能会导致从器件初始化配置错误,进而从器件无法正常运行,相应的功能失效。When the master device is initialized and configured based on model A, it may cause an initialization configuration error of the slave device, and then the slave device cannot operate normally and the corresponding functions become invalid.

有鉴于此,本申请实施例提供一种器件识别方法,主器件可以读取从器件中两个不同的寄存器的数值,得到对应的两个值进行验证当两次的值均符合预期时,器件识别成功。这样,进行二次识别,减少因不同型号从器件中的相同地址寄存器对应的值相同,导致器件误识别初始化配置失败的情况,优化用户体验。此外,未改动电子设备的硬件结构,成本友好,提高系统设计灵活性,提高产品物料供应的稳定性。In view of this, an embodiment of the present application provides a device identification method, in which the master device can read the values of two different registers in the slave device, obtain the corresponding two values for verification, and when both values meet expectations, the device identification is successful. In this way, secondary identification is performed to reduce the situation where the device misidentifies and fails to initialize the configuration due to the same values corresponding to the same address registers in different models of slave devices, thereby optimizing the user experience. In addition, the hardware structure of the electronic device is not changed, which is cost-friendly, improves the flexibility of system design, and improves the stability of product material supply.

下面结合附图对本申请实施例提供的器件识别方法进行说明。The device identification method provided in the embodiment of the present application is described below with reference to the accompanying drawings.

示例性的,图8为本申请实施例提供的一种从器件识别方法流程示意图,如图8所示,方法包括:Exemplarily, FIG8 is a schematic flow chart of a slave device identification method provided in an embodiment of the present application. As shown in FIG8 , the method includes:

S701、当电子设备开机初始化时,主器件基于从器件型号次序和对应关系读取从器件中寄存器的数值,得到第一值和/或第二值;对应关系包括从器件型号、第一地址、第一预设值、第二地址和第二预设值之间的关系。S701. When the electronic device is powered on and initialized, the master device reads the value of the register in the slave device based on the order of the slave device models and the corresponding relationship to obtain the first value and/or the second value; the corresponding relationship includes the relationship between the slave device model, the first address, the first preset value, the second address and the second preset value.

可以理解的是,在电子设备开机时,主器件从下电状态切换为上电状态,开始对从器件进行识别。It is understandable that when the electronic device is turned on, the master device switches from a power-off state to a power-on state and starts to identify the slave device.

本申请实施例中,第一地址可以为不同型号从器件对应的标识寄存器对应的地址,第二地址可以为不同型号从器件对应的复查寄存器对应的地址。标识寄存器为存储器件标识的寄存器,用于区分器件型号。复查寄存器用于对器件型号进行验证的寄存器。In the embodiment of the present application, the first address may be an address corresponding to an identification register corresponding to different models of slave devices, and the second address may be an address corresponding to a review register corresponding to different models of slave devices. The identification register is a register for storing device identification, which is used to distinguish device models. The review register is a register for verifying the device model.

示例性的,以从器件型号为A型号和B型号为例,A型号对应的标识寄存器地址为0×00,第一预设值为11;A型号对应的复查寄存器地址为0×01,第二预设值为12。B型号对应的标识寄存器地址为0×01寄存器,第一预设值为12;B型号对应的复查寄存器地址为0×02,第二预设值为14。For example, taking the slave device models A and B as an example, the identification register address corresponding to model A is 0×00, and the first preset value is 11; the review register address corresponding to model A is 0×01, and the second preset value is 12. The identification register address corresponding to model B is 0×01 register, and the first preset value is 12; the review register address corresponding to model B is 0×02, and the second preset value is 14.

可以理解的是,可以通过地址确认从器件中多个寄存器中的一个,地址也可以理解为寄存器编号。It can be understood that one of the multiple registers in the slave device can be identified by the address, and the address can also be understood as the register number.

可能的实现方式中,上述对应关系可以以表格的形式存储在主器件中。示例性的,如表3所示。In a possible implementation, the above correspondence relationship may be stored in the master device in the form of a table, as shown in Table 3 for example.

表3对应关系表Table 3 Correspondence table

可以理解的是,主器件基于第一地址和第二地址读取从器件中寄存器的数值,得到第一值和第二值。本申请实施例中,主器件可以先基于第一地址读取从器件中寄存器的数值得到第一值;也可以先基于第二地址读取从器件中寄存器的数值得到第二值。此处不做限定。It is understandable that the master device reads the value of the register in the slave device based on the first address and the second address to obtain the first value and the second value. In the embodiment of the present application, the master device may first read the value of the register in the slave device based on the first address to obtain the first value; or may first read the value of the register in the slave device based on the second address to obtain the second value. This is not limited here.

本申请实施例中,不同型号的从器件对应的第二地址可以相同,也可以不同,本申请实施例对此不作限定。In the embodiment of the present application, the second addresses corresponding to slave devices of different models may be the same or different, and the embodiment of the present application is not limited to this.

可以理解的是,主器件通过SPI总线可以兼容多个从器件连接。主器件按照预先设置的型号的次序和对应关系读取从器件中相应寄存器的数值,以确认从器件的型号。It is understandable that the master device can be compatible with multiple slave devices via the SPI bus. The master device reads the values of the corresponding registers in the slave device according to the order and correspondence of the preset models to confirm the model of the slave device.

S702、当第一值与第一预设值相同,且第二值与第二预设值相同时,主器件识别到从器件,并基于型号对从器件进行初始化配置,第二值主器件配置从器件之前为定值。S702: When the first value is the same as the first preset value and the second value is the same as the second preset value, the master device identifies the slave device and initializes the configuration of the slave device based on the model. The second value is a fixed value before the master device configures the slave device.

S703、当第一值与第一预设值不同或者第二值与第二预设值不同时,主器件确认轮询是否完成。S703: When the first value is different from the first preset value or the second value is different from the second preset value, the master device confirms whether the polling is completed.

示例性的,主器件基于型号次序确认轮询是否完成。当主器件未基于最后一个型号和对应关系读取从器件中寄存器的数值时,轮询未完成,主器件执行S701直至识别到从器件或者轮询完成。当主器件基于最后一个型号和对应关系读取从器件中寄存器的数值时,轮询完成,主器件识别从器件失败。Exemplarily, the master device confirms whether the polling is completed based on the model order. When the master device does not read the value of the register in the slave device based on the last model and the corresponding relationship, the polling is not completed, and the master device executes S701 until the slave device is identified or the polling is completed. When the master device reads the value of the register in the slave device based on the last model and the corresponding relationship, the polling is completed, and the master device fails to identify the slave device.

可能的实现方式中,主器件在识别从器件失败时,基于预设型号配置从器件。In a possible implementation, when the master device fails to identify the slave device, the master device configures the slave device based on a preset model.

可能的实现方式中,主器件在基于型号次序和对应关系读取从器件中寄存器的数值得到第二值之前,控制从器件复位。In a possible implementation, the master device controls the slave device to reset before reading the value of the register in the slave device to obtain the second value based on the model sequence and the corresponding relationship.

综上,主器件通过读取从器件中两个不同的寄存器的数值,进行验证。这样,降低不同型号从器件中的相同地址寄存器对应的值相同的概率,减少器件误识别的情况。此外,未改动电子设备的硬件结构,成本友好,提高系统设计灵活性,提高产品物料供应的稳定性。In summary, the master device performs verification by reading the values of two different registers in the slave device. In this way, the probability of the same address registers in different models of slave devices corresponding to the same value is reduced, and the device misidentification is reduced. In addition, the hardware structure of the electronic device is not changed, which is cost-friendly, improves the flexibility of system design, and improves the stability of product material supply.

下面结合图9对电子设备开机初始化的过程中器件识别方法进行说明。示例性的,如图9所示,The following is a description of a device identification method during the initialization of an electronic device when it is powered on, in conjunction with FIG9 .

S801、当电子设备接收到用于指示开机的操作时,主器件基于A型号对应的标识寄存器地址读取从器件中寄存器的数值,得到A型号对应的第一值。S801: When the electronic device receives an operation for instructing power on, the master device reads the value of the register in the slave device based on the identification register address corresponding to model A to obtain a first value corresponding to model A.

可以理解的是,主器件通过SPI总线与多个从器件连接。主器件按照预先设置的轮询次序和对应关系通过轮询的方式确认从器件的型号。对应关系为从器件型号、标识寄存器地址、第一预设值、复查寄存器地址以及第二预设值之间的关系。轮询次序与从器件型号相对应。It is understandable that the master device is connected to multiple slave devices via the SPI bus. The master device confirms the model of the slave device by polling according to the preset polling order and corresponding relationship. The corresponding relationship is the relationship between the slave device model, the identification register address, the first preset value, the review register address and the second preset value. The polling order corresponds to the slave device model.

可能的实现方式中,对应关系可以以表格的形式存储在主器件中。示例性的,从器件型号、标识寄存器地址、第一预设值、复查寄存器地址以及第二预设值之间的对应关系可以如上述表3所示。In a possible implementation, the corresponding relationship may be stored in the master device in the form of a table. For example, the corresponding relationship between the slave device model, the identification register address, the first preset value, the review register address and the second preset value may be as shown in Table 3 above.

从表3中可以看出,A型号对应的标识寄存器地址为0×00,第一预设值为11;A型号对应的复查寄存器地址为0×01,第二预设值为12。B型号对应的标识寄存器地址为0×01寄存器,第一预设值为12;B型号对应的复查寄存器地址为0×02,第二预设值为14。As can be seen from Table 3, the identification register address corresponding to model A is 0×00, and the first preset value is 11; the review register address corresponding to model A is 0×01, and the second preset value is 12. The identification register address corresponding to model B is 0×01 register, and the first preset value is 12; the review register address corresponding to model B is 0×02, and the second preset value is 14.

可以理解的是,当主器件读取从器件的0×00寄存器的数值,得到第一值为11,且主器件读取从器件的0×01寄存器的数值,得到的第二值为13时,从器件为A型号。当主器件读取从器件的0×01寄存器的数值,得到的第一值为12,且主器件读取从器件的0×02寄存器的数值得到的第二值为14时,从器件为B型号。It can be understood that when the master device reads the value of the 0×00 register of the slave device and obtains a first value of 11, and the master device reads the value of the 0×01 register of the slave device and obtains a second value of 13, the slave device is model A. When the master device reads the value of the 0×01 register of the slave device and obtains a first value of 12, and the master device reads the value of the 0×02 register of the slave device and obtains a second value of 14, the slave device is model B.

本申请实施例中,复查(double check)寄存器与标识寄存器不同。复查(doublecheck)寄存器对应的地址与标识寄存器对应的地址不同。In the embodiment of the present application, the double check register is different from the identification register, and the address corresponding to the double check register is different from the address corresponding to the identification register.

本申请实施例中,不同型号的从器件对应的复查寄存器的地址可以相同,也可以不同,本申请实施例对此不作限定。In the embodiment of the present application, the addresses of the review registers corresponding to slave devices of different models may be the same or different, and the embodiment of the present application is not limited to this.

可能的实现方式中,不同型号的从器件对应的复查寄存器的地址相同,对应的第二预设值不同。In a possible implementation, the addresses of the review registers corresponding to slave devices of different models are the same, but the corresponding second preset values are different.

这样,复查寄存器的地址相同,主器件读取一次寄存器,即可区分不同型号的从器件。此外,还可以减少误识别的风险。In this way, the address of the recheck register is the same, and the master device can distinguish different types of slave devices by reading the register once. In addition, the risk of misidentification can be reduced.

本申请实施例中,复查(double check)寄存器可以为上电后稳定的寄存器,也可以为不稳定的寄存器。In the embodiment of the present application, the double check register may be a stable register after power-on, or an unstable register.

可以理解的是,不稳定的寄存器可以为保留寄存器和值被修改的寄存器,等。It is to be understood that the unstable registers may be reserved registers, registers whose values are modified, and the like.

一些寄存器在器件运行过程中可能会被进行读写操作,导致寄存器对应的值被修改。该寄存器可以为用于数据输出的寄存器、用于指示模式切换的寄存器、以及用于指示异常情况的寄存器等。Some registers may be read and written during device operation, resulting in the modification of the corresponding value of the register. The register may be a register for data output, a register for indicating mode switching, a register for indicating abnormal conditions, etc.

示例性的,以温度传感器为例,不稳定的寄存器可以为:用于存储检测的温度的寄存器、未公开的保留寄存器等。Exemplarily, taking a temperature sensor as an example, an unstable register may be: a register for storing detected temperature, an undisclosed reserved register, and the like.

稳定的寄存器可以为:值未被修改的寄存器,例如报值固定且从器件使用过程中未被读写操作过的控制寄存器等。A stable register may be: a register whose value has not been modified, such as a control register whose value is fixed and has not been read or written during the use of the slave device.

示例性的,以温度传感器为例,稳定的寄存器可以为:中断控制寄存器,该寄存器上电复位后报值固定且非零,该中断控制寄存器用于控制中断功能的使能,处理器未操作过该中断控制寄存器,可以预见该寄存器在温度传感器上电稳定后,其寄存器值是固定的。Exemplarily, taking the temperature sensor as an example, the stable register may be: an interrupt control register, which has a fixed and non-zero value after power-on reset. The interrupt control register is used to control the enabling of the interrupt function. The processor has not operated the interrupt control register. It can be foreseen that the register value is fixed after the temperature sensor is powered on and stabilized.

可能的实现方式中,复查(double check)寄存器为上电后稳定的寄存器。这样,可以减少寄存器中的值被改变导致的识别失败的情况,提高识别的成功率。In a possible implementation, the double check register is a register that is stable after power-on, so as to reduce the situation of recognition failure caused by the change of the value in the register and improve the success rate of recognition.

可能的实现方式中,复查寄存器为非零寄存器。可以理解的是,多数寄存器上电复位后寄存器报值为0,以及寄存器异常时报值通常为0。这样,选择非零寄存器可以进一步减少误识别,提高本申请实施例稳定性。In a possible implementation, the review register is a non-zero register. It is understandable that after most registers are powered on and reset, the register value reported is 0, and when the register is abnormal, the value reported is usually 0. In this way, selecting a non-zero register can further reduce misidentification and improve the stability of the embodiment of the present application.

可能的实现方式中,复查寄存器为上电后报值固定且非零的寄存器。这样,可以减少寄存器中的值被改变导致的识别失败的情况,提高识别的成功率。In a possible implementation, the review register is a register whose reported value is fixed and non-zero after power-on, so as to reduce the situation of recognition failure caused by the value in the register being changed, and improve the success rate of recognition.

S802、当A型号对应的第一值与A型号对应第一预设值相同时,主器件基于A型号对应的复查寄存器地址读取从器件中寄存器的数值,得到A型号对应的第二值。S802: When the first value corresponding to model A is the same as the first preset value corresponding to model A, the master device reads the value of the register in the slave device based on the review register address corresponding to model A to obtain the second value corresponding to model A.

S803、当A型号对应的第二值与A型号对应第二预设值相同时,主器件识别从器件为A型号。S803: When the second value corresponding to model A is the same as the second preset value corresponding to model A, the master device identifies the slave device as model A.

适应性的,主器件基于A型号配置从器件。Adaptively, the master configures the slave based on the A model.

S804、当A型号对应的第一值与A型号对应第一预设值不同,或者A型号对应的第二值与A型号对应第二预设值不同时,主器件确认轮询是否完成。S804: When the first value corresponding to model A is different from the first preset value corresponding to model A, or the second value corresponding to model A is different from the second preset value corresponding to model A, the master device confirms whether the polling is completed.

当A型号不是最后一个型号时,轮询未完成,主器件基于B型号对应的标识寄存器地址读取从器件中寄存器的数值,得到B型号对应的第一值。When model A is not the last model, the polling is not completed, and the master device reads the value of the register in the slave device based on the identification register address corresponding to model B to obtain the first value corresponding to model B.

当A型号为最后一个型号时,主器件识别从器件失败。When model A is the last model, the master device fails to recognize the slave device.

综上,在基于第一从器件型号识别从器件时,读取从器件中两个不同的寄存器的数值,进行验证。这样,降低不同型号从器件中的相同地址寄存器对应的值相同的概率,减少器件误识别的情况。In summary, when identifying a slave device based on the first slave device model, the values of two different registers in the slave device are read for verification, thereby reducing the probability that the values corresponding to the same address registers in slave devices of different models are the same, and reducing the possibility of device misidentification.

在上述实施例的基础上,方法还包括S805。S805、在主器件基于复查寄存器地址读取从器件中寄存器的数值之前,主器件控制从器件复位。Based on the above embodiment, the method further includes S805. S805: Before the master device reads the value of the register in the slave device based on the review register address, the master device controls the slave device to reset.

需要说明的是,在电子设备的使用过程中,从器件中的部分寄存器对应的值可能会发生变化。示例性的,以从器件为温度传感器为例,用于存储检测的温度的寄存器可能会被多次改写,以存储最近一次检测得到的温度。以默认值为20,检测的温度未30为例,用于存储检测的温度的寄存器对应的值可能从20改写为30。It should be noted that during the use of the electronic device, the values corresponding to some registers in the slave device may change. For example, taking the slave device as a temperature sensor, the register for storing the detected temperature may be rewritten multiple times to store the temperature obtained by the most recent detection. Taking the default value as 20 and the detected temperature as 30 as an example, the value corresponding to the register for storing the detected temperature may be rewritten from 20 to 30.

这样,将从器件复位将从器件中寄存器的数值恢复至默认值,可以减少复查寄存器对应的值被改写等情况导致的识别失败或者误识别。In this way, resetting the slave device will restore the value of the register in the slave device to the default value, which can reduce the recognition failure or misrecognition caused by the value corresponding to the review register being rewritten.

在上述实施例的基础上,方法还包括S806。S806、当主器件识别从器件失败时,基于预设型号配置从器件。这样,主器件可能会基于预设型号成功配置从器件,使得从器件可以正常运行,进而实现电子设备的功能。Based on the above embodiment, the method further includes S806. S806: When the master device fails to identify the slave device, configure the slave device based on the preset model. In this way, the master device may successfully configure the slave device based on the preset model, so that the slave device can operate normally, thereby realizing the function of the electronic device.

可能的实现方式中,预设型号可以为电子设备中使用次数最多从器件对应的型号。这样,提高主器件成功配置从器件的可能性。In a possible implementation, the preset model may be the model corresponding to the slave device that is used most times in the electronic device, thereby increasing the possibility that the master device can successfully configure the slave device.

在上述实施例的基础上,主器件可以多次基于标识寄存器地址和/或复查寄存器地址对从器件的型号进行验证。这样,进一步减少误识别情况。On the basis of the above embodiment, the master device may verify the model of the slave device based on the identification register address and/or the review register address for multiple times, thereby further reducing the possibility of misidentification.

可以理解的是,上述图9所示的流程中SPI接口兼容A型号和B型号的从器件仅为示例,实际应用中,SPI接口还可以兼容更多型号的从器件,本申请实施例对于SPI接口兼容的从器件的型号、类型不做限定。It can be understood that the SPI interface is compatible with model A and model B slave devices in the process shown in Figure 9 above for example only. In actual applications, the SPI interface can also be compatible with more models of slave devices. The embodiments of the present application do not limit the models and types of slave devices compatible with the SPI interface.

在上述实施例中,SPI接口兼容的从器件可以为相同类型的不同型号的从器件,也可以为不同类型的从器件。本申请实施例对此不作限定。In the above embodiment, the SPI interface compatible slave devices may be slave devices of the same type but of different models, or may be slave devices of different types, which is not limited in the embodiment of the present application.

需要说明的是,当电子设备开机或者重启时,主器件从下电状态切换为上电状态,主器件需要识别并配置从器件。当从器件从下电状态切换为上电状态时,主器件也需要识别并配置从器件。It should be noted that when the electronic device is turned on or restarted, the master device switches from the power-off state to the power-on state, and the master device needs to identify and configure the slave device. When the slave device switches from the power-off state to the power-on state, the master device also needs to identify and configure the slave device.

本申请实施例提供的方法还可以适用于从器件从下电状态切换为上电状态的情况下,发生还可以适用于从器件下电后上电的过程中。例如,电子设备的软件系统出现问题导致从器件下电后上电,或者从器件发生闩锁(lanch-up)导致从器件下电后上电。The method provided in the embodiment of the present application can also be applied to the case where the slave device switches from a power-off state to a power-on state, and can also be applied to the process of powering on the slave device after powering off. For example, a problem occurs in the software system of the electronic device, causing the slave device to power on after powering off, or a latch-up occurs in the slave device, causing the slave device to power on after powering off.

上面已对本申请实施例的器件识别方法进行了说明,下面对本申请实施例提供的执行上述器件识别方法的相关装置进行描述。本领域技术人员可以理解,方法和装置可以相互结合和引用,本申请实施例提供的相关装置可以执行上述器件识别方法中的步骤。The device identification method of the embodiment of the present application has been described above, and the related device for performing the above device identification method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the related device provided by the embodiment of the present application can perform the steps in the above device identification method.

本申请实施例还提供了一种计算机可读存储介质。上述实施例中描述的方法可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。如果在软件中实现,则功能可以作为一个或多个指令或代码存储在计算机可读介质上或者在计算机可读介质上传输。计算机可读介质可以包括计算机存储介质和通信介质,还可以包括任何可以将计算机程序从一个地方传送到另一个地方的介质。存储介质可以是可由计算机访问的任何目标介质。The embodiments of the present application also provide a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

一种可能的实现方式中,计算机可读介质可以包括RAM,ROM,只读光盘(compactdisc read-only memory,CD-ROM)或其它光盘存储器,磁盘存储器或其它磁存储设备,或目标于承载的任何其它介质或以指令或数据结构的形式存储所需的程序代码,并且可由计算机访问。而且,任何连接被适当地称为计算机可读介质。例如,如果使用同轴电缆,光纤电缆,双绞线,数字用户线(digital subscriber line,DSL)或无线技术(如红外,无线电和微波)从网站,服务器或其它远程源传输软件,则同轴电缆,光纤电缆,双绞线,DSL或诸如红外,无线电和微波之类的无线技术包括在介质的定义中。如本文所使用的磁盘和光盘包括光盘,激光盘,光盘,数字通用光盘(digital versatiledisc,DVD),软盘和蓝光盘,其中磁盘通常以磁性方式再现数据,而光盘利用激光光学地再现数据。上述的组合也应包括在计算机可读介质的范围内。In one possible implementation, a computer readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile disks (DVD), floppy disks and Blu-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer readable media.

本申请实施例是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理单元以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理单元执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application embodiment is described with reference to the flowchart and/or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and/or box in the flowchart and/or block diagram, and the combination of the process and/or box in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.

以上的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本发明的保护范围之内。The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the protection scope of the present invention.

Claims (13)

1.一种器件识别方法,其特征在于,应用于电子设备,所述电子设备包括主器件和从器件,所述主器件通过串行外设接口SPI总线与所述从器件连接,所述主器件存储有至少两组地址、至少两个第一预设值、至少两个第二预设值与至少两个从器件型号之间的对应关系,所述至少两个第一预设值、所述至少两个第二预设值、至少两个从器件型号、所述至少两组地址一一对应,任一组所述地址包括第一地址和第二地址,所述方法包括:1. A device identification method, characterized in that it is applied to an electronic device, the electronic device comprises a master device and a slave device, the master device is connected to the slave device via a serial peripheral interface SPI bus, the master device stores a correspondence between at least two groups of addresses, at least two first preset values, at least two second preset values and at least two slave device models, the at least two first preset values, the at least two second preset values, the at least two slave device models, and the at least two groups of addresses correspond to each other one by one, any group of the addresses comprises a first address and a second address, the method comprises: 所述主器件按照所述至少两组地址中的第一组地址中的第一地址读取所述从器件中寄存器的数值,得到所述第一组地址中第一地址对应的第一值;The master device reads a value of a register in the slave device according to a first address in a first group of addresses in the at least two groups of addresses to obtain a first value corresponding to the first address in the first group of addresses; 所述主器件按照所述第一组地址中的第二地址读取所述从器件中寄存器的数值所述第一组地址中第二地址对应的第二值;The master device reads the value of the register in the slave device according to the second address in the first group of addresses, the second value corresponding to the second address in the first group of addresses; 当所述第一值与所述第一组地址对应的第一预设值,且所述第二值与所述第一组地址对应的第二预设值相同时,所述主器件基于所述第一组地址对应的第一从器件型号配置所述从器件;When the first value is the same as a first preset value corresponding to the first group of addresses, and the second value is the same as a second preset value corresponding to the first group of addresses, the master device configures the slave device based on a first slave device model corresponding to the first group of addresses; 或者,当所述第一值与所述第一组地址对应的第一预设值不同,或者所述主器件确定所述第二值与所述第一组地址对应的第二预设值不同时,所述主器件基于所述至少两组地址中的第二组地址读取所述从器件中寄存器的数值,所述第二组地址不为所述第一组地址;Alternatively, when the first value is different from a first preset value corresponding to the first group of addresses, or the master device determines that the second value is different from a second preset value corresponding to the first group of addresses, the master device reads a value of a register in the slave device based on a second group of addresses among the at least two groups of addresses, and the second group of addresses is not the first group of addresses; 其中,在所述主器件配置所述从器件之前第三值为固定值,所述第三值为所述从器件中第二地址对应的寄存器的数值。Wherein, before the master device configures the slave device, the third value is a fixed value, and the third value is a value of a register corresponding to the second address in the slave device. 2.根据权利要求1所述的方法,其特征在于,所述主器件按照所述第一组地址中的第二地址读取所述从器件中寄存器的数值所述第一组地址中第二地址对应的第二值,包括:2. The method according to claim 1, wherein the master device reads the value of the register in the slave device according to the second address in the first group of addresses, the second value corresponding to the second address in the first group of addresses comprising: 当所述第一值与所述第一组地址对应的第一预设值相同时,所述主器件基于所述第一组地址中的第二地址读取所述从器件中寄存器的数值,得到所述第二值。When the first value is the same as a first preset value corresponding to the first group of addresses, the master device reads a value of a register in the slave device based on a second address in the first group of addresses to obtain the second value. 3.根据权利要求1所述的方法,其特征在于,所述方法还包括:3. The method according to claim 1, characterized in that the method further comprises: 当所述主器件按照所述至少两组地址中的第一地址读取的从器件中寄存器的数值与每组所述地址对应的第一预设值不同时,所述主器件基于预设型号配置所述从器件,所述预设型号为所述对应关系中任一个从器件型号;When the value of the register in the slave device read by the master device according to the first address in the at least two groups of addresses is different from the first preset value corresponding to each group of the addresses, the master device configures the slave device based on a preset model, and the preset model is any slave device model in the corresponding relationship; 或者,当所述主器件按照所述至少两组地址中的第二地址读取的从器件中寄存器的数值与每组所述地址对应的第二预设值不同时,所述主器件基于所述预设型号配置所述从器件。Alternatively, when the value of the register in the slave device read by the master device according to the second address in the at least two groups of addresses is different from the second preset value corresponding to each group of the addresses, the master device configures the slave device based on the preset model. 4.根据权利要求1所述的方法,其特征在于,所述主器件基于所述第一组地址对应的第一从器件型号配置所述从器件,包括:4. The method according to claim 1, wherein the master device configures the slave device based on the first slave device model corresponding to the first group address, comprising: 所述主器件将所述第一从器件型号对应的调整参数写入所述从器件的寄存器中。The master device writes the adjustment parameter corresponding to the first slave device model into the register of the slave device. 5.根据权利要求1-4任一项所述的方法,其特征在于,在所述主器件基于所述第一组地址中的第二地址读取所述从器件中寄存器的数值之前,所述方法还包括:5. The method according to any one of claims 1 to 4, characterized in that before the master device reads the value of the register in the slave device based on the second address in the first group of addresses, the method further comprises: 所述主器件控制所述从器件复位。The master device controls the slave device to reset. 6.根据权利要求1-4任一项所述的方法,其特征在于,所述固定值不为零。6. The method according to any one of claims 1-4, characterized in that the fixed value is not zero. 7.根据权利要求1-4任一项所述的方法,其特征在于,所述从器件中第二地址对应的寄存器包括:读值固定且未被读写操作过的控制寄存器。7. The method according to any one of claims 1 to 4, characterized in that the register corresponding to the second address in the slave device comprises: a control register whose reading value is fixed and has not been subjected to read or write operations. 8.根据权利要求1-4任一项所述的方法,其特征在于,所述主器件基于所述第一组地址读取所述从器件中寄存器的数值之前,所述方法包括:8. The method according to any one of claims 1 to 4, characterized in that before the master device reads the value of the register in the slave device based on the first group of addresses, the method comprises: 所述主器件从第二状态切换为第一状态,所述第二状态为下电状态,所述第一状态为上电状态;The master device switches from a second state to a first state, the second state is a power-off state, and the first state is a power-on state; 或者,所述主器件检测到所述从器件从所述第二状态切换为所述第一状态。Alternatively, the master device detects that the slave device switches from the second state to the first state. 9.根据权利要求1-4任一项所述的方法,其特征在于,所述对应关系以表格的形式存储在所述主器件中。9. The method according to any one of claims 1 to 4, characterized in that the corresponding relationship is stored in the main device in the form of a table. 10.根据权利要求1-4任一项所述的方法,其特征在于,所述主器件包括下述至少一种:处理器CPU、系统级芯片SOC、微控制器MCU、微处理器MPU、可编程片上系统SOPC;10. The method according to any one of claims 1 to 4, characterized in that the main device comprises at least one of the following: a processor CPU, a system-on-chip SOC, a microcontroller MCU, a microprocessor MPU, and a programmable system on chip SOPC; 所述从器件包括下述至少一种:传感器、电池、通信模块、音频模块、按键、马达、指示器、显示屏、用户标识模块。The slave device includes at least one of the following: a sensor, a battery, a communication module, an audio module, a button, a motor, an indicator, a display screen, and a user identification module. 11.一种电子设备,其特征在于,包括:处理器和存储器;11. An electronic device, comprising: a processor and a memory; 所述存储器存储计算机执行指令;The memory stores computer-executable instructions; 所述处理器执行所述存储器存储的计算机执行指令,使得所述处理器执行如权利要求1-10中任一项所述的方法。The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 10. 12.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序或指令,当所述计算机程序或指令被运行时,实现如权利要求1-10中任一项所述的方法。12. A computer-readable storage medium, characterized in that a computer program or instruction is stored in the computer-readable storage medium, and when the computer program or instruction is executed, the method according to any one of claims 1 to 10 is implemented. 13.一种计算机程序产品,包括计算机程序或指令,其特征在于,所述计算机程序或指令被处理器执行时,实现如权利要求1-10中任一项所述的方法。13. A computer program product, comprising a computer program or an instruction, wherein when the computer program or the instruction is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
CN202310481771.6A 2022-04-12 2022-04-12 Device identification method and related device Active CN116909474B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310481771.6A CN116909474B (en) 2022-04-12 2022-04-12 Device identification method and related device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310481771.6A CN116909474B (en) 2022-04-12 2022-04-12 Device identification method and related device
CN202210380036.1A CN114780029B (en) 2022-04-12 2022-04-12 Device identification method and related device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202210380036.1A Division CN114780029B (en) 2022-04-12 2022-04-12 Device identification method and related device

Publications (2)

Publication Number Publication Date
CN116909474A CN116909474A (en) 2023-10-20
CN116909474B true CN116909474B (en) 2024-07-02

Family

ID=82429638

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210380036.1A Active CN114780029B (en) 2022-04-12 2022-04-12 Device identification method and related device
CN202310481771.6A Active CN116909474B (en) 2022-04-12 2022-04-12 Device identification method and related device

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202210380036.1A Active CN114780029B (en) 2022-04-12 2022-04-12 Device identification method and related device

Country Status (2)

Country Link
CN (2) CN114780029B (en)
WO (1) WO2023197709A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780029B (en) * 2022-04-12 2023-05-09 荣耀终端有限公司 Device identification method and related device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101493755A (en) * 2009-02-27 2009-07-29 武汉中岩科技有限公司 Method for simultaneously reading and writing memory and data acquisition unit
CN106126447A (en) * 2015-05-07 2016-11-16 三星电子株式会社 Control the storage method of device, memory module and storage system

Family Cites Families (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4313162A (en) * 1979-12-14 1982-01-26 Burroughs Corporation I/O Subsystem using data link processors
US5938742A (en) * 1995-08-18 1999-08-17 General Magic, Inc. Method for configuring an intelligent low power serial bus
EP0901081B1 (en) * 1997-07-08 2010-04-07 Texas Instruments Inc. A digital signal processor with peripheral devices and external interfaces
US8596529B1 (en) * 2001-03-26 2013-12-03 Usa Technologies, Inc. Interactive interface effectuated vending
JP2004334410A (en) * 2003-05-06 2004-11-25 Hitachi Ltd Information processing apparatus and processor
JP4463658B2 (en) * 2004-10-28 2010-05-19 日本電産サンキョー株式会社 Subordinate apparatus of information processing system, operation control program for subordinate apparatus, and operation control method for subordinate apparatus
CN100472440C (en) * 2005-11-09 2009-03-25 中兴通讯股份有限公司 A method for hardware drive program of intelligent loading mobile phone
CN201063161Y (en) * 2007-06-08 2008-05-21 威盛电子股份有限公司 Serial peripheral interface host device
US7425843B1 (en) * 2007-08-07 2008-09-16 Xilinx, Inc. Programmable logic device multi-boot state machine for serial peripheral interface (SPI) programmable read only memory (PROM)
DE102010029349A1 (en) * 2010-05-27 2011-12-01 Robert Bosch Gmbh Control unit for exchanging data with a peripheral unit, peripheral unit, and method for data exchange
US8825908B2 (en) * 2010-06-15 2014-09-02 Intel Mobile Communications GmbH Method of identifying devices on a bus and apparatus
US9547607B2 (en) * 2013-06-27 2017-01-17 Microsoft Technology Licensing, Llc Brokering application access for peripheral devices
KR102224156B1 (en) * 2014-04-02 2021-03-08 엘지전자 주식회사 Mobile terminal and method for controlling the same
KR102128406B1 (en) * 2014-09-26 2020-07-10 삼성전자주식회사 Storage device and operating emthod of storage device
CN105388805B (en) * 2015-11-01 2018-04-06 四川泛华航空仪表电器有限公司 Measurement and Control System based on spi bus
CN106982246A (en) * 2017-02-21 2017-07-25 普奥云信息科技(北京)有限公司 Smart machine
CN108052094B (en) * 2017-12-20 2021-01-15 深圳市英威腾电气股份有限公司 Expansion card identification method and device and frequency converter
US10360164B1 (en) * 2018-01-19 2019-07-23 Microchip Technology Incorporated Direct memory access adapter
CN109656841B (en) * 2018-11-16 2020-08-04 武汉精立电子技术有限公司 Hybrid control method and device based on software simulation I2C and hardware I2C
KR20210045241A (en) * 2019-10-16 2021-04-26 삼성전자주식회사 Electronic device and method for sharing voice command thereof
CN112783564B (en) * 2019-11-01 2023-03-03 华为技术有限公司 Method for accelerating starting of application program and electronic equipment
CN110958602A (en) * 2019-11-14 2020-04-03 深圳奇未智能科技有限公司 Firmware compatibility method and device for Bluetooth equipment
CN112181739B (en) * 2020-09-03 2023-08-08 博流智能科技(南京)有限公司 System bus test system and method
CN114780029B (en) * 2022-04-12 2023-05-09 荣耀终端有限公司 Device identification method and related device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101493755A (en) * 2009-02-27 2009-07-29 武汉中岩科技有限公司 Method for simultaneously reading and writing memory and data acquisition unit
CN106126447A (en) * 2015-05-07 2016-11-16 三星电子株式会社 Control the storage method of device, memory module and storage system

Also Published As

Publication number Publication date
CN114780029A (en) 2022-07-22
WO2023197709A1 (en) 2023-10-19
CN116909474A (en) 2023-10-20
CN114780029B (en) 2023-05-09

Similar Documents

Publication Publication Date Title
WO2021213120A1 (en) Screen projection method and apparatus, and electronic device
CN110347269B (en) Empty mouse mode realization method and related equipment
CN112399390B (en) Bluetooth connection method and related device
CN112395894B (en) Communication method and device based on NFC
CN113498124B (en) SIM card and eSIM card switching method and electronic equipment
CN111262975A (en) Bright screen control method and electronic equipment
CN112468979B (en) SIM card drop recovery method of electronic equipment and electronic equipment
CN112751954A (en) Operation prompting method and electronic equipment
CN114125793A (en) Bluetooth data transmission method and related device
CN113704205A (en) Log storage method, chip, electronic device and readable storage medium
CN111492678B (en) A file transmission method and electronic device
CN114880251A (en) Access method and access device of storage unit and terminal equipment
CN115589051B (en) Charging method and terminal equipment
CN113504887A (en) Volume setting method and electronic equipment
CN117708009A (en) A signal transmission method and electronic equipment
CN113901485B (en) Application program loading method, electronic device and storage medium
CN116909474B (en) Device identification method and related device
CN110806994B (en) Signal transmission method and device
WO2025030874A1 (en) Bus monitoring and control method, electronic device, chip and storage medium
CN114077519A (en) System service recovery method and device and electronic equipment
CN117130975B (en) Bus interface expansion method and related equipment
CN114089902A (en) Gesture interaction method and device and terminal equipment
CN114690849A (en) Clock skew determination method, device and storage medium
CN114116610A (en) Method, device, electronic equipment and medium for acquiring storage information
CN117234351B (en) Touch processing method, terminal equipment and storage medium

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
GR01 Patent grant
CP03 Change of name, title or address

Address after: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Patentee after: Honor Terminal Co.,Ltd.

Country or region after: China

Address before: 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong

Patentee before: Honor Device Co.,Ltd.

Country or region before: China