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

📄 def.h

📁 一个变频器的代码,用msp430就能实现.低成本,可靠性也不错.
💻 H
字号:
 #include "MSP430x14x.h" 
#define BIT(x)	(1 << (x))
#define ADCMEM ((int*) 0x0140) 
 /*************************************/
 #define setCS   P4OUT=P4OUT|BIT(5);      /* 宏定义,置高CS */
#define clrCS  P4OUT=P4OUT&(~BIT(5));      /* 宏定义,置低CS */
#define setCLK   P4OUT=P4OUT|BIT(4);     /* 宏定义,置高SCL */
#define clrCLK   P4OUT=P4OUT&(~BIT(4));     /* 宏定义,置低SCL */
#define setDATA  P4OUT=P4OUT|BIT(3);     /* 宏定义,置高SDA */
#define clrDATA  P4OUT=P4OUT&(~BIT(3));      /* 宏定义, 置低SDA */
#define setREST   P4OUT=P4OUT|BIT(2);      /* 宏定义,置/RESTS */
#define clrREST  P4OUT=P4OUT&(~BIT(2));      /* 宏定义,置/RESTS */
#define setDIR   P4OUT=P4OUT|BIT(1);      /* 宏定义,置DIR S */
#define clrDIR  P4OUT=P4OUT&(~BIT(1));      /* 宏定义,置DIR S */
#define setSETTR   P4OUT=P4OUT|BIT(0);      /* 宏定义,置SETTR */
#define clrSETTR  P4OUT=P4OUT&(~BIT(0));      /* 宏定义,置SETTRS */

#define setClkBC   P1OUT=P1OUT|BIT(7);      /* 宏定义,置SETTR */
#define clrClkBC  P1OUT=P1OUT&(~BIT(7));      /* 宏定义,置SETTRS */
#define setDatBC   P1OUT=P1OUT|BIT(5);      /* 宏定义,置SETTR */
#define clrDatBC  P1OUT=P1OUT&(~BIT(5));      /* 宏定义,置SETTRS */
#define setKeyBC   P1OUT=P1OUT|BIT(6);      /* 宏定义,置SETTR */
#define clrKeyBC  P1OUT=P1OUT&(~BIT(6));      /* 宏定义,置SETTRS */

#define setOUT1   P2OUT=P2OUT|BIT(4);      
#define clrOUT1  P2OUT=P2OUT&(~BIT(4));      
#define setOUT2   P2OUT=P2OUT|BIT(5);      
#define clrOUT2  P2OUT=P2OUT&(~BIT(5)); 
#define setOUT3   P2OUT=P2OUT|BIT(6);      
#define clrOUT3  P2OUT=P2OUT&(~BIT(6)); 
#define setOUT4   P2OUT=P2OUT|BIT(7);      
#define clrOUT4  P2OUT=P2OUT&(~BIT(7)); 

#define U unsigned

///////////////////////
enum workst {STOP,PASSRUN,UPVOLT,INISA,RUN,SASTOP,DOWNVOLT,FAIL};
struct msg
{ unsigned char msgbuf[20][2];//消息缓冲队列
  unsigned char used;//已处理的消息指针
  unsigned char last;//最后的消息
};
struct STRADC
{ unsigned int Iadc,Vadc;
  unsigned int Itemp,Vtemp;
  unsigned int gonglv;
  unsigned int gongdu;
  unsigned char last;
};
struct STRSHOW
{ unsigned char page;
  unsigned char test;
  unsigned char lowstate;//已处理的消息指针
  unsigned char initimer;//最后的消息
};
struct STRSA
{ unsigned int freset;
  unsigned char lowstate;
  unsigned char initimer;
};
struct STRWORK
{ unsigned int pwmcount;
  unsigned int stoptime;
  unsigned char onkey;
  unsigned char offkey;
  unsigned char passkey;
  unsigned char failkey;
  unsigned char errsignal;
  unsigned char invert;
  enum workst workstatic;
};
////////////////////消息
#define INISAAE  5
#define REDOWN    11
#define KEPPRESS 23
#define RESHOW  57
#define MSECON  88  //
#define BCKEYP  99
#define MIDM   170
#define UPM   68
#define DEALADC 231

#define KEY1 2
#define KEY2 1
//#define KEY3 11
//#define KEY4 7

#define RUNKEY 32
#define STOPKEY 24
#define SELTKEY 16
#define UPKEY 8
#define DOWNKEY 0

#define ON 55
#define OFF 0
#define ConInV 0x0f00

⌨️ 快捷键说明

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