⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timerdrv.h

📁 56f8300E系列dsp的BOOTloader
💻 H
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element: /project/dsp568_sdk/sdk/src/dsp56838evm/nos/bsp/timerdrv.h $ 
* $Author: saa $ 
* $Revision: /main/2 $ 
* $VOB: /project/dsp568_sdk $ 
* $OS: solaris $ 
*
* Description:       header file for the 56838 posix timer driver 
*
* Notes:  
*
******************************************************************************/

#ifndef __TIMERDRV_H
#define __TIMERDRV_H

#include "arch.h"
#include "port.h"
#include "periph.h"
#include "time.h"
#include "timer.h"

#ifdef __cplusplus
extern "C" {
#endif

/*** control bits ***/
#define QTB_COUNTMODE( mode )        ((mode + 0) << 13)
#define QTB_PRIMARYSOURCE( src )     ((src) << 9 )
#define QTB_SECONDARYSOURCE( src )   ((src) << 7 )
#define QTB_OUTPUTMODE( src )        ((src) & 0x0007)
           

#define QTB_ONCE        0x0040
#define QTB_LENGTH      0x0020
#define QTB_DIR         0x0010
#define QTB_EXTINIT     0x0008


/* status bits */

#define QTB_OEN         0x0001     /* Output Enable 						*/
#define QTB_OPS         0x0002     /* Output Polarity Select  				*/
#define QTB_FORCE       0x0004     /* Force the OFLAG output 				*/
#define QTB_VAL         0x0008     /* Forced OFLAG Value 					*/
#define QTB_EEOF        0x0010     /* Enable External OFLAG Force 			*/
#define QTB_MSTR        0x0020     /* Master Mode 							*/
#define QTB_INPUT       0x0100     /* External Input Signal 				*/
#define QTB_IPS         0x0200     /* Input Polarity Select 				*/
#define QTB_IEFIE       0x0400     /* Input Edge Flag Interrupt Enable 		*/
#define QTB_IEF         0x0800     /* Input Edge Flag 						*/
#define QTB_IEF_IEFIE	QTB_IEFIE | QTB_IEF /* Input Edge Flag + Interrupt Enable */
#define QTB_TOFIE       0x1000     /* Timer Overflow Flag Interrupt Enable 	*/
#define QTB_TOF         0x2000     /* Timer Overflow Flag 					*/
#define QTB_TOF_TOFIE	QTB_TOFIE | QTB_TOF /* Timer Overflow Flag  + Interrupt Enable */
#define QTB_TCFIE       0x4000     /* Timer Compare Flag Interrupt Enable 	*/
#define QTB_TCF         0x8000     /* Timer Compare Flag 					*/
#define QTB_TCF_TCFIE 	QTB_TCFIE | QTB_TCF /* Timer Compare Flag + Interrupt Enable */

#define QTB_CM_LOW      0x0040     /* Capture mode, low bit 				*/
#define QTB_CM_HIGH     0x0080     /* Capture mode, low bit 				*/


/*** POSIX timer device context ***/
typedef struct 
{
    unsigned short     SoftCounter;
    unsigned short     reloadSoftCounter;
    void        (*pUserFunc)(union sigval);
   // arch_sTimerChannel*     bspDevice; // !!! attention for memeory models: timer specific field
} posix_tContext;

enum
{
  SoftCounter_offset = (int)(&((posix_tContext*)0)->SoftCounter),
  reloadSoftCounter_offset = (int)(&((posix_tContext*)0)->reloadSoftCounter),
  pUserFunc_offset = (int)(&((posix_tContext*)0)->pUserFunc)
};


/*** quadrature timer configuration table ***/
typedef struct 
{
    arch_sTimerChannel *  base;
    posix_tContext*       ctx;
}posix_tConfig;


/*	definitions of Timer Channel Status and Control Register, Timer Control Register	*/
#if 0
typedef union
{
    struct {
    /*	Status reg	*/
    unsigned int    OutputEnable            :1;
    unsigned int    OutputPolarity          :1;
    unsigned int    Force                   :1;
    unsigned int    Val                     :1;
    unsigned int    OutputOnMaster          :1;
    unsigned int    Master                  :1;
    unsigned int    CaptureMode             :2;
    unsigned int                            :1;
    unsigned int    InputPolarity           :1;
    unsigned int	EdgeFlagInterrupt		:1;
    unsigned int							:1;	/* Edge flag 		*/
    unsigned int	OverflowFlagInterrupt	:1;
    unsigned int							:1;	/* Overflow flag 	*/
    unsigned int	CompareFlagInterrupt	:1;
    unsigned int							:1;	/* Compare flag 	*/

    /*	Control Reg	*/
    unsigned int    OutputMode              :3;
    unsigned int    CoChannelInitialize     :1;	/* enables another counter to force the reinit of tic timer */
    unsigned int    CountDirection          :1;
    unsigned int    CountLength             :1;
    unsigned int    CountOnce	          	:1;
    unsigned int    SecondaryInputSource    :2; /* define the source for Capture mode and Input Edge Flag	*/
    unsigned int    InputSource             :4;
    unsigned int    Mode                    :3;
    }bits;
/*** access to fast structure parameters ***/
    struct
    {
        unsigned short  StatusControlReg;
        unsigned short  ControlReg;
    }pair;

}qt_sFastState;
#endif //0

/*	64-th bits value	*/
typedef struct
{
	unsigned long w[2];

} U64;

/*****************************************************************************
* Constants set in config.h to tailor Posix timer resolution
******************************************************************************/

extern const unsigned long IP_BUS_FREQUENCY;
extern const unsigned long IP_BUS_FREQUENCY_1;
extern const unsigned long IP_BUS_FREQUENCY_2;

extern const unsigned long REAL_TIME_TIMER_RESOLUTION;
extern const unsigned short REAL_TIME_TIMER_STEP;
extern const unsigned short REAL_TIME_TIMER_PRESCALER;



/*****************************************************************************
* Prototypes - See documentation for functional descriptions
******************************************************************************/

EXPORT Result  timerCreate          (/*	const char * pName	*/);
EXPORT int     clock_get_system_time( struct timespec * tp);

/* declared in config.c for OS interfaces */
EXPORT void    timerSleep (long Ticks);
EXPORT void    timerTick  (void);

/* ISRs declare */

EXPORT void POSIXtimerISRA0(void);
EXPORT void POSIXtimerISRA1(void);
EXPORT void POSIXtimerISRA2(void);
EXPORT void POSIXtimerISRA3(void);
EXPORT void POSIXtimerISRB0(void);
EXPORT void POSIXtimerISRB1(void);
EXPORT void POSIXtimerISRB2(void);
EXPORT void POSIXtimerISRB3(void);
EXPORT void POSIXtimerISRC0(void);
EXPORT void POSIXtimerISRC1(void);
EXPORT void POSIXtimerISRC2(void);
EXPORT void POSIXtimerISRC3(void);
EXPORT void POSIXtimerISRD0(void);
EXPORT void POSIXtimerISRD1(void);
EXPORT void POSIXtimerISRD2(void);
EXPORT void POSIXtimerISRD3(void);

void  TimerCallback( posix_tContext* pDevice );


#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -