aboutsummaryrefslogtreecommitdiff
path: root/Mcu.hpp
blob: a05dafeaf41544d1c2e4a80a032a0e56b8b3b080 (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
#ifndef MCU_HPP
#define MCU_HPP 1

#include "SerialPort.hpp"
#include "McuSpecifics.hpp"

#include <cstdint>
#include <vector>
#include <memory>

using std::vector;
using std::unique_ptr;

class CMcu {
private:
    CSerialPort & mSerialPort;
    unique_ptr<IMcuSpecifics> mMcuSpecifics;
    float mMcuFrequency;

    void decodeIdentData(uint8_t data[4], uint16_t & idmanuf, uint16_t & idchip);
    void setMcuSpecificsById(uint16_t idmanuf, uint16_t idchip);
    string getMessageForRetCode(uint16_t ret);
    void sendShellCommand(uint8_t cmd);

public:
    CMcu(CSerialPort & serialPort, float mcuFrequency);

    void erase();
    void erase(list<unsigned int> blockList);
    void erase(uint32_t startAddr, uint32_t endAddr);
    void write(vector<uint8_t> data, bool printProgress);
    vector<uint8_t> read(bool printProgress);
    vector<uint8_t> read(uint32_t size, bool printProgress);
    string ident();
};

#endif