Keypad Development Guide_Rev1.2

中文

Revision History

Version

Date

Author

Reviewer

Revision Content

1.0

2023-12-1

LJZ

zlc

Initial document creation

1.1

2024-03-25

sxx

Changed document name

1.2

2024-11-07

zw

Modified document format, removed demo

1 Introduction

This document introduces the LTE-EC71X keypad interface APIs. The API interfaces are declared in the file components/kernel/lierda_api/liot_keypad/liot_keypad.h. It supports up to a 5*5 matrix keyboard. Specific pins can be confirmed according to Alt func6 in the module multiplexing table. KPC_C represents the rows of the matrix keyboard, and KPC_R represents the columns of the matrix keyboard.

2 API Function Overview

Function

Description

liot_keypad_init()

Initialize matrix keyboard

liot_keypad_state()

Get matrix keyboard status

3 Type Descriptions

3.1 liot_errcode_keypad_e

KEYPAD API execution result error codes.

  1. Declaration

typedef enum
{
    LIOT_KEYPAD_SUCCESS = LIOT_SUCCESS,
    LIOT_KEYPAD_INVALID_PARAM_ERR = 1|LIOT_KEYPAD_ERRCODE_BASE
}liot_errcode_keypad_e;
  1. Parameters

  • LIOT_KEYPAD_SUCCESS: Function executed successfully.

  • LIOT_KEYPAD_INVALID_PARAM_ERR: Parameter error.

3.2 liot_kpc_report_value_e

Key status enumeration is defined as follows:

  1. Declaration

typedef enum
{
    LIOT_KPC_REPORT_KEY_RELEASE      = 0U, //!< Key is released
    LIOT_KPC_REPORT_KEY_PRESS        = 1U, //!< Key is pressed
    LIOT_KPC_REPORT_KEY_REPEAT       = 2U, //!< Key holds pressed
}liot_kpc_report_value_e;
  1. Parameters

  • LIOT_KPC_REPORT_KEY_RELEASE: Key is released.

  • LIOT_KPC_REPORT_KEY_PRESS: Key is pressed.

  • LIOT_KPC_REPORT_KEY_REPEAT: Long press key.

3.3 liot_kpc_report_event_t

Key report structure is defined as follows:

  1. Declaration

typedef struct
{
        uint8_t    value  : 2;        //!<Key value, liot_kpc_report_value_e
        uint8_t    column : 3;        //!< Key column
        uint8_t    row    : 3;        //!<Key row
}liot_kpc_report_event_t;
  1. Parameters

Type

Parameter

Description

uint8_t

value

Key status. Type is liot_kpc_report_value_e

uint8_t

column

Column

uint8_t

row

Row

4 API Function Details

4.1 liot_keyeventcb_t

Callback function for keypad events.

  1. Declaration

typedef void (*liot_keyeventcb_t)(liot_kpc_report_event_t key);
  1. Parameters

  • key: [In] Key status structure.

4.2 liot_keypad_init

This function is used to initialize the matrix keyboard.

  1. Declaration

liot_errcode_keypad_e liot_keypad_init(liot_keyeventcb_t cb,
    uint8 keyrow[LIOT_KEYPAD_ROW_LENGTH], uint8 keycol[LIOT_KEYPAD_COL_LENGTH])
  1. Parameters

  • cb: [In] Callback function for keypad events.

  • keyrow: [In] Module pins connected to each row of keys.

  • keycol: [In] Module pins connected to each column of keys.

  1. Return Value

  • liot_errcode_keypad_e: Execution result code, see 3.1 for reference.

4.3 liot_keypad_state

This function is used to get the matrix keyboard status.

  1. Declaration

liot_errcode_keypad_e liot_keypad_state(uint8_t *pressed, uint8_t *id);
  1. Parameters

  • pressed: [Out] Key status, refer to liot_kpc_report_value_e.

  • id: [Out] Key ID.

  1. Return Value

  • liot_errcode_keypad_e: Execution result code, see 3.1 for reference.