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
|
/***************************************************************************
* Copyright (C) 2005-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 PIC_PROG_H
#define PIC_PROG_H
#include "pic_prog_specific.h"
#include "progs/base/prog_group.h"
#include "devices/base/device_group.h"
namespace Pic
{
class MemoryRange : public Device::MemoryRange {
public:
MemoryRange(MemoryRangeType type) : _type(type) {}
virtual bool all() const { return _type==MemoryRangeType::Nb_Types; }
MemoryRangeType _type;
};
} //namespace
namespace Programmer
{
//-----------------------------------------------------------------------------
class PicGroup : public Group
{
public:
virtual bool canReadVoltage(Pic::VoltageType) const { return false; }
virtual bool canReadVoltages() const;
virtual ::Debugger::DeviceSpecific *createDebuggerDeviceSpecific(::Debugger::Base &base) const;
};
//-----------------------------------------------------------------------------
class PicBase : public Base
{
public:
PicBase(const Group &group, const Pic::Data *data, const char *name);
virtual ~PicBase();
PicDeviceSpecific *specific() { return static_cast<PicDeviceSpecific *>(_specific); }
const PicDeviceSpecific *specific() const { return static_cast<PicDeviceSpecific *>(_specific); }
const Pic::Data *device() const { return static_cast<const Pic::Data *>(_device); }
const Pic::Memory &deviceMemory() const { return *_deviceMemory; }
const PicGroup &group() const { return static_cast<const PicGroup &>(_group); }
double voltage(Pic::VoltageType type) const { return _voltages[type].value; }
virtual bool readVoltages();
bool getTargetMode(Pic::TargetMode &mode);
bool eraseSingle(Pic::MemoryRangeType type);
bool readSingle(Pic::MemoryRangeType type, Pic::Memory &memory);
bool programSingle(Pic::MemoryRangeType type, const Pic::Memory &memory);
bool verifySingle(Pic::MemoryRangeType type, const Pic::Memory &memory);
bool blankCheckSingle(Pic::MemoryRangeType type);
bool readCalibration();
bool programCalibration(const Device::Array &data);
protected:
PicHardware *hardware() { return static_cast<PicHardware *>(_hardware); }
virtual bool internalSetupHardware();
virtual double vdd() const { return _voltages[Pic::TargetVdd].value; }
virtual double vpp() const { return _voltages[Pic::TargetVpp].value; }
virtual bool verifyDeviceId();
virtual uint nbSteps(Task task, const Device::MemoryRange *range) const;
bool initProgramming(Task task);
virtual bool initProgramming();
virtual bool internalRun();
virtual bool internalStop();
virtual void clear();
virtual bool checkErase();
virtual bool internalErase(const Device::MemoryRange &range);
virtual bool checkRead();
virtual bool internalRead(Device::Memory *memory, const Device::MemoryRange &range, const VerifyData *data);
bool readRange(Pic::MemoryRangeType type, Pic::Memory *memory, const VerifyData *data);
virtual bool checkProgram(const Device::Memory &memory);
virtual bool internalProgram(const Device::Memory &memory, const Device::MemoryRange &range);
virtual bool programAll(const Pic::Memory &memory);
bool programAndVerifyRange(Pic::MemoryRangeType type, const Pic::Memory &memory);
bool programRange(Pic::MemoryRangeType type, const Device::Array &array);
private:
Pic::Memory *_deviceMemory;
bool _hasProtectedCode, _hasProtectedEeprom;
PicHardware::VoltagesData _voltages;
BitValue readDeviceId();
bool eraseAll();
bool eraseRange(Pic::MemoryRangeType type);
bool restoreCalibration();
bool restoreBandGapBits();
bool doProgramCalibration(const Device::Array &data);
bool checkProgramCalibration(const Device::Array &data);
bool internalProgramCalibration(const Device::Array &data);
TQString prettyCalibration(const Device::Array &data) const;
bool tryProgramCalibration(const Device::Array &data, bool &success);
bool preserveCode();
bool preserveEeprom();
bool internalEraseRange(Pic::MemoryRangeType type);
};
} // namespace
#endif
|