WO2023116130A1 - 键盘扫描电路、键盘按键识别方法、芯片和键盘 - Google Patents

键盘扫描电路、键盘按键识别方法、芯片和键盘 Download PDF

Info

Publication number
WO2023116130A1
WO2023116130A1 PCT/CN2022/124481 CN2022124481W WO2023116130A1 WO 2023116130 A1 WO2023116130 A1 WO 2023116130A1 CN 2022124481 W CN2022124481 W CN 2022124481W WO 2023116130 A1 WO2023116130 A1 WO 2023116130A1
Authority
WO
WIPO (PCT)
Prior art keywords
keyboard
key
current
scanning
state
Prior art date
Application number
PCT/CN2022/124481
Other languages
English (en)
French (fr)
Inventor
布恩辉
欧阳帆
杨丽宁
Original Assignee
西安芯海微电子科技有限公司
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 西安芯海微电子科技有限公司 filed Critical 西安芯海微电子科技有限公司
Publication of WO2023116130A1 publication Critical patent/WO2023116130A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M11/00Coding in connection with keyboards or like devices, i.e. coding of the position of operated keys
    • H03M11/20Dynamic coding, i.e. by key scanning

Definitions

  • the present application relates to the technical field of keyboards, in particular to a keyboard scanning circuit, a keyboard key recognition method, a chip and a keyboard.
  • Embodiments of the present application provide a keyboard scanning circuit, a keyboard key recognition method, a chip, and a keyboard, so as to solve the problem of low operating efficiency caused by using a keyboard MCU for key scanning and key recognition.
  • the application provides a keyboard scanning circuit, including:
  • the key value detection circuit is connected to the keyboard scanning input interface, and is used to collect the first level state corresponding to the keyboard scanning input interface;
  • a state machine jump circuit is connected to the key value detection circuit for outputting the current keyboard state
  • the output decoding circuit is connected with the key value detection circuit, the state machine jump circuit and the keyboard scanning output interface, and is used for when the current keyboard state is an idle state and the first level state is from a high power state. When the level jumps to a low level, it controls the keyboard scan output interface to scan the keys;
  • the key value detection circuit is also used to collect the second level state corresponding to the keyboard scanning input interface after controlling the keyboard scanning output interface to perform key scanning;
  • the output decoding circuit is also used to perform key recognition according to the second level state.
  • An embodiment of the present application provides a keyboard key recognition method, including:
  • An embodiment of the present application provides a chip, including the above-mentioned keyboard scanning circuit.
  • the present application provides a keyboard, which includes keyboard keys and a keyboard MCU, and also includes the above-mentioned keyboard scanning circuit, and the keyboard scanning circuit is connected with the keyboard keys and the keyboard MCU.
  • the keyboard scanning output interface is controlled to press the key Scanning, on the one hand, can ensure that only when there is a keyboard key being pressed, key scanning will be performed, so as to avoid that the current keyboard state is idle state and the first level state is jumping from high level to When the condition of low level triggers key scanning, it can save system power consumption and improve circuit reliability.
  • the output decoding circuit to control the keyboard scanning output interface to scan the keys, and complete the key identification according to the second level state corresponding to the keyboard scanning input interface, so as to realize the hardware device using the keyboard scanning circuit to complete key scanning and key pressing
  • the identification process enables the keyboard scanning circuit to be applied to the keyboard without occupying the CPU resources of the keyboard MCU, which helps to ensure the operating efficiency of the keyboard MCU.
  • Fig. 1 is a schematic circuit diagram of a keyboard scanning circuit in an embodiment of the present application
  • Fig. 2 is another schematic circuit diagram of the keyboard scanning circuit in an embodiment of the present application.
  • Fig. 3 is another schematic circuit diagram of the keyboard scanning circuit in an embodiment of the present application.
  • Fig. 4 is another schematic circuit diagram of the keyboard scanning circuit in an embodiment of the present application.
  • Fig. 5 is another schematic circuit diagram of the keyboard scanning circuit in an embodiment of the present application.
  • Fig. 6 is another schematic circuit diagram of the keyboard scanning circuit in an embodiment of the present application.
  • Fig. 7 is a timing diagram when the keyboard scanning circuit works in an embodiment of the present application.
  • Fig. 8 is a flow chart of the keyboard key recognition method in an embodiment of the present application.
  • FIG. 9 is another flow chart of a keyboard key recognition method in an embodiment of the present application.
  • Fig. 10 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 11 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 12 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 13 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 14 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 15 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 16 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • Fig. 17 is another flow chart of the keyboard key recognition method in an embodiment of the present application.
  • FIG. 18 is another flow chart of a keyboard key recognition method in an embodiment of the present application.
  • FIG. 19 is another flow chart of a keyboard key recognition method in an embodiment of the present application.
  • FIG. 20 is another flowchart of a keyboard key recognition method in an embodiment of the present application.
  • FIG. 21 is another flow chart of a keyboard key recognition method in an embodiment of the present application.
  • Spatial terms such as “below”, “under”, “beneath”, “below”, “above”, “above”, etc., may be used herein for convenience of description The relationship of one element or feature to other elements or features shown in the figures is thus described. It will be understood that the spatially relative terms are intended to encompass different orientations of the device in use and operation in addition to the orientation depicted in the figures. For example, if the device in the figures is turned over, elements or features described as “below” or “beneath” or “beneath” other elements or features would then be oriented “above” the other elements or features. Thus, the exemplary terms “below” and “beneath” can encompass both an orientation of above and below. The device may be otherwise oriented (rotated 90 degrees or at other orientations) and the spatial descriptors used herein interpreted accordingly.
  • the keyboard scanning circuit includes:
  • the key value detection circuit is connected with the keyboard scanning input interface, and is used to collect the first level state corresponding to the keyboard scanning input interface;
  • the state machine jump circuit is connected with the key value detection circuit and is used to output the current keyboard state
  • the output decoding circuit is connected with the key value detection circuit, the state machine jump circuit and the keyboard scanning output interface, and is used for when the current keyboard state is an idle state and the first level state is jumping from high level to low level, Control the keyboard scanning output interface for key scanning;
  • the key value detection circuit is also used to collect the second level state corresponding to the keyboard scanning input interface after controlling the keyboard scanning output interface to perform key scanning;
  • the output decoding circuit is also used to perform key recognition according to the second level state.
  • keyboard scan input interface (Keyboard Scan Input, hereinafter referred to as KSI) is an input interface connected with keyboard keys, for example, KSI eight-way parallel input can be used.
  • the key value detecting circuit is a circuit connected with the keyboard scanning input interface and used for detecting the level state of the keyboard scanning input interface.
  • the key value detection circuit collects that the level state of the keyboard scanning input interface is low level; otherwise, if the keyboard key is not pressed, the key value detection circuit collects The level state to the keyboard scan input interface is high level.
  • the first level state refers to the level state of the keyboard scanning input interface collected before the key scanning is performed.
  • the second level state refers to the level state of the keyboard scanning input interface collected after the key scanning is performed.
  • the state machine jump circuit is a circuit used to jump between the two states of the keyboard key being pressed and not being pressed.
  • the current keyboard state is used to reflect whether a keyboard key has been pressed before the current moment.
  • the current key state can be an idle state and a pressed state, where the idle state refers to a state in which no keyboard key is pressed, and the pressed state refers to a state in which a keyboard key is pressed.
  • the output decoding circuit is a circuit for realizing key scanning output and key recognition processing.
  • the keyboard scanning circuit realizes the key recognition process as follows:
  • the key value detection circuit connected to the keyboard scanning input interface needs to collect the first level state corresponding to the keyboard scanning input interface in real time.
  • the first level state collected by the key value detection circuit The level state is high level; at the moment when a keyboard key is pressed, the first level state collected by the key value detection circuit is a transition from high level to low level. Understandably, the key value detection circuit collects a first level state every unit time. If the two first level states collected at two moments before and after are sequentially high level and low level, that is, the key value detection circuit successively It is detected that the keyboard scan input interface is at high level and low level, and when the transition from high level to low level is realized, it can be determined that there is a keyboard key being pressed.
  • the state machine jump circuit needs to obtain the current keyboard state corresponding to the current time T1.
  • the current keyboard state can reflect whether a keyboard button is pressed before the current time T1. For example, it can reflect the previous state before the current time T1. Whether a keyboard key is pressed at time T0. Specifically, it may be an idle state or a pressed state.
  • the output decoding circuit can obtain the first level state collected by the key value detection circuit in real time and the current keyboard state corresponding to the state machine jump circuit.
  • the current keyboard state is idle, it means that there is no keyboard key in T0 at the last moment Pressed, that is to say, the first level state collected by T0 at the last moment is high level; when the first level state is transitioned from high level to low level, it means that the state collected by T0 at the last moment
  • the first level state obtained is high level, and the first level state collected by T1 at the current moment is low level, that is, the keyboard scanning input interface jumps from high level to low level, indicating that there are keyboard keys in the current state.
  • Time T1 is pressed; therefore, when the current keyboard state is idle and the first level state is a jump from high level to low level, it can be determined that a certain keyboard key is pressed at the current time T1.
  • It is necessary to control the keyboard scan output interface to scan the keys that is, to control the keyboard scan output interface to output different levels according to specific rules to realize the key scan. For example, control all the keyboard scan output interfaces to output low levels in turn to complete the scanning of all keyboard keys , so as to complete key recognition according to the second level state collected by the key value detection circuit.
  • the state machine jump circuit is also connected with the key value detection circuit to obtain the first level state collected by the key value detection circuit in real time, the current keyboard state is idle state, and the first level state is from high level When it jumps to a low level, it can update its current keyboard state to the pressed state.
  • each keyboard scanning output interface is matched with a keyboard scanning input interface, corresponding to the same keyboard key, for example, any keyboard key A, which is connected to the keyboard scanning circuit through the keyboard scanning input interface and the keyboard scanning output interface, so as to Ensure normal signal transmission.
  • the output decoding circuit is also used to receive the second level state corresponding to the keyboard scanning input interface collected by the key value detection circuit in real time after controlling the keyboard scanning output interface to perform key scanning, so that according to the second level state, Complete key recognition.
  • the S keyboard scan output interfaces it is necessary to control the S keyboard scan output interfaces to output low levels in turn, so that the second level state corresponding to the keyboard scan output interface corresponding to each keyboard scan output interface , to determine which keyboard key is pressed, so as to identify the key value corresponding to the pressed keyboard key.
  • the output decoding circuit when controlling the keyboard scanning output interface to perform key scanning specifically to control all keyboard scanning output interfaces to output low levels, after the output decoding circuit controls the keyboard scanning output interface KSOi corresponding to the ith keyboard key to output a low level, it can Collect the second level state corresponding to the keyboard scan output interface KSIi corresponding to the keyboard scan output interface KSOi, and determine whether the i-th keyboard key is pressed according to the second level state. For example, when the second level state is low level, it is determined that the i-th keyboard key is pressed; when the second level state is high level, it is determined that the i-th keyboard key is not pressed, so as to identify the i-th The key value corresponding to each keyboard key.
  • the keyboard scanning circuit provided by this embodiment only controls the keyboard scanning output interface to perform key scanning when the current keyboard state is idle and the first level state jumps from high level to low level. On the one hand, it can ensure Only when a keyboard key is pressed, the key scan will be executed to avoid triggering the key scan when the condition that the current keyboard state is idle and the first level state is a transition from high level to low level is not met. , can save system power consumption and improve circuit reliability.
  • the keyboard scanning circuit also includes a basic counter, an output change counter and a number of scan counter;
  • the basic counter is used to update the current basic value as the target basic value when receiving the target clock edge, and control the current basic value to be cleared when the output decoding circuit controls the keyboard scanning output interface to perform key scanning;
  • the output change counter is connected to the basic counter, and is used to update the current number of changes when the current basic value is cleared. If the current number of changes reaches the target number of keys, the current number of changes is controlled to be cleared;
  • the number of scans counter is connected to the output change counter, and is used to update the current number of scans when the current number of changes is detected to be cleared. If the current number of scans reaches the target number of scans, the current number of scans is controlled to be cleared;
  • the output decoding circuit is connected with the basic counter, the output change counter and the scan times counter, and is used to complete key scanning and key recognition according to the current basic value, the current change times and the current scan times.
  • the basic counter is arranged in the keyboard scanning circuit and is used for recording when controlling the keyboard scanning output interface to perform key scanning, the counter of the level change of each keyboard scanning output interface, for example, it can be used to record whether each keyboard scanning output interface A counter that outputs a low level.
  • the target clock edge is a pre-set clock edge that can control the keyboard scan output interface to scan keys, specifically the clock edge that controls the keyboard scan output interface to output a low level change, for example, the target clock edge can be a falling edge.
  • the target base value is a preset base value, which can be set to 1.
  • the basic counter is connected to the clock bus and can receive the current clock edge sent by the clock bus in real time.
  • the basic counter is first triggered to start counting, and the current basic value is updated to be the target basic value, that is, the current basic value is changed from 0 to becomes 1.
  • the output decoding circuit can control the keyboard scanning output interface to perform key scanning, specifically, the output decoding circuit can control the keyboard scanning output interface corresponding to the i-th keyboard key Output low level, specifically during each scan control process, the output decoding circuit can control all keyboard scan output interfaces to be pulled high or all pulled low to realize keyboard scan operation.
  • the key value detection circuit can be made to collect the second level state corresponding to the keyboard scan input interface, so that subsequently according to the collected second level state, Complete key recognition.
  • the basic counter monitors that the output decoding circuit controls the keyboard scan output interface to scan the keys, that is, after controlling the keyboard scan output interface to output a low level, it needs to control the current basic value to be cleared, that is, the current basic value is changed from 1 to 0 , so that when the target clock edge is received next time, the current basic value can be changed from 0 to 1, and then based on the current basic value, the keyboard scan output interface is controlled to output a low level, thereby ensuring the reliability of the keyboard scan circuit.
  • the output change counter is a counter arranged in the keyboard scanning circuit for recording the number of key scans completed by the keyboard scanning output interface, specifically for recording the number of low-level output of the keyboard scanning output interface during this scanning process.
  • the current number of changes refers to the number of changes recorded by the output change counter at the current moment, which can be used to reflect the progress of each key scan, that is, how many keyboard keys have been scanned during each key scan.
  • the current number of changes can be Set to N1.
  • the target number of keys refers to the preset number of keyboard keys to be scanned during each key scanning process, and the target number of keys can be set to N.
  • the output change counter is connected to the basic counter, which can monitor whether the current basic value in the basic counter is cleared in real time.
  • the number of scans counter is a counter set in the keyboard scanning circuit for recording how many scans have been completed.
  • the current number of scans refers to the completed number of scans recorded by the scan number counter at the current moment, and the current change number can be set as M1.
  • the target number of scans is preset and used to control the number of scans required for each button scan, and the target number of scans can be set to M.
  • the number of scans counter is connected to the output change counter, which can monitor in real time whether the current number of changes in the output change counter is cleared.
  • the current number of scans can be cleared, so that the next time the current keyboard state is idle and the first level state is jumping from high level to low level, the key scanning can be performed again. Thereby ensuring the reliability of the keyboard scanning circuit. Understandably, if the current number of scans M1 does not reach the target number of scans M (that is, M1 ⁇ M), it is necessary to continue monitoring whether the current number of changes in the output change counter is cleared to zero.
  • the output decoding circuit is connected with the basic counter, the output change counter and the scan count counter, and is used to complete key scanning and key recognition according to the current basic value, the current change count and the current scan count.
  • the output decoding circuit can control the keyboard scanning output interface to output a low level according to the change of the current basic value to complete key scanning; it can also complete key recognition according to the current number of changes and the current number of scans.
  • the counters of the basic counter, the output change counter and the number of scan counters are used to count according to the received target clock edge, so that the output decoding circuit changes according to the values in different counters, Complete key scanning and key recognition for all keyboard keys, so that when the keyboard scanning circuit is applied to the keyboard, it does not need to occupy the CPU resources of the keyboard MCU, which helps to ensure the operating efficiency of the keyboard MCU.
  • the output decoding circuit is also used to control the keyboard scanning output interface to output a low level when the current basic value is monitored as the target basic value, so as to realize key scanning;
  • the output decoding circuit is also used to obtain the second level state corresponding to the number of target keys when the current number of changes is detected to be cleared, and to obtain the single scan result corresponding to the current number of scans according to all second level states ;
  • the output decoding circuit is also used to obtain a single scan result corresponding to the target scan count when the current scan count is cleared, and obtain a key recognition result based on all single scan results.
  • the output decoding circuit is connected to the basic counter.
  • the output decoding circuit detects that the current basic value recorded by the basic counter is the target basic value, it needs to control the keyboard scanning output interface to output a low level, so that the key value
  • the detection circuit collects the second level state corresponding to the keyboard scanning input interface. That is, every time the current basic value of the basic counter changes from 0 to 1, the output decoding circuit needs to control the keyboard scanning output interface to output a low level to realize scanning a keyboard key.
  • the key value detection circuit can collect to the second level state corresponding to the keyboard scan input interface matching the keyboard scan output interface, and feed back the second level state to the output decoding circuit.
  • the output decoding circuit is connected to the output change counter, and the output decoding circuit can determine that the keyboard keys corresponding to the target number N of keys have completed this scan when the output change counter is heard to be cleared. , it is necessary to obtain the current number of scans recorded by the number of scans counter.
  • the single-scan key value refers to the key value identified in this scan.
  • the output decoding circuit is connected to the number of scans counter.
  • the output decoding circuit detects that the current number of scans is cleared, it can be determined that the scanning operation matching the target number of scans M has been completed.
  • the final key recognition is completed, that is, according to the M single scan results, it is determined whether there is a valid key, and if there is a valid key, the current valid key value corresponding to the valid key is obtained.
  • the effective key here refers to the key that is determined to be pressed through key scanning, that is, the key that is pressed to trigger the key behavior that the first level state is to jump from high level to low level.
  • the current valid key value refers to the key value corresponding to the valid key.
  • the output decoding circuit can control the keyboard scanning output interface to output a low level according to the current basic value to realize key scanning, and realize key recognition according to the current number of changes and the current number of scans, so that When the keyboard scanning circuit is applied to the keyboard, it does not need to occupy the CPU resources of the keyboard MCU, which helps to ensure the operating efficiency of the keyboard MCU.
  • the output decoding circuit is also used to obtain the second level state corresponding to the target button number when the current number of changes is detected to be cleared; if all the second level states are high , the single-scan result that is invalid for the single-scan is obtained; if there is a second level state that is low, the single-scan result that is valid for the single-scan is obtained.
  • the output decoding circuit detects that the current number of changes is cleared each time, that is, when a key scan is completed, it needs to perform a key recognition process according to the second level state corresponding to the keyboard scan input interface output by the key value detection circuit. Specifically include the following steps:
  • the output decoding circuit can determine that this scan has been completed for the N keyboard keys when the current change times of the output change counter is cleared each time, and can obtain the corresponding keyboard scanning input interface corresponding to the N keyboard keys.
  • the second level state, the second level state can be high level or low level.
  • the output decoding circuit determines that none of the N keyboard keys has been pressed during this scanning process, and then determines that this scanning behavior is an invalid behavior , therefore, a single-scan result that is invalid for a single-scan can be obtained.
  • the output decoding circuit detects that the current number of changes is cleared each time, and the result of a single scan is that a single scan is invalid, it is determined that this scanning behavior is an invalid behavior, and the button recognition that a single scan is invalid can be directly output. As a result, the button scanning and button recognition process can be ended without waiting until the current number of scans is cleared, which helps save waiting time, simplifies the processing flow, and improves processing efficiency.
  • the output decoding circuit can determine the key identification whose second level state is low level as the target key identification; and then determine the single scan key value corresponding to the target key identification according to the target key identification.
  • the button identifier is an identifier used to uniquely identify a certain keyboard button.
  • the keyboard scan output interface and the keyboard scan input interface corresponding to each keyboard button both carry a button identifier, so that each collected second The level status also carries the button identification.
  • the target key identification here refers to the key identification corresponding to the collected second level state being low level.
  • the key value of a single scan here refers to the key value of the key determined by this scan identification.
  • the output decoding circuit is also used to output the key recognition result of a single scanning invalid when there is a single scanning result that is invalid for a single scanning; when all the single scanning results are When a single scan is valid, obtain the single-scan key value corresponding to the target scan times, and obtain the button recognition result based on all single-scan key values.
  • the current effective key value is a key value of a key identified for a key action.
  • the output decoding circuit completes a single scan operation corresponding to the current scan count each time it hears that the current scan count is cleared to obtain a single scan result corresponding to the target scan count.
  • M M single scan results can be obtained, and each single scan result can be valid or invalid for a single scan. Therefore, the output decoding circuit can perform the following according to all single scan results One operation:
  • the output decoding circuit When the output decoding circuit has a single-scanning result that is a single-scanning invalid, it outputs a single-scanning invalid key recognition result.
  • the output decoding circuit obtains the single-scan key value corresponding to the target scan times when all the single-scan results are valid, and obtains the button recognition result based on all the single-scan key values.
  • the output decoding circuit can obtain the single-scan key value identified by each scan, and can obtain M single-scan key values, because The M single-scan key values may or may not be the same. Therefore, it is necessary to perform comparative analysis based on all single-scan results to determine the final button recognition result, thereby ensuring the accuracy of the button recognition result.
  • the output decoding circuit is also used to output the invalid key recognition result of a single scan when there are different key values in a single scan; when all the key values in a single scan are the same, Key value, determine the current valid key value, and output the key recognition result including the current valid key value.
  • the output decoding circuit can obtain M single-scan key values when all M single-scan results are valid for a single scan, and the M single-scan key values can be the same or different, so the output The decoding circuit can perform one of the following operations according to all single-scan key values.
  • the output decoding circuit After the output decoding circuit obtains M single-scanning key values, it needs to determine whether the M single-scanning key values are the same. If there are different single-scanning key values, it cannot be determined which valid key corresponds to Key value, therefore, can output a key recognition result that is invalid for a single scan.
  • the output decoding circuit After the output decoding circuit obtains the M single-scanning key values, it needs to judge whether the M single-scanning key values are the same. If all the single-scanning key values are the same, the single-scanning key value is determined as The current valid key value, output the key recognition result including the current valid key value, to ensure the accuracy of the current valid key value. Understandably, when the target number of scans is 1, only one single scan key is obtained, and the current scan key can be directly determined as the current valid key.
  • the output decoding circuit is also used to determine the historical valid key value when the key recognition result contains the current valid key value, and obtain the key interval duration corresponding to the current valid key value and the historical valid key value; The key-press interval time and the current effective key value determine the target effective key value.
  • the target effective key value refers to the finally recognized key key value.
  • the output decoding circuit when the key recognition result is valid, the output decoding circuit will output a current valid key value each time the key is scanned, because there are still combinations of keys in the current keyboard recognition process, for example, Ctrl+ on the computer keyboard The combination of C is the copied shortcut command, therefore, the output decoding circuit also needs to perform the following operations after identifying and obtaining the key recognition result containing the current valid key value to determine the final target valid key value:
  • the output decoding circuit needs to obtain the historical valid key value corresponding to the current valid key value.
  • the current valid key value here can be understood as the key value of the keyboard key scanned and recognized at the current moment.
  • the historical effective key value can be understood as the key value of the keyboard key scanned and recognized at the historical time before the current time.
  • the output decoding circuit determines the current effective key value and the historical effective key value, it needs to obtain the current key value generation time corresponding to the current effective key value and the historical key value generation time corresponding to the historical effective key value respectively, and convert the current key value generation time
  • the time difference between the generation time of the historical key value and the generation time of the historical key value is determined as the key-press interval time.
  • the key-press interval can be understood as a time difference between the generation times of two valid key values.
  • the key interval time is the time difference between the current key value generation time and the historical key value generation time corresponding to the historical effective key value; when the historical effective key value is at least two, the key press interval
  • the interval length is the time difference between the generation time of the current key value and the generation time of the historical key value corresponding to the earliest historical valid key value.
  • the output decoding circuit After the output decoding circuit obtains the key-press interval time, it needs to compare the key-press interval time with the target time-length threshold, so as to compare the result according to the time length, and evaluate whether the current effective key value and the historical effective key value are possible according to the time-length comparison result To combine keys to obtain the final target effective key value, so as to ensure the accuracy of identifying the target effective key value.
  • the target duration threshold here is a preset duration threshold used to evaluate whether the combination key condition is satisfied.
  • the output decoding circuit is also used to determine the current effective key value as the target effective key value when the key interval time is greater than the target time length threshold; Key value and historical effective key value, judge whether the button combination rule is satisfied, obtain the combination judgment result, and determine the target effective key value according to the combination judgment result.
  • the output decoding circuit After the output decoding circuit obtains the key-press interval time, it needs to compare the key-press interval time with the target time-length threshold.
  • the interval between keystrokes is too long, and it is basically impossible to be a combination of keystrokes, that is, it is determined that the current effective key value is likely to be a single keystroke, and the current effective key value is determined as the target effective key value.
  • Ts>Tm it is determined that the user presses
  • C can be determined as the target valid key value.
  • the output decoding circuit After the output decoding circuit obtains the key-press interval time, it needs to compare the key-press interval time with the target time-length threshold.
  • the interval between keystrokes is small, and it may be a combination key.
  • the effective key value and the historical effective key value are combined keys, so as to obtain the final target effective key value, so as to ensure the accuracy of target effective key value identification.
  • the key combination rule here is a pre-configured rule used to reflect different key combinations so that it can complete specific function control.
  • the output decoding circuit is also used to determine the target effective key value according to the current effective key value and the historical effective key value when the combination judgment result satisfies the button combination rule; When combining rules, the current effective key value is determined as the target effective key value.
  • the output decoding circuit judges whether the key combination rule is satisfied based on the current effective key value and the historical effective key value.
  • the effective key value can form a combination key
  • the target effective key value can be determined based on the combination of the current effective key value and the historical effective key value, so as to generate a corresponding target control instruction based on the target effective key value.
  • the current valid key value is C
  • the historical valid key value is Ctrl
  • its Ctrl+C satisfies the copy combination rule of the key combination rule
  • Ctrl+C can be determined as the target valid key value.
  • the output decoding circuit judges whether the key combination rule is satisfied based on the current effective key value and the historical effective key value.
  • Historical effective key values cannot be combined to form a key, and the current effective key value can be determined as the target effective key value. For example, if the current valid key value is Ctrl, and the historical valid key value is C, which does not meet the key combination rules, C+Ctrl can be considered as not conforming to the key combination rules, and the current valid key value and historical valid key value can be determined to be a single key respectively , therefore, the current valid key value Ctrl' may be determined as the target valid key value.
  • the output decoding circuit can determine a single current valid key value as the target valid key value according to the comparison result of the key interval duration and the target duration threshold value and whether the key combination rule is met, or, based on the historical effective key value
  • the key value and the current effective key value determine the target effective key value, so as to ensure the accurate identification of the target effective key value and ensure the accuracy of function identification of the combination key.
  • the keyboard scanning circuit further includes a glitch detection circuit, and the glitch detection circuit is connected to the output decoding circuit;
  • the output decoding circuit is also used to obtain the glitch detection result with glitches if the current scan times correspond to the target scan times, if the single scan result corresponding to the current scan times is invalid for a single scan; if the current scan times correspond to If the single scan result is valid for a single scan, the glitch detection result without glitches is obtained;
  • the glitch detection circuit is used to output a glitch detection signal according to the glitch detection result.
  • the output decoding circuit is connected to the output change counter, and the output decoding circuit can determine that the keyboard keys corresponding to the target number N of keys have completed this scan when the output change counter is heard to be cleared. , the current number of scans can be updated. When the current number of scans is updated from 0 to 1, the second level state corresponding to the target number N of keys can be collected during this scan. The second level state of the current scan is determined to determine whether a valid key is recognized, so as to obtain the single scan result corresponding to the current scan times, that is, to obtain the first single scan result.
  • the result of the first single scan when the result of the first single scan is invalid, it means that there is a high probability of glitches on the keyboard, and the glitch detection results with glitches can be obtained; when the result of the first single scan is valid for a single scan, It shows that there is a high probability that there is no glitch on the keyboard, and the glitch detection result that does not exist is obtained.
  • the glitch detection result received by the glitch detection circuit includes two types: presence of glitch and absence of glitch, and the output glitch detection signal can be determined according to the glitch detection result, for example, glitch detection signal 1 can be used to indicate the presence of a glitch, The glitch detection signal 0 is used to indicate that there is no glitch, so that subsequent signal control can be performed according to the glitch detection signal, so as to avoid the impact of the glitch on the control of the keyboard keys.
  • the keyboard MCU can determine whether there is a glitch on the current keyboard key according to the glitch detection signal output by the glitch detection circuit, so as to perform subsequent signal control, thereby preventing the glitch from affecting the control of the keyboard key.
  • the output decoding circuit is also used to output the first update instruction to the state machine jump circuit when the current keyboard state is an idle state and the first level state is transitioned from high level to low level ;
  • the state machine jump circuit is also used to update the current keyboard state from the idle state to the pressed state according to the first update instruction
  • the output decoding circuit is also used to output the second update instruction to the state machine jump circuit when the result of a single scan is invalid for a single scan;
  • the state machine jump circuit is also used to update the current keyboard state from the pressed state to the idle state according to the second update instruction;
  • the output decoding circuit is also used to output the third update instruction to the state machine jump circuit after obtaining the key recognition result;
  • the state machine jump circuit is also used to update the current keyboard state from the pressed state to the idle state according to the third update instruction.
  • the output decoding circuit can form a first update instruction when the current keyboard state is an idle state and the first level state is a transition from high level to low level, and send the first update instruction to the state machine to jump Turn the circuit.
  • the first update instruction refers to the output decoding circuit used to control the state machine jump circuit to update the state when the current keyboard state is idle state and the first level state is jumping from high level to low level. instruction.
  • the state machine jump circuit in the idle state can update the current keyboard state from the idle state to the pressed state after receiving the first update instruction sent by the output decoding circuit to reflect that a keyboard key is being pressed at the current moment. Press, so that the current keyboard state of the output decoding circuit is the pressed state before the completion of the key scanning and key identification, so that the output decoding circuit will jump from high level when it receives the first level state at the next moment. Changing to a low level will not trigger new button scanning and button recognition, which will help ensure the normal operation of this button scanning and button recognition, thereby ensuring circuit reliability.
  • the state machine jump circuit is connected to the output decoding circuit, and the output decoding circuit can determine the result of a single scan according to all the collected second level states every time the current change times are cleared. , when the result of the single scan is that the single scan is invalid, a second update instruction can be formed, and the second update instruction can be sent to the state machine jump circuit.
  • the second update instruction refers to an instruction formed by the output decoding circuit for controlling the state machine jump circuit to update the state when the result of each single scan is invalid for a single scan.
  • the state machine jump circuit in the pressed state can update the current keyboard state from the pressed state to the idle state after receiving the second update instruction sent by the output decoding circuit, to reflect that no keyboard keys are pressed at the current moment. Press it, so that when the output decoding circuit receives the first level transition from high level to low level at the next moment, it will trigger a new button scan and button recognition, which helps to ensure the subsequent button scan and button Identify the normal operation, thereby ensuring the reliability of the circuit.
  • the state machine jump circuit is connected to the output decoding circuit.
  • the output decoding circuit can obtain the button identification according to the single scanning result corresponding to the target scanning number every time the output decoding circuit detects that the current scanning number is cleared.
  • a third update instruction can be formed, which is sent to the state machine jump circuit.
  • a third update command can be formed to control
  • the state machine jump circuit updates the state.
  • the third update instruction refers to an instruction formed by the output decoding circuit for controlling the state machine jump circuit to update the state after obtaining the key recognition result.
  • the state machine jump circuit in the pressed state can update the current keyboard state from the pressed state to the idle state after receiving the third update instruction sent by the output decoding circuit, to reflect that no keyboard keys are pressed at the current moment. Press it, so that when the output decoding circuit receives the first level transition from high level to low level at the next moment, it will trigger a new button scan and button recognition, which helps to ensure the subsequent button scan and button Identify the normal operation, thereby ensuring the reliability of the circuit.
  • the keyboard scanning circuit also includes a timeout detection circuit, the timeout detection circuit is connected with the output decoding circuit and the state machine jump circuit, and is used to generate an instruction corresponding to the target update instruction according to the current moment time, determine the waiting update duration; when the waiting update duration is greater than the timeout threshold, if the current keyboard state maintains the pressed state, a timeout reset signal is generated, and the timeout reset signal is output to the state machine jump circuit;
  • the state machine jump circuit is also used to update the current keyboard state from the pressed state to the idle state according to the timeout reset signal;
  • the target update instruction is the second update instruction or the third update instruction.
  • the target update instruction refers to an instruction used to control the state machine jump circuit to update the state, specifically an instruction used to control the state machine jump circuit to update from the pressed state to the idle state.
  • the target update instruction may be the second update instruction, or may be the third update instruction.
  • the command generation time refers to the time when the output decoding circuit generates the target update command.
  • the timeout threshold is a preset time threshold for evaluating whether the timeout standard is met.
  • the output decoding circuit when the output decoding circuit generates a target update command such as the second update command or the third update command, it may record the command generation time when the target update command is generated.
  • the timeout detection circuit After the timeout detection circuit detects that the output decoding circuit generates a target update instruction, it needs to obtain the instruction generation time, and then determine the time difference between the current time and the instruction generation time as the waiting update duration. The timeout detection circuit also needs to judge whether the waiting update time determined in real time reaches the timeout threshold. When the waiting update time reaches the timeout threshold, it needs to judge whether the current keyboard state has been updated from the pressed state to the idle state. If the current keyboard state is still pressed state, it means that the state machine jump circuit did not update the state in time according to the target update instruction. At this time, the timeout detection circuit needs to generate a timeout reset signal and send the timeout reset signal to the state machine jump circuit. Understandably, the timeout reset signal is an indication formed when the state machine jump circuit is not updated in time.
  • the state machine jump circuit can restore the current keyboard state from the pressed state to the default state, that is, update the pressed state to the idle state according to the timeout reset signal sent by the timeout detection circuit.
  • the timeout detection circuit can also send a timeout reset signal to other circuits such as the output decoding circuit, the key value detection circuit, the basic counter, the output change counter and the scan count counter, so that the state of other circuits can be restored to the default state, for example , so that the current basic value in the basic counter is cleared, the current number of changes in the output change counter is cleared, and the current number of scans in the scan number counter is cleared, etc., to ensure the reliability and anti-interference ability of the keyboard scanning circuit.
  • other circuits such as the output decoding circuit, the key value detection circuit, the basic counter, the output change counter and the scan count counter, so that the state of other circuits can be restored to the default state, for example , so that the current basic value in the basic counter is cleared, the current number of changes in the output change counter is cleared, and the current number of scans in the scan number counter is cleared, etc., to ensure the reliability and anti-interference ability of the keyboard scanning circuit.
  • the timeout detection circuit is used for timeout detection, and the state machine jump circuit is controlled to return to the default state according to the formed timeout reset signal, which can ensure the reliability and anti-interference ability of the keyboard scanning circuit.
  • the keyboard scanning circuit also includes an asynchronous reset circuit, which is connected with the state machine jump circuit and the key value detection circuit, and is used to update the current keyboard state from the pressed state to the idle state
  • the third level state corresponding to the keyboard scanning input interface is collected. If the third level state is a jump from high level to low level, an asynchronous reset signal is generated and the state machine jumps to the circuit Output asynchronous reset signal;
  • the state machine jump circuit is also used to reset the current keyboard state to the pressed state according to the asynchronous reset signal.
  • the asynchronous reset circuit is a circuit for realizing asynchronous reset and synchronous release.
  • the state machine jump circuit can be controlled to update the current keyboard state from the pressed state to the idle state.
  • the target update instruction refers to an instruction used to control the state machine jump circuit to update the state, specifically an instruction used to control the state machine jump circuit to update from the pressed state to the idle state.
  • the target update instruction may be the second update instruction, or may be the third update instruction.
  • the key value detection circuit acquires the key value corresponding to the keyboard scanning input interface. third level state. Understandably, at the moment when the current keyboard state is updated from the pressed state to the idle state, when the third level state jumps from high level to low level, the asynchronous reset circuit can generate an asynchronous reset signal and send the asynchronous reset signal to Send to the state machine jump circuit, so that the state machine jump circuit performs state reset.
  • the state machine jump circuit can reset the current keyboard state from the idle state to the pressed state according to the asynchronous reset signal sent by the asynchronous reset circuit. Understandably, the use of the asynchronous reset circuit to control the state machine jump circuit to perform asynchronous reset can ensure the reliability and anti-interference ability of the keyboard scanning circuit.
  • the keyboard scanning circuit further includes a turn jump control circuit, and the turn jump control circuit is connected to the output decoding circuit for outputting the first interval duration and the second interval duration to the output decoding circuit. interval length;
  • the output decoding circuit is used to control and control the keyboard scanning output interface to output a low level in turn according to the first interval duration and the second interval duration, so as to realize key scanning.
  • both the first interval duration and the second interval duration are preset durations, which can be set from 10us to 1ms.
  • the first interval length is specifically the interval length for controlling all keyboard scan output interfaces to be pulled high after a certain keyboard scan input interface is pulled low. For example, when the keyboard scan input interface KSI0 is pulled low, all keyboard scan output interfaces must be controlled to be pulled high after the first interval.
  • the second interval is the interval for controlling all keyboard scan output interfaces to output low levels in turn after all keyboard scan output interfaces are pulled high. For example, after all keyboard scan output interfaces are pulled high, after every second interval, all keyboard scan output interfaces need to be controlled to output low levels in turn to ensure that all keyboard scan output interfaces are not pulled high or low at the same time. occurs, thereby improving power integrity.
  • the default key scanning output interfaces KSO0-KSO15 are all low level. Assume that when the keyboard key corresponding to the key scanning output interface KSO0 and the keyboard scanning input interface KSI0 is pressed, the keyboard scanning input interface KSI0 is pulled low, and after every first interval Tgap1 (configurable, 1ms, 3ms, 5ms, 7ms, 9ms, 11ms), the key scan output interfaces KSO0-KSO15 are all pulled high.
  • the KSO low pulse signal (configurable duration, 15us, 20us, 25us, 30us) is generated in turn to realize the scanning control operation.
  • the key scan output interface KSO0 when the key scan output interface KSO0 is pulled low, it detects that the keyboard scan input interface KSI0 is low level, then the first scan identification is completed, and the single scan key value corresponding to the first scan identification is determined.
  • the second scan is started, and the single-scan key value corresponding to the second scan identification is obtained directly.
  • the target number of scans is two, if the two single-scan key values are consistent, the single-scan key value can be identified as the currently valid key value.
  • a keyboard key recognition method including:
  • S801 Collect the first level state corresponding to the keyboard scanning input interface
  • step S801 the key value detection circuit connected to the keyboard scanning input interface needs to collect the first level state corresponding to the keyboard scanning input interface in real time.
  • the key value detection circuit The collected first level state is high level; at the moment when a certain keyboard key is pressed, the first level state collected by the key value detection circuit is jumping from high level to low level. Understandably, the key value detection circuit collects a first level state every unit time.
  • the key value detection circuit If the two first level states collected at two moments before and after are sequentially high level and low level, that is, the key value detection circuit successively It is detected that the keyboard scan input interface is at high level and low level, and when the transition from high level to low level is realized, it can be determined that there is a keyboard key being pressed.
  • step S802 the current keyboard state output by the state machine jump circuit is acquired, and the current keyboard state can reflect the state of whether any keyboard key is pressed before the current time T1, for example, it can reflect the previous state of the keyboard key before the current time T1. Whether a keyboard key is pressed at a moment T0. Specifically, it may be an idle state or a pressed state.
  • the output decoding circuit is used to process the first level state collected by the key value detection circuit and the current keyboard state corresponding to the state machine jump circuit.
  • the current keyboard state is an idle state
  • the description above No keyboard key is pressed at T0 at a moment, that is to say, the first level state collected by T0 at the last moment is high level
  • the first level state collected by T1 at the current moment is low level, that is, the keyboard scanning input interface jumps from high level to low level
  • step S804 after the output decoding circuit controls the keyboard scanning output interface to perform key scanning (for example, after controlling all keyboard scanning output interfaces to output low levels in turn), the key value detection circuit needs to collect the keyboard scanning input in real time.
  • the second level state corresponding to the interface the second level state can be high level or low level.
  • each keyboard scanning output interface is matched with a keyboard scanning input interface, corresponding to the same keyboard key, for example, any keyboard key A, which is connected to the keyboard scanning circuit through the keyboard scanning input interface and the keyboard scanning output interface, so as to Ensure normal signal transmission.
  • step S805 after the output decoding circuit controls the keyboard scan output interface to perform key scanning, it receives the second level state corresponding to the keyboard scan input interface collected in real time by the key value detection circuit, so that In the flat state, the key recognition is completed.
  • the S keyboard scan output interfaces when there are S keyboard keys on the keyboard, it is necessary to control the S keyboard scan output interfaces to output low levels in turn, so that the second level state corresponding to the keyboard scan output interface corresponding to each keyboard scan output interface , to determine which keyboard key is pressed, so as to identify the key value corresponding to the pressed keyboard key.
  • the output decoding circuit when controlling the keyboard scanning output interface to perform key scanning specifically to control all keyboard scanning output interfaces to output low levels, after the output decoding circuit controls the keyboard scanning output interface KSOi corresponding to the ith keyboard key to output a low level, it can Collect the second level state corresponding to the keyboard scan output interface KSIi corresponding to the keyboard scan output interface KSOi, and determine whether the i-th keyboard key is pressed according to the second level state. For example, when the second level state is low level, it is determined that the i-th keyboard key is pressed; when the second level state is high level, it is determined that the i-th keyboard key is not pressed, so as to identify the i-th The key value corresponding to each keyboard key.
  • the keyboard scanning output interface is controlled to perform key scanning.
  • the key scan will only be performed when a keyboard key is pressed, and avoid triggering when the condition that the current keyboard state is idle and the first level state is a transition from high level to low level is not met Key scanning can save system power consumption and improve circuit reliability.
  • the keyboard scanning output interface By controlling the keyboard scanning output interface to perform key scanning, according to the second level state corresponding to the keyboard scanning input interface, the key recognition is completed, and the process of key scanning and key recognition can be completed, so that when the keyboard scanning circuit is applied to the keyboard, it does not need to occupy the MCU of the keyboard CPU resources help to ensure the operating efficiency of the keyboard MCU.
  • the keyboard key recognition method further includes:
  • S901 When receiving the target clock edge, update the current basic value as the target basic value, and control the current basic value to be cleared when the output decoding circuit controls the keyboard scanning output interface to perform key scanning;
  • S904 Complete key scanning and key identification according to the current basic value, the current number of changes and the current number of scans.
  • the basic counter is used to receive the current clock edge in real time.
  • the basic counter is first triggered to start counting, and the current basic value is updated to the target basic value, that is, the current basic value is changed from 0 to is 1.
  • the output decoding circuit can control the keyboard scanning output interface to perform key scanning, specifically, the output decoding circuit can control the keyboard scanning output interface corresponding to the i-th keyboard key Output low level, specifically during each scan control process, the output decoding circuit can control all keyboard scan output interfaces to be pulled high or all pulled low to realize keyboard scan operation.
  • the key value detection circuit can be made to collect the second level state corresponding to the keyboard scan input interface, so that subsequently according to the collected second level state, Complete key recognition.
  • the basic counter monitors that the output decoding circuit controls the keyboard scan output interface to scan the keys, that is, after controlling the keyboard scan output interface to output a low level, it needs to control the current basic value to be cleared, that is, the current basic value is changed from 1 to 0 , so that when the target clock edge is received next time, the current basic value can be changed from 0 to 1, and then based on the current basic value, the keyboard scan output interface is controlled to output a low level, thereby ensuring the reliability of the keyboard scan circuit.
  • the current number of scans can be cleared, so that the next time the current keyboard state is idle and the first level state is jumping from high level to low level, the key scanning can be performed again. Thereby ensuring the reliability of the keyboard scanning circuit. Understandably, if the current number of scans M1 does not reach the target number of scans M (that is, M1 ⁇ M), it is necessary to continue monitoring whether the current number of changes in the output change counter is cleared to zero.
  • the output decoding circuit is used to complete key scanning and key identification according to the current basic value, the current number of changes, and the current number of scans.
  • the output decoding circuit can control the keyboard scanning output interface to output a low level according to the change of the current basic value to complete key scanning; it can also complete key recognition according to the current number of changes and the current number of scans.
  • the current base number, the current number of changes, and the current number of scans can be updated according to the received target clock edge, so that the output decoding circuit can complete all the keyboard keys according to the value changes in different counters.
  • the keys are used for key scanning and key recognition, so that when the keyboard scanning circuit is applied to the keyboard, it does not need to occupy the CPU resources of the keyboard MCU, which helps to ensure the operating efficiency of the keyboard MCU.
  • step S904 that is, to complete button scanning and button recognition according to the current basic value, the current number of changes and the current number of scans, includes:
  • step S1001 the current basic value recorded by the basic counter is monitored by the output decoding circuit. Collect the second level state corresponding to the keyboard scanning input interface. That is, every time the current basic value of the basic counter changes from 0 to 1, the output decoding circuit needs to control the keyboard scanning output interface to output a low level to realize scanning a keyboard key. At this time, the key value detection circuit can collect to the second level state corresponding to the keyboard scan input interface matching the keyboard scan output interface, and feed back the second level state to the output decoding circuit.
  • the output decoding circuit is used to monitor the output change counter, and when the output change counter is heard to be cleared, it is determined that the keyboard keys corresponding to the target key number N have completed this scan.
  • the second level state corresponding to the target number N of keys collected during this scan can be determined according to the second level state corresponding to the target number N of keys Whether this scan recognizes a valid button to obtain the single scan result corresponding to the current scan times, that is, determine whether this scan is valid according to whether the N second level states are high or low to obtain a single scan Scanning is valid or single-scan invalid single-scan result, when the single-scan result is single-scan valid, you can also get the single-scan key value.
  • the single-scan key value refers to the key value identified in this scan.
  • the output decoding circuit is used to monitor the current number of scans to be cleared, and when the current number of scans is detected to be cleared, it is determined that the scan operation matching the target number of scans M has been completed. According to the acquired M single scans As a result, the final key recognition is completed, that is, according to the M single scan results, it is determined whether there is a valid key, and if there is a valid key, the current valid key value corresponding to the valid key is obtained.
  • the effective key here refers to the key that is determined to be pressed through key scanning, that is, the key that is pressed to trigger the key behavior that the first level state is to jump from high level to low level.
  • the current valid key value refers to the key value corresponding to the valid key.
  • the keyboard scanning output interface can be controlled to output a low level according to the current basic value to realize key scanning, and the key recognition can be realized according to the current number of changes and the current number of scans, so that the keyboard scanning circuit When it is applied to the keyboard, it does not need to occupy the CPU resources of the keyboard MCU, which helps to ensure the operating efficiency of the keyboard MCU.
  • step S1002 is to obtain the second level state corresponding to the target button number when it is detected that the current number of changes is cleared, and obtain the current level state according to all the second level states.
  • the single scan result corresponding to the number of scans including:
  • S1103 If there is a second level state that is at a low level, acquire a single scan result that is valid for a single scan.
  • step S1101 the output decoding circuit is used to monitor the current number of changes of the output change counter, and when the current number of changes of the output change counter is heard to be cleared, it is determined that the scanning of the N keyboard keys has been completed, and the obtained
  • the second level state corresponding to the keyboard scanning input interface corresponding to the N keyboard keys, the second level state can be high level or low level.
  • step S1102 the output decoding circuit is used to monitor the second level state corresponding to the N keyboard keys, and when the second level states corresponding to the N keyboard keys are all high, the N keyboard keys are determined None of them are pressed during this scanning process, and this scanning behavior is determined to be an invalid behavior. Therefore, a single scanning result that is invalid for a single scanning can be obtained.
  • the output decoding circuit detects that the current number of changes is cleared each time, and the result of a single scan is that a single scan is invalid, the scanning behavior of this scan is deemed to be invalid, and the button recognition of a single scan invalid can be directly output As a result, the button scanning and button recognition process can be ended without waiting until the current number of scans is cleared, which helps save waiting time, simplifies the processing flow, and improves processing efficiency.
  • step S1103 the output decoding circuit is used to monitor the second level state corresponding to N keyboard keys, and among the second level states corresponding to N keyboard keys, there is a second level state that is low power Usually, one of the N keyboard keys is determined to be in the pressed state during the current scanning process, and then the current scanning behavior is determined to be a valid behavior. Therefore, a single scanning result that is valid for a single scanning can be obtained.
  • step 1003 according to all single scanning results, key recognition results are obtained, including:
  • the current effective key value is a key value of a key identified for a key action.
  • the output decoding circuit completes the single scan operation corresponding to the current scan count every time it hears that the current scan count is cleared, and can obtain the single scan result corresponding to the target scan count.
  • the target scan count is M
  • M single scan results can be obtained, and each single scan result can be valid or invalid for a single scan, therefore, the output decoding circuit can perform one of the following operations according to all single scan results:
  • the output decoding circuit outputs a single-scan invalid key recognition result when there is a single-scan invalid result.
  • the output decoding circuit when any of the M single-scan results in the output decoding circuit is single-scan invalid, it is determined that the corresponding single-scan key value has not been recognized after the single-scan operation.
  • the output decoding circuit obtains the single-scan key value corresponding to the target number of scans when all single-scan results are valid for a single scan, and obtains the key value based on all single-scan key values. recognition result.
  • the output decoding circuit can obtain the single-scan key value identified by each scan, and can obtain M single-scan key values, because The M single-scan key values may or may not be the same. Therefore, it is necessary to perform comparative analysis based on all single-scan results to determine the final button recognition result, thereby ensuring the accuracy of the button recognition result.
  • step S1202 based on all single-scanning key values, key recognition results are obtained, including:
  • the output decoding circuit can obtain M single-scanning key values when the M single-scanning results are valid for a single scan, and the M single-scanning key values can be the same or different. Therefore, the output decoding circuit can be Do one of the following based on all single-scan key-values.
  • step S1301 after the output decoding circuit acquires M single-scanning key values, it needs to determine whether the M single-scanning key values are the same. Which valid key corresponds to the key value. Therefore, the key recognition result of a single scan invalid key can be output.
  • step S1302 after the output decoding circuit acquires the M single-scanning key values, it needs to judge whether the M single-scanning key values are the same, if all the single-scanning key values are the same, then the single-scanning key value will be The key value is determined as the current valid key value, and the key recognition result including the current valid key value is output to ensure the accuracy of the current valid key value. Understandably, when the target number of scans is 1, only one single scan key is obtained, and the current scan key can be directly determined as the current valid key.
  • the keyboard key recognition method further includes:
  • S1402 Determine the target effective key value according to the key-press interval time and the current effective key value.
  • the target effective key value refers to the finally recognized key key value.
  • the output decoding circuit when the key recognition result is valid, the output decoding circuit will output a current valid key value each time the key is scanned, because there are still combinations of keys in the current keyboard recognition process, for example, Ctrl+ on the computer keyboard The combination of C is the copied shortcut command, therefore, the output decoding circuit also needs to perform the following operations after identifying and obtaining the key recognition result containing the current valid key value to determine the final target valid key value:
  • step S1401 when the key recognition result includes the current valid key value, the output decoding circuit needs to obtain the historical valid key value corresponding to the current valid key value.
  • the current valid key value here can be understood as the key value of the keyboard key scanned and recognized at the current moment.
  • the historical effective key value can be understood as the key value of the keyboard key scanned and recognized at the historical time before the current time.
  • the output decoding circuit determines the current effective key value and the historical effective key value, it needs to obtain the current key value generation time corresponding to the current effective key value and the historical key value generation time corresponding to the historical effective key value respectively, and convert the current key value generation time
  • the time difference between the generation time of the historical key value and the generation time of the historical key value is determined as the key-press interval time.
  • the key-press interval can be understood as a time difference between the generation times of two valid key values.
  • the key interval time is the time difference between the current key value generation time and the historical key value generation time corresponding to the historical effective key value; when the historical effective key value is at least two, the key press interval The interval length is the time difference between the generation time of the current key value and the generation time of the historical key value corresponding to the earliest historical valid key value.
  • step S1402 after the output decoding circuit obtains the key-press interval time, it needs to compare the key-press interval time with the target time-length threshold, so as to evaluate the current effective key value according to the time-length comparison result Whether it is possible to combine keys with the historical effective key value, so as to obtain the final target effective key value, so as to ensure the accuracy of target effective key value identification.
  • the target duration threshold here is a preset duration threshold used to evaluate whether the combination key condition is satisfied.
  • step S1402 that is, to determine the target effective key value according to the key interval duration and the current effective key value, includes:
  • step S1501 after the output decoding circuit obtains the key-press interval time, it needs to compare the key-press interval time with the target time-length threshold. If the interval between keys is too long, it is almost impossible to be a combination of keys, that is, it is determined that the current effective key value is likely to be a single key, and the current effective key value is determined as the target effective key value. For example, set the key interval time between the current valid key value and the historical valid key value as Ts, the target duration threshold as Tm, the current valid key value as C, and the historical valid key value as Ctrl. When Ts>Tm, it is determined that the user presses The key interval between pressing C and Ctrl on the keyboard is too long, therefore, C can be determined as the target valid key value.
  • step S1502 after the output decoding circuit obtains the key-press interval time, it needs to compare the key-press interval time with the target time-length threshold.
  • the key interval between valid key values is small, and it may be a combination key.
  • the key combination rule here is a pre-configured rule used to reflect different key combinations so that it can complete specific function control.
  • determining the target effective key value includes:
  • step S1601 the output decoding circuit judges whether the key combination rule is satisfied based on the current effective key value and the historical effective key value, and when the current effective key value and the historical effective key value meet the key combination rule, it is determined that it is currently valid.
  • the key value and the historical effective key value can form a combined key
  • the target effective key value can be determined based on the combination of the current effective key value and the historical effective key value, so as to generate a corresponding target control instruction based on the target effective key value.
  • the current valid key value is C
  • the historical valid key value is Ctrl
  • its Ctrl+C satisfies the copy combination rule of the key combination rule, so Ctrl+C can be determined as the target valid key value.
  • the output decoding circuit judges whether the key combination rule is satisfied based on the current effective key value and the historical effective key value.
  • Effective key values and historical effective key values cannot form a combination key, and the current effective key value can be determined as the target effective key value.
  • Ctrl the current valid key value
  • C+Ctrl can be considered as not conforming to the key combination rules, and the current valid key value and historical valid key value can be determined to be a single key respectively , therefore, the current valid key value Ctrl' may be determined as the target valid key value.
  • the output decoding circuit can determine a single current valid key value as the target valid key value according to the comparison result of the key interval duration and the target duration threshold value and whether the key combination rule is met, or, based on the historical effective key value
  • the key value and the current effective key value determine the target effective key value, so as to ensure the accurate identification of the target effective key value and ensure the accuracy of function identification of the combination key.
  • the keyboard key recognition method After obtaining the single scan result corresponding to the current number of scans, the keyboard key recognition method also includes:
  • S1702 Output a glitch detection signal according to the glitch detection result.
  • the output decoding circuit is used to monitor the current number of scans, and when the current number of scans is updated from 0 to the target number of scans (such as 1), the number N of keys collected during this scan can be compared with the target number N Corresponding to the second level state, according to the second level state corresponding to the target number N of keys, determine whether this scan recognizes a valid key, so as to obtain the single scan result corresponding to the current number of scans, that is, to obtain the first A single scan result.
  • the target number of scans such as 1
  • the number N of keys collected during this scan can be compared with the target number N Corresponding to the second level state, according to the second level state corresponding to the target number N of keys, determine whether this scan recognizes a valid key, so as to obtain the single scan result corresponding to the current number of scans, that is, to obtain the first A single scan result.
  • the result of the first single scan when the result of the first single scan is invalid, it means that there is a high probability of glitches on the keyboard, and the glitch detection results with glitches can be obtained; when the result of the first single scan is valid for a single scan, It shows that there is a high probability that there is no glitch on the keyboard, and the glitch detection result that does not exist is obtained.
  • the glitch detection circuit is used to receive the glitch detection result, and the glitch detection signal output by the glitch detection circuit can be determined according to the glitch detection result. There is no glitch, so that subsequent signal control can be performed according to the glitch detection signal, so as to avoid the impact of the glitch on the control of the keyboard keys.
  • the glitch detection circuit communicates with the keyboard MCU, the keyboard MCU can determine whether there is a glitch on the current keyboard key according to the glitch detection signal output by the glitch detection circuit, so as to perform subsequent signal control, thereby preventing the glitch from affecting the control of the keyboard key.
  • the keyboard key recognition method further includes:
  • the output decoding circuit can form a first update instruction when the current keyboard state is an idle state and the first level state is a transition from high level to low level, and send the first update instruction Give the state machine a jump circuit.
  • the state machine jump circuit in the idle state can update the current keyboard state from the idle state to the pressed state after receiving the first update instruction sent by the output decoding circuit, to reflect that a keyboard key is pressed at the current moment
  • the output decoding circuit completes the key scanning and key identification, its current keyboard state is the pressing state, so that the output decoding circuit receives the first level state at the next moment as a jump from high level When it reaches a low level, no new key scanning and key recognition will be triggered, which helps to ensure the normal operation of this key scanning and key recognition, thereby ensuring the reliability of the circuit.
  • step S1802 the state machine jump circuit is used to monitor the current number of changes, and each time the current number of changes is detected to be cleared, it is necessary to determine the single scan result according to all the collected second level states, When the result of the single scan is that the single scan is invalid, a second update instruction can be formed, and the second update instruction can be sent to the state machine jump circuit.
  • the state machine jump circuit in the pressed state can update the current keyboard state from the pressed state to the idle state after receiving the second update instruction sent by the output decoding circuit, to reflect that no keyboard key is pressed at the current moment.
  • the output decoding circuit receives the first level transition from high level to low level at the next moment, it will trigger new key scanning and key identification, which helps to ensure subsequent key scanning and key identification normal operation, thereby ensuring circuit reliability.
  • step S1803 the output decoding circuit is used to monitor the current number of scans.
  • the current number of scans is cleared each time, it is necessary to obtain the button recognition result according to the single scan result corresponding to the target number of scans.
  • a third update instruction is formed, and the third update instruction is sent to the state machine jump circuit. Regardless of whether the button recognition result is invalid for a single scan or contains the current valid key value, since the button scanning and button recognition corresponding to the button behavior have been completed when the button recognition result is obtained, a third update command can be formed to control the state machine to jump Circuit update status.
  • the state machine jump circuit in the pressed state can update the current keyboard state from the pressed state to the idle state after receiving the third update instruction sent by the output decoding circuit, to reflect that no keyboard key is pressed at the current moment.
  • the output decoding circuit receives the first level transition from high level to low level at the next moment, it will trigger new key scanning and key identification, which helps to ensure subsequent key scanning and key identification normal operation, thereby ensuring circuit reliability.
  • the keyboard key recognition method further includes:
  • S1901 Determine the waiting update duration according to the instruction generation time corresponding to the target update instruction at the current moment; when the waiting update duration is greater than the timeout duration threshold, if the current keyboard state remains pressed, generate a timeout reset signal and output a timeout reset signal;
  • the target update instruction is the second update instruction or the third update instruction.
  • step S1901 after the timeout detection circuit detects that the output decoding circuit generates a target update command, it needs to obtain the command generation time, and then determine the time difference between the current time and the command generation time as the waiting update time .
  • the timeout detection circuit also needs to judge whether the waiting update time determined in real time reaches the timeout threshold.
  • the waiting update time reaches the timeout threshold, it needs to judge whether the current keyboard state has been updated from the pressed state to the idle state. If the current keyboard state is still pressed state, it means that the state machine jump circuit did not update the state in time according to the target update instruction.
  • the timeout detection circuit needs to generate a timeout reset signal and send the timeout reset signal to the state machine jump circuit. Understandably, the timeout reset signal is an indication formed when the state machine jump circuit is not updated in time.
  • the state machine jump circuit can restore the current keyboard state from the pressed state to the default state according to the timeout reset signal sent by the timeout detection circuit, that is, update the pressed state to the idle state, so as to ensure that the keyboard scanning circuit reliability and anti-interference ability.
  • the keyboard key recognition method further includes:
  • step S2001 after the asynchronous reset circuit detects that the output decoding circuit generates a target update command, and controls the state machine jump circuit to update the current keyboard state from the pressed state to the idle state, the key value detection circuit acquires the keyboard Scan the third level state corresponding to the input interface. Understandably, at the moment when the current keyboard state is updated from the pressed state to the idle state, when the third level state jumps from high level to low level, the asynchronous reset circuit can generate an asynchronous reset signal and send the asynchronous reset signal to Send to the state machine jump circuit, so that the state machine jump circuit performs state reset.
  • the state machine jump circuit can be used to reset the current keyboard state from the idle state to the pressed state according to the asynchronous reset signal sent by the asynchronous reset circuit. Understandably, the use of the asynchronous reset circuit to control the state machine jump circuit to perform asynchronous reset can ensure the reliability and anti-interference ability of the keyboard scanning circuit.
  • controlling the keyboard scanning output interface to perform key scanning includes:
  • the first interval length is used to control the interval length of all keyboard scan output interfaces to output high level; the second interval length is used to control the interval length of all keyboard scan output interfaces to output low level.
  • an output decoding circuit is used to obtain a preset first interval duration and a second interval duration.
  • the first interval length is specifically the interval length for controlling the pull-up of all keyboard scan output interfaces after a certain keyboard scan input interface is pulled low.
  • the second interval is the interval for controlling all keyboard scan output interfaces to output low levels in turn after all keyboard scan output interfaces are pulled high.
  • step S2102 when the keyboard scan input interface KSI0 is pulled low by using the output decoding circuit, all keyboard scan output interfaces need to be controlled to be pulled high after the first interval.
  • all the keyboard scanning output interfaces after all the keyboard scanning output interfaces are pulled high by using the output decoding circuit, after every second interval, it is necessary to sequentially control all the keyboard scanning output interfaces to output low levels in turn, so as to ensure the pull-up of all keyboard scanning output interfaces.
  • the highs or lows are not simultaneous, improving power integrity.
  • the present application also provides a chip, including the keyboard scanning identification circuit of the above embodiment, the keyboard scanning identification circuit only when the current keyboard state is an idle state and the first level state is a jump from high level to low level, the Control the keyboard scan output interface to scan the keys.
  • the keyboard scanning identification circuit only when the current keyboard state is an idle state and the first level state is a jump from high level to low level
  • the Control the keyboard scan output interface to scan the keys.
  • it can ensure that the key scan will only be performed when there is a keyboard key being pressed, so as to avoid that the current keyboard state is idle and the first level state is from high level.
  • the condition of jumping to low level triggers key scanning, it can save system power consumption and improve circuit reliability.
  • the present application also provides a keyboard.
  • the keyboard includes keyboard keys and a keyboard MCU, and further includes the keyboard scanning circuit in the above embodiment, and the keyboard scanning circuit is connected with the keyboard keys and the keyboard MCU. Only when the current keyboard state is idle state and the first level state is jumping from high level to low level, the keyboard scanning output interface is controlled to perform key scanning. On the one hand, it can ensure that only when there are keyboard keys being pressed, Only when the key scanning is performed, the key scanning is avoided when the condition that the current keyboard state is idle and the first level state is transitioned from high level to low level is not met, which can save system power consumption and improve circuit reliability.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Input From Keyboards Or The Like (AREA)

Abstract

本申请公开一种键盘扫描电路、键盘按键识别方法、芯片和键盘。该键盘扫描电路包括:键值检测电路与键盘扫描输入接口相连,用于采集键盘扫描输入接口对应的第一电平状态;状态机跳转电路,用于输出当前键盘状态;输出译码电路,与键值检测电路、状态机跳转电路和键盘扫描输出接口相连,用于在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;键值检测电路,还用于在控制键盘扫描输出接口进行按键扫描之后,采集键盘扫描输入接口对应的第二电平状态;输出译码电路,还用于根据第二电平状态,进行按键识别。该键盘扫描电路可实现按键扫描和按键识别,具有高可靠性,无需额外占用键盘MCU运行资源。

Description

键盘扫描电路、键盘按键识别方法、芯片和键盘 技术领域
本申请涉及键盘技术领域,尤其涉及一种键盘扫描电路、键盘按键识别方法、芯片和键盘。
背景技术
现有键盘按键识别过程中,大多需要在键盘MCU上执行键盘扫描程序实现按键扫描,采集键盘按键对应的IO接口的变化信号,根据该变化信号进行按键识别。这种采用键盘MCU执行键盘扫描程序进行按键扫描和按键识别的方式,需占用键盘MCU的CPU资源,影响键盘MCU的运行效率。
发明内容
本申请实施例提供一种键盘扫描电路、键盘按键识别方法、芯片和键盘,以解决现有采用键盘MCU进行按键扫描和按键识别所导致的运行效率低的问题。
本申请提供一种键盘扫描电路,包括:
键值检测电路,与键盘扫描输入接口相连,用于采集所述键盘扫描输入接口对应的第一电平状态;
状态机跳转电路,与所述键值检测电路相连,用于输出当前键盘状态;
输出译码电路,与所述键值检测电路、所述状态机跳转电路和键盘扫描输 出接口相连,用于在所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;
键值检测电路,还用于在控制键盘扫描输出接口进行按键扫描之后,采集所述键盘扫描输入接口对应的第二电平状态;
输出译码电路,还用于根据所述第二电平状态,进行按键识别。
本申请实施例提供一种键盘按键识别方法,包括:
采集键盘扫描输入接口对应的第一电平状态;
输出当前键盘状态;
在所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;
在控制键盘扫描输出接口进行按键扫描之后,采集所述键盘扫描输入接口对应的第二电平状态;
根据所述第二电平状态,进行按键识别。
本申请实施例提供一种芯片,包括上述键盘扫描电路。
本申请提供一种键盘,包括键盘按键和键盘MCU,还包括上述键盘扫描电路,所述键盘扫描电路与所述键盘按键和所述键盘MCU相连。
上述键盘扫描电路、键盘按键识别方法、芯片和键盘,只有在当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,才控制键盘扫描输出接口进行按键扫描,一方面可确保只有在存在键盘按键被按下时,才会执行按键扫描,避免在不满足所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平这一条件时触发按键扫描,可节省系统功耗,并提高电路可靠性。采用输出译码电路控制键盘扫描输出接口进行按键扫描,并根据所述键盘扫描输入接口对应的第二电平状态,完成按键识别,以实现采用键 盘扫描电路这一硬件设备,完成按键扫描及按键识别过程,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例中键盘扫描电路的一电路示意图;
图2是本申请一实施例中键盘扫描电路的另一电路示意图;
图3是本申请一实施例中键盘扫描电路的另一电路示意图;
图4是本申请一实施例中键盘扫描电路的另一电路示意图;
图5是本申请一实施例中键盘扫描电路的另一电路示意图;
图6是本申请一实施例中键盘扫描电路的另一电路示意图;
图7是本申请一实施例中键盘扫描电路工作时的一时序图;
图8是本申请一实施例中键盘按键识别方法的一流程图;
图9是本申请一实施例中键盘按键识别方法的另一流程图;
图10是本申请一实施例中键盘按键识别方法的另一流程图;
图11是本申请一实施例中键盘按键识别方法的另一流程图;
图12是本申请一实施例中键盘按键识别方法的另一流程图;
图13是本申请一实施例中键盘按键识别方法的另一流程图;
图14是本申请一实施例中键盘按键识别方法的另一流程图;
图15是本申请一实施例中键盘按键识别方法的另一流程图;
图16是本申请一实施例中键盘按键识别方法的另一流程图;
图17是本申请一实施例中键盘按键识别方法的另一流程图;
图18是本申请一实施例中键盘按键识别方法的另一流程图;
图19是本申请一实施例中键盘按键识别方法的另一流程图;
图20是本申请一实施例中键盘按键识别方法的另一流程图;
图21是本申请一实施例中键盘按键识别方法的另一流程图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
应当理解的是,本申请能够以不同形式实施,而不应当解释为局限于这里提出的实施例。相反地,提供这些实施例将使公开彻底和完全,并且将本申请的范围完全地传递给本领域技术人员。在附图中,为了清楚,层和区的尺寸以及相对尺寸可能被夸大自始至终相同附图标记表示相同的元件。
应当明白,当元件或层被称为“在…上”、“与…相邻”、“连接到”或“耦合到”其它元件或层时,其可以直接地在其它元件或层上、与之相邻、连接或耦合到其它元件或层,或者可以存在居间的元件或层。相反,当元件被称为“直接在…上”、“与…直接相邻”、“直接连接到”或“直接耦合到”其它元件或层时,则不存在居间的元件或层。应当明白,尽管可使用术语第一、第二、第三等描述各种元件、部件、区、层和/或部分,这些元件、部件、区、层和/或部分不应当被这些术语限制。这些术语仅仅用来区分一个元件、部件、 区、层或部分与另一个元件、部件、区、层或部分。因此,在不脱离本申请教导之下,下面讨论的第一元件、部件、区、层或部分可表示为第二元件、部件、区、层或部分。
空间关系术语例如“在…下”、“在…下面”、“下面的”、“在…之下”、“在…之上”、“上面的”等,在这里可为了方便描述而被使用从而描述图中所示的一个元件或特征与其它元件或特征的关系。应当明白,除了图中所示的取向以外,空间关系术语意图还包括使用和操作中的器件的不同取向。例如,如果附图中的器件翻转,然后,描述为“在其它元件下面”或“在其之下”或“在其下”元件或特征将取向为在其它元件或特征“上”。因此,示例性术语“在…下面”和“在…下”可包括上和下两个取向。器件可以另外地取向(旋转90度或其它取向)并且在此使用的空间描述语相应地被解释。
在此使用的术语的目的仅在于描述具体实施例并且不作为本申请的限制。在此使用时,单数形式的“一”、“一个”和“所述/该”也意图包括复数形式,除非上下文清楚指出另外的方式。还应明白术语“组成”和/或“包括”,当在该说明书中使用时,确定所述特征、整数、步骤、操作、元件和/或部件的存在,但不排除一个或更多其它的特征、整数、步骤、操作、元件、部件和/或组的存在或添加。在此使用时,术语“和/或”包括相关所列项目的任何及所有组合。
为了彻底理解本申请,将在下列的描述中提出详细的结构及步骤,以便阐释本申请提出的技术方案。本申请的较佳实施例详细描述如下,然而除了这些详细描述外,本申请还可以具有其他实施方式。
本申请实施例提供一种键盘扫描电路,如图1所示,键盘扫描电路包括:
键值检测电路,与键盘扫描输入接口相连,用于采集键盘扫描输入接口对 应的第一电平状态;
状态机跳转电路,与键值检测电路相连,用于输出当前键盘状态;
输出译码电路,与键值检测电路、状态机跳转电路和键盘扫描输出接口相连,用于在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;
键值检测电路,还用于在控制键盘扫描输出接口进行按键扫描之后,采集键盘扫描输入接口对应的第二电平状态;
输出译码电路,还用于根据第二电平状态,进行按键识别。
其中,键盘扫描输入接口(Keyboard Scan Input,以下简称KSI)是与键盘按键相连的输入接口,例如,可采用KSI八路并行输入。
其中,键值检测电路是与键盘扫描输入接口相连的用于检测键盘扫描输入接口的电平状态的电路。一般来说,在某一键盘按键被按下时,键值检测电路采集到键盘扫描输入接口的电平状态为低电平,反之,若该键盘按键未被按下时,键值检测电路采集到键盘扫描输入接口的电平状态为高电平。
其中,第一电平状态是指在执行按键扫描之前采集到的键盘扫描输入接口的电平状态。第二电平状态是指在执行按键扫描之后采集到的键盘扫描输入接口的电平状态。
状态机跳转电路是用于实现在键盘按键被按下和未被按下这两种状态之间跳转的电路。当前键盘状态是用于反映当前时刻之前是否有键盘按键被按下的状态。一般来说,该当前按键状态可以为空闲状态和按压状态,此处的空闲状态是指没有键盘按键被按下的状态,按压状态是指有键盘按键被按下的状态。
输出译码电路是用于实现按键扫描输出和按键识别处理的电路。
在一示例中,键盘扫描电路实现按键识别过程如下:
(1)与键盘扫描输入接口相连的键值检测电路,需实时采集键盘扫描输入接口对应的第一电平状态,在某一键盘按键未被按下时,键值检测电路采集到的第一电平状态为高电平;在某一键盘按键被按下的瞬间,键值检测电路采集到的第一电平状态为从高电平跳变到低电平。可理解地,键值检测电路每隔单位时间采集一个第一电平状态,若前后两个时刻采集到的两个第一电平状态依次为高电平和低电平,即键值检测电路先后检测到键盘扫描输入接口为高电平和低电平,实现从高电平到低电平跳变时,可认定存在键盘按键被按下。
(2)状态机跳转电路需获取当前时刻T1对应的当前键盘状态,该当前键盘状态可以反映当前时刻T1之前是否有键盘按键被按下的状态,例如,可反映当前时刻T1之前的上一时刻T0是否有键盘按键被按下的状态。具体可以为空闲状态,也可以为按压状态。
(3)输出译码电路可实时获取键值检测电路采集的第一电平状态和状态机跳转电路对应的当前键盘状态,在当前键盘状态为空闲状态时,说明上一时刻T0没有键盘按键被按下,也就是说上一时刻T0所采集到的第一电平状态为高电平;在第一电平状态为从高电平跳变到低电平时,说明上一时刻T0所采集到的第一电平状态为高电平,当前时刻T1采集到的第一电平状态为低电平,即键盘扫描输入接口从高电平跳变到低电平,说明存在键盘按键在当前时刻T1被按下;因此,在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,可确定某一键盘按键在当前时刻T1被按下,此时,需控制键盘扫描输出接口进行按键扫描,即控制键盘扫描输出接口依据特定规则输出可实现按键扫描的不同电平,例如,控制所有键盘扫描输出接口轮流输出低电平,完成对所有键盘按键进行扫描,以便根据键值检测电路采集到的第二电平状态 完成按键识别。
进一步地,状态机跳转电路还与键值检测电路相连,实时获取键值检测电路采集到的第一电平状态,在当前键盘状态为空闲状态,且第一电平状态为从高电平跳变到低电平时,可更新其当前键盘状态为按压状态。
(4)键值检测电路在输出译码电路控制键盘扫描输出接口进行按键扫描之后,例如,控制所有键盘扫描输出接口轮流输出低电平之后,需实时采集键盘扫描输入接口对应的第二电平状态,该第二电平状态可以为高电平也可以为低电平。本示例中,每一键盘扫描输出接口与一键盘扫描输入接口相匹配,对应同一键盘按键,例如,任一键盘按键A,其与键盘扫描电路通过键盘扫描输入接口和键盘扫描输出接口相连,以保障正常的信号传输。
(5)输出译码电路还用于在控制键盘扫描输出接口进行按键扫描之后,接收键值检测电路实时采集到的键盘扫描输入接口对应的第二电平状态,以便根据第二电平状态,完成按键识别。本示例中,在键盘上设有S个键盘按键时,需控制S个键盘扫描输出接口轮流输出低电平,以便根据每个键盘扫描输出接口对应的键盘扫描输出接口对应的第二电平状态,确定具体是哪个键盘按键被按下,以识别被按下的键盘按键对应的按键键值。例如,在控制键盘扫描输出接口进行按键扫描具体为控制所有键盘扫描输出接口轮流输出低电平时,输出译码电路在控制第i个键盘按键对应的键盘扫描输出接口KSOi输出低电平之后,可采集与该键盘扫描输出接口KSOi相对应的键盘扫描输出接口KSIi对应的第二电平状态,可根据第二电平状态,确定第i个键盘按键是否被按下。例如,在第二电平状态为低电平时,认定第i个键盘按键被按下;在第二电平状态为高电平时,认定第i个键盘按键未被按下,以识别出第i个键盘按键对应的按键键值。
本实施例所提供的键盘扫描电路,只有在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,才控制键盘扫描输出接口进行按键扫描,一方面可确保只有在存在键盘按键被按下时,才会执行按键扫描,避免在不满足当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平这一条件时触发按键扫描,可节省系统功耗,并提高电路可靠性。采用输出译码电路控制键盘扫描输出接口进行按键扫描,并根据键盘扫描输入接口对应的第二电平状态,完成按键识别,以实现采用键盘扫描电路这一硬件设备,完成按键扫描及按键识别过程,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
在一实施例中,如图2所示,键盘扫描电路还包括基础计数器、输出变化计数器和扫描次数计数器;
基础计数器,用于在接收到目标时钟沿时,更新当前基础数值为目标基础数值,在监听到输出译码电路控制键盘扫描输出接口进行按键扫描时,控制当前基础数值清零;
输出变化计数器,与基础计数器相连,用于在监听到当前基础数值清零时,更新当前变化次数,若当前变化次数达到目标按键数量,则控制当前变化次数清零;
扫描次数计数器,与输出变化计数器相连,用于在监听到当前变化次数清零时,更新当前扫描次数,若当前扫描次数达到目标扫描次数,则控制当前扫描次数清零;
输出译码电路,与基础计数器、输出变化计数器和扫描次数计数器相连,用于根据当前基础数值、当前变化次数和当前扫描次数,完成按键扫描和按键识别。
其中,基础计数器是设置在键盘扫描电路中的用于记录控制键盘扫描输出接口进行按键扫描时,每一键盘扫描输出接口的电平变化的计数器,例如,可以为记录每一键盘扫描输出接口是否输出低电平的计数器。目标时钟沿是预先设置的可控制键盘扫描输出接口进行按键扫描的时钟沿,具体为控制键盘扫描输出接口输出低电平变化的时钟沿,例如,目标时钟沿可以为下降沿。目标基础数值是预先设置的基础数值,可设置为1。
作为一示例,该基础计数器与时钟总线相连,可实时接收时钟总线发送的当前时钟沿为目标时钟沿时,先触发基础计数器开始计数,更新当前基础数值为目标基础数值,即将当前基础数值由0变为1。然后,基础计数器在当前基础数值由0变为1时,可使输出译码电路控制键盘扫描输出接口进行按键扫描,具体为可使输出译码电路控制第i个键盘按键对应的键盘扫描输出接口输出低电平,具体在每次扫描控制过程中,可使输出译码电路控制所有键盘扫描输出接口全部拉高或全部拉低,以实现键盘扫描操作。可理解地,在输出译码电路控制键盘扫描输出接口输出低电平时,可使键值检测电路采集键盘扫描输入接口对应的第二电平状态,以便后续根据采集到的第二电平状态,完成按键识别。最后,基础计数器在监听到输出译码电路控制键盘扫描输出接口进行按键扫描时,即控制键盘扫描输出接口输出低电平之后,需控制当前基础数值清零,即将当前基础数值由1变为0,以便在下次接收到目标时钟沿时,可将当前基础数值由0变为1,再基于当前基础数值,控制键盘扫描输出接口输出低电平,从而保障键盘扫描电路的可靠性。
其中,输出变化计数器是设置在键盘扫描电路中的用于记录键盘扫描输出接口完成按键扫描的次数的计数器,具体用于记录本次扫描过程中键盘扫描输出接口输出低电平的次数。当前变化次数是指输出变化计数器在当前时刻记录 到的变化次数,可用于反映每次按键扫描进度,即每次按键扫描过程中,有多少个键盘按键已经被扫描的状态,该当前变化次数可设为N1。目标按键数量是指预先设置的每次按键扫描过程需要扫描的键盘按键的数量,该目标按键数量可设为N。
作为一示例,输出变化计数器与基础计数器相连,可实时监听基础计数器中的当前基础数值是否清零,在每次监听到当前基础数值清零时,需更新当前变化次数N1,即在上一时刻的当前变化次数N0的基础上加1,以获取当前时刻对应的当前变化次数N1,即N1=N0+1。输出变化计数器在获取到更新后的当前变化次数N1时,需将当前变化次数N1与预先设置的目标按键数量N进行比较;若当前变化次数N1达到目标按键数量N(即N1=N),则认定本次按键扫描完成,此时,需控制当前变化次数清零,以便下次进行按键扫描时,可重新计数,从而保障键盘扫描电路的可靠性。可理解地,若当前变化次数N1未达到目标按键数量N(即N1<N),则需继续监听当前基础数值是否清零。
其中,扫描次数计数器是设置在键盘扫描电路中的用于记录已经完成多少次扫描的计数器。当前扫描次数是指扫描次数计数器在当前时刻记录到的已经完成的扫描次数,该当前变化次数可设为M1。目标扫描次数是预先设置的用于控制每次按键扫描所需扫描的次数,该目标扫描次数可设为M。
作为一示例,扫描次数计数器与输出变化计数器相连,可实时监听输出变化计数器中的当前变化次数是否清零,在每次监听到当前变化次数清零时,需要更新当前扫描次数M1,即在上一时刻的当前扫描次数M0的基础上加1,以获取当前时刻对应的当前扫描次数M1,即M1=M0+1。扫描次数计数器在获取到更新后的当前扫描次数M1之后,需将当前扫描次数M1与预先设置的目标扫描次数M进行比较;若当前扫描次数M1达到目标扫描次数M(即M1=M),则认 定完成按键扫描,此时,可当前扫描次数清零,以便在下次监听到当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,可重新进行按键扫描,从而保障键盘扫描电路的可靠性。可理解地,若当前扫描次数M1未达到目标扫描次数M(即M1<M)时,则需要继续监听输出变化计数器中的当前变化次数是否清零。
作为一示例,输出译码电路,与基础计数器、输出变化计数器和扫描次数计数器相连,用于根据当前基础数值、当前变化次数和当前扫描次数,完成按键扫描和按键识别。例如,输出译码电路可根据当前基础数值的变化,控制键盘扫描输出接口输出低电平,以完成按键扫描;还可以根据当前变化次数和当前扫描次数,完成按键识别。
本实施例所提供的键盘扫描电路中,采用基础计数器、输出变化计数器和扫描次数计数器这几个计数器,根据接收到的目标时钟沿进行计数,以便输出译码电路根据不同计数器中的数值变化,完成对所有键盘按键进行按键扫描和按键识别,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
在一实施例中,输出译码电路,还用于在监听到当前基础数值为目标基础数值时,控制键盘扫描输出接口输出低电平,实现按键扫描;
输出译码电路,还用于在监听到当前变化次数清零时,获取与目标按键数量相对应的第二电平状态,根据所有第二电平状态,获取当前扫描次数对应的单次扫描结果;
输出译码电路,还用于在监听到当前扫描次数清零时,获取与目标扫描次数相对应的单次扫描结果,根据所有单次扫描结果,获取按键识别结果。
作为一示例,输出译码电路与基础计数器相连,该输出译码电路可在监听 到基础计数器记录的当前基础数值为目标基础数值时,需控制键盘扫描输出接口输出低电平,以使键值检测电路采集键盘扫描输入接口对应的第二电平状态。即基础计数器的当前基础数值每次由0变为1时,输出译码电路均需控制键盘扫描输出接口输出一次低电平,实现对一个键盘按键进行扫描,此时,键值检测电路可采集到与该键盘扫描输出接口相匹配的键盘扫描输入接口对应的第二电平状态,并将该第二电平状态反馈给输出译码电路。可理解地,在键值检测电路采集到的某一第二电平状态为低电平时,认定与该键盘扫描输入接口相对应的键盘按键被按下;在键值检测电路采集到的某一第二电平状态为高电平时,认定与该键盘扫描输入接口相对应的键盘按键没有被按下,为释放按键。
作为一示例,输出译码电路与输出变化计数器相连,该输出译码电路可在监听到输出变化计数器清零时,认定已经对与目标按键数量N相对应的键盘按键完成本次扫描,此时,需获取扫描次数计数器记录的当前扫描次数,可对本次扫描过程中采集到的与目标按键数量N相对应的第二电平状态,根据与目标按键数量N相对应的第二电平状态,判定本次扫描是否识别到有效按键,以获取当前扫描次数对应的单次扫描结果,即根据N个第二电平状态为高电平还是低电平,确定本次扫描是否有效,以获取单次扫描有效或者单次扫描无效的单次扫描结果,在单次扫描结果为单次扫描有效时,还可获取单次扫描键值。该单次扫描键值是指本次扫描所识别到的键值。
作为一示例,输出译码电路与扫描次数计数器相连,该输出译码电路可在监听到当前扫描次数清零时,认定已经完成与目标扫描次数M相匹配的扫描操作,可根据获取到的M个单次扫描结果,完成最终的按键识别,即根据M个单次扫描结果,确定是否存在有效按键,在存在有效按键的情况下,获取有效按 键对应的当前有效键值。此处的有效按键是指通过按键扫描确定被按下的按键,即触发第一电平状态为从高电平跳变到低电平这一按键行为所按下的按键。当前有效键值是指有效按键对应的键值。
本实施例所提供的键盘扫描电路中,输出译码电路可根据当前基础数值,控制键盘扫描输出接口输出低电平,实现按键扫描,并根据当前变化次数和当前扫描次数,实现按键识别,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
在一实施例中,输出译码电路,还用于在监听到当前变化次数清零时,获取与目标按键数量相对应的第二电平状态;若所有第二电平状态均为高电平,则获取单次扫描无效的单次扫描结果;若存在一个第二电平状态为低电平,则获取单次扫描有效的单次扫描结果。
作为一示例,输出译码电路在每次监听到当前变化次数清零,即完成一次按键扫描时,需根据键值检测电路输出的键盘扫描输入接口对应的第二电平状态进行按键识别过程,具体包括如下步骤:
(1)输出译码电路可在每次监听到输出变化计数器的当前变化次数清零时,认定已经对N个键盘按键完成本次扫描,可获取N个键盘按键对应的键盘扫描输入接口对应的第二电平状态,该第二电平状态可以为高电平也可以为低电平。
(2)输出译码电路在N个键盘按键对应的第二电平状态均为高电平时,认定N个键盘按键在本次扫描过程均没有被按下,进而认定本次扫描行为为无效行为,因此,可获取单次扫描无效的单次扫描结果。
进一步地,在输出译码电路每次监听到当前变化次数清零时,其单次扫描结果为单次扫描无效时,认定本次扫描行为为无效行为,可直接输出单次扫描 无效的按键识别结果,无需等待监听到当前扫描次数清零,即可结束本次按键扫描及按键识别过程,有助于节省等待时间,简化处理流程,提高处理效率。
(3)输出译码电路在N个键盘按键对应的第二电平状态中,存在一个第二电平状态为低电平时,认定N个键盘按键中的一个键盘按键在本次扫描过程中被认定为处于按压状态,进而认定本次扫描行为为有效行为,因此,可获取单次扫描有效的单次扫描结果。
进一步地,在输出译码电路每次监听到当前变化次数清零时,其单次扫描结果为单次扫描有效时,需获取单次扫描键值。本示例中,输出译码电路可将第二电平状态为低电平的按键标识,确定为目标按键标识;再根据目标按键标识,确定目标按键标识对应的单次扫描键值。其中,按键标识是用于唯一识别某一键盘按键的标识,本示例中,每一键盘按键对应的键盘扫描输出接口和键盘扫描输入接口均携带有按键标识,以使采集到的每一第二电平状态也携带有按键标识。此处的目标按键标识是指采集到的第二电平状态为低电平对应的按键标识。此处的单次扫描键值本次扫描识别所确定的按键键值。
在一实施例中,输出译码电路,输出译码电路,还用于在存在单次扫描结果为单次扫描无效时,输出单次扫描无效的按键识别结果;在所有单次扫描结果均为单次扫描有效时,获取与目标扫描次数相对应的单次扫描键值,基于所有单次扫描键值,获取按键识别结果。
其中,当前有效键值是针对一个按键行为所识别出的按键键值。
作为一示例,输出译码电路在每次监听到当前扫描次数清零时,即完成与当前扫描次数相对应的单次扫描操作可获取与目标扫描次数相对应的单次扫描结果,在目标扫描次数为M时,可获取M个单次扫描结果,每个单次扫描结果可以为单次扫描有效也可以为单次扫描无效,因此,输出译码电路可根据所 有单次扫描结果执行以下之一的操作:
(1)输出译码电路在存在单次扫描结果为单次扫描无效时,输出单次扫描无效的按键识别结果。
本示例中,输出译码电路在M个单次扫描结果中,任一次单次扫描结果为单次扫描无效时,认定单次扫描操作之后,没有识别到相应的单次扫描键值,此时,可直接输出单次扫描无效的按键识别结果,无需执行后续操作,即可结束本次按键扫描及按键识别过程,有助于节省等待时间,简化处理流程,提高处理效率。
(2)输出译码电路在所有单次扫描结果均为单次扫描有效时,获取与目标扫描次数相对应的单次扫描键值,基于所有单次扫描键值,获取按键识别结果。
本示例中,输出译码电路在M个单次扫描结果均为单次扫描有效时,可获取每次扫描所识别出的单次扫描键值,即可获取M个单次扫描键值,由于M个单次扫描键值可能相同,也可能不相同,因此,需要基于所有单次扫描结果进行比较分析,以确定最终的按键识别结果,从而保障按键识别结果的准确性。
在一实施例中,输出译码电路,还用于在存在单次扫描键值不相同时,输出单次扫描无效的按键识别结果;在所有单次扫描键值均相同时,根据单次扫描键值,确定当前有效键值,输出包含当前有效键值的按键识别结果。
作为一示例,输出译码电路在M个单次扫描结果均为单次扫描有效时,可获取M个单次扫描键值,M个单次扫描键值可以相同也可以不相同,因此,输出译码电路可根据所有单次扫描键值执行以下之一的操作。
(1)输出译码电路在获取M个单次扫描键值之后,需判断M个单次扫描键值是否相同,若存在单次扫描键值不同,则无法确定其具体为哪个有效按键 对应的键值,因此,可输出单次扫描无效的按键识别结果。
(2)输出译码电路在获取M个单次扫描键值之后,需判断M个单次扫描键值是否相同,若所有单次扫描键值均相同,则将单次扫描键值,确定为当前有效键值,输出包含当前有效键值的按键识别结果,以保障当前有效键值的准确性。可理解地,在目标扫描次数为1时,其只获取到1个单次扫描键值,可直接将该当前扫描键值确定为当前有效键值。
在一实施例中,输出译码电路,还用于在按键识别结果为包含当前有效键值时,则确定历史有效键值,获取当前有效键值和历史有效键值对应的按键间隔时长;根据按键间隔时长和当前有效键值,确定目标有效键值。
其中,目标有效键值是指最终识别出的按键键值。
作为一示例,输出译码电路在按键识别结果为有效时,每次按键扫描均会输出一个当前有效键值,由于当前键盘识别过程中还存在组合按键的情况,例如,电脑键盘上的Ctrl+C组合为复制的快捷指令的情况,因此,输出译码电路还需要在识别获取包含当前有效键值的按键识别结果之后,还可以执行如下操作,以确定最终的目标有效键值:
(1)输出译码电路在按键识别结果为包含当前有效键值时,需获取与当前有效键值相对应的历史有效键值。此处的当前有效键值可以理解为当前时刻扫描识别出的键盘按键的键值。相应地,历史有效键值可以理解为当前时刻之前的历史时刻扫描识别出的键盘按键的键值。输出译码电路在确定当前有效键值和历史有效键值时,需分别获取当前有效键值对应的当前键值生成时间和历史有效键值对应的历史键值生成时间,将当前键值生成时间和历史键值生成时间的时间差,确定为按键间隔时长。可理解地,该按键间隔时长可理解为两个有效键值的生成时间的时间差。在历史有效键值为一个时,该 按键间隔时长为当前键值生成时间与该历史有效键值对应的历史键值生成时间之间的时间差;在历史有效键值为至少两个时,该按键间隔时长为当前键值生成时间与最早一个历史有效键值对应的历史键值生成时间之间的时间差。
输出译码电路在获取到按键间隔时长之后,需将按键间隔时长与目标时长阈值进行比较,以便根据时长比较结果,以根据该时长比较结果,评估当前有效键值和历史有效键值是否有可能为组合按键,从而获取最终的目标有效键值,以保障目标有效键值识别的准确性。此处的目标时长阈值是预先设置的用于评估是否满足组合按键条件的时长阈值。
在一实施例中,输出译码电路,还用于在按键间隔时长大于目标时长阈值时,将当前有效键值确定为目标有效键值;在按键间隔时长不大于目标时长阈值时,基于当前有效键值和历史有效键值,判断是否满足按键组合规则,获取组合判断结果,根据组合判断结果,确定目标有效键值。
作为一示例,输出译码电路在获取到按键间隔时长之后,需将按键间隔时长与目标时长阈值进行比较,在按键间隔时长大于目标时长阈值时,认定当前有效键值和历史有效键值之间的按键间隔时长过大,基本不可能为组合按键,即认定当前有效键值极可能为单个按键,将当前有效键值确定为目标有效键值。例如,设当前有效键值和历史有效键值之间的按键间隔时长为Ts,目标时长阈值为Tm,当前有效键值为C,历史有效键值为Ctrl,在Ts>Tm时,认定用户按下键盘按键C和Ctrl之间的按键间隔时长过长,因此,可将C确定为目标有效键值。
作为一示例,输出译码电路在获取到按键间隔时长之后,需将按键间隔时长与目标时长阈值进行比较,在按键间隔时长不大于目标时长阈值时,认定当 前有效键值和历史有效键值之间的按键间隔时长较小,有可能为组合按键,此时,需基于当前有效键值和历史有效键值,判断是否满足按键组合规则,获取组合判断结果,以便根据该组合判断结果,评估当前有效键值和历史有效键值是否为组合按键,从而获取最终的目标有效键值,以保障目标有效键值识别的准确性。此处的按键组合规则是预先配置的用于反映不同按键组合,以使其可完成特定功能控制的规则。
在一实施例中,输出译码电路,还用于在组合判断结果为满足按键组合规则时,根据当前有效键值和历史有效键值,确定目标有效键值;在组合判断结果为不满足按键组合规则时,将当前有效键值确定为目标有效键值。
作为一示例,输出译码电路基于当前有效键值和历史有效键值,判断是否满足按键组合规则,在当前有效键值和历史有效键值满足按键组合规则时,认定其当前有效键值和历史有效键值可形成组合按键,可基于当前有效键值和历史有效键值的组合,确定目标有效键值,以便基于目标有效键值,生成对应的目标控制指令。例如,当前有效键值为C,历史有效键值为Ctrl,其Ctrl+C满足按键组合规则的复制组合规则,可将Ctrl+C确定为目标有效键值。
作为一示例,输出译码电路基于当前有效键值和历史有效键值,判断是否满足按键组合规则,在当前有效键值和历史有效键值不满足按键组合规则时,认定其当前有效键值和历史有效键值不可形成组合按键,可将当前有效键值,确定为目标有效键值。例如,若当前有效键值为Ctrl,历史有效键值为C,其不满足按键组合规则,可将C+Ctrl不符合按键组合规则,可认定当前有效键值和历史有效键值分别为单个按键,因此,可将当前有效键值Ctrl,确定为目标有效键值。
本实施例中,输出译码电路可根据按键间隔时长与目标时长阈值的比较结 果以及是否符合按键组合规则这两个条件,将单个当前有效键值确定为目标有效键值,或者,基于历史有效键值和当前有效键值确定目标有效键值,以保障目标有效键值的准确识别,确保组合按键的功能识别的准确性。
在一实施例中,如图3所示,键盘扫描电路还包括毛刺检测电路,毛刺检测电路与输出译码电路相连;
输出译码电路,还用于在监听到当前扫描次数为目标扫描次数时,若当前扫描次数对应的单次扫描结果为单次扫描无效,则获取存在毛刺的毛刺检测结果;若当前扫描次数对应的单次扫描结果为单次扫描有效,则获取不存在毛刺的毛刺检测结果;
毛刺检测电路,用于根据毛刺检测结果,输出毛刺检测信号。
作为一示例,输出译码电路与输出变化计数器相连,该输出译码电路可在监听到输出变化计数器清零时,认定已经对与目标按键数量N相对应的键盘按键完成本次扫描,此时,可更新当前扫描次数,在当前扫描次数由0更新为1时,可对本次扫描过程中采集到的与目标按键数量N相对应的第二电平状态,根据与目标按键数量N相对应的第二电平状态,判定本次扫描是否识别到有效按键,以获取当前扫描次数对应的单次扫描结果,即获取第1个单次扫描结果。本示例中,在第1个单次扫描结果为单次扫描无效时,说明键盘较大概率存在毛刺,可获取存在毛刺的毛刺检测结果;在第1个单次扫描结果为单次扫描有效,说明键盘较大概率不存在毛刺,获取不存在毛刺的毛刺检测结果。
作为一示例,毛刺检测电路接收到的毛刺检测结果包括存在毛刺和不存在毛刺两种,可根据该毛刺检测结果,确定其输出的毛刺检测信号,例如,可采用毛刺检测信号1表示存在毛刺,采用毛刺检测信号0表示不存在毛刺,以便根据该毛刺检测信号进行后续信号控制,以避免毛刺对键盘按键的控制造成影 响。例如,在毛刺检测电路与键盘MCU通信时,键盘MCU可根据毛刺检测电路输出的毛刺检测信号,确定当前键盘按键是否存在毛刺,从而进行后续信号控制,从而避免毛刺对键盘按键的控制造成影响。
在一实施例中,输出译码电路,还用于在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,向状态机跳转电路输出第一更新指令;
状态机跳转电路,还用于根据第一更新指令,将当前键盘状态由空闲状态更新为按压状态;
输出译码电路,还用于在单次扫描结果为单次扫描无效时,向状态机跳转电路输出第二更新指令;
状态机跳转电路,还用于根据第二更新指令,将当前键盘状态由按压状态更新为空闲状态;
输出译码电路,还用于在获取按键识别结果之后,向状态机跳转电路输出第三更新指令;
状态机跳转电路,还用于根据第三更新指令,将当前键盘状态由按压状态更新为空闲状态。
作为一示例,输出译码电路可在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,形成第一更新指令,将第一更新指令发送给状态机跳转电路。该第一更新指令是指输出译码电路在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,形成的用于控制状态机跳转电路进行状态更新的指令。
本示例中,处于空闲状态的状态机跳转电路,在接收到输出译码电路发送的第一更新指令之后,可将当前键盘状态由空闲状态更新为按压状态,以反映当前时刻有键盘按键被按下,使得输出译码电路在没有完成本次按键扫描和按 键识别之前,其当前键盘状态均为按压状态,使得输出译码电路在下一时刻接收到第一电平状态为从高电平跳变到低电平,不会再触发新的按键扫描和按键识别,有助于保障本次按键扫描和按键识别的正常运行,进而保障电路可靠性。
作为一示例,状态机跳转电路与输出译码电路相连,输出译码电路可在每次监听到当前变化次数清零时,需根据采集到的所有第二电平状态,确定单次扫描结果,在单次扫描结果为单次扫描无效时,可形成第二更新指令,将第二更新指令发送给状态机跳转电路。该第二更新指令是指输出译码电路在每个单次扫描结果为单次扫描无效时,形成的用于控制状态机跳转电路进行状态更新的指令。
本示例中,处于按压状态的状态机跳转电路,在接收到输出译码电路发送的第二更新指令后,可将当前键盘状态由按压状态更新为空闲状态,以反映当前时刻没有键盘按键被按下,使得输出译码电路在下一时刻接收到第一电平状态为从高电平跳变到低电平时,会再触发新的按键扫描和按键识别,有助于保障后续按键扫描和按键识别的正常运行,进而保障电路可靠性。
作为一示例,状态机跳转电路与输出译码电路相连,输出译码电路可在每次监听到当前扫描次数清零时,需根据与目标扫描次数相对应的单次扫描结果,获取按键识别结果,可形成第三更新指令,将第三更新指令发送给状态机跳转电路。本示例中,不管按键识别结果为单次扫描无效还是包含当前有效键值,由于在获取按键识别结果时,该按键行为对应的按键扫描和按键识别均已完成,可形成第三更新指令,控制状态机跳转电路更新状态。该第三更新指令是指输出译码电路在获取按键识别结果之后,形成的用于控制状态机跳转电路进行状态更新的指令。
本示例中,处于按压状态的状态机跳转电路,在接收到输出译码电路发送 的第三更新指令后,可将当前键盘状态由按压状态更新为空闲状态,以反映当前时刻没有键盘按键被按下,使得输出译码电路在下一时刻接收到第一电平状态为从高电平跳变到低电平时,会再触发新的按键扫描和按键识别,有助于保障后续按键扫描和按键识别的正常运行,进而保障电路可靠性。
在一实施例中,如图4所示,键盘扫描电路还包括超时检测电路,超时检测电路与输出译码电路和状态机跳转电路相连,用于根据当前时刻与目标更新指令对应的指令生成时刻,确定等待更新时长;在等待更新时长大于超时时长阈值时,若当前键盘状态维持按压状态,则生成超时复位信号,向状态机跳转电路输出超时复位信号;
状态机跳转电路,还用于根据超时复位信号,将当前键盘状态由按压状态更新为空闲状态;
其中,目标更新指令为第二更新指令或者第三更新指令。
其中,目标更新指令是指用于控制状态机跳转电路进行状态更新的指令,具体为用于控制状态机跳转电路从按压状态更新为空闲状态的指令。本示例中,目标更新指令可以为第二更新指令,也可以为第三更新指令。指令生成时刻是指输出译码电路生成目标更新指令的时刻。超时时长阈值是预先设置的用于评估是否达到超时标准的时长阈值。
作为一示例,输出译码电路在生成第二更新指令或者第三更新指令等目标更新指令时,可记录生成该目标更新指令的指令生成时刻。
本示例中,超时检测电路在监听到输出译码电路生成目标更新指令之后,需获取该指令生成时刻,再将当前时刻与指令生成时刻之间的时间差,确定为等待更新时长。超时检测电路还需判断实时确定的等待更新时长是否达到超时时长阈值,在等待更新时长达到超时时长阈值时,需判断当前键盘状态是否已 经由按压状态更新为空闲状态,若当前键盘状态仍维持按压状态时,说明状态机跳转电路没有及时根据目标更新指令进行状态更新,此时,超时检测电路需生成超时复位信号,并将该超时复位信号发送给状态机跳转电路。可理解地,该超时复位信号是在状态机跳转电路没有及时更新时形成的标识。
本示例中,状态机跳转电路可根据超时检测电路发送的超时复位信号,将当前键盘状态由按压状态恢复为默认状态,即由按压状态更新为空闲状态。
进一步地,超时检测电路还可将超时复位信号发送给输出译码电路、键值检测电路、基础计数器、输出变化计数器和扫描次数计数器等其他电路,以使其他电路的状态恢复为默认状态,例如,使基础计数器中的当前基础数值清零、输出变化计数器中的当前变化次数清零和扫描次数计数器中的当前扫描次数清零等,以保障键盘扫描电路的可靠性和抗干扰能力。
可理解地,采用超时检测电路进行超时检测,可根据形成的超时复位信号,控制状态机跳转电路恢复为默认状态,可保障键盘扫描电路的可靠性和抗干扰能力。
在一实施例中,如图5所示,键盘扫描电路还包括异步复位电路,异步复位电路与状态机跳转电路和键值检测电路相连,用于在当前键盘状态由按压状态更新为空闲状态时,获取键值检测电路采集键盘扫描输入接口对应的第三电平状态,若第三电平状态为从高电平跳变到低电平,则生成异步复位信号,向状态机跳转电路输出异步复位信号;
状态机跳转电路,还用于根据异步复位信号,将当前键盘状态复位为按压状态。
其中,异步复位电路是用于实现异步复位和同步释放的电路。
作为一示例,输出译码电路在生成第二更新指令或者第三更新指令等目标 更新指令,可基于该目标更新指令,控制状态机跳转电路将当前键盘状态由按压状态更新为空闲状态。目标更新指令是指用于控制状态机跳转电路进行状态更新的指令,具体为用于控制状态机跳转电路从按压状态更新为空闲状态的指令。本示例中,目标更新指令可以为第二更新指令,也可以为第三更新指令。
本示例中,异步复位电路在监听到输出译码电路生成目标更新指令,控制状态机跳转电路将当前键盘状态由按压状态更新为空闲状态之后,获取键值检测电路采集键盘扫描输入接口对应的第三电平状态。可理解地,在当前键盘状态由按压状态更新为空闲状态的瞬间,在第三电平状态从高电平跳变到低电平,异步复位电路可生成异步复位信号,并将该异步复位信号发送给状态机跳转电路,以使状态机跳转电路进行状态复位。
本示例中,状态机跳转电路可根据异步复位电路发送的异步复位信号,将当前键盘状态由空闲状态复位为按压状态。可理解地,采用异步复位电路控制状态机跳转电路进行异步复位,可保障键盘扫描电路的可靠性和抗干扰能力。
在一实施例中,如图6所示,键盘扫描电路还包括轮流跳变控制电路,轮流跳变控制电路与输出译码电路相连,用于向输出译码电路输出第一间隔时长和第二间隔时长;
输出译码电路,用于根据第一间隔时长和第二间隔时长,轮流控制控制键盘扫描输出接口输出低电平,实现按键扫描。
其中,第一间隔时长和第二间隔时长均为预先设置的时长,可设置为10us到1ms。该第一间隔时长具体为某一键盘扫描输入接口拉低之后,用于控制所有键盘扫描输出接口拉高的间隔时长。例如,在键盘扫描输入接口KSI0拉低时,在第一间隔时长之后,需控制所有键盘扫描输出接口全部拉高。该第二间隔时长为所有键盘扫描输出接口全部拉高之后,用于控制所有键盘扫描输出接 口轮流输出低电平的间隔时长。例如,在所有键盘扫描输出接口全部拉高之后,每隔第二间隔时长之后,需依次控制所有键盘扫描输出接口轮流输出低电平,以保障所有键盘扫描输出接口的拉高或拉低不是同时发生,从而提高电源的完整性。
如图7所示的键盘扫描电路对应的时序图中,默认按键扫描输出接口KSO0-KSO15均为低电平。假设按下按键扫描输出接口KSO0和键盘扫描输入接口KSI0对应的键盘按键时,键盘扫描输入接口KSI0拉低,每隔第一间隔时长Tgap1后(可配置,1ms,3ms,5ms,7ms,9ms,11ms),按键扫描输出接口KSO0-KSO15全部拉高。再隔第二间隔时长Tgap2(可配置,25us,50us,75us,100us)后,轮流产生KSO低脉冲信号(持续时间可配置,15us,20us,25us,30us),以实现扫描控制操作。本示例中,在按键扫描输出接口KSO0拉低时,其检测到键盘扫描输入接口KSI0为低电平,则完成第一次扫描识别,确定第一次扫描识别对应的单次扫描键值。在第一次扫描识别结束后,再隔第一间隔时长Tgap1后,开始第二次扫描,直接获取第二次扫描识别对应的单次扫描键值。在目标扫描次数为两次时,若两个单次扫描键值一致,则该单次扫描键值可认定为当前有效键值。
在一实施例中,如图8所示,提供一种键盘按键识别方法,包括:
S801:采集键盘扫描输入接口对应的第一电平状态;
S802:获取当前键盘状态;
S803:在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;
S804:在控制键盘扫描输出接口进行按键扫描之后,采集键盘扫描输入接口对应的第二电平状态;
S805:根据第二电平状态,进行按键识别。
作为一示例,步骤S801,采用与键盘扫描输入接口相连的键值检测电路,需实时采集键盘扫描输入接口对应的第一电平状态,在某一键盘按键未被按下时,键值检测电路采集到的第一电平状态为高电平;在某一键盘按键被按下的瞬间,键值检测电路采集到的第一电平状态为从高电平跳变到低电平。可理解地,键值检测电路每隔单位时间采集一个第一电平状态,若前后两个时刻采集到的两个第一电平状态依次为高电平和低电平,即键值检测电路先后检测到键盘扫描输入接口为高电平和低电平,实现从高电平到低电平跳变时,可认定存在键盘按键被按下。
作为一示例,步骤S802中,获取状态机跳转电路输出的当前键盘状态,该当前键盘状态可以反映当前时刻T1之前是否有键盘按键被按下的状态,例如,可反映当前时刻T1之前的上一时刻T0是否有键盘按键被按下的状态。具体可以为空闲状态,也可以为按压状态。
作为一示例,步骤S803中,采用输出译码电路对键值检测电路采集的第一电平状态和状态机跳转电路对应的当前键盘状态进行处理,在当前键盘状态为空闲状态时,说明上一时刻T0没有键盘按键被按下,也就是说上一时刻T0所采集到的第一电平状态为高电平;在第一电平状态为从高电平跳变到低电平时,说明上一时刻T0所采集到的第一电平状态为高电平,当前时刻T1采集到的第一电平状态为低电平,即键盘扫描输入接口从高电平跳变到低电平,说明存在键盘按键在当前时刻T1被按下;因此,在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,可确定某一键盘按键在当前时刻T1被按下,此时,需控制键盘扫描输出接口进行按键扫描,即控制键盘扫描输出接口依据特定规则输出可实现按键扫描的不同电平,例如,控制所有键盘扫描 输出接口轮流输出低电平,完成对所有键盘按键进行扫描,以便根据键值检测电路采集到的第二电平状态完成按键识别。
作为一示例,步骤S804中,采用键值检测电路在输出译码电路控制键盘扫描输出接口进行按键扫描之后(例如,控制所有键盘扫描输出接口轮流输出低电平之后),需实时采集键盘扫描输入接口对应的第二电平状态,该第二电平状态可以为高电平也可以为低电平。本示例中,每一键盘扫描输出接口与一键盘扫描输入接口相匹配,对应同一键盘按键,例如,任一键盘按键A,其与键盘扫描电路通过键盘扫描输入接口和键盘扫描输出接口相连,以保障正常的信号传输。
作为一示例,步骤S805中,采用输出译码电路在控制键盘扫描输出接口进行按键扫描之后,接收键值检测电路实时采集到的键盘扫描输入接口对应的第二电平状态,以便根据第二电平状态,完成按键识别。本示例中,在键盘上设有S个键盘按键时,需控制S个键盘扫描输出接口轮流输出低电平,以便根据每个键盘扫描输出接口对应的键盘扫描输出接口对应的第二电平状态,确定具体是哪个键盘按键被按下,以识别被按下的键盘按键对应的按键键值。例如,在控制键盘扫描输出接口进行按键扫描具体为控制所有键盘扫描输出接口轮流输出低电平时,输出译码电路在控制第i个键盘按键对应的键盘扫描输出接口KSOi输出低电平之后,可采集与该键盘扫描输出接口KSOi相对应的键盘扫描输出接口KSIi对应的第二电平状态,可根据第二电平状态,确定第i个键盘按键是否被按下。例如,在第二电平状态为低电平时,认定第i个键盘按键被按下;在第二电平状态为高电平时,认定第i个键盘按键未被按下,以识别出第i个键盘按键对应的按键键值。
本实施例所提供的键盘按键识别方法中,只有在当前键盘状态为空闲状态 且第一电平状态为从高电平跳变到低电平时,才控制键盘扫描输出接口进行按键扫描,一方面可确保只有在存在键盘按键被按下时,才会执行按键扫描,避免在不满足当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平这一条件时触发按键扫描,可节省系统功耗,并提高电路可靠性。通过控制键盘扫描输出接口进行按键扫描,根据键盘扫描输入接口对应的第二电平状态,完成按键识别,可完成按键扫描及按键识别过程,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
在一实施例中,在步骤S803之后,在控制键盘扫描输出接口进行按键扫描之后,键盘按键识别方法还包括:
S901:在接收到目标时钟沿时,更新当前基础数值为目标基础数值,在监听到输出译码电路控制键盘扫描输出接口进行按键扫描时,控制当前基础数值清零;
S902:在监听到当前基础数值清零时,更新当前变化次数,若当前变化次数达到目标按键数量,则控制当前变化次数清零;
S903:在监听到当前变化次数清零时,更新当前扫描次数,若当前扫描次数达到目标扫描次数,则控制当前扫描次数清零;
S904:根据当前基础数值、当前变化次数和当前扫描次数,完成按键扫描和按键识别。
作为一示例,步骤S901中,采用基础计数器实时接收当前时钟沿,在当前时钟沿为目标时钟沿时,先触发基础计数器开始计数,更新当前基础数值为目标基础数值,即将当前基础数值由0变为1。然后,基础计数器在当前基础数值由0变为1时,可使输出译码电路控制键盘扫描输出接口进行按键扫描,具体为可使输出译码电路控制第i个键盘按键对应的键盘扫描输出接口输出 低电平,具体在每次扫描控制过程中,可使输出译码电路控制所有键盘扫描输出接口全部拉高或全部拉低,以实现键盘扫描操作。可理解地,在输出译码电路控制键盘扫描输出接口输出低电平时,可使键值检测电路采集键盘扫描输入接口对应的第二电平状态,以便后续根据采集到的第二电平状态,完成按键识别。最后,基础计数器在监听到输出译码电路控制键盘扫描输出接口进行按键扫描时,即控制键盘扫描输出接口输出低电平之后,需控制当前基础数值清零,即将当前基础数值由1变为0,以便在下次接收到目标时钟沿时,可将当前基础数值由0变为1,再基于当前基础数值,控制键盘扫描输出接口输出低电平,从而保障键盘扫描电路的可靠性。
作为一示例,步骤S902中,采用输出变化计数器实时监听基础计数器中的当前基础数值是否清零,在每次监听到当前基础数值清零时,需更新当前变化次数N1,即在上一时刻的当前变化次数N0的基础上加1,以获取当前时刻对应的当前变化次数N1,即N1=N0+1。输出变化计数器在获取到更新后的当前变化次数N1时,需将当前变化次数N1与预先设置的目标按键数量N进行比较;若当前变化次数N1达到目标按键数量N(即N1=N),则认定本次按键扫描完成,此时,需控制当前变化次数清零,以便下次进行按键扫描时,可重新计数,从而保障键盘扫描电路的可靠性。可理解地,若当前变化次数N1未达到目标按键数量N(即N1<N),则需继续监听当前基础数值是否清零。
作为一示例,步骤S903中,采用扫描次数计数器实时监听输出变化计数器中的当前变化次数是否清零,在每次监听到当前变化次数清零时,需要更新当前扫描次数M1,即在上一时刻的当前扫描次数M0的基础上加1,以获取当前时刻对应的当前扫描次数M1,即M1=M0+1。扫描次数计数器在获取到更新后的当前扫描次数M1之后,需将当前扫描次数M1与预先设置的目标扫描次数M 进行比较;若当前扫描次数M1达到目标扫描次数M(即M1=M),则认定完成按键扫描,此时,可当前扫描次数清零,以便在下次监听到当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,可重新进行按键扫描,从而保障键盘扫描电路的可靠性。可理解地,若当前扫描次数M1未达到目标扫描次数M(即M1<M)时,则需要继续监听输出变化计数器中的当前变化次数是否清零。
作为一示例,步骤S904中,采用输出译码电路根据当前基础数值、当前变化次数和当前扫描次数,完成按键扫描和按键识别。例如,输出译码电路可根据当前基础数值的变化,控制键盘扫描输出接口输出低电平,以完成按键扫描;还可以根据当前变化次数和当前扫描次数,完成按键识别。
本实施例所提供的键盘按键识别方法中,可根据接收到的目标时钟沿更新当前基础数、当前变化次数和当前扫描次数,以便输出译码电路根据不同计数器中的数值变化,完成对所有键盘按键进行按键扫描和按键识别,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
在一实施例中,如图10所示,步骤S904,即根据当前基础数值、当前变化次数和当前扫描次数,完成按键扫描和按键识别,包括:
S1001:在监听到当前基础数值为目标基础数值时,控制键盘扫描输出接口输出低电平,实现按键扫描;
S1002:在监听到当前变化次数清零时,获取与目标按键数量相对应的第二电平状态,根据所有第二电平状态,获取当前扫描次数对应的单次扫描结果;
S1003:在监听到当前扫描次数清零时,获取与目标扫描次数相对应的单次扫描结果,根据所有单次扫描结果,获取按键识别结果。
作为一示例,步骤S1001中,采用输出译码电路监听到基础计数器记录的当前基础数值,在当前基础数值为目标基础数值时,需控制键盘扫描输出接口输出低电平,以使键值检测电路采集键盘扫描输入接口对应的第二电平状态。即基础计数器的当前基础数值每次由0变为1时,输出译码电路均需控制键盘扫描输出接口输出一次低电平,实现对一个键盘按键进行扫描,此时,键值检测电路可采集到与该键盘扫描输出接口相匹配的键盘扫描输入接口对应的第二电平状态,并将该第二电平状态反馈给输出译码电路。可理解地,在键值检测电路采集到的某一第二电平状态为低电平时,认定与该键盘扫描输入接口相对应的键盘按键被按下;在键值检测电路采集到的某一第二电平状态为高电平时,认定与该键盘扫描输入接口相对应的键盘按键没有被按下,为释放按键。
作为一示例,步骤S1002中,采用输出译码电路监控输出变化计数器,在监听到输出变化计数器清零时,认定已经对与目标按键数量N相对应的键盘按键完成本次扫描,此时,需获取扫描次数计数器记录的当前扫描次数,可对本次扫描过程中采集到的与目标按键数量N相对应的第二电平状态,根据与目标按键数量N相对应的第二电平状态,判定本次扫描是否识别到有效按键,以获取当前扫描次数对应的单次扫描结果,即根据N个第二电平状态为高电平还是低电平,确定本次扫描是否有效,以获取单次扫描有效或者单次扫描无效的单次扫描结果,在单次扫描结果为单次扫描有效时,还可获取单次扫描键值。该单次扫描键值是指本次扫描所识别到的键值。
作为一示例,采用输出译码电路监听当前扫描次数清零,在监听到当前扫描次数清零时,认定已经完成与目标扫描次数M相匹配的扫描操作,可根据获取到的M个单次扫描结果,完成最终的按键识别,即根据M个单次扫描结果,确定是否存在有效按键,在存在有效按键的情况下,获取有效按键对应的当前 有效键值。此处的有效按键是指通过按键扫描确定被按下的按键,即触发第一电平状态为从高电平跳变到低电平这一按键行为所按下的按键。当前有效键值是指有效按键对应的键值。
本实施例所提供的键盘按键识别方法中,可根据当前基础数值,控制键盘扫描输出接口输出低电平,实现按键扫描,并根据当前变化次数和当前扫描次数,实现按键识别,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
在一实施例中,如图11所示,步骤S1002,即在监听到当前变化次数清零时,获取与目标按键数量相对应的第二电平状态,根据所有第二电平状态,获取当前扫描次数对应的单次扫描结果,包括:
S1101:在监听到当前变化次数清零时,获取与目标按键数量相对应的第二电平状态;
S1102:若所有第二电平状态均为高电平,则获取单次扫描无效的单次扫描结果;
S1103:若存在一个第二电平状态为低电平,则获取单次扫描有效的单次扫描结果。
作为一示例,步骤S1101中,采用输出译码电路监听输出变化计数器的当前变化次数,在监听到输出变化计数器的当前变化次数清零时,认定已经对N个键盘按键完成本次扫描,可获取N个键盘按键对应的键盘扫描输入接口对应的第二电平状态,该第二电平状态可以为高电平也可以为低电平。
作为一示例中,步骤S1102中,采用输出译码电路监听N个键盘按键对应的第二电平状态,在N个键盘按键对应的第二电平状态均为高电平时,认定N个键盘按键在本次扫描过程均没有被按下,进而认定本次扫描行为为无效行 为,因此,可获取单次扫描无效的单次扫描结果。相应地,在输出译码电路每次监听到当前变化次数清零时,其单次扫描结果为单次扫描无效时,认定本次扫描行为为无效行为,可直接输出单次扫描无效的按键识别结果,无需等待监听到当前扫描次数清零,即可结束本次按键扫描及按键识别过程,有助于节省等待时间,简化处理流程,提高处理效率。
作为一示例,步骤S1103中,采用输出译码电路监听N个键盘按键对应的第二电平状态,在N个键盘按键对应的第二电平状态中,存在一个第二电平状态为低电平时,认定N个键盘按键中的一个键盘按键在本次扫描过程中被认定为处于按压状态,进而认定本次扫描行为为有效行为,因此,可获取单次扫描有效的单次扫描结果。
在一实施例中,如图12所示,步骤1003中,根据所有单次扫描结果,获取按键识别结果,包括:
S1201:若存在单次扫描结果为单次扫描无效,则输出单次扫描无效的按键识别结果;
S1202:若所有单次扫描结果均为单次扫描有效,则获取与目标扫描次数相对应的单次扫描键值,基于所有单次扫描键值,获取按键识别结果。
其中,当前有效键值是针对一个按键行为所识别出的按键键值。
输出译码电路在每次监听到当前扫描次数清零时,即完成与当前扫描次数相对应的单次扫描操作可获取与目标扫描次数相对应的单次扫描结果,在目标扫描次数为M时,可获取M个单次扫描结果,每个单次扫描结果可以为单次扫描有效也可以为单次扫描无效,因此,输出译码电路可根据所有单次扫描结果执行以下之一的操作:
作为一示例,步骤S1201,输出译码电路在存在单次扫描结果为单次扫描 无效时,输出单次扫描无效的按键识别结果。本示例中,输出译码电路在M个单次扫描结果中,任一次单次扫描结果为单次扫描无效时,认定单次扫描操作之后,没有识别到相应的单次扫描键值,此时,可直接输出单次扫描无效的按键识别结果,无需执行后续操作,即可结束本次按键扫描及按键识别过程,有助于节省等待时间,简化处理流程,提高处理效率。
作为一示例,步骤S1202,即输出译码电路在所有单次扫描结果均为单次扫描有效时,获取与目标扫描次数相对应的单次扫描键值,基于所有单次扫描键值,获取按键识别结果。本示例中,输出译码电路在M个单次扫描结果均为单次扫描有效时,可获取每次扫描所识别出的单次扫描键值,即可获取M个单次扫描键值,由于M个单次扫描键值可能相同,也可能不相同,因此,需要基于所有单次扫描结果进行比较分析,以确定最终的按键识别结果,从而保障按键识别结果的准确性。
在一实施例中,如图13所示,步骤S1202中,基于所有单次扫描键值,获取按键识别结果,包括:
S1301:若存在单次扫描键值不相同,则输出单次扫描无效的按键识别结果;
S1302:若所有单次扫描键值均相同,则根据单次扫描键值,确定当前有效键值,输出包含当前有效键值的按键识别结果。
输出译码电路在M个单次扫描结果均为单次扫描有效时,可获取M个单次扫描键值,M个单次扫描键值可以相同也可以不相同,因此,输出译码电路可根据所有单次扫描键值执行以下之一的操作。
作为一示例,步骤S1301中,输出译码电路在获取M个单次扫描键值之后,需判断M个单次扫描键值是否相同,若存在单次扫描键值不同,则无法确定其 具体为哪个有效按键对应的键值,因此,可输出单次扫描无效的按键识别结果。
作为一示例,步骤S1302中,输出译码电路在获取M个单次扫描键值之后,需判断M个单次扫描键值是否相同,若所有单次扫描键值均相同,则将单次扫描键值,确定为当前有效键值,输出包含当前有效键值的按键识别结果,以保障当前有效键值的准确性。可理解地,在目标扫描次数为1时,其只获取到1个单次扫描键值,可直接将该当前扫描键值确定为当前有效键值。
在一实施例中,如图14所示,在步骤S1003之后,即在根据所有单次扫描结果,获取按键识别结果之后,键盘按键识别方法还包括:
S1401:在按键识别结果为包含当前有效键值时,则确定历史有效键值,获取当前有效键值和历史有效键值对应的按键间隔时长;
S1402:根据按键间隔时长和当前有效键值,确定目标有效键值。
其中,目标有效键值是指最终识别出的按键键值。
作为一示例,输出译码电路在按键识别结果为有效时,每次按键扫描均会输出一个当前有效键值,由于当前键盘识别过程中还存在组合按键的情况,例如,电脑键盘上的Ctrl+C组合为复制的快捷指令的情况,因此,输出译码电路还需要在识别获取包含当前有效键值的按键识别结果之后,还可以执行如下操作,以确定最终的目标有效键值:
作为一示例,步骤S1401中,输出译码电路在按键识别结果为包含当前有效键值时,需获取与当前有效键值相对应的历史有效键值。此处的当前有效键值可以理解为当前时刻扫描识别出的键盘按键的键值。相应地,历史有效键值可以理解为当前时刻之前的历史时刻扫描识别出的键盘按键的键值。输出译码电路在确定当前有效键值和历史有效键值时,需分别获取当前有效键值对应的当前键值生成时间和历史有效键值对应的历史键值生成时间,将当前键值生成 时间和历史键值生成时间的时间差,确定为按键间隔时长。可理解地,该按键间隔时长可理解为两个有效键值的生成时间的时间差。在历史有效键值为一个时,该按键间隔时长为当前键值生成时间与该历史有效键值对应的历史键值生成时间之间的时间差;在历史有效键值为至少两个时,该按键间隔时长为当前键值生成时间与最早一个历史有效键值对应的历史键值生成时间之间的时间差。
作为一示例,步骤S1402中,输出译码电路在获取到按键间隔时长之后,需将按键间隔时长与目标时长阈值进行比较,以便根据时长比较结果,以根据该时长比较结果,评估当前有效键值和历史有效键值是否有可能为组合按键,从而获取最终的目标有效键值,以保障目标有效键值识别的准确性。此处的目标时长阈值是预先设置的用于评估是否满足组合按键条件的时长阈值。
在一实施例中,如图15所示,步骤S1402,即根据按键间隔时长和当前有效键值,确定目标有效键值,包括:
S1501:若按键间隔时长大于目标时长阈值,则将当前有效键值确定为目标有效键值;
S1502:若按键间隔时长不大于目标时长阈值,则基于当前有效键值和历史有效键值,判断是否满足按键组合规则,获取组合判断结果,根据组合判断结果,确定目标有效键值。
作为一示例,步骤S1501中,输出译码电路在获取到按键间隔时长之后,需将按键间隔时长与目标时长阈值进行比较,在按键间隔时长大于目标时长阈值时,认定当前有效键值和历史有效键值之间的按键间隔时长过大,基本不可能为组合按键,即认定当前有效键值极可能为单个按键,将当前有效键值确定为目标有效键值。例如,设当前有效键值和历史有效键值之间的按键间隔时长 为Ts,目标时长阈值为Tm,当前有效键值为C,历史有效键值为Ctrl,在Ts>Tm时,认定用户按下键盘按键C和Ctrl之间的按键间隔时长过长,因此,可将C确定为目标有效键值。
作为一示例,步骤S1502中,输出译码电路在获取到按键间隔时长之后,需将按键间隔时长与目标时长阈值进行比较,在按键间隔时长不大于目标时长阈值时,认定当前有效键值和历史有效键值之间的按键间隔时长较小,有可能为组合按键,此时,需基于当前有效键值和历史有效键值,判断是否满足按键组合规则,获取组合判断结果,以便根据该组合判断结果,评估当前有效键值和历史有效键值是否为组合按键,从而获取最终的目标有效键值,以保障目标有效键值识别的准确性。此处的按键组合规则是预先配置的用于反映不同按键组合,以使其可完成特定功能控制的规则。
在一实施例中,如图16所示,步骤S1502中,根据组合判断结果,确定目标有效键值,包括:
S1601:若组合判断结果为满足按键组合规则,则根据当前有效键值和历史有效键值,确定目标有效键值;
S1602:若组合判断结果为不满足按键组合规则,则将当前有效键值确定为目标有效键值。
作为一示例,步骤S1601中,输出译码电路基于当前有效键值和历史有效键值,判断是否满足按键组合规则,在当前有效键值和历史有效键值满足按键组合规则时,认定其当前有效键值和历史有效键值可形成组合按键,可基于当前有效键值和历史有效键值的组合,确定目标有效键值,以便基于目标有效键值,生成对应的目标控制指令。例如,当前有效键值为C,历史有效键值为Ctrl,其Ctrl+C满足按键组合规则的复制组合规则,可将Ctrl+C确定为目标有效键 值。
作为一示例,步骤S1602中,输出译码电路基于当前有效键值和历史有效键值,判断是否满足按键组合规则,在当前有效键值和历史有效键值不满足按键组合规则时,认定其当前有效键值和历史有效键值不可形成组合按键,可将当前有效键值,确定为目标有效键值。例如,若当前有效键值为Ctrl,历史有效键值为C,其不满足按键组合规则,可将C+Ctrl不符合按键组合规则,可认定当前有效键值和历史有效键值分别为单个按键,因此,可将当前有效键值Ctrl,确定为目标有效键值。
本实施例中,输出译码电路可根据按键间隔时长与目标时长阈值的比较结果以及是否符合按键组合规则这两个条件,将单个当前有效键值确定为目标有效键值,或者,基于历史有效键值和当前有效键值确定目标有效键值,以保障目标有效键值的准确识别,确保组合按键的功能识别的准确性。
在一实施例中,如图17所示,在步骤S1003之后,即在监听到当前变化次数清零时,获取与目标按键数量相对应的第二电平状态,根据所有第二电平状态,获取当前扫描次数对应的单次扫描结果之后,键盘按键识别方法还包括:
S1701:在监听到当前扫描次数为目标扫描次数时,若当前扫描次数对应的单次扫描结果为单次扫描无效,则获取存在毛刺的毛刺检测结果;若当前扫描次数对应的单次扫描结果为单次扫描有效,则获取不存在毛刺的毛刺检测结果;
S1702:根据毛刺检测结果,输出毛刺检测信号。
作为一示例,步骤S1701中,采用输出译码电路监听当前扫描次数,在当前扫描次数由0更新为目标扫描次数(如1)时,可对本次扫描过程中采集到的与目标按键数量N相对应的第二电平状态,根据与目标按键数量N相对应的 第二电平状态,判定本次扫描是否识别到有效按键,以获取当前扫描次数对应的单次扫描结果,即获取第1个单次扫描结果。本示例中,在第1个单次扫描结果为单次扫描无效时,说明键盘较大概率存在毛刺,可获取存在毛刺的毛刺检测结果;在第1个单次扫描结果为单次扫描有效,说明键盘较大概率不存在毛刺,获取不存在毛刺的毛刺检测结果。
作为一示例,步骤S1702中,采用毛刺检测电路接收毛刺检测结果,可根据该毛刺检测结果,确定其输出的毛刺检测信号,例如,可采用毛刺检测信号1表示存在毛刺,采用毛刺检测信号0表示不存在毛刺,以便根据该毛刺检测信号进行后续信号控制,以避免毛刺对键盘按键的控制造成影响。例如,在毛刺检测电路与键盘MCU通信时,键盘MCU可根据毛刺检测电路输出的毛刺检测信号,确定当前键盘按键是否存在毛刺,从而进行后续信号控制,从而避免毛刺对键盘按键的控制造成影响。
在一实施例中,如图18所示,键盘按键识别方法还包括:
S1801:在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,输出第一更新指令,根据第一更新指令,将当前键盘状态由空闲状态更新为按压状态;
S1802:在单次扫描结果为单次扫描无效时,输出第二更新指令,根据第二更新指令,将当前键盘状态由按压状态更新为空闲状态;
S1803:在获取按键识别结果之后,输出第三更新指令,根据第三更新指令,将当前键盘状态由按压状态更新为空闲状态。
作为一示例,步骤S1801中,输出译码电路可在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,形成第一更新指令,将第一更新指令发送给状态机跳转电路。相应地,处于空闲状态的状态机跳转电路,在接 收到输出译码电路发送的第一更新指令之后,可将当前键盘状态由空闲状态更新为按压状态,以反映当前时刻有键盘按键被按下,使得输出译码电路在没有完成本次按键扫描和按键识别之前,其当前键盘状态均为按压状态,使得输出译码电路在下一时刻接收到第一电平状态为从高电平跳变到低电平,不会再触发新的按键扫描和按键识别,有助于保障本次按键扫描和按键识别的正常运行,进而保障电路可靠性。
作为一示例,步骤S1802中,采用状态机跳转电路监听到当前变化次数,在每次监听到当前变化次数清零时,需根据采集到的所有第二电平状态,确定单次扫描结果,在单次扫描结果为单次扫描无效时,可形成第二更新指令,将第二更新指令发送给状态机跳转电路。相应地,处于按压状态的状态机跳转电路,在接收到输出译码电路发送的第二更新指令后,可将当前键盘状态由按压状态更新为空闲状态,以反映当前时刻没有键盘按键被按下,使得输出译码电路在下一时刻接收到第一电平状态为从高电平跳变到低电平时,会再触发新的按键扫描和按键识别,有助于保障后续按键扫描和按键识别的正常运行,进而保障电路可靠性。
作为一示例,步骤S1803中,采用输出译码电路监听当前扫描次数,在每次监听到当前扫描次数清零时,需根据与目标扫描次数相对应的单次扫描结果,获取按键识别结果,可形成第三更新指令,将第三更新指令发送给状态机跳转电路。不管按键识别结果为单次扫描无效还是包含当前有效键值,由于在获取按键识别结果时,该按键行为对应的按键扫描和按键识别均已完成,可形成第三更新指令,控制状态机跳转电路更新状态。相应地,处于按压状态的状态机跳转电路,在接收到输出译码电路发送的第三更新指令后,可将当前键盘状态由按压状态更新为空闲状态,以反映当前时刻没有键盘按键被按下,使得 输出译码电路在下一时刻接收到第一电平状态为从高电平跳变到低电平时,会再触发新的按键扫描和按键识别,有助于保障后续按键扫描和按键识别的正常运行,进而保障电路可靠性。
在一实施例中,如图19所示,键盘按键识别方法还包括:
S1901:根据当前时刻与目标更新指令对应的指令生成时刻,确定等待更新时长;在等待更新时长大于超时时长阈值时,若当前键盘状态维持按压状态,则生成超时复位信号,输出超时复位信号;
S1902:根据超时复位信号,将当前键盘状态由按压状态更新为空闲状态;
其中,目标更新指令为第二更新指令或者第三更新指令。
作为一示例,步骤S1901中,采用超时检测电路在监听到输出译码电路生成目标更新指令之后,需获取该指令生成时刻,再将当前时刻与指令生成时刻之间的时间差,确定为等待更新时长。超时检测电路还需判断实时确定的等待更新时长是否达到超时时长阈值,在等待更新时长达到超时时长阈值时,需判断当前键盘状态是否已经由按压状态更新为空闲状态,若当前键盘状态仍维持按压状态时,说明状态机跳转电路没有及时根据目标更新指令进行状态更新,此时,超时检测电路需生成超时复位信号,并将该超时复位信号发送给状态机跳转电路。可理解地,该超时复位信号是在状态机跳转电路没有及时更新时形成的标识。
作为一示例,步骤S1902中,状态机跳转电路可根据超时检测电路发送的超时复位信号,将当前键盘状态由按压状态恢复为默认状态,即由按压状态更新为空闲状态,以保障键盘扫描电路的可靠性和抗干扰能力。
在一实施例中,如图20所示,键盘按键识别方法还包括:
S2001:在当前键盘状态由按压状态更新为空闲状态时,获取键盘扫描输 入接口对应的第三电平状态,若第三电平状态为从高电平跳变到低电平,则生成异步复位信号,向状态机跳转电路输出异步复位信号;
S2002:根据异步复位信号,将当前键盘状态复位为按压状态。
作为一示例,步骤S2001中,采用异步复位电路在监听到输出译码电路生成目标更新指令,控制状态机跳转电路将当前键盘状态由按压状态更新为空闲状态之后,获取键值检测电路采集键盘扫描输入接口对应的第三电平状态。可理解地,在当前键盘状态由按压状态更新为空闲状态的瞬间,在第三电平状态从高电平跳变到低电平,异步复位电路可生成异步复位信号,并将该异步复位信号发送给状态机跳转电路,以使状态机跳转电路进行状态复位。
作为一示例,步骤S2002中,采用状态机跳转电路可根据异步复位电路发送的异步复位信号,将当前键盘状态由空闲状态复位为按压状态。可理解地,采用异步复位电路控制状态机跳转电路进行异步复位,可保障键盘扫描电路的可靠性和抗干扰能力。
在一实施例中,如图21所示,控制键盘扫描输出接口进行按键扫描,包括:
S2101:获取第一间隔时长和第二间隔时长;
S2102:根据第一间隔时长和第二间隔时长,轮流控制控制键盘扫描输出接口输出低电平,实现按键扫描;
其中,第一间隔时长是用于控制所有键盘扫描输出接口输出高电平的间隔时长;第二间隔时长是用于控制所有键盘扫描输出接口输出低电平的间隔时长。
作为一示例,步骤S2101中,采用输出译码电路获取预先设置的第一间隔时长和第二间隔时长。该第一间隔时长具体为某一键盘扫描输入接口拉低之 后,用于控制所有键盘扫描输出接口拉高的间隔时长。该第二间隔时长为所有键盘扫描输出接口全部拉高之后,用于控制所有键盘扫描输出接口轮流输出低电平的间隔时长。
作为一示例,步骤S2102中,采用输出译码电路在键盘扫描输入接口KSI0拉低时,在第一间隔时长之后,需控制所有键盘扫描输出接口全部拉高。相应地,采用输出译码电路在所有键盘扫描输出接口全部拉高之后,每隔第二间隔时长之后,需依次控制所有键盘扫描输出接口轮流输出低电平,以保障所有键盘扫描输出接口的拉高或拉低不是同时发生,从而提高电源的完整性。
本申请还提供一种芯片,包括上述实施例的键盘扫描识别电路,该键盘扫描识别电路只有在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,才控制键盘扫描输出接口进行按键扫描,一方面可确保只有在存在键盘按键被按下时,才会执行按键扫描,避免在不满足当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平这一条件时触发按键扫描,可节省系统功耗,并提高电路可靠性。采用输出译码电路控制键盘扫描输出接口进行按键扫描,并根据键盘扫描输入接口对应的第二电平状态,完成按键识别,以实现采用键盘扫描电路这一硬件设备,完成按键扫描及按键识别过程,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
本申请还提供一种键盘,键盘包括键盘按键和键盘MCU,还包括上述实施例中的键盘扫描电路,键盘扫描电路与键盘按键和键盘MCU相连。只有在当前键盘状态为空闲状态且第一电平状态为从高电平跳变到低电平时,才控制键盘扫描输出接口进行按键扫描,一方面可确保只有在存在键盘按键被按下时,才会执行按键扫描,避免在不满足当前键盘状态为空闲状态且第一电平状态为从 高电平跳变到低电平这一条件时触发按键扫描,可节省系统功耗,并提高电路可靠性。采用输出译码电路控制键盘扫描输出接口进行按键扫描,并根据键盘扫描输入接口对应的第二电平状态,完成按键识别,以实现采用键盘扫描电路这一硬件设备,完成按键扫描及按键识别过程,使键盘扫描电路应用在键盘时,无需占用键盘MCU的CPU资源,有助于保障键盘MCU的运行效率。
以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (30)

  1. 一种键盘扫描电路,包括:
    键值检测电路,与键盘扫描输入接口相连,用于采集所述键盘扫描输入接口对应的第一电平状态;
    状态机跳转电路,与所述键值检测电路相连,用于输出当前键盘状态;
    输出译码电路,与所述键值检测电路、所述状态机跳转电路和键盘扫描输出接口相连,用于在所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;
    键值检测电路,还用于在控制键盘扫描输出接口进行按键扫描之后,采集所述键盘扫描输入接口对应的第二电平状态;
    输出译码电路,还用于根据所述第二电平状态,进行按键识别。
  2. 如权利要求1所述的键盘扫描电路,其中,所述键盘扫描电路还包括基础计数器、输出变化计数器和扫描次数计数器;
    所述基础计数器,用于在接收到目标时钟沿时,更新当前基础数值为目标基础数值,在监听到输出译码电路控制键盘扫描输出接口进行按键扫描时,控制所述当前基础数值清零;
    所述输出变化计数器,与所述基础计数器相连,用于在监听到所述当前基础数值清零时,更新当前变化次数,若所述当前变化次数达到目标按键数量,则控制所述当前变化次数清零;
    所述扫描次数计数器,与所述输出变化计数器相连,用于在监听到所述当前变化次数清零时,更新当前扫描次数,若所述当前扫描次数达到目标扫描次数,则控制所述当前扫描次数清零;
    所述输出译码电路,与所述基础计数器、所述输出变化计数器和所述扫描次数计数器相连,用于根据所述当前基础数值、所述当前变化次数和所述当前扫描次数,完成按键扫描和按键识别。
  3. 如权利要求2所述的键盘扫描电路,其中,所述输出译码电路,还用于在监听到所述当前基础数值为目标基础数值时,控制键盘扫描输出接口输出低电平,实现按键扫描;
    所述输出译码电路,还用于在监听到所述当前变化次数清零时,获取与目标按键数量相对应的所述第二电平状态,根据所有所述第二电平状态,获取所述当前扫描次数对应的单次扫描结果;
    所述输出译码电路,还用于在监听到所述当前扫描次数清零时,获取与所述目标扫描次数相对应的单次扫描结果,根据所有所述单次扫描结果,获取按键识别结果。
  4. 如权利要求3所述的键盘扫描电路,其中,所述输出译码电路,还用于在监听到所述当前变化次数清零时,获取与目标按键数量相对应的所述第二电平状态;若所有所述第二电平状态均为高电平,则获取单次扫描无效的单次扫描结果;若存在一个所述第二电平状态为低电平,则获取单次扫描有效的单次扫描结果。
  5. 如权利要求3所述的键盘扫描电路,其中,所述输出译码电路,还用于在存在所述单次扫描结果为单次扫描无效时,输出单次扫描无效的按键识别结果;在所有所述单次扫描结果均为单次扫描有效时,获取与所述目标扫描次数相对应的单次扫描键值,基于所有所述单次扫描键值,获取按键识别结果。
  6. 如权利要求5所述的键盘扫描电路,其中,所述输出译码电路,还用 于在存在所述单次扫描键值不相同时,输出单次扫描无效的按键识别结果;在所有所述单次扫描键值均相同时,根据所述单次扫描键值,确定当前有效键值,输出包含当前有效键值的按键识别结果。
  7. 如权利要求3所述的键盘扫描电路,其中,所述输出译码电路,还用于在所述按键识别结果为包含当前有效键值时,则确定历史有效键值,获取所述当前有效键值和所述历史有效键值对应的按键间隔时长;根据所述按键间隔时长和所述当前有效键值,确定目标有效键值。
  8. 如权利要求7所述的键盘扫描电路,其中,所述输出译码电路,还用于在所述按键间隔时长大于目标时长阈值时,将所述当前有效键值确定为目标有效键值;在所述按键间隔时长不大于目标时长阈值时,基于所述当前有效键值和所述历史有效键值,判断是否满足按键组合规则,获取组合判断结果,根据所述组合判断结果,确定目标有效键值。
  9. 如权利要求8所述的键盘扫描电路,其中,所述输出译码电路,还用于在所述组合判断结果为满足按键组合规则时,根据所述当前有效键值和所述历史有效键值,确定目标有效键值;在所述组合判断结果为不满足按键组合规则时,将所述当前有效键值确定为目标有效键值。
  10. 如权利要求3所述的键盘扫描电路,其中,所述键盘扫描电路还包括毛刺检测电路,所述毛刺检测电路与所述输出译码电路相连;
    所述输出译码电路,还用于在监听到所述当前扫描次数为目标扫描次数时,若所述当前扫描次数对应的所述单次扫描结果为单次扫描无效,则获取存在毛刺的毛刺检测结果;若所述当前扫描次数对应的所述单次扫描结果为单次扫描有效,则获取不存在毛刺的毛刺检测结果;
    所述毛刺检测电路,用于根据所述毛刺检测结果,输出毛刺检测信号。
  11. 如权利要求3所述的键盘扫描电路,其中,所述输出译码电路,还用于在所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,向所述状态机跳转电路输出第一更新指令;
    所述状态机跳转电路,还用于根据所述第一更新指令,将所述当前键盘状态由空闲状态更新为按压状态;
    所述输出译码电路,还用于在所述单次扫描结果为单次扫描无效时,向所述状态机跳转电路输出第二更新指令;
    所述状态机跳转电路,还用于根据所述第二更新指令,将所述当前键盘状态由按压状态更新为空闲状态;
    所述输出译码电路,还用于在获取所述按键识别结果之后,向所述状态机跳转电路输出第三更新指令;
    所述状态机跳转电路,还用于根据所述第三更新指令,将所述当前键盘状态由按压状态更新为空闲状态。
  12. 如权利要求11所述的键盘扫描电路,其中,所述键盘扫描电路还包括超时检测电路,所述超时检测电路与所述输出译码电路和所述状态机跳转电路相连,用于根据当前时刻与目标更新指令对应的指令生成时刻,确定等待更新时长;在所述等待更新时长大于超时时长阈值时,若所述当前键盘状态维持按压状态,则生成超时复位信号,向所述状态机跳转电路输出超时复位信号;
    所述状态机跳转电路,还用于根据所述超时复位信号,将所述当前键盘状态由按压状态更新为空闲状态;
    其中,所述目标更新指令为所述第二更新指令或者所述第三更新指令。
  13. 如权利要求11所述的键盘扫描电路,其中,所述键盘扫描电路还包 括异步复位电路,所述异步复位电路与所述状态机跳转电路和所述键值检测电路相连,用于在所述当前键盘状态由按压状态更新为空闲状态时,获取所述键值检测电路采集所述键盘扫描输入接口对应的第三电平状态,若所述第三电平状态为从高电平跳变到低电平,则生成异步复位信号,向所述状态机跳转电路输出异步复位信号;
    所述状态机跳转电路,还用于根据所述异步复位信号,将所述当前键盘状态复位为按压状态。
  14. 如权利要求1所述的键盘扫描电路,其中,所述键盘扫描电路还包括轮流跳变控制电路,所述轮流跳变控制电路与所述输出译码电路相连,用于向所述输出译码电路输出第一间隔时长和第二间隔时长;
    所述输出译码电路,用于根据所述第一间隔时长和所述第二间隔时长,轮流控制所述控制键盘扫描输出接口输出低电平,实现按键扫描;
    其中,所述第一间隔时长是用于控制所有键盘扫描输出接口输出高电平的间隔时长;所述第二间隔时长是用于控制所有键盘扫描输出接口输出低电平的间隔时长。
  15. 一种键盘按键识别方法,包括:
    采集键盘扫描输入接口对应的第一电平状态;
    输出当前键盘状态;
    在所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,控制键盘扫描输出接口进行按键扫描;
    在控制键盘扫描输出接口进行按键扫描之后,采集所述键盘扫描输入接口对应的第二电平状态;
    根据所述第二电平状态,进行按键识别。
  16. 如权利要求15所述的键盘按键识别方法,其中,在所述控制键盘扫描输出接口进行按键扫描之后,所述键盘按键识别方法还包括:
    在接收到目标时钟沿时,更新当前基础数值为目标基础数值,在监听到输出译码电路控制键盘扫描输出接口进行按键扫描时,控制所述当前基础数值清零;
    在监听到所述当前基础数值清零时,更新当前变化次数,若所述当前变化次数达到目标按键数量,则控制所述当前变化次数清零;
    在监听到所述当前变化次数清零时,更新当前扫描次数,若所述当前扫描次数达到目标扫描次数,则控制所述当前扫描次数清零;
    根据所述当前基础数值、所述当前变化次数和所述当前扫描次数,完成按键扫描和按键识别。
  17. 如权利要求16所述的键盘按键识别方法,其中,所述根据所述当前基础数值、所述当前变化次数和所述当前扫描次数,完成按键扫描和按键识别,包括:
    在监听到所述当前基础数值为目标基础数值时,控制键盘扫描输出接口输出低电平,实现按键扫描;
    在监听到所述当前变化次数清零时,获取与目标按键数量相对应的所述第二电平状态,根据所有所述第二电平状态,获取所述当前扫描次数对应的单次扫描结果;
    在监听到所述当前扫描次数清零时,获取与所述目标扫描次数相对应的单次扫描结果,根据所有所述单次扫描结果,获取按键识别结果。
  18. 如权利要求17所述的键盘按键识别方法,其中,所述在监听到所述当前变化次数清零时,获取与目标按键数量相对应的所述第二电平状态,根 据所有所述第二电平状态,获取所述当前扫描次数对应的单次扫描结果,包括:
    在监听到所述当前变化次数清零时,获取与目标按键数量相对应的所述第二电平状态;
    若所有所述第二电平状态均为高电平,则获取单次扫描无效的单次扫描结果;
    若存在一个所述第二电平状态为低电平,则获取单次扫描有效的单次扫描结果。
  19. 如权利要求17所述的键盘按键识别方法,其中,所述根据所有所述单次扫描结果,获取按键识别结果,包括:
    若存在所述单次扫描结果为单次扫描无效,则输出单次扫描无效的按键识别结果;
    若所有所述单次扫描结果均为单次扫描有效,则获取与所述目标扫描次数相对应的单次扫描键值,基于所有所述单次扫描键值,获取按键识别结果。
  20. 如权利要求19所述的键盘按键识别方法,其中,所述基于所有所述单次扫描键值,获取按键识别结果,包括:
    若存在所述单次扫描键值不相同,则输出单次扫描无效的按键识别结果;
    若所有所述单次扫描键值均相同,则根据所述单次扫描键值,确定当前有效键值,输出包含当前有效键值的按键识别结果。
  21. 如权利要求17所述的键盘按键识别方法,其中,在所述根据所有所述单次扫描结果,获取按键识别结果之后,所述键盘按键识别方法还包括:
    在所述按键识别结果为包含当前有效键值时,则确定历史有效键值,获取所述当前有效键值和所述历史有效键值对应的按键间隔时长;
    根据所述按键间隔时长和所述当前有效键值,确定目标有效键值。
  22. 如权利要求21所述的键盘按键识别方法,其中,所述根据所述按键间隔时长和所述当前有效键值,确定目标有效键值,包括:
    若所述按键间隔时长大于目标时长阈值,则将所述当前有效键值确定为目标有效键值;
    若所述按键间隔时长不大于目标时长阈值,则基于所述当前有效键值和所述历史有效键值,判断是否满足按键组合规则,获取组合判断结果,根据所述组合判断结果,确定目标有效键值。
  23. 如权利要求22所述的键盘按键识别方法,其中,所述根据所述组合判断结果,确定目标有效键值,包括:
    若所述组合判断结果为满足按键组合规则,则根据所述当前有效键值和所述历史有效键值,确定目标有效键值;
    若所述组合判断结果为不满足按键组合规则,则将所述当前有效键值确定为目标有效键值。
  24. 如权利要求17所述的键盘按键识别方法,其中,在监听到所述当前变化次数清零时,获取与目标按键数量相对应的所述第二电平状态,根据所有所述第二电平状态,获取所述当前扫描次数对应的单次扫描结果之后,所述键盘按键识别方法还包括:
    在监听到所述当前扫描次数为目标扫描次数时,若所述当前扫描次数对应的所述单次扫描结果为单次扫描无效,则获取存在毛刺的毛刺检测结果;若所述当前扫描次数对应的所述单次扫描结果为单次扫描有效,则获取不存在毛刺的毛刺检测结果;
    根据所述毛刺检测结果,输出毛刺检测信号。
  25. 如权利要求17所述的键盘按键识别方法,其中,所述键盘按键识别方法还包括:
    在所述当前键盘状态为空闲状态且所述第一电平状态为从高电平跳变到低电平时,输出第一更新指令,根据所述第一更新指令,将所述当前键盘状态由空闲状态更新为按压状态;
    在所述单次扫描结果为单次扫描无效时,输出第二更新指令,根据所述第二更新指令,将所述当前键盘状态由按压状态更新为空闲状态;
    在获取所述按键识别结果之后,输出第三更新指令,根据所述第三更新指令,将所述当前键盘状态由按压状态更新为空闲状态。
  26. 如权利要求25所述的键盘按键识别方法,其中,所述键盘按键识别方法还包括:
    根据当前时刻与目标更新指令对应的指令生成时刻,确定等待更新时长;在所述等待更新时长大于超时时长阈值时,若所述当前键盘状态维持按压状态,则生成超时复位信号,输出超时复位信号;
    根据所述超时复位信号,将所述当前键盘状态由按压状态更新为空闲状态;
    其中,所述目标更新指令为所述第二更新指令或者所述第三更新指令。
  27. 如权利要求25所述的键盘按键识别方法,其中,所述键盘按键识别方法还包括:
    在所述当前键盘状态由按压状态更新为空闲状态时,获取所述键盘扫描输入接口对应的第三电平状态,若所述第三电平状态为从高电平跳变到低电平,则生成异步复位信号,向所述状态机跳转电路输出异步复位信号;
    根据所述异步复位信号,将所述当前键盘状态复位为按压状态。
  28. 如权利要求15所述的键盘按键识别方法,其中,所述控制键盘扫描输出接口进行按键扫描,包括:
    获取第一间隔时长和第二间隔时长;
    根据所述第一间隔时长和所述第二间隔时长,轮流控制所述控制键盘扫描输出接口输出低电平,实现按键扫描;
    其中,所述第一间隔时长是用于控制所有键盘扫描输出接口输出高电平的间隔时长;所述第二间隔时长是用于控制所有键盘扫描输出接口输出低电平的间隔时长。
  29. 一种芯片,包括权利要求1-15任一项所述键盘扫描电路。
  30. 一种键盘,包括键盘按键和键盘MCU,还包括权利要求1-15任一项所述键盘扫描电路,所述键盘扫描电路与所述键盘按键和所述键盘MCU相连。
