tao_z
2022-06-01 0ff91e66071237834a1501c78648729c8c32f67a
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
/**
  ******************************************************************************
  * @file     xl_pit.h
  * @author   software group
  * @brief    This file contains all the functions prototypes for the PIT 
  *           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_PIT_H_
#define __XL_PIT_H_
 
#ifdef __cplusplus
extern "C"{
#endif
 
/* Includes ---------------------------------------------------------------*/
#include "XL6600.h"
/* Register define ------------------------------------------------------------*/
 
/* LC Bit Fields */
#define PIT_LC_LC_MASK                                                        0xFFFFFFFFu
#define PIT_LC_LC_SHIFT                                                        0
    
/* CV Bit Fields */
#define PIT_CV_CV_MASK                                                        0xFFFFFFFFu
#define PIT_CV_CV_SHIFT                                                        0
    
/* CTR Bit Fields */
#define PIT_CTR_EN_MASK                                                        0x1u
#define PIT_CTR_EN_SHIFT                                                    0
#define PIT_CTR_MODE_MASK                                                    0x2u
#define PIT_CTR_MODE_SHIFT                                                1
#define PIT_CTR_IM_MASK                                                        0x4u
#define PIT_CTR_IM_SHIFT                                                    2
    
/* EOI Bit Fields */
#define PIT_EOI_EOI_MASK                                                    0x1u
#define PIT_EOI_EOI_SHIFT                                                    0
 
/* IS Bit Fields */    
#define PIT_IS_IS_MASK                                                        0x1u
#define PIT_IS_IS_SHIFT                                                        0
 
/* AIS Bit Fields */
#define PIT_AIS_AIS_MASK                                                    0x3u
#define PIT_AIS_AIS_SHIFT                                                    0
 
/* AEOI Bit Fields */
#define PIT_AEOI_AEOI_MASK                                                0x3u
#define PIT_AEOI_AEOI_SHIFT                                                0
 
/* RAWIS Bit Fields */
#define PIT_RAWIS_RAWIS_MASK                                            0x3u
#define PIT_RAWIS_RAWIS_SHIFT                                            0
 
/* DEBUG Bit Fields */
#define PIT_DEBUG_FRZ_MASK                                              0x10u
#define PIT_DEBUG_FRZ_SHIFT                                              4
 
/** PIT - Register Layout Typedef */
typedef struct{
    struct{
        __IO    uint32_t    LC;                                                   /*!< ¶¨Ê±Æ÷¼ÓÔØÖµ¼Ä´æÆ÷, offset: 0x00 */
        __O        uint32_t    CV;                                                   /*!< ¶¨Ê±Æ÷µ±Ç°Öµ¼Ä´æÆ÷, offset: 0x04 */
        __IO    uint32_t    CTR;                                               /*!< ¶¨Ê±Æ÷¿ØÖƼĴæÆ÷, offset: 0x08 */
        __O        uint32_t    EOI;                                               /*!< ¶¨Ê±Æ÷ÖжÏÇåÁã¼Ä´æÆ÷, offset: 0x0C */
        __O        uint32_t    IS;                                                   /*!< PIT Interrupt Status Register, offset: 0x10 */
    }CHANNEL[2];
    uint32_t RESERVED_0[30];
    __O        uint32_t        AIS;                                                 /*!< ¶¨Ê±Æ÷ËùÓÐÖжÏ״̬¼Ä´æÆ÷, offset: 0xa0 */
    __O        uint32_t        AEOI;                                                 /*!< ¶¨Ê±Æ÷ÇåÁãËùÓÐÖжϼĴæÆ÷, offset: 0xa4 */
    __O        uint32_t        RAWIS;                                             /*!< ¶¨Ê±Æ÷ԭʼÖжÏ״̬¼Ä´æÆ÷, offset: 0xa8 */
    uint32_t RESERVED_1[9];
    __IO    uint32_t        PIT_DIV[2];
    uint32_t RESERVED_2[10];
    __IO  uint32_t        CHAIN;                                             /*!< ¶¨Ê±Æ÷µ÷ÊÔģʽÉèÖüĴæÆ÷, offset: 0x100 */    
}PIT_Type,*PIT_MemMapPtr;
extern PIT_Type* PIT;    
 
 
/** @addtogroup XL6600_StdPeriph_Driver
  * @{
  */
 
/** @addtogroup PIT 
  * @{
  */
 
/* Exported constants --------------------------------------------------------*/
/** @defgroup ACMP_Exported_Constants ACMPÄ£¿éʹÓòÎÊý¶¨Òå
  * @{
  */
    
/** @defgroup PIT_Mode_Seclect PITģʽѡÔñ¶¨Òå
  * @{
  */
#define PIT_Run_Mode                                                ((uint8_t)0x00)                /*!< ×ÔÓÉÔËÐÐģʽ */
#define PIT_Count_Mode                                            ((uint8_t)0x02)                /*!< Óû§¶¨ÒåµÄ¼ÆÊýģʽ */
/**
  * @}
  */    
 
/** @defgroup PIT_Channels_Seclect PITͨµÀÑ¡Ôñ
  * @{
  */
typedef enum
{
        PIT_Channel0     =    0 ,                /*!< PITͨµÀ0 */
        PIT_Channel1                                  /*!< PITͨµÀ1 */
 
}PIT_Channel;
/**
  * @}
  */
 
 
/**
  * @}
  */
 
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
void PIT_DeInit(void);
void PIT_Init(uint8_t Channel,uint8_t PIT_Mode,uint16_t CLK_DIV);
 
/* PIT channel function-----------------------------------*/
void PIT_EnableCmd(uint8_t Channel,FunctionalState NewState);
void PIT_InterruptEn(uint8_t Channel,FunctionalState NewState);
 
void PIT_SetLoadCount(uint8_t Channel,uint32_t loadVal);
uint32_t PIT_GetCurrentVal(uint8_t Channel);
 
ITStatus PIT_GetIntStatus(uint8_t Channel);
void PIT_ClrInterrupt(uint8_t Channel);
 
/* PIT function-----------------------------------*/
uint8_t PIT_GetAllIntStatus(void);
void PIT_ClrAllInterrupt(void);
uint8_t PIT_GetRawIntStatus(void);
void PIT_ChainCmd(FunctionalState NewState);
void PIT_FreezeCmd(FunctionalState NewState);
 
 
#ifdef __cplusplus
}
#endif
 
#endif        /*__XL_PIT_H__ */
 
/**
  * @}
  */
 
/**
  * @}
  */