PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
dt.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
51 #ifndef __DT_H__
52 #define __DT_H__
53 
54 /******************************************************************************/
55 /* Include files */
56 /******************************************************************************/
57 #include "pdl.h"
58 
59 #if (defined(PDL_PERIPHERAL_DT_ACTIVE))
60 
61 /* C binding of definitions if building with C++ compiler */
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif
66 
118 
119 /******************************************************************************
120  * Global type definitions
121  ******************************************************************************/
126 typedef FM4_DTIM_TypeDef stc_dtn_t;
127 
134 typedef enum en_dt_mode
135 {
136  DtFreeRun = 0,
139 } en_dt_mode_t;
140 
147 typedef enum en_dt_prescaler
148 {
153 
160 typedef enum en_dt_countersize
161 {
165 
170 typedef enum en_dt_channel
171 {
176 
183 typedef struct stc_dt_channel_config
184 {
185  uint8_t u8Mode;
186  uint8_t u8PrescalerDiv;
187  uint8_t u8CounterSize;
189 
194 typedef void (*dt_cb_func_ptr_t)(void);
195 
196 /******************************************************************************
197  * Global definitions
198  ******************************************************************************/
199 #define DT0 (*((volatile stc_dtn_t *) FM4_DTIM_BASE))
200 
201 /* for TimerPre of TimerXControl */
202 #define DT_PRE_TIMER_DIV_1 (0x00)
203 #define DT_PRE_TIMER_DIV_16 (0x01)
204 #define DT_PRE_TIMER_DIV_256 (0x02)
205 
206 /******************************************************************************/
207 /* Local type definitions ('typedef') */
208 /******************************************************************************/
209 
212 {
213 #if (PDL_PERIPHERAL_ENABLE_DT0 == PDL_ON)
215 #endif
218 
220 typedef struct stc_dt_intern_data
221 {
225 
227 typedef struct stc_dt_instance_data
228 {
229  volatile stc_dtn_t* pstcInstance;
232 
233 /******************************************************************************/
234 /* Global variable definitions ('extern') */
235 /******************************************************************************/
236 
237 /******************************************************************************/
238 /* Global function prototypes (definition in C source) */
239 /******************************************************************************/
240 /* External function */
241 extern void DtIrqHandler(uint8_t u8Ch);
242 
243 /* Init/Deinit */
244 extern en_result_t Dt_Init(stc_dt_channel_config_t* pstcConfig,
245  uint8_t u8Ch
246  );
247 extern en_result_t Dt_DeInit(uint8_t u8Ch);
248 
249 /* Function/Int Enable/Disable */
250 extern en_result_t Dt_EnableCount(uint8_t u8Ch);
251 extern en_result_t Dt_DisableCount(uint8_t u8Ch);
252 
253 extern en_result_t Dt_EnableInt(dt_cb_func_ptr_t pfnIntCallback,
254  uint8_t u8Ch
255  );
256 extern en_result_t Dt_DisableInt(uint8_t u8Ch);
257 
258 /* Get/Clr Status/Int flag */
259 extern boolean_t Dt_GetIntFlag(uint8_t u8Ch);
260 extern boolean_t Dt_GetMaskIntFlag(uint8_t u8Ch);
261 extern en_result_t Dt_ClrIntFlag(uint8_t u8Ch);
262 
263 /* Write/Read count value */
264 extern en_result_t Dt_WriteLoadVal(uint32_t u32LoadVal,
265  uint8_t u8Ch
266  );
267 extern en_result_t Dt_WriteBgLoadVal(uint32_t u32BgLoadVal,
268  uint8_t u8Ch
269  );
270 
271 extern uint32_t Dt_ReadCurCntVal(uint8_t u8Ch);
272 
274 
275 #ifdef __cplusplus
276 }
277 #endif
278 
279 #endif /* #if (defined(PDL_PERIPHERAL_DT_ACTIVE)) */
280 
281 #endif /* __DT_H__ */
282 /******************************************************************************/
283 /* EOF (not truncated) */
284 /******************************************************************************/