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

📄 timer.h

📁 56f8300E系列dsp的BOOTloader
💻 H
📖 第 1 页 / 共 2 页
字号:



inline void timer_CallbackOnCompare_On( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfset 0x4000, x:(arch_quad + BSP_PERIPH_OFF + 7) );
}

inline void timer_qtCallbackOnCompare_Off( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfclr 0x4000, x:(arch_quad + BSP_PERIPH_OFF + 7) );
}

inline void timer_CallbackOnOverflow_On( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfset 0x1000, x:(arch_quad + BSP_PERIPH_OFF + 7) );
}

inline void timer_qtCallbackOnOverflow_Off( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfclr 0x1000, x:(arch_quad + BSP_PERIPH_OFF + 7) );
}

inline void timer_CallbackOnInputEdge_On( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfset 0x0400, x:(arch_quad + BSP_PERIPH_OFF + 7) );
}

inline void timer_qtCallbackOnInputEdge_Off( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfclr 0x0400, x:(arch_quad + BSP_PERIPH_OFF + 7) );
}
/***********************************************************
*														   * 	
*					MEAUSURE BLOCK						   *
*														   *
***********************************************************/
typedef  unsigned long measure_t;

/*Initialization*/
EXPORT  UWord32 timer_Init_Measure(volatile arch_sTimerChannel * ,volatile arch_sTimerChannel * );
    
EXPORT  void   timer_Uninit_Measure(void);

/*Control measure process*/ 
EXPORT  void   timer_begin_measure(measure_t* pTime);

EXPORT  void   timer_resume(measure_t* pTime);    
    
EXPORT  void   timer_end_measure(measure_t* pTime);

/* Output measure process */
EXPORT UWord32 timer_measure_ticks_to_us(measure_t* pTime);

/*****************************************************************************/
/*****************************************************************************/
/*                  P O S I X   T I M E R   P A R T                          */
/*****************************************************************************/
/*****************************************************************************/

extern const arch_sTimerChannel * realTimer;
//#define CLOCK_REALTIME ((UWord16)&ArchIO.TimerD.Channel0)
#define CLOCK_REALTIME (UWord16)realTimer

#define CLOCK_AUX0     ((UWord16)&ArchIO.TimerA.Channel0)
#define CLOCK_AUX1     ((UWord16)&ArchIO.TimerA.Channel1)
#define CLOCK_AUX2     ((UWord16)&ArchIO.TimerA.Channel2)
#define CLOCK_AUX3     ((UWord16)&ArchIO.TimerA.Channel3)

#define CLOCK_AUX4     ((UWord16)&ArchIO.TimerC.Channel0)
#define CLOCK_AUX5     ((UWord16)&ArchIO.TimerC.Channel1)
#define CLOCK_AUX6     ((UWord16)&ArchIO.TimerC.Channel2)
#define CLOCK_AUX7     ((UWord16)&ArchIO.TimerC.Channel3)

#define CLOCK_AUX8     ((UWord16)&ArchIO.TimerD.Channel0)
#define CLOCK_AUX9     ((UWord16)&ArchIO.TimerD.Channel1)
#define CLOCK_AUX10    ((UWord16)&ArchIO.TimerD.Channel2)
#define CLOCK_AUX11    ((UWord16)&ArchIO.TimerD.Channel3)


/**************************************************************************
*  TIMESPEC 
*  Implementation Status:
*     IMPLEMENTED - Because it is required by POSIX and is used for the 
*                   nanosleep function. 
*  Semantics:
*     The contents of the timespec structure are specified by the POSIX standard
*     and are therefore public.
**************************************************************************/
struct timespec
{
	time_t tv_sec;       /* seconds */
	long   tv_nsec;      /* nanoseconds (0 - 999,999,999) */
};

/*************************************************************************
* timespecAdd
* Semantics:
*    Augments the POSIX time interface to add two timespecs;
*    timeres = time1 + time2
**************************************************************************/
EXPORT void timespecAdd (   struct timespec * pTimeres, 
							struct timespec * pTime1, 
							struct timespec * pTime2);


