| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

C:/pdl_v10/library/driver/dt/dt.h
Go to the documentation of this file.

    00001 /*******************************************************************************
    00002 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
    00003 *
    00004 * This software is owned and published by:
    00005 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA  94088-3453 ("Spansion").
    00006 *
    00007 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
    00008 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
    00009 *
    00010 * This software contains source code for use with Spansion
    00011 * components. This software is licensed by Spansion to be adapted only
    00012 * for use in systems utilizing Spansion components. Spansion shall not be
    00013 * responsible for misuse or illegal use of this software for devices not
    00014 * supported herein.  Spansion is providing this software "AS IS" and will
    00015 * not be responsible for issues arising from incorrect user implementation
    00016 * of the software.
    00017 *
    00018 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
    00019 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
    00020 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
    00021 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
    00022 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
    00023 * WARRANTY OF NONINFRINGEMENT.
    00024 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
    00025 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
    00026 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
    00027 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
    00028 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
    00029 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
    00030 * SAVINGS OR PROFITS,
    00031 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    00032 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
    00033 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
    00034 * FROM, THE SOFTWARE.
    00035 *
    00036 * This software may be replicated in part or whole for the licensed use,
    00037 * with the restriction that this Disclaimer and Copyright notice must be
    00038 * included with each copy of this software, whether used in part or whole,
    00039 * at all times.
    00040 */
    00041 /******************************************************************************/
    00051 #ifndef __DT_H__
    00052 #define __DT_H__
    00053
    00054 /******************************************************************************/
    00055 /* Include files                                                              */
    00056 /******************************************************************************/
    00057 #include "mcu.h"
    00058 #include "pdl_user.h"
    00059
    00060 #if (defined(PDL_PERIPHERAL_DT_ACTIVE))
    00061
    00062 /* C binding of definitions if building with C++ compiler */
    00063 #ifdef __cplusplus
    00064 extern "C"
    00065 {
    00066 #endif
    00067
    00117
    00118 /******************************************************************************
    00119  * Global type definitions
    00120  ******************************************************************************/
    00125 typedef FM0P_DTIM_TypeDef stc_dtn_t;
    00126
    00133 typedef enum en_dt_mode
    00134 {
    00135     DtFreeRun      = 0,
    00136     DtPeriodic     = 1,
    00137     DtOneShot      = 2
    00138 } en_dt_mode_t;
    00139
    00146 typedef enum en_dt_prescaler
    00147 {
    00148     DtPrescalerDiv1     = 0,
    00149     DtPrescalerDiv16    = 1,
    00150     DtPrescalerDiv256   = 2
    00151 } en_dt_prescaler_t;
    00152
    00159 typedef enum en_dt_countersize
    00160 {
    00161     DtCounterSize16     = 0,
    00162     DtCounterSize32     = 1
    00163 } en_dt_countersize_t;
    00164
    00169 typedef enum en_dt_channel
    00170 {
    00171     DtChannel0     = 0,
    00172     DtChannel1     = 1,
    00173     DtMaxChannels  = 2
    00174 } en_dt_channel_t;
    00175
    00182 typedef struct stc_dt_channel_config
    00183 {
    00184   uint8_t u8Mode;
    00185   uint8_t u8PrescalerDiv;
    00186   uint8_t u8CounterSize;
    00187 } stc_dt_channel_config_t;
    00188
    00193 typedef void (*dt_cb_func_ptr_t)(void);
    00194
    00195 /******************************************************************************
    00196  * Global definitions
    00197  ******************************************************************************/
    00198 #define DT0     (*((volatile stc_dtn_t *) FM0P_DTIM_BASE))
    00199
    00200 /* for TimerPre of TimerXControl */
    00201 #define DT_PRE_TIMER_DIV_1      (0x00)
    00202 #define DT_PRE_TIMER_DIV_16     (0x01)
    00203 #define DT_PRE_TIMER_DIV_256    (0x02)
    00204
    00205 /******************************************************************************/
    00206 /* Local type definitions ('typedef')                                         */
    00207 /******************************************************************************/
    00208
    00210 typedef enum en_dt_instance_index
    00211 {
    00212 #if (PDL_PERIPHERAL_ENABLE_DT == PDL_ON)
    00213     DtInstanceIndexDt0 = 0u,
    00214 #endif
    00215     DtInstanceIndexMax
    00216 } en_dt_instance_index_t;
    00217
    00219 typedef struct stc_dt_intern_data
    00220 {
    00222     dt_cb_func_ptr_t  pfnIntCallbackIntern[DtMaxChannels] ;
    00223 } stc_dt_intern_data_t ;
    00224
    00226 typedef struct stc_dt_instance_data
    00227 {
    00228     volatile stc_dtn_t*  pstcInstance;
    00229     stc_dt_intern_data_t stcInternData;
    00230 } stc_dt_instance_data_t;
    00231
    00232 /******************************************************************************/
    00233 /* Global variable definitions ('extern')                                     */
    00234 /******************************************************************************/
    00235
    00236 /******************************************************************************/
    00237 /* Global function prototypes (definition in C source)                        */
    00238 /******************************************************************************/
    00239 #if (PDL_INTERRUPT_ENABLE_DT == PDL_ON)
    00240 /* External function  */
    00241 void DtIrqHandler(uint8_t u8Ch);
    00242 en_result_t Dt_EnableInt(dt_cb_func_ptr_t pfnIntCallback,
    00243                          uint8_t          u8Ch);
    00244 en_result_t Dt_DisableInt(uint8_t u8Ch);
    00245 #endif
    00246
    00247 /* Init/Deinit */
    00248 en_result_t Dt_Init(stc_dt_channel_config_t* pstcConfig,
    00249                            uint8_t                  u8Ch
    00250                           );
    00251 en_result_t Dt_DeInit(uint8_t u8Ch);
    00252
    00253 /* Function/Int Enable/Disable */
    00254 en_result_t Dt_EnableCount(uint8_t u8Ch);
    00255 en_result_t Dt_DisableCount(uint8_t u8Ch);
    00256
    00257 /* Get/Clr Status/Int flag */
    00258 boolean_t Dt_GetIntFlag(uint8_t u8Ch);
    00259 boolean_t Dt_GetMaskIntFlag(uint8_t u8Ch);
    00260 en_result_t Dt_ClrIntFlag(uint8_t u8Ch);
    00261
    00262 /* Write/Read count value */
    00263 en_result_t Dt_WriteLoadVal(uint32_t u32LoadVal,
    00264                                    uint8_t  u8Ch);
    00265 en_result_t Dt_WriteBgLoadVal(uint32_t u32BgLoadVal,
    00266                                      uint8_t  u8Ch);
    00267 uint32_t Dt_ReadCurCntVal(uint8_t u8Ch);
    00268
    00270
    00271 #ifdef __cplusplus
    00272 }
    00273 #endif
    00274
    00275 #endif /* #if (defined(PDL_PERIPHERAL_DT_ACTIVE)) */
    00276
    00277 #endif /* __DT_H__ */
    00278 /******************************************************************************/
    00279 /* EOF (not truncated)                                                        */
    00280 /******************************************************************************/