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

📄 timer.h

📁 56f8300E系列dsp的BOOTloader
💻 H
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element: /project/dsp568_sdk/sdk/src/dsp56838evm/nos/include/timer.h $ 
* $Author: saa $ 
* $Revision: /main/2 $ 
* $VOB: /project/dsp568_sdk $ 
* $OS: solaris $ 
*
* Description:  standard SDK timer header
*
* Notes:    
*
******************************************************************************/

#ifndef __TIME_H
#define __TIME_H

#include "port.h"
#include "bsp.h"
#include "arch.h"
#include <ctime> 



#ifdef __cplusplus
extern "C" {
#endif

/*****************************************************************************/
/*****************************************************************************/
/*                    R A W   T I M E R   P A R T                            */
/*****************************************************************************/
/*****************************************************************************/


typedef enum
{
    qtCount = 1,
    qtCountBothEdges,
    qtGatedCount,
    qtQuadratureCount,
    qtSignedCount,
    qtTriggeredCount,
    qtCascadeCount
} qt_eMode;

typedef enum
{
    qtCounter0Input,
    qtCounter1Input,
    qtCounter2Input,
    qtCounter3Input,
    qtCounter0Output,
    qtCounter1Output,
    qtCounter2Output,
    qtCounter3Output,
    qtPrescalerDiv1,
    qtPrescalerDiv2,
    qtPrescalerDiv4,
    qtPrescalerDiv8,
    qtPrescalerDiv16,
    qtPrescalerDiv32,
    qtPrescalerDiv64,
    qtPrescalerDiv128
} qt_eInputSource;
 
typedef enum
{
    qtSISCounter0Input,
    qtSISCounter1Input,
    qtSISCounter2Input,
    qtSISCounter3Input
} qt_eSecondaryInputSource;

typedef enum
{
    qtNormal,
    qtInverted
}qt_ePolarity;

typedef enum
{
    qtRepeatedly,
    qtOnce
} qt_eCountFrequency;

typedef enum
{
    qtPastCompare,
    qtUntilCompare
} qt_eCountLength;

typedef enum
{
    qtUp,
    qtDown
} qt_eCountDirection;

typedef enum
{
    qtAssertWhileActive,
    qtAssertOnCompare,
    qtDeassertOnCompare,
    qtToggleOnCompare,
    qtToggleUsingAlternateCompare,
    qtDeassertOnSecondary,
    qtDeassertOnCounterRollover,
    qtAssertOnGatedClock
} qt_eOutputMode;

typedef enum
{
    qtCompare,
    qtOverflow,
    qtInputEdge
} qt_eCallbackType;

typedef enum
{
    qtDisabled,
    qtRisingEdge,
    qtFallingEdge,
    qtBothEdges
} qt_eCaptureMode;


/* definitions of  Status and Control Registers */
union qtQuadState
{
    struct {
    unsigned int    OutputMode              :3;
    unsigned int    CoChannelInitialize     :1;
    unsigned int    CountDirection          :1;
    unsigned int    CountLength             :1;
    unsigned int    CountFrequency          :1;
    unsigned int    SecondaryInputSource    :2; 
    unsigned int    InputSource             :4;
    unsigned int    Mode                    :3;
    unsigned int    OutputEnable            :1;
    unsigned int    OutputPolarity          :1;
    unsigned int                            :1;
    unsigned int                            :1;
    unsigned int    OutputOnMaster          :1;
    unsigned int    Master                  :1;                                                  
    unsigned int    CaptureMode             :2;
    unsigned int                            :1;
    unsigned int    InputPolarity           :1;
    unsigned int                            :6;
    }bits;
/*** access to fast structure parameters ***/
    struct
    {
        UWord16  ControlReg;
        UWord16  StatusControlReg;
    }pair;
    unsigned long value;
};
typedef union qtQuadState qt_sQuadState;


inline void timer_qt_start( register volatile arch_sTimerChannel * arch_quad,
                            register unsigned long state )
{
    register unsigned long value;
    register unsigned long mask;

	asm( move.l x:(arch_quad + BSP_PERIPH_OFF + 6), value ); 
    asm( move.l #0x54000000, mask );    /*  do not disable callbacks */
    asm( and.l  mask, value );
    asm( or.l  value, state );
	asm( move.l  state, x:(arch_quad + BSP_PERIPH_OFF + 6) ); 
}


inline void timer_qt_disable( register volatile arch_sTimerChannel * arch_quad )
{   
    asm( bfclr 0xE000, x:(arch_quad + BSP_PERIPH_OFF + 6) ); /* Mode = 0 on ControlReg */
    asm( bfclr 0xA800, x:(arch_quad + BSP_PERIPH_OFF + 7) ); /* all ISR flags on StatusControlReg */
}

inline void timer_qt_enable_output( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfset 0x0001, x:(arch_quad + BSP_PERIPH_OFF + 7) ); /* Output Enable on StatusControlReg */
}

inline void timer_qt_disable_output( register volatile arch_sTimerChannel * arch_quad )
{
    asm( bfclr 0x0001, x:(arch_quad + BSP_PERIPH_OFF + 7) ); /* Output Enable on StatusControlReg */
}

inline void timer_qt_force_output( register volatile arch_sTimerChannel * arch_quad,
                                   register int output )
{
    if( output ){ asm( bfset 0x0008, x:(arch_quad + BSP_PERIPH_OFF + 7) ); } /* Forced OFLAG Value on StatusControlReg */
    else  {       asm( bfclr 0x0008, x:(arch_quad + BSP_PERIPH_OFF + 7) ); } /* Forced OFLAG Value on StatusControlReg */
    asm( bfset 0x0004, x:(arch_quad + BSP_PERIPH_OFF + 7) ); /* Force the OFLAG output on StatusControlReg */
}

inline UWord16 timer_qt_readCompareReg1(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 0), value );
	return value;
}

