14#ifndef __PAN_KSCAN_H__
15#define __PAN_KSCAN_H__
30#define KS_PERIPHRAL_ENABLE (0X00000001)
31#define KS_WAKEUP_ENABLE (0X00000002)
32#define KS_WAKEUP_AND_PERIPH_ENABLE (0X00000003)
38#define KS_INTERVAL_TIME_CLK_1 (0X0)
39#define KS_INTERVAL_TIME_CLK_2 (0X1)
40#define KS_INTERVAL_TIME_CLK_4 (0X2)
41#define KS_INTERVAL_TIME_CLK_8 (0X3)
42#define KS_INTERVAL_TIME_CLK_16 (0X4)
43#define KS_INTERVAL_TIME_CLK_32 (0X5)
44#define KS_INTERVAL_TIME_CLK_64 (0X6)
45#define KS_INTERVAL_TIME_CLK_128 (0X7)
46#define KS_INTERVAL_TIME_CLK_256 (0X8)
47#define KS_INTERVAL_TIME_CLK_512 (0X9)
48#define KS_INTERVAL_TIME_CLK_1024 (0XA)
49#define KS_INTERVAL_TIME_CLK_2048 (0XB)
50#define KS_INTERVAL_TIME_CLK_4K (0XC)
51#define KS_INTERVAL_TIME_CLK_8K (0XD)
52#define KS_INTERVAL_TIME_CLK_16K (0XE)
53#define KS_INTERVAL_TIME_CLK_32K (0XF)
67__STATIC_INLINE
void KS_Enable(KSCAN_T *ks,FunctionalState NewState,uint32_t func)
69 (NewState != DISABLE)?((ks)->KS_EN |= func):((ks)->KS_EN &= ~func);
80__STATIC_INLINE
void KS_InputEnable(KSCAN_T *ks,FunctionalState NewState,uint32_t func)
82 (NewState != DISABLE)?((ks)->KS_IO_CFG |= func):((ks)->KS_IO_CFG &= ~func);
92__STATIC_INLINE
void KS_OutputEnable(KSCAN_T *ks,FunctionalState NewState,uint32_t func)
94 (NewState != DISABLE)?((ks)->KS_IO_CFG |= (func << 8)):((ks)->KS_IO_CFG &= ~(func << 8));
105 (NewState != DISABLE)?((ks)->KS_INT_CFG |= KS_INT_ENABLE_Msk):((ks)->KS_INT_CFG &= ~KS_INT_ENABLE_Msk);
118 return ((ks)->KS_INT_CFG & func)?(
true):(
false);
131 (ks)->KS_INT_CFG |= func;
142 (NewState != DISABLE)?((ks)->KS_CFG |= KS_POLARITY_VALID_HIGH_Msk):((ks)->KS_CFG &= ~KS_POLARITY_VALID_HIGH_Msk);
153 (NewState != DISABLE)?((ks)->KS_CFG |= KS_STATUS_CLEAR_Msk):((ks)->KS_CFG &= ~KS_STATUS_CLEAR_Msk);
165 (ks)->KS_CFG = ((ks)->KS_CFG & ~KS_SCAN_INTERVAL_Msk) | (func << KS_SCAN_INTERVAL_Pos);
175 return (((ks)->KS_CFG & KS_SCAN_INTERVAL_Msk) >> KS_SCAN_INTERVAL_Pos);
187 (ks)->KS_CFG = ((ks)->KS_CFG & ~KS_ROW_INTERVAL_Msk) | (func << KS_ROW_INTERVAL_Pos);
196 return (((ks)->KS_CFG & KS_ROW_INTERVAL_Msk) >> KS_ROW_INTERVAL_Pos);
208 (ks)->KS_CFG = ((ks)->KS_CFG & ~KS_DEBOUNCE_TIME_Msk) | (func << KS_DEBOUNCE_TIME_Pos);
218 return (((ks)->KS_CFG & KS_DEBOUNCE_TIME_Msk) >> KS_DEBOUNCE_TIME_Pos);
229 (enable) ? (ks->KS_EN |= KS_DLY_DISABLE_Msk) : (ks->KS_EN &= ~KS_DLY_DISABLE_Msk);
__STATIC_INLINE void KS_SetFrameInterval(KSCAN_T *ks, uint32_t func)
This function is used to set keyscan interval time between current frame to next.
Definition: pan_kscan.h:163
__STATIC_INLINE void KS_WaitScanFinish(KSCAN_T *ks, bool enable)
This function is used to enable keyscan delay function,if enabled isr will reported after scan finish...
Definition: pan_kscan.h:227
__STATIC_INLINE bool KS_StatusCheck(KSCAN_T *ks, uint32_t func)
This function is used to check keyscan status.
Definition: pan_kscan.h:116
__STATIC_INLINE void KS_ClearKeyscanStatus(KSCAN_T *ks, FunctionalState NewState)
This function is used to clear all key status enable.
Definition: pan_kscan.h:151
__STATIC_INLINE uint32_t KS_GetRowInterval(KSCAN_T *ks)
This function is used to get keyscan interval time between current row to next.
Definition: pan_kscan.h:194
uint32_t KS_ReadKeyRowInfo(KSCAN_T *ks, uint8_t rowIdx)
This function is used to read key info.
__STATIC_INLINE void KS_OutputEnable(KSCAN_T *ks, FunctionalState NewState, uint32_t func)
This function is set keyscan output enable function.
Definition: pan_kscan.h:92
__STATIC_INLINE void KS_SetDebounceTime(KSCAN_T *ks, uint32_t func)
This function is used to set keyscan debounce time.
Definition: pan_kscan.h:206
__STATIC_INLINE void KS_ClearFlag(KSCAN_T *ks, uint32_t func)
This function is used to clear keyscan status.
Definition: pan_kscan.h:129
__STATIC_INLINE void KS_SetKeyscanPolarity(KSCAN_T *ks, FunctionalState NewState)
This function is used to set keyscan polarity as high.
Definition: pan_kscan.h:140
__STATIC_INLINE uint32_t KS_GetFrameInterval(KSCAN_T *ks)
This function is used to get keyscan interval time between current frame to next.
Definition: pan_kscan.h:173
__STATIC_INLINE void KS_SetRowInterval(KSCAN_T *ks, uint32_t func)
This function is used to set keyscan interval time between current row to next.
Definition: pan_kscan.h:185
__STATIC_INLINE void KS_IntEnable(KSCAN_T *ks, FunctionalState NewState)
This function is used to check keyscan status.
Definition: pan_kscan.h:103
__STATIC_INLINE uint32_t KS_GetDebounceTime(KSCAN_T *ks)
This function is used to get keyscan debounce time.
Definition: pan_kscan.h:216
__STATIC_INLINE void KS_InputEnable(KSCAN_T *ks, FunctionalState NewState, uint32_t func)
This function is set keyscan input enable function.
Definition: pan_kscan.h:80
bool KS_IsKeyPressed(KSCAN_T *ks, uint8_t rowIdx, uint8_t colIdx)
This function is used to read key info.
__STATIC_INLINE void KS_Enable(KSCAN_T *ks, FunctionalState NewState, uint32_t func)
This function is set keyscan enable bit.
Definition: pan_kscan.h:67