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

📄 timer.h

📁 该代码实现了 两次下载法在dspC6713平台上 烧写flash的操作过程
💻 H
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------*/
#define TOUT1_IS_TSTAT1()   SET_REG_BIT(TIMER1_CTRL, FUNC)

/*----------------------------------------------------------------------------*/
/* TOUT1_IS_DATOUT1() - TOUT1follow the value of DATOUT1 by clearing the       */
/*             CLKSRC  bit (bit 0) in the TIMER1_CTRL.                        */
/*----------------------------------------------------------------------------*/
#define TOUT1_IS_DATOUT1()   RESET_REG_BIT(TIMER1_CTRL, CLKSRC)

/*----------------------------------------------------------------------------*/
/* INVER_TSTAT1() - Inverse value of TSTAT1 by setting the INVOUT             */
/*              bit (bit 1) in the TIMER1_CTRL                                */
/*----------------------------------------------------------------------------*/
#define INVER_TSTAT1()   SET_REG_BIT(TIMER1_CTRL, INVOUT)

/*----------------------------------------------------------------------------*/
/* NOT_INVER_TSTAT1() - Not Inverse value of TSTAT1 by clearing the INVOUT    */
/*              bit (bit 1) in the TIMER1_CTRL                                */
/*----------------------------------------------------------------------------*/
#define NOT_INVER_TSTAT1()   RESET_REG_BIT(TIMER1_CTRL, INVOUT)

/*----------------------------------------------------------------------------*/
/* WRITE_DATOUT1() - Write value of DATOUT1 bit (bit 2) in the TIMER1_CTRL    */
/*----------------------------------------------------------------------------*/
#define WRITE_DATOUT1(val)    ASSIGN_BIT_VAL(TIMER1_CTRL,DATOUT,val)

/*----------------------------------------------------------------------------*/
/* READ_DATIN1() - Read  value of DATIN1 bit (bit 3) in the TIMER1_CTRL       */
/*----------------------------------------------------------------------------*/
#define READ_DATIN1()    GET_BIT(TIMER1_CTRL,DATIN)

/*----------------------------------------------------------------------------*/
/*  PULSE_WIDTH_ONE1() - Pulse Width is one clock by  setting the PWID        */
/*           bit (bit 4) in the TIMER1_CTRL                                   */                            
/*----------------------------------------------------------------------------*/
#define PULSE_WIDTH_ONE1()   SET_REG_BIT(TIMER1_CTRL, PWID)

/*----------------------------------------------------------------------------*/
/*  PULSE_WIDTH_TWO1() - Pulse Width is one clock by  clearing the PWID       */     
/*           bit (bit 4) in the TIMER1_CTRL                                   */                            
/*----------------------------------------------------------------------------*/
#define PULSE_WIDTH_TWO1()   RESET_REG_BIT(TIMER1_CTRL, PWID)

/*----------------------------------------------------------------------------*/
/*  TSTAT1_IS_CLOCK1() - Out of TSTAT1 is clock,by setting the C/P             */
/*        bit bit(8) in the TIMER1_CTRL                                       */
/*----------------------------------------------------------------------------*/
#define TSTAT1_IS_CLOCK1()  SET_REG_BIT(TIMER1_CTRL, CP) 

/*----------------------------------------------------------------------------*/
/*  TSTAT1_IS_PULSE1() - Out of TSTAT1 is pluse,by clearing the C/P           */
/*        bit bit(8) in the TIMER1_CTRL                                       */
/*----------------------------------------------------------------------------*/
#define TSTAT1_IS_PULSE1()  RESET_REG_BIT(TIMER1_CTRL, CP)

/*----------------------------------------------------------------------------*/
/* TIMER_INT_CLOCK1() - TIMER use internal clock source by setting the CLKSRC */
/*              bit (bit 9) in the TIMER1_CTRL                                */
/*----------------------------------------------------------------------------*/
#define TIMER_INT_CLOCK1()   SET_REG_BIT(TIMER1_CTRL, CLKSRC)

/*----------------------------------------------------------------------------*/
/* TIMER_EXT_CLOCK1() - TIMER use external clock source by clearing the       */
/*            CLKSRC  bit (bit 9) in the TIMER1_CTRL.                         */
/*----------------------------------------------------------------------------*/
#define TIMER_EXT_CLOCK1()   RESET_REG_BIT(TIMER1_CTRL, CLKSRC)

/*----------------------------------------------------------------------------*/
/*  RIS_EDGE_TRIG1() - Rising edge of DATIN trigger counting,by setting       */
/*            INVINP bit bit(10) in the TIMER1_CTRL                           */
/*----------------------------------------------------------------------------*/
#define RIS_EDGE_TRIG1()  SET_REG_BIT(TIMER1_CTRL, INVINP)

/*----------------------------------------------------------------------------*/
/*  FAL_EDGE_TRIG1() - Falling edge of DATIN trigger counting,by clearing     */
/*           INVINP bit bit(10) in the TIMER1_CTRL                            */
/*----------------------------------------------------------------------------*/
#define FAL_EDGE_TRIG1()  RESET_REG_BIT(TIMER1_CTRL, INVINP)

/*----------------------------------------------------------------------------*/
/* READ_TSTAT1() - Read  value of TSTAT bit (bit 11) in the TIMER1_CTRL       */
/*----------------------------------------------------------------------------*/
#define READ_TSTAT1()    GET_BIT(TIMER1_CTRL,TSTAT)

/*----------------------------------------------------------------------------*/
/*               FUNCTIONS:                                                   */
/*----------------------------------------------------------------------------*/

void timer0_reset(void);
void timer1_init();

void timer0_reset(void);
void timer1_init();

static inline int  read_timer_register( );
static inline void set_timer_register( );
static inline void change_timer_status( );

/*  set_timer_regster() - Set timer register, by writing it  directly         */
static inline void set_timer_register(int timer_select,int reg_sel,int value)
{
  int addr;
  
  if(timer_select==0)
    addr=0x1940000+4*reg_sel;
  else if(timer_select==1)
         addr=0x1980000+4*reg_sel; 
       else
        printf( "Timer Select Error!");
      
  REG_WRITE(addr,value);
} 

/*  read_timer_register() - Read current register value, by reading it directly */
static inline int read_timer_register(int timer_sel,int reg_sel)
{
  int addr;
  
  if(timer_sel==0)
    addr=0x1940000+4*reg_sel;
  else if(timer_sel==1)
         addr=0x1980000+4*reg_sel; 
       else
        printf( "Timer Select Error!");

  return(REG_READ(addr));
} 

/*  change_timer_status() - Change the selected timer's working status         */
static inline void change_timer_status(int timer_sel,int status_sel)
{
  int addr;
  if(timer_sel==0)
     addr=TIMER0_CTRL;  
  else if(timer_sel==1)
         addr=TIMER1_CTRL; 
       else
         printf( "Timer Select Error!");
   
  if(status_sel==TIMER_HOLD)
     LOAD_FIELD(addr,TIMER_HOLD,GO,2);  
  else if(status_sel==TIMER_RESUME)
         LOAD_FIELD(addr,TIMER_RESUME,GO,2); 
       else if(status_sel==TIMER_START)
             LOAD_FIELD(addr,TIMER_START,GO,2);
            else 
             printf( "Timer Select Error!");
} 

#endif /* _TIMER_H_ */

⌨️ 快捷键说明

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