tao_z
2022-06-11 d8a5f3225d105585a4f181ed884adb2a861e0d13
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
/**
  ******************************************************************************
  * @file     xl_pwt.h
  * @author   software group
  * @brief    This file contains all the functions prototypes for the PWT
  *           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_PWT_H
#define __XL_PWT_H
 
#ifdef __cplusplus
extern "C"{
#endif
 
/* Includes ---------------------------------------------------------------*/
#include "XL6600.h"
    /* Register define ------------------------------------------------------------*/    
/* R1 Bit Fields */
#define PWT_R1_PWTOV_MASK                     0x1u
#define PWT_R1_PWTRDY_MASK                    0x2u
#define PWT_R1_PWTRDY_SHIFT                   1
#define PWT_R1_PWTSR_MASK                     0x8u
#define PWT_R1_PWTSR_SHIFT                    3
#define PWT_R1_POVIE_MASK                     0x10u
#define PWT_R1_POVIE_SHIFT                    4
#define PWT_R1_PRDYIE_MASK                    0x20u
#define PWT_R1_PRDYIE_SHIFT                   5
#define PWT_R1_PWTIE_MASK                     0x40u
#define PWT_R1_PWTIE_SHIFT                    6
#define PWT_R1_PWTEN_MASK                     0x80u
#define PWT_R1_PWTEN_SHIFT                    7
#define PWT_R1_PRE_MASK                       0x700u
#define PWT_R1_PRE_SHIFT                      8
#define PWT_R1_EDGE_MASK                      0x1800u
#define PWT_R1_EDGE_SHIFT                     11
#define PWT_R1_PINSEL_MASK                    0x6000u
#define PWT_R1_PINSEL_SHIFT                   13
#define PWT_R1_PCLKS_MASK                     0x8000u
#define PWT_R1_PCLKS_SHIFT                    15
#define PWT_R1_PPW_MASK                       0xFFFF0000u
#define PWT_R1_PPW_SHIFT                      16
 
/* R2 Bit Fields */
#define PWT_R2_NPW_MASK                       0xFFFFu
#define PWT_R2_NPW_SHIFT                      0
#define PWT_R2_PWTC_MASK                      0xFFFF0000u
#define PWT_R2_PWTC_SHIFT                     16
 
/** PWT - Register Layout Typedef */
typedef struct {
  __IO uint32_t R1;                                /**< Âö¿í¶¨Ê±Æ÷¼Ä´æÆ÷1, offset: 0x0 */
  __I  uint32_t R2;                                /**< Âö¿í¶¨Ê±Æ÷¼Ä´æÆ÷2, offset: 0x4 */
} PWT_Type, *PWT_MemMapPtr;
 
extern PWT_Type* PWT;
/** @addtogroup XL6600_StdPeriph_Driver
  * @{
  */
 
/** @addtogroup PWT
  * @{
  */
 
/* Exported types ------------------------------------------------------------*/ 
 
/** 
  * @brief PWT³õʼ»¯½á¹¹Ì嶨Òå
  */
typedef struct 
{
  uint32_t         PWT_ClkSource;                                  /*!< PWT Ê±ÖÓÔ´Ñ¡Ôñ */
    uint32_t      PWT_PulseInputSelect;                        /*!< PWT Âö³åÊäÈëÑ¡Ôñ */
    uint32_t      PWT_EdgeSensitivity;                    /*!< PWT ÊäÈë±ßÑØÁéÃô¶ÈÑ¡Ôñ */
    uint32_t      PWT_ClkPrescaler;                              /*!< PWT Ê±ÖÓ·ÖÆµÑ¡Ôñ */
}PWT_InitTypeDef;
 
/* Exported constants --------------------------------------------------------*/  
/** @defgroup PWT_Exported_Constants PWTÄ£¿éʹÓòÎÊý¶¨Òå
  * @{
  */
/** @defgroup PWT_ClocksSource_Select PWTʱÖÓÔ´Ñ¡Ôñ
  * @{
  */
#define PWT_BusClock                                         ((uint16_t)0x0000)                    /*!< BUS_CLK×ÜÏßʱÖÓ */
#define PWT_AltClock                                                     ((uint16_t)0x8000)                    /*!< Alternative clock¿ÉѡʱÖÓ */
/**
    * @}
    */
 
/** @defgroup PWT_PulseInputs_Select PWTÊäÈëͨµÀÑ¡Ôñ
  * @{
  */
