📄 board.h
字号:
#ifndef __BOARD_H__
#define __BOARD_H__
#include <SST89x5x.H>
#define MAIN_CLOCK 3686400
sbit MCU_RX = P3^0;
sbit MCU_TX = P3^1;
sbit MCU_ADI = P3^2;
sbit MCU_KEYI = P3^3;
sbit MCU_STATLED = P3^4;
sbit MCU_DE = P3^5;
sbit MCU_DCLK = P3^6;
sbit MCU_DDAT = P3^7;
sbit MCU_SCL = P1^0;
sbit MCU_SDA = P1^1;
sbit MCU_EWP = P1^2;
sbit MCU_NRST = P1^3;
sbit MCU_SCS = P1^4;
sbit MCU_DOUT = P1^5;
sbit MCU_DIN = P1^6;
sbit MCU_SCK = P1^7;
#define KEYPORT P0
#define WAITBYTE 0x0f
sbit MCU_RI0 = P0^0;
sbit MCU_RI1 = P0^1;
sbit MCU_RI2 = P0^2;
sbit MCU_RI3 = P0^3;
sbit MCU_CO0 = P0^4;
sbit MCU_CO1 = P0^5;
sbit MCU_CO2 = P0^6;
sbit MCU_CO3 = P0^7;
sbit MCU_OUT0 = P2^0;
sbit MCU_OUT1 = P2^1;
sbit MCU_BL = P2^2;
sbit MCU_IN0 = P2^3;
sbit MCU_IN1 = P2^4;
sbit MCU_SW0 = P2^5;
sbit MCU_SW1 = P2^6;
sbit MCU_DLD = P2^7;
#define DISABLE_INTERRUPT EA=0
#define ENABLE_INTERRUPT EA=1
/*
//*************************************************************************
// macros
//*************************************************************************
*/
#define SWAP(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
#define MSB(x) (((x) >> 8) & 0xFF)
#define LSB(x) ((x) & 0xFF)
#define FALSE 0
#define TRUE (!FALSE)
/*
//*************************************************************************
// basic typedefs
//*************************************************************************
*/
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef unsigned char BOOL;
/*
//*************************************************************************
// structure and union definitions
//*************************************************************************
*/
typedef union _epp_flags
{
struct _flags
{
unsigned char CommTimeOver : 1;
unsigned char NewCommand : 1;
unsigned char fHaveDLE : 1;
unsigned char fADValid : 1;
unsigned char DeviceStat : 4;
unsigned char CommCode : 4;
unsigned char CommStat : 4;
} bits;
unsigned short value;
} EPPFLAGS;
typedef struct _COMM_CONTROL {
unsigned char bPointer;
unsigned char bSerial;
unsigned char bCommand;
unsigned char bLength;
unsigned char bAck; //存放应答字
} COMM_CONTROL;
typedef struct _WEIGHT_TEMP {
unsigned char fNewWeight:1;
unsigned char bTimes;
unsigned long lMinWeight;
unsigned long lMaxWeight;
unsigned long lTempWeight;
unsigned long lNowWeight;
} WEIGHT_TEMP;
#define AVERAVGETIMES 10
//======================================================
//设备状态恒量
#define NoLogin_Mode 0x00
#define Balance_Mode 0x01
#define Charge_Mode 0x02
//设备状态
#define A 0
//显示错误编号
#define ERROR_NOREF 0
//======================================================
//函数声明
void Delay(unsigned int iTime);
void reserved(void);
//读取设备数据
void Read_Data(void);
//写入设备数据
void Write_Data(void);
//获取状态
void Get_Status(void);
//设置状态
void Set_Status(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -