Key-Scan

Introduction

As a keypad scan device, Key-Scan can be applied to simple key, remote control or even game pad. It needs to scan the operations of key press and release accurately and timely.

The major benefit of this device is to free up the CPU from scanning the keypad all the time. It triggers the corresponding interrupts to inform CPU in time. In addition, chip can enter low-power state in most of time, and take little time to wake up and handle the key events.

Features

  • Supports keypad arrays up to 8 x 8 (64 keys) using 16 GPIOs.

  • Configurable number of rows and columns to accommodate various keypad sizes.

  • Hardware debounce with configurable timing for each scan cycle.

  • Configurable scan clock frequency, scan interval, and key release time.

  • Comprehensive interrupt management: interrupt generation, masking, clearing, and status reporting.

  • Simultaneous multiple-key press detection.

  • Built-in FIFO buffer (12-bit width, 16-entry depth) to store key press and release events.

  • Two operating modes:

    • Event Trigger Mode: Responds to press and release events.

    • Regular Scan Mode: Continuously scans at a high priority.

  • Low power support: Key press events can wake up the CPU from sleep mode.

  • Stuck key detection and handling.

Function Description

Work principle

The block diagram of Key-Scan is illustrated in Key-Scan Block Diagram. The Key-Scan contains six main parts:

  • Interrupt Control: control and manage interrupts.

  • Control Register and FIFO: configure Key-Scan parameters and FIFO.

  • Clock: Key-Scan clock, 131K clock is used for stuck row detection and low-power wake-up.

  • Keypad Control: contains Key-Scan control, wake up control and key input/output control.

  • Keypad: up to 8*8 keypad array with use of 16 GPIOs.

../../_images/keyscan_block_diagram.svg

Key-Scan Block Diagram

Taking 8*8 keypad array for example, the typical application setup is depicted in 8 x 8 keypad, and external keypad is needed.

../../_images/keyscan_array.svg

8 x 8 keypad

At the beginning, all columns output low, and all rows are set as input with internal pull up.

When there is a key or multiple keys pressed (short between the Column and the Row), the input level of the corresponding row changes from high to low. It triggers an internal state machine to start a Key-Scan cycle to determine the column and row of the key that is pressed. The state machine sets first column as an output low and all other columns are in Hi-Z state. The state machine then scans all rows to determine which keys are being pressed, and then second column is output low until the last column. Firstly, scan circuit waits for a first debounce time and does first scan. Then, the circuit waits for a debounce time and scans again. After the two scan cycles, the circuit decides the current key status, and compares with internal key status table to find which key is pressed or released. After a full scan, the key press or release events are stored in the key event FIFO. Debounce time for the keypad is for each full scan and is configurable, as shown in Key-Scan flow.

../../_images/keyscan_flow.svg

Key-Scan flow

Interval time between each full scan is configurable. Once all keys are detected release, there is a release timer to confirm that, then an all release interrupt is triggered and state machine enters idle state. The Key-Scan timing is shown in Key-Scan timing.

../../_images/keyscan_timing.svg

Key-Scan timing

Work Mode

Key-Scan supports two working modes:

  • Event Trigger Mode: Each press or release operation stores the event into the FIFO only once.

  • Regular Scan Mode: During every full key scan, pressed events are continuously written into the FIFO until release (in this mode, only pressed events are recorded).

As shown in Key-Scan Work Mode, the differences between the two modes are illustrated.

../../_images/keyscan_fifo_in_diff_work_mode.svg

Key-Scan Work Mode

FIFO

Key-Scan FIFO structure shows the difference of FIFO items between Event Trigger Mode and Regular Scan Mode during a key press and release.

../../_images/keyscan_fifo_structure.svg

Key-Scan FIFO structure


Bit

Indication

Description

[8]

Event

  • 1: key press event

  • 0: key release event

[7:4]

Row index

  • 1: row 0

  • 2: row 1

  • 3: row 2

  • 8: row 7

[3:0]

Column index

  • 1: column 0

  • 2: column 1

  • 3: column 2

  • 8: column 7

When the FIFO is full and another item is pushed into the FIFO, an overflow interrupt is triggered. When the FIFO is empty and is read, an overread interrupt is triggered.

The key value assignment is listed in following Table.

