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

📄 appdefine.h

📁 单片机P89V51RD2在操纵系统RTX下的各个功能
💻 H
字号:
/******************************************************************************/
/*                                                                            */
/*   TRAFFIC.H:  Project specific header for the Traffic example              */
/*                                                                            */
/******************************************************************************/

#include "REG51V.H"
#include <intrins.H>


#define INIT      0                   /* task number of task:  init           */
#define CLOCK     1                   /* task number of task:  clock          */
#define SEND      2                   /* task number of task:  SEND       */
#define RECV      3                   /* task number of task:  RECEIVE      */

//定义ACC的位,利用ACC操作速度最快
sbit acc0=ACC^0;
sbit acc1=ACC^1;
sbit acc2=ACC^2;
sbit acc3=ACC^3;
sbit acc4=ACC^4;
sbit acc5=ACC^5;
sbit acc6=ACC^6;
sbit acc7=ACC^7;


sbit LED_CLK   = P0^7;
sbit LED_RUN   = P0^6;
sbit LED_FLG   = P0^5;
sbit LED_ERR   = P0^4;

sbit LED2   = P0^7;
sbit LED3   = P0^6;
sbit LED4   = P0^5;
sbit LED5   = P0^4;


sbit EN485  = P3^2;

sbit SCL    = P3^7; //24C01
sbit SDA    = P3^6; //24C01

#define T_EN485      0x01                  
#define R_EN485      0x00   
                
sbit DOUT   = P1^5;
//sbit DOUT   = P1^6;
sbit DCLK   = P1^7;
sbit DCS0   = P0^1;

#define   ANG485      0x11            
#define   MOTOR485    0x21            
#define   DAMP485     0x22            
#define   STEER485    0x01            

#define   MY485ADDR    MOTOR485           //本机地址
#define   BG485ADDR    0x00               //广播地址

#define	  BAUD_4800   0xFA
#define	  BAUD_9600   0xFD
#define	  BAUD_19200  0xFD

#define	  BAUD_SMOD0  0x00
#define	  BAUD_SMOD1  0x01

#define	  TIME_1MSH  0xFC
#define	  TIME_1MSL  0x66
#define	  TIME_5MSH  0xEE
#define	  TIME_5MSL  0x00

#define	CMD_NO_FLAG	  0x00//
#define	CMD_ERR_FLAG	0xf1//
#define	CMD_END_FLAG	0xf2//

#define	CMD_RESET_FLAG	    0x1//配置命令
#define	CMD_RESET_NUM	    0x6//配置命令有7个字节,7f no

#define	CMD_REQUEST_FLAG	0x2//
#define	CMD_REQUEST_NUM	    0x6//有7个字节

#define	CMD_DATA_FLAG	    0x3//读全部数据命令
#define	CMD_DATA_NUM	    0x6//读全部数据命令有7个字节,7f no

#define	DATA_SEND_CMD	    'S'//0x53
#define	DATA_RECV_CMD	    'R'//0x52

#define	RUN_NO_FLAG	        0x00
#define	RUN_RESET_FLAG	    0x01
#define	RUN_ACT_FLAG	    0x02
#define	RUN_ACQ_FLAG	    0x03
#define	RUN_WAIT_FLAG	    0x04

sbit DOUT0   = P1^0;
sbit DOUT1   = P1^1;
sbit DOUT2   = P1^2;
sbit PWM0    = P1^3;
sbit PWM1    = P1^4;

sbit PWM_DIR   = P1^0;
sbit PWM_CP    = P1^3;

sbit DAMP_L   = P1^1;//左转灯
sbit DAMP_R   = P1^2;//右转灯
/*
204       238
217       239
227       240
244	      241
263	      242
286	      243
303	     	244
333	     	245
370	     	246
416	     	247
476	     	248
526	     	249
625	     	250
740	     	251
926	      252
1220	    253
1852	    254
*/

/////////////////////////////////////
void Uart_Init(unsigned char smod, unsigned char ctime);
void Uart_SendChar(unsigned char ch);  
unsigned char Uart_SendFrame(unsigned char addr, unsigned char *ch, unsigned char datalen);  
//void Uart_INT () interrupt 4 using 2 
void Uart_Do(void);
//
void   bubble(unsigned short *item, unsigned char count);  
unsigned short AD_acq(void);
unsigned short AD_result (void);  
//
void start24(void);
void stop24(void);
unsigned char read24(void);
void write24(unsigned char dd);
unsigned char xbRead24(unsigned int address);
void xbWrite24(unsigned int address,unsigned char cdata);
//
void PWM_init(void);
void PWM_run(void);
void PWM_stop(void);
void PWM_changfreq(unsigned short freq);
unsigned char PWM_status(void);
//
void Mytime2_init(void);
//void Timer2_INT(void) interrupt 5 using 2

⌨️ 快捷键说明

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