encoder.h

来自「Texas-Instrument C2000 Series DSP exampl」· C头文件 代码 · 共 56 行

H
56
字号
/*==============================================================*/
/* Name:           ENCODER.H					*/
/* Project:        ENCODER                                      */
/* Originator:     Martin Staebler				*/
/* Description:    Header File for ENCODER.C			*/	
/*==============================================================*/
#ifndef  __ENCODER_H_
#define  __ENCODER_H_

/*===============================================================*/
/* USER SETTABLE ENCODER CONSTANTS                               */
/*===============================================================*/
/*---------------------------*/
/* 1) Incremental resolution */
/*---------------------------*/
#define QEP_ROLLOVER    8192      /* incremental counts          */
asm("QEP_ROLLOVER  .set 8192 ");  /* dito, assembler support     */
/* #define QEP_POWER2 */            /* undefine if incremental     */
                                  /*   count isn't a power of 2  */

/*-------------------------------------------------*/
/* 2) 'F240 ADC's input channel selection & offset */
/*-------------------------------------------------*/
/* Pin ADCIN5  (ADC0, channel 5)  selected for U0  */
/* Pin ADCIN13 (ADC1, channel 5)  selected for U90 */
#define ENC_U0_OFFSET   (0x8000 + 0)    /* U0  (sin) offset      */
#define ENC_U90_OFFSET  (0x8000 + 300)  /* U90 (-cos) offset     */


/*==================*/
/* OTHER CONSTANTS  */
/*==================*/
#define PI              32768
#define ENABLE		1
#define DISABLE		0


/*--------------------*/
/* Global Variables   */
/*--------------------*/
extern volatile unsigned encoder_position[2];

/*----------------------*/
/* Function Declaration */
/*----------------------*/
extern void Encoder_Init(unsigned rollover);
extern void Encoder_ZeroPosition(void);
extern void Encoder_MatchIncrPhase(void);
extern int  Encoder_CalcPhase(int sin,int ncos); 
extern unsigned Encoder_SamplePosition(void);
extern void Encoder_CalcPosition(unsigned qep_incr_sample);

#endif


⌨️ 快捷键说明

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