Row0

Row1

Row2

Row3

Row4

Row5

Row6

Row7

Col0

11

12

13

14

15

16

17

18

Col1

21

22

23

24

25

26

27

28

Col2

31

32

33

34

35

36

37

38

Col3

41

42

43

44

45

46

47

48

Col4

51

52

53

54

55

56

57

58

Col5

61

62

63

64

65

66

67

68

Col6

71

72

73

74

75

76

77

78

Col7

81

82

83

84

85

86

87

88

Clock Configuration

There are two clock domains in the Key-Scan design, as shown in Key-Scan Clock.

  • The green part works in low-power clock domain, whose clock will not be gated in low power modes.

  • The blue part works under bus clock domain (40MHz), whose clock will be gated in low power modes. In bus clock domain, some of the logic works in scan_clk frequency that is divided from bus clock.

../../_images/keyscan_clock.svg

Key-Scan Clock

The Key-Scan trigger signal is generated by lower frequency (131K). When the low power clock detects a key press, hardware starts scan by scan clock to confirm the key values.

Shadow Key

Problems with shadow keys may occur during multi-key detection. The applications requiring three-key combinations (such as Ctrl + Alt + Del ), or any other combinations) must ensure that the three keys are wired in appropriate key positions to avoid shadow key (or appearing like that a 4th key has been pressed).

To avoid shadow key, it is best to keep 3-button combinations that are pressed on separate rows and columns. Considering the situation with the keypad is described in KeyPad Example.

In KeyPad Example, there is a 4*3 keypad matrix, connected to Row0 ~ Row3, and Column0 ~ Column2. All of the rows are configured as inputs with pull-up resistors. The columns are configured as outputs, driving low. When a key press is made, one of the row inputs is pulled low, letting the scan circuit know that a key has been pressed, then the KeyScan starts the key scanning algorithm. This algorithm sweeps the output low across the columns, such that only 1 column is driven low at a time. While this is done to each column, the KeyScan reads the row inputs, to determine which keys on a column are being pressed.

../../_images/keypad_example.svg

KeyPad Example

The shadow key can occur when multiple keys are pressed, which makes it appear that additional keys (actually not being pressed) are being pressed. In shadow key, key 11, key 12, and key 21 are pressed, which causes a shadow key issue. Since Row1 becomes pulled to ground through key 11 (which is pulled through key 12 when Column1 is transmitting a low), when Column1 is driving low, the scan circuit sees a low signal at both Row0 and Row1. This falsely triggers key 22 as being pressed (the key highlighted as yellow).

The reason is that keypad matrix connects the columns and the rows together. When Column1 is driving low, the low gets transmitted onto Row0 via key 12. When key 11 is being pressed, this shorts Column0 to ground, and then shorts Row1 to Column0. In this process, Row1 is shorted to Column1, which is the reason shadow Key occurs.

../../_images/keyscan_shadow_key.svg

shadow key

Keypad matrix can support multiple key presses properly when choosing the layout carefully. Figure correct key combination shows a 3-button combination which works as expected.

../../_images/keyscan_correct_3_key.svg

correct key combination

Stuck Key

In actual application scenarios, the situation of key stuck (not released after being pressed) may occur. In the case of key stuck, to make sure that the system can still enter low power mode and can be woken up through Key-Scan, users can enable auto_check_key_stuck function.

When the auto_check_key_stuck function is disabled, the state machine of Key-Scan will keep scanning as long as the key stuck, and cannot enter IDLE state unless the keys are released. Thus, the system cannot enter low power mode.