PCT/CN2022/124481 2021-12-23 2022-10-11 键盘扫描电路、键盘按键识别方法、芯片和键盘 WO2023116130A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111592083.4 2021-12-23
CN202111592083.4A CN114257249A (zh) 2021-12-23 2021-12-23 键盘扫描电路、键盘按键识别方法、芯片和键盘

Publications (1)

Publication Number Publication Date
WO2023116130A1 true WO2023116130A1 (zh) 2023-06-29

Family

ID=80794726

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/124481 WO2023116130A1 (zh) 2021-12-23 2022-10-11 键盘扫描电路、键盘按键识别方法、芯片和键盘

Country Status (2)

Country Link
CN (1) CN114257249A (zh)
WO (1) WO2023116130A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114257249A (zh) * 2021-12-23 2022-03-29 西安芯海微电子科技有限公司 键盘扫描电路、键盘按键识别方法、芯片和键盘
CN116880716B (zh) * 2023-09-06 2023-12-29 深圳市英菲克电子有限公司 产品输入控制电路及方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075194A (zh) * 2009-11-23 2011-05-25 鸿富锦精密工业(深圳)有限公司 键盘扫描电路和方法及电子设备
CN105634503A (zh) * 2015-12-28 2016-06-01 北京锦鸿希电信息技术股份有限公司 检测键盘键值的方法及装置
CN105634502A (zh) * 2015-12-24 2016-06-01 安徽润谷网络科技有限公司 基于状态机的按键扫描的实现方法
CN110932733A (zh) * 2019-11-29 2020-03-27 百富计算机技术(深圳)有限公司 按键扫描方法及输入设备
CN111880447A (zh) * 2020-07-22 2020-11-03 深圳和而泰智能控制股份有限公司 基于状态机的多按键状态扫描方法、装置及计算设备
CN114257249A (zh) * 2021-12-23 2022-03-29 西安芯海微电子科技有限公司 键盘扫描电路、键盘按键识别方法、芯片和键盘

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075194A (zh) * 2009-11-23 2011-05-25 鸿富锦精密工业(深圳)有限公司 键盘扫描电路和方法及电子设备
CN105634502A (zh) * 2015-12-24 2016-06-01 安徽润谷网络科技有限公司 基于状态机的按键扫描的实现方法
CN105634503A (zh) * 2015-12-28 2016-06-01 北京锦鸿希电信息技术股份有限公司 检测键盘键值的方法及装置
CN110932733A (zh) * 2019-11-29 2020-03-27 百富计算机技术(深圳)有限公司 按键扫描方法及输入设备
CN111880447A (zh) * 2020-07-22 2020-11-03 深圳和而泰智能控制股份有限公司 基于状态机的多按键状态扫描方法、装置及计算设备
CN114257249A (zh) * 2021-12-23 2022-03-29 西安芯海微电子科技有限公司 键盘扫描电路、键盘按键识别方法、芯片和键盘