inline void timer_qt_writeCompareReg1(register volatile arch_sTimerChannel * arch_quad, 
                                     register UWord16 value )
{
	asm( move.w  value, X:(arch_quad + BSP_PERIPH_OFF + 0) );
}


inline UWord16 timer_qt_readCompareReg2(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 1), value );
	return value;
}

inline void timer_qt_writeCompareReg2(register volatile arch_sTimerChannel * arch_quad, 
                                     register UWord16 value )
{
	asm( move.w  value, X:(arch_quad + BSP_PERIPH_OFF + 1) );
}


inline UWord16 timer_qt_readCaptureReg(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 2), value );
	return value;
}

inline void timer_qt_writeCaptureReg(register volatile arch_sTimerChannel * arch_quad, 
                                     register UWord16 value )
{
	asm( move.w  value, X:(arch_quad + BSP_PERIPH_OFF + 2) );
}


inline UWord16 timer_qt_readLoadReg(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 3), value );
	return value;
}

inline void timer_qt_writeLoadReg(register volatile arch_sTimerChannel * arch_quad, 
                                     register UWord16 value )
{
	asm( move.w  value, X:(arch_quad + BSP_PERIPH_OFF + 3) );
}



inline UWord16 timer_qt_readHoldReg(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 4), value );
	return value;
}

inline void timer_qt_writeHoldReg(register volatile arch_sTimerChannel * arch_quad, 
                                     register UWord16 value )
{
	asm( move.w  value, X:(arch_quad + BSP_PERIPH_OFF + 4) );
}

inline UWord16 timer_qt_readCounterReg(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 5), value );
	return value;
}

inline void timer_qt_writeCounterReg(register volatile arch_sTimerChannel * arch_quad, 
                                     register UWord16 value )
{
	asm( move.w  value, X:(arch_quad + BSP_PERIPH_OFF + 5) );
}

inline UWord16 timer_qt_readControlReg(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 6), value );
	return value;
}

inline UWord16 timer_qt_readStatusControlReg(register volatile arch_sTimerChannel * arch_quad)
{
	register UWord16 value;
	asm( move.w  X:(arch_quad + BSP_PERIPH_OFF + 7), value );
	return value;
}

⌨️ 快捷键说明

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