When the auto_check_key_stuck function is enabled:

  1. When the key stuck time exceeds the configured stuck_time_threshold, the stuck_event_raw_int_status bit in the KS_ISR_RAW register will be set. If the stuck event interrupt is enabled at the same time, the stuck_event_int_status bit in the KS_ISR register will be set, and the software will jump to the interrupt handling function of Key-Scan.

  2. In the interrupt handling function, the software can locate the stuck key or the row of stuck key by reading the KS_STUCK_KEY_STATUS and the KS_STUCK_KEY_ROW_STATUS1 registers, and sets the default state of the stuck row through the KS_STUCK_CFG1 register. At the same time, the software clears the current stuck interrupt by writing the KS_ICR register.

  3. When all default interrupt is enabled, the software will jump to the all default interrupt handling function.

  4. The next time when the state machine of Key-Scan scans, it will detect that the current state of the stuck row is the same as the configured default state, and consider the state is normal, then enter IDLE state. Thus, the system can smoothly enter the low power mode.

  5. In the IDLE state, if the stuck key is released, the Key-Scan will wake up the system and trigger scanning since it detects that the current state of the stuck row is different from the configured default state, and report a stuck interrupt at the same time. If all keys are released and all release interrupt is enabled, then an all release interrupt will be generated.

  6. The software gets the state of the stuck row by reading the KS_STUCK_KEY_ROW_STATUS1 register in stuck interrupt handling function., and sets the default state of the stuck row again.

  7. If all default interrupt is enabled, there will be an all default interrupt.

The figure Stuck Key detect describes the detection process of stuck button pressing and releasing:

../../_images/keyscan_stuck_flow.svg

Stuck Key detect

Caution

Since the auto_check_key_stuck function configures the key stuck status on a per-row basis, the following corner cases need to be noted:

  • When other keys in the same row are pressed or released after a key stuck occurs:

    • In low power state, pressing or releasing other keys in the same row cannot wake up the system. Since the stuck key connects its row and column, the row is pulled low. When other keys in this row are pressed or released, it does not affect the row’s level, so these actions cannot be detected.

    • After the keyscan wakes up, if other keys in the same row as the stuck key are pressed or released during scanning, they can be detected normally. However, if the release timer has already expired after wakeup and the state machine has entered the idle state, these key presses or releases cannot be detected.

  • When keys in rows other than the stuck row are pressed or released after a key stuck occurs:

    • Pressing or releasing keys not in the same row will pull the level of their respective rows low or high accordingly, so these keys can be detected.

    • If the system is in low power state, such actions can also wake up the circuit as expected.

Low Power Management

In practical applications, keeping Key-Scan in Active mode can result in high power consumption. To save power and optimize performance, Key-Scan can operate in Sleep mode, during which only partial wakeup circuitry remains active and the clock source is 131KHz. In Sleep mode, the CPU enters a low power state to reduce energy consumption. When a key is pressed, the CPU is awakened and Key-Scan begins scanning to determine which keys are pressed. Key-Scan will continue scanning as long as the key is held down. When all keys are released and no other events occur, the CPU returns to sleep mode.

When a key is stuck and the Key-Scan enters the idle state, the stuck row is directly connected to the corresponding column, resulting in the output level of the row being low. As a consequence, the pull-up resistor causes leakage current at the I/O port. At this time, the current generated by the pull-up resistor on the row flows along two paths: one part flows through the stuck key to the corresponding column, and the other part flows directly to the row input pin. This increases power consumption, as shown in Schematic diagram of leakage current caused by a stuck key.

  • If the periodic detection function for the stuck row is not enabled, Key-Scan will continuously scan each row in turn, including the stuck row. In this situation, the continuous leakage current keeps the power consumption elevated.

  • To reduce leakage duration and power consumption, the periodic detection function for the stuck row must be enabled. The software can configure two timing parameters: stuckrow_detect_time and stuckrow_detect_time_interval. After enabling periodic detection, Key-Scan will check the status of the stuck row at intervals specified by stuckrow_detect_time_interval, and each detection lasts for the period set by stuckrow_detect_time. During the detection interval, the stuck row’s I/O pin is set to no pull-up (high impedance); during the detection period, it is set to input with pull-up enabled. If the system is in low power mode at this time, the stuck row detection operation will not wake up the system. In addition, for other rows that are not stuck, the I/O port status is continuously monitored to ensure response speed.

Note

This periodic detection function of the stuck row is only valid when auto_check_key_stuck function is enabled, otherwise it will not take effect.

../../_images/keyscan_stuck_current.svg

Schematic diagram of leakage current caused by a stuck key

Registers

Base Address: 0x41013000

Name

Address offset

Access

Description

REG_KS_CLK_DIV

000h

R/W

This register is for Key-Scan scan clock division.

REG_KS_TIM_CFG0

004h

R/W

This is configuration register for timers.

REG_KS_TIM_CFG1

008h

R/W