#define PWT_Pulse_Inputs0                                             ((uint16_t)0x0000)                    /*!< PWTIN[0]ʹÄÜΪÊäÈëͨµÀ */
#define PWT_Pulse_Inputs1                                             ((uint16_t)0x2000)                    /*!< PWTIN[1]ʹÄÜΪÊäÈëͨµÀ */
#define PWT_Pulse_Inputs2                                             ((uint16_t)0x4000)                    /*!< PWTIN[2]ʹÄÜΪÊäÈëͨµÀ */
#define PWT_Pulse_Inputs3                                             ((uint16_t)0x6000)                    /*!< PWTIN[3]ʹÄÜΪÊäÈëͨµÀ */
/**
    * @}
    */
    
/** @defgroup PWT_InputEdge_Select PWT²¶»ñ±ßÑØ
  * @{
  */
#define PWT_FallStart_FallEdge                             ((uint16_t)0x0000)                        /*!< ÔÚµÚÒ»¸öϽµÑØ¿ªÊ¼²âÁ¿Âö¿í£¬ÔÚËùÓÐÖ®ºóµÄϽµÑØÉϲ¶×½Âö¿í */
#define PWT_RiseStart_FallAndRise                             ((uint16_t)0x0800)                    /*!< ÔÚµÚÒ»¸öÉÏÉýÑØ¿ªÊ¼²âÁ¿Âö¿í£¬ÔÚËùÓÐÖ®ºóµÄÉÏÉýÑØºÍϽµÑØÉϲ¶×½Âö¿í */
#define PWT_FallStart_FallAndRise                             ((uint16_t)0x1000)                    /*!< ÔÚµÚÒ»¸öϽµÑØ¿ªÊ¼²âÁ¿Âö¿í£¬ÔÚËùÓÐÖ®ºóµÄÉÏÉýÑØºÍϽµÑØÉϲ¶×½Âö¿í */
#define PWT_RiseStart_RiseEdge                                 ((uint16_t)0x1800)                    /*!< ÔÚµÚÒ»¸öÉÏÉýÑØ¿ªÊ¼²âÁ¿Âö¿í£¬ÔÚËùÓÐÖ®ºóµÄÉÏÉýÑØÉϲ¶×½Âö¿í */
/**
    * @}
    */
    
/** @defgroup PWT_ClockPrescaler_Select PWTʱÖÓ·ÖÆµ
  * @{
  */
#define PWT_Clock_Divided1                             ((uint16_t)0x0000)                    /*!< Ê±ÖÓ1·ÖƵ */
#define PWT_Clock_Divided2                             ((uint16_t)0x0100)                    /*!< Ê±ÖÓ2·ÖƵ */
#define PWT_Clock_Divided4                                     ((uint16_t)0x0200)                    /*!< Ê±ÖÓ4·ÖƵ */
#define PWT_Clock_Divided8                                     ((uint16_t)0x0300)                    /*!< Ê±ÖÓ8·ÖƵ */
#define PWT_Clock_Divided16                                     ((uint16_t)0x0400)                    /*!< Ê±ÖÓ16·ÖƵ */
#define PWT_Clock_Divided32                                     ((uint16_t)0x0500)                    /*!< Ê±ÖÓ32·ÖƵ */
#define PWT_Clock_Divided64                                     ((uint16_t)0x0600)                    /*!< Ê±ÖÓ64·ÖƵ */
#define PWT_Clock_Divided128                                 ((uint16_t)0x0700)                    /*!< Ê±ÖÓ128·ÖƵ */
/**
    * @}
    */
 
/**
    * @}
    */
    
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ 
void PWT_DeInit(PWT_Type *PWTx);
void PWT_Init(PWT_Type *PWTx,const PWT_InitTypeDef *PWT_InitStruct);
void PWT_EnableCmd(PWT_Type *PWTx,FunctionalState NewState);
void PWT_InterruptEn(PWT_Type *PWTx,FunctionalState NewState);
void PWT_PWTRDYIntCmd(PWT_Type *PWTx,FunctionalState NewState);
void PWT_OverflowIntCmd(PWT_Type *PWTx,FunctionalState NewState);
void PWT_SetSoftReset(PWT_Type *PWTx);
FlagStatus PWT_GetOverflowFlag(const PWT_Type *PWTx);
void PWT_ClrOverflowFlag(PWT_Type *PWTx);
FlagStatus PWT_GetPWTRDY(const PWT_Type *PWTx);
void PWT_ClrPWTRDYFlag(PWT_Type *PWTx);
uint16_t PWT_GetPPW(const PWT_Type *PWTx);
uint16_t PWT_GetNPW(const PWT_Type *PWTx);
uint16_t PWT_GetPWTCounter(const PWT_Type *PWTx);
 
#ifdef __cplusplus
}
#endif
 
#endif   
/**
    * @}
    */
    
/**
    * @}
    */