EasyMCU 1.0.0
Утилита для прошивки МК К1946ВМ014 по протоколу STK500v1
Загрузка...
Поиск...
Не найдено
stk500v1.h
См. документацию.
1
12
13#ifndef STK500V1_H
14#define STK500V1_H
15
16#include <cstdint>
17#include <vector>
18#include <string>
19#include "../lib/serialib.h"
20
66{
67public:
73 explicit STK500v1(serialib &serialPort);
74
76 ~STK500v1() = default;
77
83 bool resetMCU();
84
92 bool sync();
93
100 bool getSignature(std::vector<uint8_t> &sig);
101
110 bool loadAddress(uint32_t byteAddress, bool isEeprom = false);
111
121 bool readPage(uint16_t size, std::vector<uint8_t> &buffer, bool isEeprom = false);
122
132 bool progPage(uint16_t size, const std::vector<uint8_t> &data, bool isEeprom = false);
133
141 bool verifyMemory(const std::vector<uint8_t> &expected, uint32_t size, bool isEeprom = false);
142
149 bool leaveProgMode();
150
160 static bool parseHex(const std::string &filename, std::vector<uint8_t> &firmware, uint16_t pageSize);
161
165 static bool saveAsHex(const std::string &filename,
166 const std::vector<uint8_t> &data);
167
171 static bool saveEepromAsHex(const std::string &filename,
172 const std::vector<uint8_t> &data);
173
174private:
184 bool sendCommand(const std::vector<uint8_t> &cmd, std::vector<uint8_t> &response, size_t expectedLen);
185
186 serialib &serial;
187 // Константы протокола STK500. Подробнее в AVR061
188 static const uint8_t STK_GET_SYNC = 0x30;
189 static const uint8_t STK_LOAD_ADDRESS = 0x55;
190 static const uint8_t STK_PROG_PAGE = 0x64;
191 static const uint8_t STK_READ_PAGE = 0x74;
192 static const uint8_t STK_READ_SIGN = 0x75;
193 static const uint8_t STK_LEAVE_PROGMODE = 0x51;
194 static const uint8_t STK_INSYNC = 0x14;
195 static const uint8_t STK_OK = 0x10;
196 static const uint8_t CRC_EOP = 0x20;
197 static const uint8_t MEM_FLASH = 0x46;
198 static const uint8_t MEM_EEPROM = 0x45;
199};
200
201#endif // STK500V1_H
static bool parseHex(const std::string &filename, std::vector< uint8_t > &firmware, uint16_t pageSize)
Определения stk500v1.cpp:223
bool getSignature(std::vector< uint8_t > &sig)
Определения stk500v1.cpp:89
bool leaveProgMode()
Определения stk500v1.cpp:169
bool readPage(uint16_t size, std::vector< uint8_t > &buffer, bool isEeprom=false)
Определения stk500v1.cpp:126
static bool saveAsHex(const std::string &filename, const std::vector< uint8_t > &data)
Определения stk500v1.cpp:432
bool progPage(uint16_t size, const std::vector< uint8_t > &data, bool isEeprom=false)
Определения stk500v1.cpp:147
bool verifyMemory(const std::vector< uint8_t > &expected, uint32_t size, bool isEeprom=false)
Определения stk500v1.cpp:176
static bool saveEepromAsHex(const std::string &filename, const std::vector< uint8_t > &data)
Определения stk500v1.cpp:472
bool sync()
Определения stk500v1.cpp:75
STK500v1(serialib &serialPort)
Определения stk500v1.cpp:18
~STK500v1()=default
bool loadAddress(uint32_t byteAddress, bool isEeprom=false)
Определения stk500v1.cpp:105
bool resetMCU()
Определения stk500v1.cpp:64