This is configuration register for timers.

REG_KS_CTRL

00Ch

R/W

This register controls Key-Scan working mode and enable.

REG_KS_FIFO_CFG

010h

R/W

REG_KS_COL_CFG

014h

R/W

This register selects which column is used.

REG_KS_ROW_CFG

018h

R/W

This register selects which row is used.

REG_KS_DATA_NUM

01Ch

R

FIFO status register

REG_KS_DATA

020h

R

User can read scan result from this register, meaning pop one scan result from FIFO.

REG_KS_IMR

024h

R/W

This register is used to mask unused interrupts.

REG_KS_ICR

028h

R/W

This register is used to clear interrupts.

REG_KS_ISR

02Ch

R

This register is about interrupt flags.

REG_KS_ISR_RAW

030h

R

The raw interupt flags do not effected by interrupt mask register.

REG_KS_DISCHARGED_CTRL

034h

R/W

REG_KS_STUCK_CFG0

03Ch

R/W

REG_KS_STUCK_CFG1

040h

R/W

REG_KS_STUCK_CFG2

044h

R/W

REG_KS_STUCK_KEY_STATUS1

048h

R

REG_KS_STUCK_KEY_STATUS2

04Ch

R

REG_KS_STUCK_KEY_ROW_STATUS1

050h

R

REG_KS_DUMMY

058h

R/W

REG_KS_CLK_DIV

  • Name : clock division register

  • Size : 32

  • Address offset : 000h

  • Read/write access : R/W

This register is for Key-Scan scan clock division.

31:12 RSVD 11:0 KS_CLK_DIV

Bit

Symbol

Access

Reset

Description

31:12

RSVD

R

-

Reserved

11:0

KS_CLK_DIV

R/W

0x0

Scan clock = bus clock/(keyscan_clk_div+1)

REG_KS_TIM_CFG0

  • Name : Key-Scan configure register 0

  • Size : 32

  • Address offset : 004h

  • Read/write access : R/W

This is configuration register for timers.

31:28 RSVD 27:24 KS_POST_GUARD_TIMER 23:20 RSVD 19:16 KS_PRE_GUARD_TIMER 15:12 RSVD 11:0 KS_DEB_TIMER

Bit

Symbol

Access

Reset

Description

31:28

RSVD

R

-

Reserved

27:24

KS_POST_GUARD_TIMER

R/W

0x3

Post guard time for key column, post guard time = scan_clk * reg_col_gt_post_sel

23:20

RSVD

R

-

Reserved

19:16

KS_PRE_GUARD_TIMER

R/W

0x3

Pre guard time for key column, pre guard time = scan_clk * r eg_col_gt_pre_sel

15:12

RSVD

R

-

Reserved

11:0

KS_DEB_TIMER

R/W

0x0

Debounce counter n*scan_clk

REG_KS_TIM_CFG1

  • Name : Key-Scan configure register 1

  • Size : 32

  • Address offset : 008h

  • Read/write access : R/W

This is configuration register for timers.

31:28 RSVD 27:16 KS_INTERVAL_TIMER 15:12 RSVD 11:0 KS_RELEASE_TIMER

Bit

Symbol

Access

Reset

Description

31:28

RSVD

R

-

Reserved

27:16

KS_INTERVAL_TIMER

R/W

0x0

Scan interval counter n*scan_clk

15:12

RSVD

R

-

Reserved

11:0

KS_RELEASE_TIMER

R/W

0x0

Release detect counter n*scan_clk

REG_KS_CTRL

  • Name : Key-Scan control register

  • Size : 32

  • Address offset : 00Ch

  • Read/write access : R/W

This register controls Key-Scan working mode and enable.

31:4 RSVD 3 KS_WORK_MODE 2 RSVD 1 KS_BUSY_STATUS 0 KS_RUN_ENABLE

Bit

Symbol

Access

Reset

Description

31:4

RSVD

R

-

Reserved

3

KS_WORK_MODE

R/W

0x0

Work mode

  • 0x1: Event Trigger Mode

  • 0x0: Regular Scan Mode

2

RSVD

R

-

Reserved

1

KS_BUSY_STATUS

R

0x0

FSM busy status

0

KS_RUN_ENABLE

R/W

0x0