Also Published As

Publication number Publication date
CN114257249A (zh) 2022-03-29

Similar Documents

Publication Publication Date Title
WO2023116130A1 (zh) 键盘扫描电路、键盘按键识别方法、芯片和键盘
US20100049882A1 (en) Hotkey processing method and computer system
CN103582862A (zh) 与触敏显示屏幕结合使用压力差
CN105573522B (zh) 一种移动终端的操作方法及移动终端
US20090315826A1 (en) Method for identifying a single tap, double taps and a drag and a controller for a touch device employing the method
CN109582536B (zh) 应用程序无响应的上报方法、装置和计算机设备
CN105634503B (zh) 检测键盘键值的方法及装置
CN109379305A (zh) 一种数据下发方法、装置、服务器及存储介质
CN104933048A (zh) 一种语音信息处理方法、装置和电子设备
CN105844241A (zh) 一种触控压力检测方法及终端
US8407381B2 (en) Keypad de-bouncing apparatus and method
CN107479744B (zh) 调整触摸屏调度优先级的方法、装置、终端及存储介质
CN105487800B (zh) 智能终端的输入方法和系统
CA2076466C (en) Method for buffering high bandwidth data from an input device
CN114489374A (zh) 多点触控的数据输入方法、装置、销售终端及存储介质
CN103558922A (zh) 一种按键处理方法、装置及系统
EP3698235B1 (en) User input devices and methods for identifying a user input in a user input device
RU2566966C2 (ru) Способ и устройство ускорения нажатия кнопок
KR102456150B1 (ko) 실제 환경에서 대용량 시스템에 대한 포괄적 성능평가를 수행하는 방법 및 이를 지원하는 장치
CN104898925B (zh) 智能终端触摸屏的控制方法及智能终端
KR100474267B1 (ko) 차량용 터치 패널의 인식오류 최소화 방법
CN104867508A (zh) 一种声音文件连续播放的方法和装置
US6075517A (en) System and method for synchronization of pointing devices with different data packet sizes
CN113220352A (zh) 关机控制方法及装置
CN109661644A (zh) 一种压力触控方法及终端

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22909448

Country of ref document: EP

Kind code of ref document: A1