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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/*******************************************************************************
* Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
*
* This software component is licensed by HDSC under BSD 3-Clause license
* (the "License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*/
/******************************************************************************/
/** \file hc32f460_timer4_sevt.h
**
** A detailed description is available at
** @link Timer4SevtGroup Timer4SEVT description @endlink
**
** - 2018-11-02 CDT First version for Device Driver Library of Timer4SEVT.
**
******************************************************************************/
#ifndef __HC32F460_TIMER4_SEVT_H__
#define __HC32F460_TIMER4_SEVT_H__
/*******************************************************************************
* Include files
******************************************************************************/
#include "hc32_common.h"
/* C binding of definitions if building with C++ compiler */
#ifdef __cplusplus
extern "C"
{
#endif
/**
*******************************************************************************
** \defgroup Timer4SevtGroup Timer4 Special Event(Timer4SEVT)
**
******************************************************************************/
//@{
/*******************************************************************************
* Global type definitions ('typedef')
******************************************************************************/
/**
*******************************************************************************
** \brief Timer4 SEVT channel enumeration
**
******************************************************************************/
typedef enum en_timer4_sevt_ch
{
Timer4SevtCh0 = 0u, ///< Timer4 SEVT channel:0
Timer4SevtCh1 = 1u, ///< Timer4 SEVT channel:1
Timer4SevtCh2 = 2u, ///< Timer4 SEVT channel:2
Timer4SevtCh3 = 3u, ///< Timer4 SEVT channel:3
Timer4SevtCh4 = 4u, ///< Timer4 SEVT channel:4
Timer4SevtCh5 = 5u, ///< Timer4 SEVT channel:5
} en_timer4_sevt_ch_t;
/**
*******************************************************************************
** \brief Timer4 Special-EVT buffer type of SCCR and SCMR
**
******************************************************************************/
typedef enum en_timer4_sevt_buf
{
SevtBufDisable = 0u, ///< Disable Timer4 Special-EVT buffer function
SevtBufCntZero = 1u, ///< Timer4 Special-EVT transfer buffer register of SCCR and SCMR when counter value of Cnt connected= 0x0000
SevtBufCntPeak = 2u, ///< Timer4 Special-EVT transfer buffer register of SCCR and SCMR when counter value of Cnt connected= TCCP
SevtBufCntZeroOrCntPeak = 3u, ///< Timer4 Special-EVT transfer buffer register of SCCR and SCMR both when counter value of Cnt connected= 0x0000 and TCCP
SevtBufCntZeroZicZero = 4u, ///< Timer4 Special-EVT transfer buffer register of SCCR and SCMR when counter value of Cnt connected= 0x0000 and zero value detection mask counter value is 0
SevtBufCntPeakPicZero = 5u, ///< Timer4 Special-EVT transfer buffer register of SCCR and SCMR when counter value of Cnt connected= peak and peak value detection mask counter value is 0
SevtBufCntZeroZicZeroOrCntPeakPicZero = 6u, ///< Timer4 Special-EVT transfer buffer register of SCCR and SCMR when counter value of Cnt connected= 0x0000 and zero value detection mask counter value is 0
///< or counter value of CNT connected= peak and peak value detection mask counter value is 0
} en_timer4_sevt_buf_t;
/**
*******************************************************************************
** \brief Timer4 Special-EVT output trigger signal type
**
******************************************************************************/
typedef enum en_timer4_sevt_trigger_evt
{
SevtTrgEvtSCMUH = 0u, ///< Timer4 Special-EVT Event: TMR4_Ux_SCMUH
SevtTrgEvtSCMUL = 1u, ///< Timer4 Special-EVT Event: TMR4_Ux_SCMUL
SevtTrgEvtSCMVH = 2u, ///< Timer4 Special-EVT Event: TMR4_Ux_SCMVH
SevtTrgEvtSCMVL = 3u, ///< Timer4 Special-EVT Event: TMR4_Ux_SCMVL
SevtTrgEvtSCMWH = 4u, ///< Timer4 Special-EVT Event: TMR4_Ux_SCMWH
SevtTrgEvtSCMWL = 5u, ///< Timer4 Special-EVT Event: TMR4_Ux_SCMWL
} en_timer4_sevt_trigger_evt_t;
/**
*******************************************************************************
** \brief Timer4 Special-EVT OCCRx select type
**
******************************************************************************/
typedef enum en_timer4_sevt_occr_sel
{
SevtSelOCCRxh = 0u, ///< Select OCCRxh of high channel
SevtSelOCCRxl = 1u, ///< Select OCCRxl of low channel
} en_timer4_sevt_occr_sel_t;
/**
*******************************************************************************
** \brief Timer4 Special-EVT running mode
**
******************************************************************************/
typedef enum en_timer4_sevt_mode
{
SevtCompareTrigMode = 0u, ///< Select Timer4 Special-EVT compare mode
SevtDelayTrigMode = 1u, ///< Select Timer4 Special-EVT delay mode
} en_timer4_sevt_mode_t;
/**
*******************************************************************************
** \brief Timer4 SEVT mask times enumeration
**
******************************************************************************/
typedef enum en_timer4_sevt_mask
{
Timer4SevtMask0 = 0u, ///< Mask 0 time.
Timer4SevtMask1 = 1u, ///< Mask 1 times.
Timer4SevtMask2 = 2u, ///< Mask 2 times.
Timer4SevtMask3 = 3u, ///< Mask 3 times.
Timer4SevtMask4 = 4u, ///< Mask 4 times.
Timer4SevtMask5 = 5u, ///< Mask 5 times.
Timer4SevtMask6 = 6u, ///< Mask 6 times.
Timer4SevtMask7 = 7u, ///< Mask 7 times.
Timer4SevtMask8 = 8u, ///< Mask 8 times.
Timer4SevtMask9 = 9u, ///< Mask 9 times.
Timer4SevtMask10 = 10u, ///< Mask 10 times.
Timer4SevtMask11 = 11u, ///< Mask 11 times.
Timer4SevtMask12 = 12u, ///< Mask 12 times.
Timer4SevtMask13 = 13u, ///< Mask 13 times.
Timer4SevtMask14 = 14u, ///< Mask 14 times.
Timer4SevtMask15 = 15u, ///< Mask 15 times.
} en_timer4_sevt_mask_t;
/**
*******************************************************************************
** \brief Timer4 Special-EVT trigger condition
**
******************************************************************************/
typedef struct stc_timer4_sevt_trigger_cond
{
en_functional_state_t enDownMatchCmd; ///< Enable: Send trigger signal when match with SCCR&SCMR and Timer4CNT count down.
///< Disable: Don't send trigger signal when match with SCCR&SCMR and Timer4CNT count down.
en_functional_state_t enPeakMatchCmd; ///< Enable: Send trigger signal when match with SCCR&SCMR and Timer4CNT count peak.
///< Disable: Don't send trigger signal when match with SCCR&SCMR and Timer4CNT count peak.
en_functional_state_t enUpMatchCmd; ///< Enable: Send trigger signal when match with SCCR&SCMR and Timer4CNT count up.
///< Disable: Don't send trigger signal when match with SCCR&SCMR and Timer4CNT count up.
en_functional_state_t enZeroMatchCmd; ///< Enable: Send trigger signal when match with SCCR&SCMR and Timer4CNT count zero.
///< Disable: Don't send trigger signal when match with SCCR&SCMR and Timer4CNT count zero.
} stc_timer4_sevt_trigger_cond_t;
/**
*******************************************************************************
** \brief Timer4 Special-EVT initialization configuration
**
******************************************************************************/
typedef struct stc_timer4_sevt_init
{
en_timer4_sevt_buf_t enBuf; ///< Configure Timer4 Special-EVT Buffer transfer type and this parameter can be a value of @ref en_timer4_sevt_buf_t
en_timer4_sevt_mode_t enMode; ///< Configure Timer4 Special-EVT Running mode and this parameter can be a value of @ref en_timer4_sevt_mode_t
en_timer4_sevt_occr_sel_t enOccrSel; ///< Select Timer4 Special-EVT Occr channel and this parameter can be a value of @ref en_timer4_sevt_occr_sel_t
en_timer4_sevt_trigger_evt_t enTrigEvt; ///< Configure Timer4 Special-EVT Trigger type and this parameter can be a value of @ref en_timer4_sevt_trigger_evt_t
en_functional_state_t enCmpAmcZicCmd; ///< Enable: Comparison is performed with the CNT zero interrupt mask counter.
///< Disable: Comparison is not performed with the CNT zero interrupt mask counter.
en_functional_state_t enCmpAmcPicCmd; ///< Enable: Comparison is performed with the CNT peak interrupt mask counter.
///< Disable: Comparison is not performed with the CNT peak interrupt mask counter.
en_timer4_sevt_mask_t enMaskTimes; ///< Specifies start time by the value to be compared with the CNT interrupt mask counter. And this parameter can be a value of @ref en_timer4_sevt_mask_t
} stc_timer4_sevt_init_t;
/*******************************************************************************
* Global pre-processor symbols/macros ('#define')
******************************************************************************/
/*******************************************************************************
* Global variable definitions ('extern')
******************************************************************************/
/*******************************************************************************
* Global function prototypes (definition in C source)
******************************************************************************/
en_result_t TIMER4_SEVT_Init(M4_TMR4_TypeDef *TMR4x,
en_timer4_sevt_ch_t enCh,
const stc_timer4_sevt_init_t *pstcInitCfg);
en_result_t TIMER4_SEVT_DeInit(M4_TMR4_TypeDef *TMR4x,
en_timer4_sevt_ch_t enCh);
en_result_t TIMER4_SEVT_SetTriggerEvent(M4_TMR4_TypeDef *TMR4x,
en_timer4_sevt_ch_t enCh,
en_timer4_sevt_trigger_evt_t enTrgEvt);
en_result_t TIMER4_SEVT_SetTriggerCond(M4_TMR4_TypeDef *TMR4x,
en_timer4_sevt_ch_t enCh,
const stc_timer4_sevt_trigger_cond_t *pstcTrigCond);
en_result_t TIMER4_SEVT_WriteSCCR(M4_TMR4_TypeDef *TMR4x,
en_timer4_sevt_ch_t enCh,
uint16_t u16SccrVal);
uint16_t TIMER4_SEVT_ReadSCCR(M4_TMR4_TypeDef *TMR4x,
en_timer4_sevt_ch_t enCh);
//@} // Timer4SevtGroup
#ifdef __cplusplus
}
#endif
#endif /* __HC32F460_TIMER4_SEVT_H__ */
/*******************************************************************************
* EOF (not truncated)
******************************************************************************/
|