summaryrefslogtreecommitdiffstats
path: root/src/devices/mem24/prog/mem24_prog.h
blob: 86948c29e13d7d75aabdcd44524de18ca4190f02 (plain)
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
/***************************************************************************
 *   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 MEM24_PROG_H
#define MEM24_PROG_H

#include "progs/base/generic_prog.h"
#include "devices/mem24/mem24/mem24_memory.h"

namespace Programmer
{
//-----------------------------------------------------------------------------
class Mem24DeviceSpecific : public DeviceSpecific
{
public:
  Mem24DeviceSpecific(::Programmer::Base &base) : DeviceSpecific(base) {}
  const Mem24::Data &device() const { return static_cast<const Mem24::Data &>(*_base.device()); }
  bool read(Device::Array &data, const VerifyData *vdata);
  bool write(const Device::Array &data);
  bool verifyByte(uint index, BitValue d, const VerifyData &vdata);
  virtual bool verifyPresence() = 0;

protected:
  virtual bool doRead(Device::Array &data, const VerifyData *vdata) = 0;
  virtual bool doWrite(const Device::Array &data) = 0;
};

//-----------------------------------------------------------------------------
class Mem24Hardware : public Hardware
{
public:
  Mem24Hardware(::Programmer::Base &base, Port::Base *port, const QString &name) : Hardware(base, port, name) {}
  const Mem24::Data &device() const { return static_cast<const Mem24::Data &>(*_base.device()); }
};

//-----------------------------------------------------------------------------
class Mem24Base : public Base
{
public:
  Mem24Base(const Group &group, const Mem24::Data *data, const char *name) : Base(group, data, name) {}
  const Mem24::Data *device() const { return static_cast<const Mem24::Data *>(_device); }

protected:
  Mem24DeviceSpecific *specific() const { return static_cast<Mem24DeviceSpecific *>(_specific); }
  virtual bool verifyDeviceId();
  virtual uint nbSteps(Task task, const Device::MemoryRange *range) const;
  virtual bool initProgramming() { return true; }
  virtual bool checkErase() { return true; }
  virtual bool internalErase(const Device::MemoryRange &range);
  virtual bool checkRead() { return true; }
  virtual bool internalRead(Device::Memory *memory, const Device::MemoryRange &range, const VerifyData *vdata);
  virtual bool checkProgram(const Device::Memory &) { return true; }
  virtual bool internalProgram(const Device::Memory &memory, const Device::MemoryRange &range);
};

} // namespace

#endif