tao_z
2022-05-29 fa8669b0092240642af78e84c0e89f596444fdad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**
  ******************************************************************************
  * @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.
  *
  * <h2><center>&copy; COPYRIGHT 2019 Chipways</center></h2>
  ******************************************************************************
  */
    
/* 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__ */    
 
/**
  * @}
  */
 
/**
  * @}
  */