Enable internal Key-Scan scan clock. The Key-Scan clock en able must be after Key-Scan configuration is done.

  • 0x1: Key-Scan clock enabled (HW FSM starts to run).

  • 0x0: Key-Scan clock disabled (HW FSM stops).

REG_KS_FIFO_CFG

  • Name : FIFO configuration register

  • Size : 32

  • Address offset : 010h

  • Read/write access : R/W

31:28 RSVD 27:24 KS_FIFO_LIMIT_LEVEL 23:20 RSVD 19:16 KS_FIFO_TH_LEVEL 15:2 RSVD 1 KS_FIFO_OV_CTRL 0 KS_FIFO_CLR

Bit

Symbol

Access

Reset

Description

31:28

RSVD

R

-

Reserved

27:24

KS_FIFO_LIMIT_LEVEL

R/W

0x0

Limit the max allowable key number be pressed at a time

  • 0x0: no limit

  • 0x1: only one scan data is allowable in each key scan

  • 0x6: Max 6 scan data is allowable in each key scan

0x7 ~ 0xf: DO NOT USE

23:20

RSVD

R

-

Reserved

19:16

KS_FIFO_TH_LEVEL

R/W

0x0

FIFO threshold setup

15:2

RSVD

R

-

Reserved

1

KS_FIFO_OV_CTRL

R/W

0x0

FIFO overflow control

  • 0x0: rejects the new scan data when FIFO is full

  • 0x1: discard the oldest scan data when FIFO is full

0

KS_FIFO_CLR

R/W

0x0

Write 1to clear FIFO data

REG_KS_COL_CFG

  • Name : column selection register

  • Size : 32

  • Address offset : 014h

  • Read/write access : R/W

This register selects which column is used.

31:8 RSVD 7:0 KS_COL_SEL

Bit

Symbol

Access

Reset

Description

31:8

RSVD

R

-

Reserved

7:0

KS_COL_SEL

R/W

0x0

The control register to define which column is used.

  • 0x0: No key column selected

  • 0x1: Key column 0 selected

  • 0x2: Key column 1 selected

  • 0x3: Key column 0 and column 1 selected

  • 0x4: Key column 2 selected

  • ...

REG_KS_ROW_CFG

  • Name : row selection register

  • Size : 32

  • Address offset : 018h

  • Read/write access : R/W

This register selects which row is used.

31:8 RSVD 7:0 KS_ROW_SEL

Bit

Symbol

Access

Reset

Description

31:8

RSVD

R

-

Reserved

7:0

KS_ROW_SEL

R/W

0x0

The control register to define which row is used.

  • 0x0: No key row selected

  • 0x1: Key row 0 selected

  • 0x2: Key row 1 selected

  • 0x3: Key row 0 and row 1 selected

  • 0x4: Key row 2 selected

  • ...

REG_KS_DATA_NUM

  • Name : FIFO status

  • Size : 32

  • Address offset : 01Ch

  • Read/write access : R

FIFO status register

31:18 RSVD 17 KS_FIFO_FULL 16 KS_FIFO_EMPTY 15:5 RSVD 4:0 KS_FIFO_DATA_LEVEL

Bit

Symbol

Access

Reset

Description

31:18

RSVD

R

-

Reserved

17

KS_FIFO_FULL

R

0x0

FIFO full status

16

KS_FIFO_EMPTY

R

0x1

FIFO empty status

15:5

RSVD

R

-

Reserved

4:0

KS_FIFO_DATA_LEVEL

R

0x0

Number of entry in FIFO

REG_KS_DATA

  • Name : Key-Scan data register

  • Size : 32

  • Address offset : 020h

  • Read/write access : R

User can read scan result from this register, meaning pop one scan result from FIFO.

31:12 RSVD 11:0 KS_DATA

Bit

Symbol

Access

Reset

Description

31:12

RSVD

R

-

Reserved

11:0

KS_DATA

R

0x0

When reading this register, these bits return the value in t he Event FIFO.

  • Bit[11:8]: press or release event - 0x0: release event - 0x1: press event

  • Bit[7:4]: row index

  • Bit[3:0]: column index

REG_KS_IMR

  • Name : interrupt mask register

  • Size : 32

  • Address offset : 024h

  • Read/write access : R/W

This register is used to mask unused interrupts.

31:9 RSVD 8 KS_ALL_DEFAULT_INT_MASK 7 KS_STUCK_EVENT_INT_MASK 6 KS_SCAN_EVENT_INT_MASK 5 KS_FIFO_LIMIT_INT_MASK 4 KS_FIFO_OV_INT_MASK 3 KS_FIFO_FULL_INT_MASK 2 KS_SCAN_FINISH_INT_MASK 1 KS_FIFO_NOTEMPTY_INT_MASK 0 KS_ALL_RELEASE_INT_MASK

Bit

Symbol

Access

Reset

Description

31:9

RSVD

R

-

Reserved

8

KS_ALL_DEFAULT_INT_MASK

R/W

0x0

  • 0x0: Mask all default interrupt

7

KS_STUCK_EVENT_INT_MASK

R/W

0x0

  • 0x0: Mask stuck event interrupt

6

KS_SCAN_EVENT_INT_MASK

R/W

0x0

  • 0x0: Mask scan event interrupt

5

KS_FIFO_LIMIT_INT_MASK

R/W

0x0

  • 0x0: Mask FIFO limit interrupt

4

KS_FIFO_OV_INT_MASK

R/W

0x0

  • 0x0: Mask FIFO overflow interrupt

3

KS_FIFO_FULL_INT_MASK

R/W

0x0

  • 0x0: Mask FIFO full interrupt

2

KS_SCAN_FINISH_INT_MASK

R/W

0x0

  • 0x0: Mask scan finish interrupt

1

KS_FIFO_NOTEMPTY_INT_MASK

R/W

0x0

  • 0x0: Mask FIFO nonempty interrupt

0

KS_ALL_RELEASE_INT_MASK

R/W

0x0

  • 0x0: Mask All Release interrupt

REG_KS_ICR

  • Name : interrupt clear register

  • Size : 32

  • Address offset : 028h

  • Read/write access : R/W

This register is used to clear interrupts.

31:9 RSVD 8 KS_ALL_DEFAULT_INT_CLR 7 KS_STUCK_INT_CLR 6 RSVD 5 KS_FIFO_LIMIT_INT_CLR 4 KS_FIFO_OV_INT_CLR 3 RSVD 2 KS_SCAN_FINISH_INT_CLR 1 RSVD 0 KS_ALL_RELEASE_INT_CLR

Bit

Symbol

Access

Reset

Description

31:9

RSVD

R

-

Reserved

8

KS_ALL_DEFAULT_INT_CLR

R/W

0x0

Clear All Default interrupt flag

Write ‘1’ to clear

7

KS_STUCK_INT_CLR

R/W

0x0

Clear Stuck interrupt flag

Write ‘1’ to clear

6

RSVD

R

-

Reserved

5

KS_FIFO_LIMIT_INT_CLR

R/W

0x0

Clear FIFO limit interrupt flag

Write ‘1’ to clear

4

KS_FIFO_OV_INT_CLR

R/W

0x0

Clear FIFO overflow interrupt flag

Write ‘1’ to clear

3

RSVD

R

-

Reserved

2

KS_SCAN_FINISH_INT_CLR

R/W

0x0

Clear scan finish interrupt flag

Write ‘1’ to clear

1

RSVD

R

-

Reserved

0

KS_ALL_RELEASE_INT_CLR

R/W

0x0

Clear all release interrupt flag

Write ‘1’ to clear

REG_KS_ISR

  • Name : interrupt status register

  • Size : 32

  • Address offset : 02Ch

  • Read/write access : R

This register is about interrupt flags.

31:9 RSVD 8 KS_ALL_DEFAULT_INT_STATUS 7 KS_STUCK_EVENT_INT_STATUS 6 KS_SCAN_EVENT_INT_STATUS 5 KS_FIFO_LIMIT_INT_STATUS 4 KS_FIFO_OV_INT_STATUS 3 KS_FIFO_FULL_INT_STATUS 2 KS_SCAN_FINISH_INT_STATUS 1 KS_FIFO_NOTEMPTY_INT_STATUS 0 KS_ALL_RELEASE_INT_STATUS

Bit

Symbol

Access

Reset

Description

31:9

RSVD

R

