summaryrefslogtreecommitdiffstats
path: root/src/progs/direct/base/direct_prog.cpp
blob: 3e4f1685717f0c8b2413ae37186a165494a43578 (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
/***************************************************************************
 *   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.                                   *
 ***************************************************************************/
#include "direct_prog.h"

#include "devices/base/device_group.h"
#include "devices/list/device_list.h"
#include "direct_prog_config.h"
#include "direct_mem24.h"
//#include "direct_30.h"

Hardware::Config *Direct::DGroup::hardwareConfig() const
{
  return new Config;
}

void Direct::DGroup::initSupported()
{
  Group::initSupported();
  //  const ::Group::Base *gpic = Device::lister().group("pic");
  ::Group::Base::ConstIterator pit;
  //  for (pit=gpic->begin(); pit!=gpics->end(); ++pit) {
  //    ::Group::DeviceData data = pit.data();
  //    if ( static_cast<const Pic::Data *>(data.data)->architecture()!=Pic::Architecture::P30X ) continue;
  //    data.supportType = ::Group::Untested;
  //    addDevice(data);
  //  }
  const ::Group::Base *gmem24 = Device::lister().group("mem24");
  for (pit=gmem24->begin(); pit!=gmem24->end(); ++pit) addDevice(pit.key(), pit.data().data, pit.data().support);
}

::Programmer::Base *Direct::DGroup::createBase(const Device::Data *data) const
{
  if ( data==0 || data->group().name()=="pic" ) return new PicBase(*this, static_cast<const Pic::Data *>(data));
  return new Mem24Base(*this, static_cast<const Mem24::Data *>(data));
}

::Programmer::Hardware *Direct::DGroup::createHardware(::Programmer::Base &base, const ::Programmer::HardwareDescription &hd) const
{
  Config config;
  HardwareData *hdata = static_cast<HardwareData *>(config.hardwareData(hd.name));
  Q_ASSERT( hdata->portType==hd.port.type );
  ::Programmer::Hardware *hardware = 0;
  if ( hd.port.type==PortType::Serial ) hardware = new SerialHardware(base, hd.port.device, *hdata);
  else hardware = new ParallelHardware(base, hd.port.device, *hdata);
  delete hdata;
  return hardware;
}

::Programmer::DeviceSpecific *Direct::DGroup::createDeviceSpecific(::Programmer::Base &base) const
{
  if ( base.device()->group().name()=="pic" ) {
    //    if ( static_cast<const Pic::Data *>(base.device())->architecture()==Pic::Architecture::P30X ) return new Pic30(base);
    return Group::createDeviceSpecific(base);
  }
  return new Mem24DeviceSpecific(base);
}