MTB CAT1 Peripheral driver library

General Description

Functions

cy_en_ks_status_t Cy_Keyscan_Register_Callback (cy_cb_keyscan_handle_events_t cbEvents, cy_stc_keyscan_context_t *context)
 Registers for callback Application has to register for callback for receiving the key press events. More...
 
cy_en_ks_status_t Cy_Keyscan_Init (MXKEYSCAN_Type *base, const cy_stc_ks_config_t *config, cy_stc_keyscan_context_t *context)
 Register Context with the driver This Function registers for the event callback and FW FIFO buffer. More...
 
cy_en_ks_status_t Cy_Keyscan_DeInit (MXKEYSCAN_Type *base, cy_stc_keyscan_context_t *context)
 Deinit Keyscan. More...
 
cy_en_ks_status_t Cy_Keyscan_Enable (MXKEYSCAN_Type *base, cy_stc_keyscan_context_t *context)
 Enable Keyscan. More...
 
cy_en_ks_status_t Cy_Keyscan_Disable (MXKEYSCAN_Type *base, cy_stc_keyscan_context_t *context)
 Disable keyscan Reset's the Keyscan hardware and disables the keyscan hardware. More...
 
cy_en_ks_status_t Cy_Keyscan_EventsPending (MXKEYSCAN_Type *base, bool *eventsPending, cy_stc_keyscan_context_t *context)
 Events pending Return whether any events are in the FW FIFO or not. More...
 
cy_en_ks_status_t Cy_Keyscan_GetNextEvent (MXKEYSCAN_Type *base, cy_stc_key_event *event, cy_stc_keyscan_context_t *context)
 Get next event from FW FIFO. More...
 
cy_en_ks_status_t Cy_Keyscan_SetInterruptMask (MXKEYSCAN_Type *base, uint32_t mask)
 Setup interrupt source to be accepted. More...
 
cy_en_ks_status_t Cy_Keyscan_GetInterruptMask (MXKEYSCAN_Type *base, uint32_t *mask)
 Return interrupt mask setting. More...
 
cy_en_ks_status_t Cy_Keyscan_GetInterruptMaskedStatus (MXKEYSCAN_Type *base, uint32_t *status)
 Return interrupt masked status. More...
 
cy_en_ks_status_t Cy_Keyscan_GetInterruptStatus (MXKEYSCAN_Type *base, uint32_t *status)
 Return interrupt raw status. More...
 
cy_en_ks_status_t Cy_Keyscan_ClearInterrupt (MXKEYSCAN_Type *base, uint32_t mask)
 Clear interrupt status. More...
 
cy_en_ks_status_t Cy_Keyscan_Interrupt_Handler (MXKEYSCAN_Type *base, cy_stc_keyscan_context_t *context)
 Handler for keyscan interrupts. More...
 
cy_en_ks_status_t Cy_Keyscan_FlushEvents (MXKEYSCAN_Type *base, cy_stc_keyscan_context_t *context)
 Flush events from HW FIFO. More...
 
cy_en_ks_status_t Cy_Keyscan_EnableGhostDetection (MXKEYSCAN_Type *base)
 Enables Ghost detection. More...
 
cy_en_ks_status_t Cy_Keyscan_DisableGhostDetection (MXKEYSCAN_Type *base)
 Disables Ghost detection. More...
 
cy_en_ks_status_t Cy_Keyscan_EnableClockStayOn (MXKEYSCAN_Type *base)
 Enables Clock Stay On Clock to the IP is always enabled. More...
 
cy_en_ks_status_t Cy_Keyscan_DisableClockStayOn (MXKEYSCAN_Type *base)
 Disables Clock Stay On When there is no activity detected the clock to the Keyscan is gated off. More...
 

Function Documentation

◆ Cy_Keyscan_Register_Callback()

cy_en_ks_status_t Cy_Keyscan_Register_Callback ( cy_cb_keyscan_handle_events_t  cbEvents,
cy_stc_keyscan_context_t context 
)

Registers for callback Application has to register for callback for receiving the key press events.

In the interrupt handler data from HW FIFO is copied to FW FIFO and application is notified to get the data using this callback function.

Parameters
[in]cbEventsPointer to the callback function.
[in]contextPointer to the context.
Return values
Refercy_en_ks_status_t
Function Usage
if(CY_KEYSCAN_SUCCESS != Cy_Keyscan_Register_Callback(key_detected_callback, &context))
{
/* Insert error handling */
}
Registers for callback Application has to register for callback for receiving the key press events.