-

Reserved

8

KS_ALL_DEFAULT_INT_STATUS

R

0x0

Masked All Default interrupt status, means row status equal to ks_row_default_status

7

KS_STUCK_EVENT_INT_STATUS

R

0x0

Masked Stuck event interrupt status

6

KS_SCAN_EVENT_INT_STATUS

R

0x0

Masked Scan event interrupt status

5

KS_FIFO_LIMIT_INT_STATUS

R

0x0

Masked FIFO limit interrupt status

4

KS_FIFO_OV_INT_STATUS

R

0x0

Masked FIFO overflow interrupt status

3

KS_FIFO_FULL_INT_STATUS

R

0x0

Masked FIFO full interrupt status

2

KS_SCAN_FINISH_INT_STATUS

R

0x0

Masked Scan finish interrupt status

1

KS_FIFO_NOTEMPTY_INT_STATUS

R

0x0

Masked FIFO nonempty interrupt status

0

KS_ALL_RELEASE_INT_STATUS

R

0x0

Masked All release interrupt status

REG_KS_ISR_RAW

  • Name : raw interrupt flag register

  • Size : 32

  • Address offset : 030h

  • Read/write access : R

The raw interupt flags do not effected by interrupt mask register.

31:9 RSVD 8 KS_ALL_DEFAULT_RAW_INT_STATUS 7 KS_STUCK_EVENT_RAW_INT_STATUS 6 KS_SCAN_EVENT_RAW_INT_STATUS 5 KS_FIFO_LIMIT_RAW_INT_STATUS 4 KS_FIFO_OV_RAW_INT_STATUS 3 KS_FIFO_FULL_RAW_INT_STATUS 2 KS_SCAN_FINISH_RAW_INT_STATUS 1 KS_FIFO_NOTEMPTY_RAW_INT_STATUS 0 KS_ALL_RELEASE_RAW_INT_STATUS

Bit

Symbol

Access

Reset

Description

31:9

RSVD

R

-

Reserved

8

KS_ALL_DEFAULT_RAW_INT_STATUS

R

0x0

All default interrupt, means row status equal to ks_row_defa ult_status

7

KS_STUCK_EVENT_RAW_INT_STATUS

R

0x0

Key stuck event raw interrupt

6

KS_SCAN_EVENT_RAW_INT_STATUS

R

0x0

Scan event raw interrupt, auto clear when the item is read

5

KS_FIFO_LIMIT_RAW_INT_STATUS

R

0x0

FIFO limit raw interrupt

4

KS_FIFO_OV_RAW_INT_STATUS

R

0x0

FIFO overflow raw interrupt

3

KS_FIFO_FULL_RAW_INT_STATUS

R

0x0

FIFO full raw interrupt

2

KS_SCAN_FINISH_RAW_INT_STATUS

R

0x0

Scan finish raw interrupt

1

KS_FIFO_NOTEMPTY_RAW_INT_STATUS

R

0x0

FIFO nonempty raw interrupt

Auto clear when FIFO is empty

0

KS_ALL_RELEASE_RAW_INT_STATUS

R

0x0

All Release raw interrupt

REG_KS_DISCHARGED_CTRL

  • Name : keyboard discharged register

  • Size : 32

  • Address offset : 034h

  • Read/write access : R/W

31:2 RSVD 1 KS_DISCHARGE 0 KS_INTERVAL_POL

Bit

Symbol

Access

Reset

Description

31:2

RSVD

R

-

Reserved

1

KS_DISCHARGE

R/W

0x0

  • 1: The keyboard is discharged before scan.

0

KS_INTERVAL_POL

R/W

0x0

  • 1: The keyboard is discharged at interval (FSM!=scan idle allrelease).

REG_KS_STUCK_CFG0

  • Name : Key-Scan Stuck Configuration Register

  • Size : 32

  • Address offset : 03Ch

  • Read/write access : R/W

31 KS_AUTO_CHECK_STUCK_ENABLE 30:0 KS_STUCK_TIME_THRESHOLD

Bit

Symbol

Access

Reset

Description

31

KS_AUTO_CHECK_STUCK_ENABLE

R/W

0x0

Enable auto check stuck or not

  • 0x1: Key-Scan auto chek stuck enabled.

  • 0x0: Key-Scan auto check stuck disabled.

