blob: 322df3e86355c0a01b9cb4cd92273f839806b055 (
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
64
65
66
67
68
69
70
71
72
73
74
|
/***************************************************************************
* Copyright (C) 2007 Nicolas Hadacek <[email protected]> *
* *
* 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 TBL_BOOTLOADER_H
#define TBL_BOOTLOADER_H
#include "progs/bootloader/base/bootloader.h"
#include "progs/bootloader/base/bootloader_prog.h"
#include "common/port/serial.h"
#include "common/global/generic_config.h"
namespace TinyBootloader
{
//-----------------------------------------------------------------------------
class Config : public GenericConfig
{
public:
Config() : GenericConfig("tiny_bootloader") {}
Port::Serial::Speed readSpeed();
void writeSpeed(Port::Serial::Speed speed);
uint readTimeout(); // ms
void writeTimeout(uint timeout); // ms
uint readRetries();
void writeRetries(uint nb);
};
//-----------------------------------------------------------------------------
class Hardware : public ::Bootloader::Hardware
{
public:
Hardware(::Programmer::Base &base, const TQString &portDevice);
Port::Serial *port() { return static_cast<Port::Serial *>(_port); }
bool verifyDeviceId();
virtual bool write(Pic::MemoryRangeType type, const Device::Array &data);
virtual bool read(Pic::MemoryRangeType, Device::Array &, const ::Programmer::VerifyData *) { return false; }
bool writeCode(const Device::Array &data, bool erase);
bool writeConfig(const Device::Array &data);
bool writeEeprom(const Device::Array &data);
virtual bool internalConnectHardware();
virtual bool openPort();
private:
uchar _id;
uint _timeout; // ms
uint _retries;
bool waitReady(bool *checkCRC);
bool sendChar(char c, uchar *crc);
bool sendCodeAddress(uint address, uchar &crc);
bool endWrite(uchar crc, uint &retries, bool &ok);
};
//-----------------------------------------------------------------------------
class DeviceSpecific : public ::Bootloader::DeviceSpecific
{
public:
DeviceSpecific(::Programmer::Base &base) : ::Bootloader::DeviceSpecific(base) {}
virtual bool canEraseAll() const { return true; }
virtual bool canEraseRange(Pic::MemoryRangeType type) const { return canWriteRange(type); }
virtual bool emulatedErase() const { return true; }
virtual bool canReadRange(Pic::MemoryRangeType) const { return false; }
virtual bool canWriteRange(Pic::MemoryRangeType type) const;
virtual bool doEraseRange(Pic::MemoryRangeType type);
virtual bool doErase(bool);
};
} // namespace
#endif
|