📄 prg0.h
字号:
#if !defined(AFX_PRG0_H__2A6E2ECF_C923_11D5_BD16_00608F001738__INCLUDED_)
#define AFX_PRG0_H__2A6E2ECF_C923_11D5_BD16_00608F001738__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Prg0.h : header file
//
#include "resource.h"
#define MAXLEN 62 //通讯收发的最大字节数
#define BAUDRATE CBR_57600//CBR_9600
#define BYTESIZE 8
#define PARITY MARKPARITY
#define STOPBITS ONESTOPBIT
#define FPARITY TRUE
#define COMMPORT "COM1"
#define FStartComm232 0x88 //通讯起始标志
#define FILENAMELEN 30
#define MAXFILELEN 5000000 //5M
#define MAXLINESINONEPAGE 20 //max lines in one page
#define MAXBYTESINONELINE 16 //max lines in one page
#define COMMOK 0 //通讯正常结束
#define ERRLEN 1 //通讯参数错误:发的字节数=0/发的字节数>MaxLen
#define ERRCOMM 2 //通讯错误:通讯未成功
//通讯命令(常数)定义
#define COMM_START 0x88 //通讯起始标识
#define CMD_CHIP_ERASE 0x11 //指令: 擦除
#define CMD_SECT_ERASE 0x22 //指令: 擦除
#define CMD_PROG 0x33 //编程指令: 传送编程地址、长度
#define CMD_PROGX 0x44 //编程指令: 传送编程数据
#define CMD_READ 0x55 //指令: 读FLASH
#define CMD_RSTFLASH 0x66 //FLASH复位
#define CMD_ERR 0x77 //错误返回:由错误码确定
#define CMD_OK 0x99 //接收正确:错误码=0
#define CMD_CHIP_ID 0xAA //指令: FLASH ID
#define CMD_ERR_PRG 0xBB //编程错误:CMD+ADDR(3 byteS)+SOURCE DATA+REAL DATA+SUM
#define CMD_END 0xCC //编程、读FLASH指令执行完毕
/////////////////////////////////////////////////////////////////////////////
// CPrg0 dialog
class CPrg0 : public CDialog
{
// Construction
public:
time_t st,ct;
int SaveFlashData();
void DspPrgErr();
int TX_PrgData();
void DspID(int);
int Rcv0();
void Rcv();
void Stopx(int);
void DspErrRcv();
void DspErrMessage(char *);
int Comm_Test(int);
int DspHint();
void DspButton();
void OnDspFile();
BOOL Receive232();
int Comm232();
BOOL PrepareComm(int CommType);
HANDLE HComm232; //232通讯句柄
int InitComm232();
CPrg0(CWnd* pParent = NULL); // standard constructor
BYTE ID_MCH,ID_MCL,ID_DCH,ID_DCL;
BYTE RBuf[100],SBuf[100],*w,*r,ErrByte,ErrCode0,ErrCode1,ErrSum,ErrNull,ErrTimeOut,Dsp_flag,Dsp_Cnt;
BYTE rfile_flag,wfile_flag,comm_OK,in_erase,in_readF,in_prgF,in_commtest,Cur_CMD,in_x,len_rcv;
BYTE B_FOpen,B_FSave,B_BufClr,B_BufLocate,B_CommTest,B_RFlash,B_WFlash,B_EFlash,B_Verify,B_Stop,B_NextPage,B_LastPage;
CButton *b_FOpen,*b_FSave,*b_BufClr,*b_BufLocate,*b_CommTest,*b_RFlash,*b_WFlash,*b_EFlash,*b_Verify,*b_Stop,*b_NextPage,*b_LastPage;
int Cur_progressPtr;
CString FileName,tmp,tmp1;
DWORD FileLen,Cur_FilePtr,SetTo_FPtr,RDataLen,Cur_RDataPtr,Cur_Ptr,MaxLen,FlashAddr,BufAddr,DataLen,DataLenx,TmOut,TmConst;
// Dialog Data
//{{AFX_DATA(CPrg0)
enum { IDD = IDD_prg0 };
CEdit m_DspStCtl;
CEdit m_DspDeviceInfoCtl;
CProgressCtrl m_Progr;
CString m_Dsp;
CString m_DspState;
CString m_DspDeviceInf;
CString m_ProgressNum;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPrg0)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
int fstart;
// Generated message map functions
//{{AFX_MSG(CPrg0)
virtual BOOL OnInitDialog();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnOpenfile();
afx_msg void OnSavefile();
afx_msg void OnTestcomm();
afx_msg void OnRead();
afx_msg void OnErase();
afx_msg void OnProg();
virtual void OnCancel();
afx_msg void OnNextpage();
afx_msg void OnLastpage();
afx_msg void OnClearfilebuf();
afx_msg void OnLocatebuf();
afx_msg void OnVerify();
afx_msg void OnStopx();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PRG0_H__2A6E2ECF_C923_11D5_BD16_00608F001738__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -