File: dialogsecurity.h

package info (click to toggle)
imsprog 1.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,828 kB
  • sloc: cpp: 6,525; ansic: 5,899; xml: 552; sh: 231; makefile: 5
file content (87 lines) | stat: -rw-r--r-- 2,873 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright (C) 2025 Mikhail Medvedev <e-ink-reader@yandex.ru>
 *
 *
 * 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 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef DIALOGSECURITY_H
#define DIALOGSECURITY_H

#include <QDialog>
#include "qhexedit.h"
extern "C" {
#include "ch341a_spi.h"
#include "spi_controller.h"
}

namespace Ui {
class DialogSecurity;
}

class DialogSecurity : public QDialog
{
    Q_OBJECT

public:
    explicit DialogSecurity(QWidget *parent = nullptr);
    void setAlgorithm(uint8_t currentAlg);
    void setPath(QString lastPath);
    void closeEvent(QCloseEvent* event);
    ~DialogSecurity();

private slots:
    void on_toolButton_read_clicked();
    void on_toolButton_write_clicked();
    void on_toolButton_erase_clicked();
    void on_toolButton_open_clicked();
    void on_toolButton_save_clicked();

signals:
    void closeRequestHasArrived();

private:
    Ui::DialogSecurity *ui;
    struct algSettings
    {
        uint8_t id;          // Algirithm number
        bool     algType;    // 0 - default with 0x48, 0x42, 0x44 commands
                             // 1 - with OTP mode and standart write/read commands
        uint8_t  regNumber;  // Number of registers by chip (1...4)
        uint8_t  size;       // size*64 = size of register bytes;
        uint16_t rg0addr;    // register 0 address / enter OTP mode
        uint16_t rg1addr;    // register 1 address / exit OTP mode
        uint16_t rg2addr;    // register 2 address
        uint16_t rg3addr;    // register 3 address
        bool     allErase;   // 1 - zero code for erasing all registers, 0 - none;
        bool     a4byte;     // 1 - 32 bit addressing using, 0 - 24 bit address using
        uint8_t  curCommand; // Current command pattern
    };
    struct securCommands
    {
       uint8_t id;        // Pattern number
       uint8_t RDSCUR;    // Read security register command
       uint8_t WRSCUR;    // Write security register command
       uint8_t ERSCUR;    // Erase cecurity register command
       uint8_t ENSO;      // Enter secured OTP mode command
       uint8_t EXSO;      // Exit secured OTP mode command
       bool    DUMRD;     // Dummy Byte on read cycle 1 - enable, 0 - disable
    };
    uint8_t curAlg;
    securCommands comPattern;
    algSettings curSettings;
    securCommands curCommands;
    QByteArray regData;
    QColor defaultTextColor;
    QHexEdit *hexEdit;
    QString curPath;
};

#endif // DIALOGSECURITY_H