/**
******************************************************************************
* @file xl_kbi.h
* @author software group
* @brief This file contains all the functions prototypes for the KBI
* firmware library.
******************************************************************************
* @attention
*
* 2019 by Chipways Communications,Inc. All Rights Reserved.
* This software is supplied under the terms of a license
* agreement or non-disclosure agreement with Chipways.
* Passing on and copying of this document,and communication
* of its contents is not permitted without prior written
* authorization.
*
*
© COPYRIGHT 2019 Chipways
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __XL_KBI_H__
#define __XL_KBI_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ---------------------------------------------------------------*/
#include "XL6600.h"
/* Register define ------------------------------------------------------------*/
/* PE Bit Fields */
#define KBI_PE_KBIPE_MASK 0xFFFFFFFFu
#define KBI_PE_KBIPE_SHIFT 0
/* ES Bit Fields */
#define KBI_ES_KBEDG_MASK 0xFFFFFFFFu
#define KBI_ES_KBEDG_SHIFT 0
/* SC Bit Fields */
#define KBI_SC_KBMOD_MASK 0x1u
#define KBI_SC_KBMOD_SHIFT 0
#define KBI_SC_KBIE_MASK 0x2u
#define KBI_SC_KBIE_SHIFT 1
#define KBI_SC_KBACK_MASK 0x4u
#define KBI_SC_KBACK_SHIFT 2
#define KBI_SC_KBF_MASK 0x8u
#define KBI_SC_KBF_SHIFT 3
#define KBI_SC_KBSPEN_MASK 0x10u
#define KBI_SC_KBSPEN_SHIFT 4
#define KBI_SC_RSTKBSP_MASK 0x20u
#define KBI_SC_RSTKBSP_SHIFT 5
/* SP Bit Fields */
#define KBI_SP_SP_MASK 0xFFFFFFFFu
#define KBI_SP_SP_SHIFT 0
/** KBI - Register Layout Typedef */
typedef struct {
__IO uint32_t PE; /*!< KBI Òý½ÅʹÄܼĴæÆ÷, offset: 0x0 */
__IO uint32_t ES; /*!< KBI ±ßÑØÑ¡Ôñ¼Ä´æÆ÷, offset: 0x4 */
__IO uint32_t SC; /*!< KBI ״̬ºÍ¿ØÖƼĴæÆ÷, offset: 0x8 */
__I uint32_t SP; /*!< KBI Ô´Òý½Å¼Ä´æÆ÷, offset: 0xC */
} KBI_Type, *KBI_MemMapPtr;
extern KBI_Type * KBI0;
extern KBI_Type * KBI1;
/** @addtogroup XL6600_StdPeriph_Driver
* @{
*/
/** @addtogroup KBI
* @{
*/
/* Exported types ------------------------------------------------------------*/
/**
* @brief KBI ³õʼ»¯½á¹¹Ì嶨Òå
*/
typedef struct
{
uint32_t KBI_SPRegValue; /*!< KBIÔ´Òý½Å */
uint32_t KBI_DetectMode; /*!< KBI¼ì²âģʽ */
}KBI_InitTypeDef;
/* Exported constants --------------------------------------------------------*/
/** @defgroup KBI_Exported_Constants KBIÄ£¿éʹÓòÎÊý¶¨Òå
* @{
*/
/** @defgroup KBI_SourcePin_Enable KBIÔ´Òý½ÅʹÄÜ
* @{
*/
#define KBI_SP_RealValue (uint8_t)0x00 /*!< ¶ÁÈ¡µÄ¼üÅÌÔ´Òý½ÅµÄʵʱֵ */
#define KBI_SP_LatchedValue (uint8_t)0x10 /*!< µ±ÖжϱêÖ¾³öÏÖʱҪ¶ÁÈ¡µÄKBxSP¼Ä´æÆ÷ÖеÄËø´æÖµ */
/**
* @}
*/
/** @defgroup KBI_Detection_Mode KBI´¥·¢Ä£Ê½Ñ¡Ôñ
* @{
*/
#define KBI_Detect_Edge (uint8_t)0x0 /*!< KBI½ö¼ì²â±ßÑØ´¥·¢ */
#define KBI_Detect_EdgeANDLevel (uint8_t)0x1 /*!< KBI¼ì²â±ßÑØºÍµçƽ´¥·¢ */
/**
* @}
*/
/** @defgroup KBI_EdgeLevel_Seclect KBI´¥·¢±ßÑØºÍµçƽ¶¨Òå
* @{
*/
#define KBI_FallEdge_LowLevel 0 /*!< ¼üÅ̼ì²âϽµÑØºÍµÍµçÆ½ */
#define KBI_RiseEdge_HighLevel 1 /*!< ¼üÅ̼ì²âÉÏÉýÑØºÍ¸ßµçƽ */
/**
* @}
*/
/** @defgroup KBI_Pin_Seclect KBIͨµÀÒý½ÅÑ¡Ôñ
* @{
*/
#define KBI_P0 0 /*!< Òý½Å0. */
#define KBI_P1 1 /*!< Òý½Å1. */
#define KBI_P2 2 /*!< Òý½Å2. */
#define KBI_P3 3 /*!< Òý½Å3. */
#define KBI_P4 4 /*!< Òý½Å4. */
#define KBI_P5 5 /*!< Òý½Å5. */
#define KBI_P6 6 /*!< Òý½Å6. */
#define KBI_P7 7 /*!< Òý½Å7. */
#define KBI_P8 8 /*!< Òý½Å8. */
#define KBI_P9 9 /*!< Òý½Å9. */
#define KBI_P10 10 /*!< Òý½Å10. */
#define KBI_P11 11 /*!< Òý½Å11. */
#define KBI_P12 12 /*!< Òý½Å12. */
#define KBI_P13 13 /*!< Òý½Å13. */
#define KBI_P14 14 /*!< Òý½Å14. */
#define KBI_P15 15 /*!< Òý½Å15. */
#define KBI_P16 16 /*!< Òý½Å16. */
#define KBI_P17 17 /*!< Òý½Å17. */
#define KBI_P18 18 /*!< Òý½Å18. */
#define KBI_P19 19 /*!< Òý½Å19. */
#define KBI_P20 20 /*!< Òý½Å20. */
#define KBI_P21 21 /*!< Òý½Å21. */
#define KBI_P22 22 /*!< Òý½Å22. */
#define KBI_P23 23 /*!< Òý½Å23. */
#define KBI_P24 24 /*!< Òý½Å24. */
#define KBI_P25 25 /*!< Òý½Å25. */
#define KBI_P26 26 /*!< Òý½Å26. */
#define KBI_P27 27 /*!< Òý½Å27. */
#define KBI_P28 28 /*!< Òý½Å28. */
#define KBI_P29 29 /*!< Òý½Å29. */
#define KBI_P30 30 /*!< Òý½Å30. */
#define KBI_P31 31 /*!< Òý½Å31. */
/**
* @}
*/
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
void KBI_Deinit(KBI_Type *KBIx);
void KBI_Init(KBI_Type *KBIx, const KBI_InitTypeDef *KBI_InitStruct);
void KBI_PinConfig(KBI_Type *KBIx, uint8_t KBI_Pin,uint8_t EdgeSelect);
void KBI_BatchPinConfig(KBI_Type *KBIx, uint32_t KBI_Pin,uint32_t EdgeRegSelect);
void KBI_InterruptEn(KBI_Type *KBIx,FunctionalState NewState);
FlagStatus KBI_GetInterruptFlag(const KBI_Type *KBIx);
void KBI_ClrInterruptFlag(KBI_Type *KBIx);
void KBI_RstSP(KBI_Type *KBIx);
uint32_t KBI_GetSP(const KBI_Type *KBIx);
#ifdef __cplusplus
}
#endif
#endif /*__XL_KBI_H__ */
/**
* @}
*/
/**
* @}
*/