30:0

KS_STUCK_TIME_THRESHOLD

R/W

0x7FFFFFFF

When the threshold is exceeded, it is considered to be stuck event or release stuck key, this counter is in scan clk.

REG_KS_STUCK_CFG1

  • Name : Key-Scan Stuck Configuration Register 1

  • Size : 32

  • Address offset : 040h

  • Read/write access : R/W

31:8 RSVD 7:0 KS_ROW_DEFAULT_STATUS

Bit

Symbol

Access

Reset

Description

31:8

RSVD

R

-

Reserved

7:0

KS_ROW_DEFAULT_STATUS

R/W

0xFF

Keyboard row default status:

  • 0b11111111: No key row is stucked

  • 0b11111110: Key row 0 is stucked

  • 0b11111101: Key row 1 is stucked

  • 0b11111100: Key row 0 and column 1 are stucked

  • 0b11111011: Key row 2 is stucked

REG_KS_STUCK_CFG2

  • Name : Key-Scan Stuck Configuration Register 2

  • Size : 32

  • Address offset : 044h

  • Read/write access : R/W

31 KS_STUCKROW_DETECT_ENABLE 30:24 RSVD 23:13 KS_STUCKROW_DETECT_TIME 12 RSVD 11:0 KS_STUCKROW_DETECT_TIME_INTERVAL

Bit

Symbol

Access

Reset

Description

31

KS_STUCKROW_DETECT_ENABLE

R/W

0x0

Enable stuckrow detect function, and row gpio will be “no pu ll” state in ks_stuckrow_detect_time_interval

30:24

RSVD

R

-

Reserved

23:13

KS_STUCKROW_DETECT_TIME

R/W

0x1

Key-Scan stuckrow detect timer, this counter is in clk_131k

12

RSVD

R

-

Reserved

11:0

KS_STUCKROW_DETECT_TIME_INTERVAL

R/W

0x0

Key-Scan stuckrow detect interval timer, this counter is in clk_131k

REG_KS_STUCK_KEY_STATUS1

  • Name : Key-Scan Status Register 1

  • Size : 32

  • Address offset : 048h

  • Read/write access : R

31:0 KS_KEY_STATUS1

Bit

Symbol

Access

Reset

Description

31:0

KS_KEY_STATUS1

R

0x0

Each bit means the corresponding key’s stuck state

  • 0x1: key stucked

  • 0x0: key unstucked

Corresponding:

Key_status1[7:0] - row0[7:0]

Key_status1[15:8] - row1[7:0]

Key_status1[13:16] - row2[7:0]

Key_status1[31:24] - row3[7:0]

REG_KS_STUCK_KEY_STATUS2

  • Name : Key-Scan Status Register 2

  • Size : 32

  • Address offset : 04Ch

  • Read/write access : R

31:0 KS_KEY_STATUS2

Bit

Symbol

Access

Reset

Description

31:0

KS_KEY_STATUS2

R

0x0

Each bit means the corresponding key’s stuck state

  • 0x1: key stucked

  • 0x0: key unstucked

Corresponding:

Key_status2[7:0] - row4[7:0]

Key_status2[15:8] - row5[7:0]

Key_status2[13:16] - row6[7:0]

Key_status2[31:24] - row7[7:0]

REG_KS_STUCK_KEY_ROW_STATUS1

  • Name : Key-Scan Row Status Register 1

  • Size : 32

  • Address offset : 050h

  • Read/write access : R

31:8 RSVD 7:0 KS_ROW_STATUS

Bit

Symbol

Access

Reset

Description

31:8

RSVD

R

-

Reserved

7:0

KS_ROW_STATUS

R

0x0

Each bit means the corresponding key row’s stuck state

  • 0x1: row stucked

  • 0x0: row unstucked

Corresponding: row_status[7:0] - row[7:0]

REG_KS_DUMMY

  • Name : Key-Scan Dummy Register

  • Size : 32

  • Address offset : 058h

  • Read/write access : R/W

31:16 RSVD 15:0 DUMMY

Bit

Symbol

Access

Reset

Description

31:16

RSVD

R

-

Reserved

15:0

DUMMY

R/W

0x0

Reserved for HW