1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/***************************************************************************
* Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef PICKIT2_H
#define PICKIT2_H
#include "pickit.h"
#include "pickit2_data.h"
namespace Pickit2
{
//-----------------------------------------------------------------------------
class Array : public Pickit::Array
{
public:
Array() : Pickit::Array(64, 'Z', PrintAlphaNum) {}
};
//-----------------------------------------------------------------------------
class USBPort : public Pickit::USBPort
{
public:
USBPort(Log::Base &log) : Pickit::USBPort(0x0033, log) {}
virtual Pickit::Array array() const { return Array(); }
void fillCommand(Pickit::Array &cmd1, uchar cmd2, uint nbBytes, uint address, uint i, bool longAddress = true) const;
Pickit::Array createCommand(uchar cmd, uint nbBytes, uint address, bool longAddress = true) const;
bool readFirmwareCodeMemory(Device::Array &data, const Device::Array *vdata, ProgressMonitor &monitor);
//bool readFirmwareEepromMemory(Device::Array &data);
bool eraseFirmwareCodeMemory();
bool writeFirmwareCodeMemory(const Device::Array &data, ProgressMonitor &monitor);
//bool writeFirmwareEepromMemory(const Device::Array &data);
bool resetFirmwareDevice(::Programmer::Mode mode) { return command(mode==::Programmer::BootloadMode ? 'B' : 0xFF); }
bool uploadFirmware(const Pic::Memory &memory, ProgressMonitor &monitor);
private:
virtual uint readEndPoint() const { return 0x81; }
virtual uint writeEndPoint() const { return 0x01; }
};
//-----------------------------------------------------------------------------
class Hardware : public Pickit::Hardware
{
public:
Hardware(::Programmer::Base &base) : Pickit::Hardware(base, new USBPort(base)) {}
virtual bool readVoltages(VoltagesData &voltages);
bool setVddVpp(double vdd, double vpp);
};
//-----------------------------------------------------------------------------
class Baseline : public Pickit::Baseline
{
public:
Baseline(::Programmer::Base &base) : Pickit::Baseline(base) {}
virtual bool init();
virtual char entryMode() const { return data(device().name()).entryMode; }
virtual uint nbWrites(Pic::MemoryRangeType type) const { return (type==Pic::MemoryRangeType::Eeprom ? 4 : 16); }
};
//-----------------------------------------------------------------------------
class P16F : public Pickit::P16F
{
public:
P16F(::Programmer::Base &base) : Pickit::P16F(base) {}
virtual bool init();
virtual char entryMode() const { return data(device().name()).entryMode; }
virtual uint nbWrites(Pic::MemoryRangeType type) const { return (type==Pic::MemoryRangeType::Code ? 16 : 4); }
};
class P16F87XA : public P16F
{
public:
P16F87XA(::Programmer::Base &base) : P16F(base) {}
virtual bool init();
};
class P16F7X : public P16F
{
public:
P16F7X(::Programmer::Base &base) : P16F(base) {}
virtual bool init();
virtual char writeCode() const { return 'w'; }
};
class P16F716 : public P16F
{
public:
P16F716(::Programmer::Base &base) : P16F(base) {}
virtual bool init();
};
//-----------------------------------------------------------------------------
class P18F : public Pickit::DeviceSpecific
{
public:
P18F(::Programmer::Base &base) : Pickit::DeviceSpecific(base) {}
Hardware &hardware() { return static_cast<Hardware &>(Pickit::DeviceSpecific::hardware()); }
virtual bool init();
virtual bool doEraseRange(Pic::MemoryRangeType type);
virtual bool doErase(bool) { return doEraseCommand(0x87, 0x0F); }
bool doEraseCommand(uint cmd1, uint cmd2);
virtual bool doRead(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata);
virtual bool doWrite(Pic::MemoryRangeType type, const Device::Array &data, bool force);
virtual char entryMode() const { return data(device().name()).entryMode; }
};
class P18F2X20 : public P18F
{
public:
P18F2X20(::Programmer::Base &base) : P18F(base) {}
virtual bool doEraseRange(Pic::MemoryRangeType type);
virtual bool doErase(bool) { return doEraseCommand(0x80); }
bool doEraseCommand(uint cmd);
};
} // namespace
#endif
|