[in] cbEvents Pointer to the callback function.

[in] context Pointer to the context.

◆ Cy_Keyscan_Init()

cy_en_ks_status_t Cy_Keyscan_Init ( MXKEYSCAN_Type *  base,
const cy_stc_ks_config_t config,
cy_stc_keyscan_context_t context 
)

Register Context with the driver This Function registers for the event callback and FW FIFO buffer.

Precondition
The Application must configure corresponding keyscan pins according to requirements and settings of keyscan instance.
Parameters
[in]basePointer to KeyScan instance register area
[in]configKeyScan module configuration. See cy_stc_ks_config_t.
[in]contextPointer to the context.
Return values
Refercy_en_ks_status_t
Function Usage
cy_stc_ks_config_t keyscan_config =
{
.macroUpDebCnt = 3u,
.microDebCnt = 3u,
.noofRows = 8u,
.noofColumns = 20u,
.ghostEnable = true,
.cpuWakeupEnable = true,
.clkStayOn = true
};
status = Cy_Keyscan_Init(MXKEYSCAN, &keyscan_config, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
/* Insert error handling */
}
The Application must configure corresponding keyscan pins according to requirements and settings of keyscan instance.

[in] base Pointer to KeyScan instance register area [in] config KeyScan module configuration. See cy_stc_ks_config_t. [out] context Pointer to the context.

◆ Cy_Keyscan_DeInit()

cy_en_ks_status_t Cy_Keyscan_DeInit ( MXKEYSCAN_Type *  base,
cy_stc_keyscan_context_t context 
)

Deinit Keyscan.

Deinits the Keyscan HW Clear FW FIFO after a HW reset. Restores the control data and enables scans if they were enabled before this function was called.

Parameters
base[in] Pointer to Keyscan instance register area.
context[in] Pointer to the context.
Return values
Refercy_en_ks_status_t
Function Usage
status = Cy_Keyscan_DeInit (MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
/* Insert error handling */
}
Deinit Keyscan.

base [in] Pointer to KEYSCAN instance register area.

◆ Cy_Keyscan_Enable()

cy_en_ks_status_t Cy_Keyscan_Enable ( MXKEYSCAN_Type *  base,
cy_stc_keyscan_context_t context 
)

Enable Keyscan.

Enables the keyscan hardware.

Parameters
base[in] Pointer to KeyScan instance register area.
context[in] Pointer to the context.
Return values
Refercy_en_ks_status_t
Function Usage
if(CY_KEYSCAN_SUCCESS != Cy_Keyscan_Enable(MXKEYSCAN, &context))
{
/* Insert error handling */
}
base [in] Pointer to KeyScan instance register area. context [in] Pointer to the context.

◆ Cy_Keyscan_Disable()

cy_en_ks_status_t Cy_Keyscan_Disable ( MXKEYSCAN_Type *  base,
cy_stc_keyscan_context_t context 
)

Disable keyscan Reset's the Keyscan hardware and disables the keyscan hardware.

When disabled, clock to the keyscan IP is gated.

Parameters
base[in] Pointer to KeyScan instance register area.
context[in] Pointer to the context.
Return values
Refercy_en_ks_status_t
Function Usage
if(CY_KEYSCAN_SUCCESS != Cy_Keyscan_Disable(MXKEYSCAN, &context))
{
/* Insert error handling */
}
Disable keyscan Reset's the Keyscan hardware and disables the keyscan hardware.

base [in] Pointer to KeyScan instance register area. context [in] Pointer to the context.

◆ Cy_Keyscan_EventsPending()

cy_en_ks_status_t Cy_Keyscan_EventsPending ( MXKEYSCAN_Type *  base,
bool *  eventsPending,
cy_stc_keyscan_context_t context 
)

Events pending Return whether any events are in the FW FIFO or not.

Parameters
base[in] Pointer to KeyScan instance register area.
context[in] Pointer to the context.
eventsPending[out] Pointer to the eventsPending, True if events pending and otherwise False.
Return values
Refercy_en_ks_status_t
Function Usage
if(CY_KEYSCAN_SUCCESS != Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context))
{
/* Insert error handling */
}
Events pending Return whether any events are in the FW FIFO or not.

base [in] Pointer to KeyScan instance register area. context [in] Pointer to the context. eventsPending [out] Pointer to the eventsPending.

◆ Cy_Keyscan_GetNextEvent()

cy_en_ks_status_t Cy_Keyscan_GetNextEvent ( MXKEYSCAN_Type *  base,
cy_stc_key_event event,
cy_stc_keyscan_context_t context 
)

Get next event from FW FIFO.

Applications have to call Cy_Keyscan_Interrupt_Handler from keyscan interrupt handler. After successfully reading from HW FIFO and writing to FW FIFO applications will be notified through the registered callback. Applications to read from the FW FIFO has to call this function in a loop till the return value is CY_KEYSCAN_EVENT_NONE

Parameters
base[in] Pointer to KeyScan instance register area.
context[in] Pointer to the context.
event[out] Pointer to the next event.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
Get next event from FW FIFO.

base [in] Pointer to KeyScan instance register area. context [in] Pointer to the context. event [out] Pointer to the next event.

◆ Cy_Keyscan_SetInterruptMask()

cy_en_ks_status_t Cy_Keyscan_SetInterruptMask ( MXKEYSCAN_Type *  base,
uint32_t  mask 
)

Setup interrupt source to be accepted.

Parameters
base[in] Pointer to KeyScan instance register area.
mask[in] The mask with the OR of the interrupt source to be accepted. See KeyScan ALL interrupt mask definition for the set of constants.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
base [in] Pointer to KeyScan instance register area. mask [in] The mask with the OR of the interrupt source to be accepted. See \ group_keyscan_intr_mask_macro for the set of constants.

◆ Cy_Keyscan_GetInterruptMask()

cy_en_ks_status_t Cy_Keyscan_GetInterruptMask ( MXKEYSCAN_Type *  base,
uint32_t *  mask 
)

Return interrupt mask setting.

Parameters
base[in] Pointer to KeyScan instance register area.
mask[out] The mask with the OR of the interrupt source which is masked. See KeyScan ALL interrupt mask definition for the set of constants.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
base [in] Pointer to KeyScan instance register area. mask [out] The mask with the OR of the interrupt source which is masked. See \ group_keyscan_intr_mask_macro for the set of constants.

◆ Cy_Keyscan_GetInterruptMaskedStatus()

cy_en_ks_status_t Cy_Keyscan_GetInterruptMaskedStatus ( MXKEYSCAN_Type *  base,
uint32_t *  status 
)

Return interrupt masked status.

Parameters
base[in] Pointer to KeyScan instance register area.
status[out] The mask with the OR of the interrupt source which occurs. See KeyScan ALL interrupt mask definition for the set of constants.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
base [in] Pointer to KeyScan instance register area. status [out] The mask with the OR of the interrupt source which occurs. See \ group_keyscan_intr_mask_macro for the set of constants.

◆ Cy_Keyscan_GetInterruptStatus()

cy_en_ks_status_t Cy_Keyscan_GetInterruptStatus ( MXKEYSCAN_Type *  base,
uint32_t *  status 
)

Return interrupt raw status.

Parameters
base[in] Pointer to Keyscan instance register area.
status[out] The mask with the OR of the interrupt source which occurs. See KeyScan ALL interrupt mask definition for the set of constants.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
base [in] Pointer to Keyscan instance register area. status [out] The mask with the OR of the interrupt source which occurs. See \ group_keyscan_intr_mask_macro for the set of constants.

◆ Cy_Keyscan_ClearInterrupt()

cy_en_ks_status_t Cy_Keyscan_ClearInterrupt ( MXKEYSCAN_Type *  base,
uint32_t  mask 
)

Clear interrupt status.

Parameters
base[in] Pointer to Keyscan instance register area.
mask[in] The mask with the OR of the interrupt source to be cleared. See KeyScan ALL interrupt mask definition for the set of constants.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
base [in] Pointer to Keyscan instance register area. mask [in] The mask with the OR of the interrupt source to be cleared. See \ group_keyscan_intr_mask_macro for the set of constants.

◆ Cy_Keyscan_Interrupt_Handler()

cy_en_ks_status_t Cy_Keyscan_Interrupt_Handler ( MXKEYSCAN_Type *  base,
cy_stc_keyscan_context_t context 
)

Handler for keyscan interrupts.

Applications have to call this function from keyscan interrupt handler. After successfully reading from HW FIFO and writing to FW FIFO this function will notify application to read from the FW FIFO. Application has to call Cy_Keyscan_getNextEvent() in a loop till the return value is CY_KEYSCAN_EVENT_NONE

Parameters
base[in] Pointer to Keyscan instance register area.
context[in] Pointer to the context.
Return values
Refercy_en_ks_status_t
Function Usage
/*
** Applications have to call Cy_Keyscan_Interrupt_Handler function from keyscan interrupt handler.
** Applications will be notified of any key events through the registered callback.
** Applications have to read the events in the callback function by calling Cy_Keyscan_GetNextEvent function in a loop till
** the return value is CY_KEYSCAN_EVENT_NONE.
*/
void keyscan_intHandler(void)
{
uint32_t int_status;
Cy_Keyscan_GetInterruptMaskedStatus(MXKEYSCAN, &int_status);
if(0UL != (MXKEYSCAN_INTR_FIFO_THRESH_DONE & int_status))
{
status = Cy_Keyscan_Interrupt_Handler(MXKEYSCAN, &context);
if(CY_KEYSCAN_SUCCESS != status)
{
// Keyscan interrupt handler failed
}
}
else
{
}
}
static void key_detected_callback(void)
{
uint8_t keyCode, scanCycle, upDownFlag;
bool events_pending;
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
while (events_pending)
{
status = Cy_Keyscan_GetNextEvent(MXKEYSCAN, &kevent, &context);
if(status != CY_KEYSCAN_SUCCESS)
{
// Keyscan get next event failed
}
/* Check value of keycode for the corresponding key being pressed
Keycode is calculated as ((no of rows * column num) + row num) */
keyCode = kevent.keyCode;
scanCycle = kevent.scanCycleFlag;
upDownFlag = kevent.upDownFlag;
if(keyCode == KEYSCAN_KEYCODE_ROLLOVER)
{
// ROLLOVER KEY DETECTED
}
{
// End of Scan Cycle event. Added by driver when an event is occurred in different scan cycle.
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
continue;
}
Cy_Keyscan_EventsPending(MXKEYSCAN, &events_pending, &context);
(void)keyCode;
(void)scanCycle;
(void)upDownFlag;
}
}
Applications have to call this function from keyscan interrupt handler.

base [in] Pointer to Keyscan instance register area. context [in] Pointer to the context.

◆ Cy_Keyscan_FlushEvents()

cy_en_ks_status_t Cy_Keyscan_FlushEvents ( MXKEYSCAN_Type *  base,
cy_stc_keyscan_context_t context 
)

Flush events from HW FIFO.

Flush the Fw FIFO also and it is equivalent to no key press events.

Parameters
base[in] Pointer to Keyscan instance register area.
context[in] Pointer to the context.
Return values
Refercy_en_ks_status_t

Flush events from HW FIFO.

[in] context Pointer to the context. [in] base Pointer to KeyScan instance register area

◆ Cy_Keyscan_EnableGhostDetection()

cy_en_ks_status_t Cy_Keyscan_EnableGhostDetection ( MXKEYSCAN_Type *  base)

Enables Ghost detection.

Parameters
base[in] Pointer to Keyscan instance register area.
Return values
Refercy_en_ks_status_t
Function Usage
{
/* Insert error handling */
}
base [in] Pointer to Keyscan instance register area.

◆ Cy_Keyscan_DisableGhostDetection()

cy_en_ks_status_t Cy_Keyscan_DisableGhostDetection ( MXKEYSCAN_Type *  base)

Disables Ghost detection.

Parameters
base[in] Pointer to Keyscan instance register area.
Return values
Refercy_en_ks_status_t
Function Usage
{
/* Insert error handling */
}
base [in] Pointer to Keyscan instance register area.

◆ Cy_Keyscan_EnableClockStayOn()

cy_en_ks_status_t Cy_Keyscan_EnableClockStayOn ( MXKEYSCAN_Type *  base)

Enables Clock Stay On Clock to the IP is always enabled.

Parameters
base[in] Pointer to Keyscan instance register area.
Return values
Refercy_en_ks_status_t
Function Usage
{
/* Insert error handling */
}
base [in] Pointer to Keyscan instance register area.

◆ Cy_Keyscan_DisableClockStayOn()

cy_en_ks_status_t Cy_Keyscan_DisableClockStayOn ( MXKEYSCAN_Type *  base)

Disables Clock Stay On When there is no activity detected the clock to the Keyscan is gated off.

Parameters
base[in] Pointer to Keyscan instance register area.
Return values
Refercy_en_ks_status_t
Function Usage
{
/* Insert error handling */
}
Disables Clock Stay On When there is no activity detected the clock to the Keyscan is gated off.

base [in] Pointer to Keyscan instance register area.