📄 stk500.h
字号:
//---------------------------------------------------------------------------
#ifndef stk500H
#define stk500H
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include "RS232Comm.h"
#define STK500_MCUCLK 7370000
//---------------------------------------------------------------------------
#ifndef CHIP_STRUCT
#define CHIP_STRUCT
typedef struct
{
int flashsize; // Size of Flash Memory in Bytes
bool paged; // true = Flash is programmed Page wise
int pagesize; // Size of one Page in Bytes
int WD_Flash; // Minimum Wait Time after Flash Write
int eepromsize; // Size of EEPROM Memory in Bytes
int WD_EEPROM; // Minimum Wait Time after EEPROM Write
int signature; // Chip Signature
int lockbittype; // Internal Use (Choose Method to Read/Write Lock Bits)
int fusebittype; // Internal Use (Choose Method to Read/Write Fuse Bits)
int calibbytes; // Number of Oscillator Calibration Bytes
int stk500_dev; // STK500 Device Code
int progtype; // SPI / HV Programming
bool hvserial; // true = HV Serial Programming , false = HV Parallel Programming
int parmode;
int lockbytes; // Number of Lock Bytes
int fusebytes; // Number of Fuse Bytes
int selftimed; // Polling available
} TChipInfo;
#define CHIP_PROGSPI 0
#define CHIP_PROGHV 1
#endif
//---------------------------------------------------------------------------
class TSTK500 : public TComponent
{
private:
TRS232Comm *Comm;
void __fastcall OnReceive (DWORD Count);
bool __fastcall DoCommand (unsigned char *com, int len, int num);
bool __fastcall DoCommandV2 (unsigned char *com, int len, int num);
char response;
int bytesrx, protocol;
unsigned char rxdata[1024];
void __fastcall ErrorMessage (AnsiString msg);
bool __fastcall GetSync (void);
int scklen;
bool __fastcall ChangeSCKLen (void);
bool __fastcall ChangeSCKLenV2 (void);
TChipInfo ChipInfoV2;
public:
__fastcall TSTK500 (TComponent* Owner);
__fastcall ~TSTK500 (void);
bool __fastcall CheckPresence (void);
void __fastcall SetPort (AnsiString port);
bool __fastcall EnablePGM (TChipInfo *chip);
bool __fastcall EnablePGMV2 (TChipInfo *chip);
void __fastcall DisablePGM (void);
void __fastcall DisablePGMV2 (void);
bool __fastcall GetSignature (unsigned char *sig);
bool __fastcall GetSignatureV2 (unsigned char *sig);
bool __fastcall SetDevParameters (TChipInfo *chip);
bool __fastcall LoadAddress (int adr);
bool __fastcall LoadAddressV2 (int adr);
bool __fastcall ReadFlash (unsigned char *data);
bool __fastcall ReadPage (unsigned char *data, int size, char type);
bool __fastcall ReadPageV2 (unsigned char *data, int size, char type);
void __fastcall SetSCKLen (int len);
bool __fastcall ChipErase (void);
bool __fastcall ChipEraseV2 (void);
bool __fastcall WritePage (unsigned char *data, int size, char type);
bool __fastcall WritePageV2 (unsigned char *data, int size, char type);
bool __fastcall ReadVTarget (double *vtarget);
bool __fastcall ReadVTargetV2 (double *vtarget);
bool __fastcall ReadARef (double *aref);
bool __fastcall ReadARefV2 (double *aref);
bool __fastcall WriteVTarget (double vtarget);
bool __fastcall WriteVTargetV2 (double vtarget);
bool __fastcall WriteARef (double aref);
bool __fastcall WriteARefV2 (double aref);
bool __fastcall StartComm (void);
void __fastcall StopComm (void);
bool __fastcall ReadOscValues (int *pre, int *comp);
bool __fastcall ReadOscValuesV2 (int *pre, int *comp);
bool __fastcall WriteOscValues (int pre, int comp);
bool __fastcall WriteOscValuesV2 (int pre, int comp);
bool __fastcall UniversalCmd (unsigned char *tx, unsigned char *rx);
bool __fastcall UniversalCmdV2 (unsigned char *tx, unsigned char *rx);
bool __fastcall ReadFuseBits (unsigned char *low, unsigned char *hi);
bool __fastcall ReadFuseBitsV2 (unsigned char *low, unsigned char *hi);
bool __fastcall ReadFuseBitsEx (unsigned char *low, unsigned char *hi,
unsigned char *ext);
bool __fastcall ReadFuseBitsExV2 (unsigned char *low, unsigned char *hi,
unsigned char *ext);
bool __fastcall ReadLockBits (unsigned char *lock);
bool __fastcall ReadLockBitsV2 (unsigned char *lock);
bool __fastcall WriteFuseBits (unsigned char low, unsigned char hi);
bool __fastcall WriteFuseBitsV2 (unsigned char low, unsigned char hi);
bool __fastcall WriteFuseBitsEx (unsigned char low, unsigned char hi,
unsigned char ext);
bool __fastcall WriteFuseBitsExV2 (unsigned char low, unsigned char hi,
unsigned char ext);
bool __fastcall WriteLockBits (unsigned char lock);
bool __fastcall WriteLockBitsV2 (unsigned char lock);
bool __fastcall ReadCalibrationByte (int num, unsigned char *byte);
bool __fastcall ReadCalibrationByteV2 (int num, unsigned char *byte);
};
//---------------------------------------------------------------------------
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -