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

📄 motor.h

📁 Motor & key & LED
💻 H
字号:
#ifndef STP_MOTOR
#define STP_MOTOR

///////////////////////////////////////////////////
//
// Step Motor head file
//
///////////////////////////////////////////////////

//Environment info
typedef unsigned char Uint8;
typedef unsigned short Uint16;
typedef int Sint;
typedef unsigned int Uint;
typedef char Boolean;

#if !defined(TRUE)
#define TRUE (1)
#endif

#if !defined(FALSE)
#define FALSE (0)
#endif

#ifndef DEBUG
#define DEBUG 1
#endif

#define MOTOR_NEVER_STOP 0x01

#define  regINT       IE  /* Interrupt control */
#define  regPIO       P2    /* Motor IO output register */
#define  regTIMCTRL   TCON  /* Timer CTRL register */
#define  MSB_regTimer TH0   /* MSB of motor timer */
#define  LSB_regTimer TL0   /* LCD of motor timer */
#define  regKEY       P1    /* KEY IO register */
//#define  KEY_MASK     0xFF  /* 4 x 4 Maxtrix */ 
#define  startINT     do{ ET1 = 1; }while(0) 
#define  endINT       do{ ET1 = 0; }while(0)
#define  startTim     do{ TR1 = 1; }while(0) 
#define  endTim       do{ \
	                        TF1 = 0; \
	                        TR1 = 0; \
	                      }while(0)

#define SCAN_MSB       0x0F
#define SCAN_LSB       0xF0 

#define ENABLE_INTS       do{   regINT = regINT | 0xFF;     }while(0)
#define DISABLE_INTS      do{   regINT = regINT & (~0xFF);  }while(0)
#define RESTART_TIMER       do{   regTIMCTRL = regTIMCTRL | 0x10;    }while(0)
#define DISABLE_TIMER       do{   regTIMCTRL = regTIMCTRL & (~0x10);  }while(0)

//#define IO_READ8(p)      (Uint8) //(Uint8)(*(volatile Uint8 *)(p))
//#define IO_WRITE8(p,c)   (*((volatile Uint8 *)(p)) = ((Uint8)(c)))

#define CURRENT_SPEED_MENU    0x01
#define REMAIN_STEPS_MENU    0x02

// paper move info
typedef enum
{
   STP_MOV_FWD = 0,
   STP_MOV_REV 
} STP_MOV_DIR;

//
typedef enum
{
	MICRO_MODE = 1,
	HALF_MODE = 2,
	FULL_MODE = 4
} STP_RUN_MODE;

typedef enum
{
   STP_MOV_ONLY	= 0,
   STP_MOV_WHILE_S 
} STP_MOV_TYPE;

typedef enum
{
   STP_INIT = 0,
   STP_START,
   STP_ACCEL,
   STP_RUNNING,
   STP_DECEL,
   STP_STOPPED,
   STP_ERROR
} STP_MOV_STATUS;

typedef struct
{
   STP_MOV_DIR		 dir;
   STP_MOV_TYPE	   moveType;
   STP_RUN_MODE    stepMode;
   //Uint8		 dir;
   //Uint8	   moveType;
   //Uint8     stepMode;
   Uint16	         steps;
   Uint16		       vInit;
   Uint16		       vFinal;
   //Uint16		       smoothStep;
   //Uint16		       postFeed;
} STP_MOV_INFO;

typedef struct STPControlStruct
{
	 Uint8             flag;
	 Uint8             phaseIndex;
	 Uint8             accelIndex;
	 Uint8             accelSteps;
	 Uint16            curSpeed;
	 STP_MOV_INFO      curStatus;
	 STP_MOV_STATUS    state;
} STP_CONTROLLER;

typedef struct
{
         Uint8   newButton;
         Uint8   preButton;
         Uint8   dbcButton;   // debounce button
         Uint8   curMenu;      
         Uint16  ledValue;   
} UI_CONTROLLER;



#endif

⌨️ 快捷键说明

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