Keypad Library
The mikroC PRO for ARM provides a library for working with 4x4 keypad. The library routines can also be used with 4x1, 4x2, or 4x3 keypad.
External dependencies of Keypad Library
Stellaris
| The following variable must be defined in all projects using Keypad Library: | Description : | Example : | 
|---|---|---|
| extern sfr unsigned long keypadPort; | Keypad Port. | unsigned long keypadPort at GPIO_PORTH_DATA; | 
| extern sfr unsigned long keypadPort_Direction; | Keypad Port direction. | unsigned long keypadPort_Direction at GPIO_PORTH_DIR; | 
MSP432
| The following variable must be defined in all projects using Keypad Library: | Description : | Example : | 
|---|---|---|
| extern sfr unsigned int keypadPort_Output; | Keypad Port Output. | unsigned int keypadPort_Output at DIO_P5OUT; | 
| extern sfr unsigned int keypadPort_Input; | Keypad Port Input. | unsigned int keypadPort_Input at DIO_P5IN; | 
STM32
| The following variable must be defined in all projects using Keypad Library: | Description : | Example : | 
|---|---|---|
| extern sfr unsigned long keypadPort_Input; | Keypad Input Port. | unsigned long keypadPort_Input at GPIOD_IDR; | 
| extern sfr unsigned long keypadPort_Output; | Keypad Output Port. | unsigned long keypadPort_Output at GPIOD_ODR; | 
CEC1x02
| The following variable must be defined in all projects using Keypad Library: | Description : | Example : | 
|---|---|---|
| extern sfr unsigned long keypadPort_Input; | Keypad Input Port. | unsigned long keypadPort_Input at GPIO_INPUT_010_017; | 
| extern sfr unsigned long keypadPort_Output; | Keypad Output Port. | unsigned long keypadPort_Output at GPIO_OUTPUT_010_017; | 
Library Routines
Keypad_Init
| Prototype | void Keypad_Init(); | 
|---|---|
| Description | Initializes given port for working with keypad. | 
| Parameters | None. | 
| Returns | Nothing. | 
| Requires | External dependencies of the library from the top of the page must be defined before using this function. | 
| Example | Stellaris// Keypad module connections unsigned long keypadPort at GPIO_PORTH_DATA; unsigned long keypadPort_Direction at GPIO_PORTH_DIR; // End Keypad module connections ... Keypad_Init(); MSP432// Keypad module connections unsigned int keypadPort_Output at DIO_P5IN; unsigned int keypadPort_Input at DIO_P5OUT; // End Keypad module connections ... Keypad_Init(); STM32// Keypad module connections unsigned long keypadPort_Input at GPIOD_IDR; unsigned long keypadPort_Output at GPIOD_ODR; // End Keypad module connections ... Keypad_Init(); CEC1x02// Keypad module connections unsigned long keypadPort_Input at GPIO_INPUT_010_017; unsigned long keypadPort_Output at GPIO_OUTPUT_010_017; // End Keypad module connections ... Keypad_Init(); | 
| Notes | The Keypad library uses lower byte (bits <7..0>) of  | 
Keypad_Key_Press
| Prototype | unsigned Keypad_Key_Press(); | 
|---|---|
| Description | Reads the key from keypad when key gets pressed. | 
| Parameters | None. | 
| Returns | The code of a pressed key (1..16). If no key is pressed, returns 0. | 
| Requires | Port needs to be initialized for working with the Keypad library, see Keypad_Init. | 
| Example | unsigned kp; ... kp = Keypad_Key_Press(); | 
| Notes | None. | 
Keypad_Key_Click
| Prototype | unsigned Keypad_Key_Click(); | 
|---|---|
| Description | Call to  | 
| Parameters | None. | 
| Returns | The code of a clicked key (1..16). If no key is clicked, returns 0. | 
| Requires | Port needs to be initialized for working with the Keypad library, see Keypad_Init. | 
| Example | kp = Keypad_Key_Click(); | 
| Notes | None. | 
What do you think about this topic ? Send us feedback!



