KEYSCAN - Keyboard Scan
Description
Keyscan (KEYSCAN) Peripheral API.
This module contains functions to control the KEYSCAN peripheral of Silicon Labs 32-bit MCUs and SoCs. The KEYSCAN module connects through rows and columns of GPIOs to an external mechanical keypad.
| Data Structures | |
| struct | sl_keyscan_config_t | 
| KEYSCAN configuration structure. | |
| Functions | |
| void | sl_keyscan_init (const sl_keyscan_config_t *p_config) | 
| Initializes KEYSCAN module. | |
| void | sl_keyscan_enable (void) | 
| Enables KEYSCAN module. | |
| void | sl_keyscan_disable (void) | 
| Disables KEYSCAN module. | |
| void | sl_keyscan_reset (void) | 
| Restores KEYSCAN to its reset state. | |
| void | sl_keyscan_wait_ready (void) | 
| Waits for the KEYSCAN to complete reseting or disabling procedure. | |
| void | sl_keyscan_wait_sync (void) | 
| Waits for the KEYSCAN to complete all synchronization of register changes and commands. | |
| void | sl_keyscan_start_scan (void) | 
| Starts KEYSCAN scan. | |
| void | sl_keyscan_stop_scan (void) | 
| Stops the KEYSCAN scan. | |
| uint32_t | sl_keyscan_get_status (void) | 
| Gets KEYSCAN STATUS register value. | |
| void | sl_keyscan_enable_interrupts (uint32_t flags) | 
| Enables one or more KEYSCAN interrupts. | |
| void | sl_keyscan_disable_interrupts (uint32_t flags) | 
| Disables one or more KEYSCAN interrupts. | |
| void | sl_keyscan_clear_interrupts (uint32_t flags) | 
| Clears one or more pending KEYSCAN interrupts. | |
| uint32_t | sl_keyscan_get_interrupts (void) | 
| Gets pending KEYSCAN interrupt flags. | |
| uint32_t | sl_keyscan_get_enabled_interrupts (void) | 
| Gets enabled and pending KEYSCAN interrupt flags. | |
| void | sl_keyscan_set_interrupts (uint32_t flags) | 
| Sets one or more pending KEYSCAN interrupts from Software. | |
| Macros | |
| #define | KEYSCAN_CONFIG_DEFAULT | 
| Suggested default values for KEYSCAN configuration structure. | |
| Enumerations | |
| enum | sl_keyscan_delay_t
         
         { SL_KEYSCAN_DELAY_2MS = 0, SL_KEYSCAN_DELAY_4MS , SL_KEYSCAN_DELAY_6MS , SL_KEYSCAN_DELAY_8MS , SL_KEYSCAN_DELAY_10MS , SL_KEYSCAN_DELAY_12MS , SL_KEYSCAN_DELAY_14MS , SL_KEYSCAN_DELAY_16MS , SL_KEYSCAN_DELAY_18MS , SL_KEYSCAN_DELAY_20MS , SL_KEYSCAN_DELAY_22MS , SL_KEYSCAN_DELAY_24MS , SL_KEYSCAN_DELAY_26MS , SL_KEYSCAN_DELAY_28MS , SL_KEYSCAN_DELAY_30MS , SL_KEYSCAN_DELAY_32MS } | 
| KEYSCAN configuration delay values. | |
Function Documentation
◆ sl_keyscan_init()
| void sl_keyscan_init | ( | const sl_keyscan_config_t * | 
            p_config
            | ) | 
Initializes KEYSCAN module.
- Parameters
- 
         [in] p_configA pointer to the KEYSCAN initialization structure variable. 
◆ sl_keyscan_enable()
| void sl_keyscan_enable | ( | void | 
            | ) | 
Enables KEYSCAN module.
◆ sl_keyscan_disable()
| void sl_keyscan_disable | ( | void | 
            | ) | 
Disables KEYSCAN module.
- Note
- The disabling of the module could take some time. This function will not wait for the disabling to finish before returning. Use the function sl_keyscan_wait_ready to wait for the module to be fully disable.
◆ sl_keyscan_reset()
| void sl_keyscan_reset | ( | void | 
            | ) | 
Restores KEYSCAN to its reset state.
- Note
- The register STATUS get reset value after enabling the module because it is of type RSYNC
- The resetting of the module could take some time. This function will not wait for the resetting to finish before returning. Use the function sl_keyscan_wait_ready to wait for the module to be fully reset.
◆ sl_keyscan_wait_ready()
| 
 | inline | 
Waits for the KEYSCAN to complete reseting or disabling procedure.
◆ sl_keyscan_wait_sync()
| 
 | inline | 
Waits for the KEYSCAN to complete all synchronization of register changes and commands.
◆ sl_keyscan_start_scan()
| 
 | inline | 
Starts KEYSCAN scan.
- Note
- This function will send a start command to the KEYSCAN peripheral. The sl_keyscan_wait_sync function can be used to wait for the start command to be executed.
- This function requires the KEYSCAN to be enabled.
◆ sl_keyscan_stop_scan()
| 
 | inline | 
Stops the KEYSCAN scan.
- Note
- This function will send a stop command to the KEYSCAN peripheral. The sl_keyscan_wait_sync function can be used to wait for the stop command to be executed.
- This function requires the KEYSCAN to be enabled.
◆ sl_keyscan_get_status()
| 
 | inline | 
Gets KEYSCAN STATUS register value.
- Returns
- Current STATUS register value.
◆ sl_keyscan_enable_interrupts()
| 
 | inline | 
Enables one or more KEYSCAN interrupts.
- Note
- Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using sl_keyscan_clear_interrupts prior to enabling the interrupt.
- Parameters
- 
         [in] flagsKEYSCAN interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources. 
◆ sl_keyscan_disable_interrupts()
| 
 | inline | 
Disables one or more KEYSCAN interrupts.
- Parameters
- 
         [in] flagsKEYSCAN interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt sources. 
◆ sl_keyscan_clear_interrupts()
| 
 | inline | 
Clears one or more pending KEYSCAN interrupts.
- Parameters
- 
         [in] flagsKEYSCAN interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources. 
◆ sl_keyscan_get_interrupts()
| 
 | inline | 
Gets pending KEYSCAN interrupt flags.
- Note
- Event bits are not cleared by using this function.
- Returns
- Pending KEYSCAN interrupt sources. Returns a set of interrupt flags OR-ed together for multiple interrupt sources.
◆ sl_keyscan_get_enabled_interrupts()
| 
 | inline | 
Gets enabled and pending KEYSCAN interrupt flags.
Useful for handling more interrupt sources in the same interrupt handler.
- Note
- Interrupt flags are not cleared by using this function.
- Returns
- 
         Pending and enabled KEYSCAN interrupt sources. The return value is the bitwise AND of
         - the enabled interrupt sources in KEYSCAN_IEN and
- the pending interrupt flags KEYSCAN_IF.
 
◆ sl_keyscan_set_interrupts()
| 
 | inline | 
Sets one or more pending KEYSCAN interrupts from Software.
- Parameters
- 
         [in] flagsKEYSCAN interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources. 
Macro Definition Documentation
◆ KEYSCAN_CONFIG_DEFAULT
| #define KEYSCAN_CONFIG_DEFAULT | 
Suggested default values for KEYSCAN configuration structure.
Enumeration Type Documentation
◆ sl_keyscan_delay_t
| enum sl_keyscan_delay_t | 
KEYSCAN configuration delay values.