/*************************************************************************
* timespecSub
* Semantics:
*    Augments the POSIX time interface to subtract two timespecs;
*    timeres = time1 - time2
**************************************************************************/

EXPORT void timespecSub (   struct timespec * pTimeres, 
							struct timespec * pTime1, 
							struct timespec * pTime2);

/*************************************************************************
* timespecGE
* Semantics:
*    Augments the POSIX time interface to subtract two timespecs;
*    returns time1 >= time2
**************************************************************************/
EXPORT bool timespecGE (	struct timespec * pTime1, 
							struct timespec * pTime2);

/**************************************************************************
*  ITIMERSPEC 
*  Implementation Status:
*     IMPLEMENTED - Because it is required by POSIX
*  Semantics:
*     The contents of the timespec structure are specified by the POSIX standard
*     and are therefore public.
**************************************************************************/
struct itimerspec
{
	struct timespec it_interval;     /* timer period (reload value) */
	struct timespec it_value;        /* timer expiration */
};

/**************************************************************************
*  LOCALTIME
*
* See Metrowerks 56800E library.
*
* extern struct tm * localtime(const time_t *);
**************************************************************************/

/**************************************************************************
*  MKTIME
*
* See Metrowerks 56800E library.
*
* extern time_t mktime(struct tm *timeptr);
**************************************************************************/

/**************************************************************************
*  TIMER_CREATE
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int timer_create(const clockid_t cid,const struct sigevent * evp, timer_t * tid);

/**************************************************************************
*  LOCALTIME
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int clock_settime(clockid_t cid, const struct timespec * tp);

/**************************************************************************
*  TIMER_DELETE
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int timer_delete(timer_t tid);

/**************************************************************************
*  TIMER_SETTIME
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int timer_settime(timer_t tid, int flags, 
						const struct itimerspec * value, struct itimerspec * ovalue);

/**************************************************************************
*  CLOCK_GETTIME
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int clock_gettime(clockid_t cid, struct timespec * tp);

/**************************************************************************
*  CLOCK_GETRES
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int clock_getres(clockid_t cid, struct timespec * res);

/**************************************************************************
*  CLOCK_GET_SYSTEM_TIME
*
*  Implementation Status:
*     IMPLEMENTED 
*
*  Semantics:
*
*  Return Value:
*
**************************************************************************/
EXPORT int     clock_get_system_time( struct timespec * tp);
/**************************************************************************
*  NANOSLEEP
*
*  Implementation Status:
*     IMPLEMENTED 
*        The rmtp parameter to nanosleep must be NULL because nanosleep
*        always suspends the thread for at least the amount of time
*        specified in rqtp and so would return 0.
*
*  Semantics:
*     The nanosleep() function shall cause the current thread to be suspended
*     from execution until either the time interval specified by the rqtp
*     argument has elapsed, a signal is delivered to the calling thread and
*     the action of the signal is to invoke a signal-catching function, or
*     the process is terminated.  
*
*     The suspension time may be longer than requested because the argument
*     value is rounded up to an integer multiple of the sleep resolution or
*     because of the scheduling of other activity by the system.  But, except
*     for the case of being interrupted by a signal, the suspension time shall
*     not be less than the time specified by rqtp, as measured by the system
*     clock, CLOCK_REALTIME.
*
*     The use of nanosleep() function shall have no effect on the action or
*     blockage of any signal.
*
*  Return Value:
*     If the nanosleep() function returns because the requested time has
*     elapsed, its return value shall be zero.
*
*     If the nanosleep() function returns because it has been interrupted by
*     a signal, the function shall return a value of -1 and set errno to
*     indicate the interruption.  If the rmtp argument is non-NULL, the
*     timespec structure referenced by it shall be updated to contain the 
*     amount of time remaining in the interval (the requested time minus the
*     time actually slept).  If the rmtp argument is NULL, the remaining
*     time is not returned.
*
*     If nanosleep() fails, it shall return a value of -1 and set errno to
*     indicate the error.
*
**************************************************************************/
EXPORT int nanosleep(const struct timespec * rqtp, struct timespec * rmtp);


#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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