Skip to content

Commit ca16c0c

Browse files
committed
Separate parallel and SPI configuration
1 parent d2be0bf commit ca16c0c

18 files changed

+607
-305
lines changed

qt/chip_db.cpp

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,117 @@
44
*/
55

66
#include "chip_db.h"
7+
8+
QString ChipDb::getChipName(int chipIndex)
9+
{
10+
ChipInfo *ci = getChipInfo(chipIndex);
11+
12+
return ci ? ci->name : QString();
13+
}
14+
15+
int ChipDb::setChipName(int chipIndex, const QString &name)
16+
{
17+
ChipInfo *ci = getChipInfo(chipIndex);
18+
19+
if (!ci)
20+
return -1;
21+
22+
ci->name = name;
23+
24+
return 0;
25+
}
26+
27+
uint32_t ChipDb::getPageSize(int chipIndex)
28+
{
29+
ChipInfo *ci = getChipInfo(chipIndex);
30+
31+
return ci ? ci->pageSize : 0;
32+
}
33+
34+
int ChipDb::setPageSize(int chipIndex, uint32_t pageSize)
35+
{
36+
ChipInfo *ci = getChipInfo(chipIndex);
37+
38+
if (!ci)
39+
return -1;
40+
41+
ci->pageSize = pageSize;
42+
43+
return 0;
44+
}
45+
46+
uint32_t ChipDb::getBlockSize(int chipIndex)
47+
{
48+
ChipInfo *ci = getChipInfo(chipIndex);
49+
50+
return ci ? ci->blockSize : 0;
51+
}
52+
53+
int ChipDb::setBlockSize(int chipIndex, uint32_t blockSize)
54+
{
55+
ChipInfo *ci = getChipInfo(chipIndex);
56+
57+
if (!ci)
58+
return -1;
59+
60+
ci->blockSize = blockSize;
61+
62+
return 0;
63+
}
64+
65+
uint32_t ChipDb::getTotalSize(int chipIndex)
66+
{
67+
ChipInfo *ci = getChipInfo(chipIndex);
68+
69+
return ci ? ci->totalSize : 0;
70+
}
71+
72+
int ChipDb::setTotalSize(int chipIndex, uint32_t totalSize)
73+
{
74+
ChipInfo *ci = getChipInfo(chipIndex);
75+
76+
if (!ci)
77+
return -1;
78+
79+
ci->totalSize = totalSize;
80+
81+
return 0;
82+
}
83+
84+
uint32_t ChipDb::getSpareSize(int chipIndex)
85+
{
86+
ChipInfo *ci = getChipInfo(chipIndex);
87+
88+
return ci ? ci->spareSize : 0;
89+
}
90+
91+
int ChipDb::setSpareSize(int chipIndex, uint32_t spareSize)
92+
{
93+
ChipInfo *ci = getChipInfo(chipIndex);
94+
95+
if (!ci)
96+
return -1;
97+
98+
ci->spareSize = spareSize;
99+
100+
return 0;
101+
}
102+
103+
uint32_t ChipDb::getBBMarkOffset(int chipIndex)
104+
{
105+
ChipInfo *ci = getChipInfo(chipIndex);
106+
107+
return ci ? ci->bbMarkOffset : 0;
108+
}
109+
110+
int ChipDb::setBBMarkOffset(int chipIndex, uint32_t bbMarkOffset)
111+
{
112+
ChipInfo *ci = getChipInfo(chipIndex);
113+
114+
if (!ci)
115+
return -1;
116+
117+
ci->bbMarkOffset = bbMarkOffset;
118+
119+
return 0;
120+
}

qt/chip_db.h

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,9 @@
66
#ifndef CHIP_DB_H
77
#define CHIP_DB_H
88

9+
#include "chip_info.h"
910
#include <QStringList>
1011

11-
enum
12-
{
13-
CHIP_PARAM_NAME,
14-
CHIP_PARAM_PAGE_SIZE,
15-
CHIP_PARAM_BLOCK_SIZE,
16-
CHIP_PARAM_TOTAL_SIZE,
17-
CHIP_PARAM_SPARE_SIZE,
18-
CHIP_PARAM_T_CS,
19-
CHIP_PARAM_T_CLS,
20-
CHIP_PARAM_T_ALS,
21-
CHIP_PARAM_T_CLR,
22-
CHIP_PARAM_T_AR,
23-
CHIP_PARAM_T_WP,
24-
CHIP_PARAM_T_RP,
25-
CHIP_PARAM_T_DS,
26-
CHIP_PARAM_T_CH,
27-
CHIP_PARAM_T_CLH,
28-
CHIP_PARAM_T_ALH,
29-
CHIP_PARAM_T_WC,
30-
CHIP_PARAM_T_RC,
31-
CHIP_PARAM_T_REA,
32-
CHIP_PARAM_ROW_CYCLES,
33-
CHIP_PARAM_COL_CYCLES,
34-
CHIP_PARAM_READ1_CMD,
35-
CHIP_PARAM_READ2_CMD,
36-
CHIP_PARAM_READ_SPARE_CMD,
37-
CHIP_PARAM_READ_ID_CMD,
38-
CHIP_PARAM_RESET_CMD,
39-
CHIP_PARAM_WRITE1_CMD,
40-
CHIP_PARAM_WRITE2_CMD,
41-
CHIP_PARAM_ERASE1_CMD,
42-
CHIP_PARAM_ERASE2_CMD,
43-
CHIP_PARAM_STATUS_CMD,
44-
CHIP_PARAM_BB_MARK_OFF,
45-
CHIP_PARAM_ID1,
46-
CHIP_PARAM_ID2,
47-
CHIP_PARAM_ID3,
48-
CHIP_PARAM_ID4,
49-
CHIP_PARAM_ID5,
50-
CHIP_PARAM_NUM,
51-
};
52-
53-
typedef struct
54-
{
55-
uint32_t id;
56-
QString name;
57-
uint32_t params[CHIP_PARAM_NUM];
58-
} ChipInfo;
59-
6012
enum CHIP_HAL
6113
{
6214
CHIP_HAL_PARALLEL = 0,
@@ -75,6 +27,19 @@ class ChipDb
7527
virtual uint32_t totalSizeGetByName(const QString &name) = 0;
7628
virtual uint32_t extendedTotalSizeGetByName(const QString &name) = 0;
7729
virtual uint8_t getHal() = 0;
30+
virtual ChipInfo *getChipInfo(int chipIndex) = 0;
31+
QString getChipName(int chipIndex);
32+
int setChipName(int chipIndex, const QString &name);
33+
uint32_t getPageSize(int chipIndex);
34+
int setPageSize(int chipIndex, uint32_t pageSize);
35+
uint32_t getBlockSize(int chipIndex);
36+
int setBlockSize(int chipIndex, uint32_t blockSize);
37+
uint32_t getTotalSize(int chipIndex);
38+
int setTotalSize(int chipIndex, uint32_t totalSize);
39+
uint32_t getSpareSize(int chipIndex);
40+
int setSpareSize(int chipIndex, uint32_t spareSize);
41+
uint32_t getBBMarkOffset(int chipIndex);
42+
int setBBMarkOffset(int chipIndex, uint32_t bbMarkOffset);
7843
};
7944

8045
#endif // CHIP_DB_H

qt/chip_info.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* Copyright (C) 2020 NANDO authors
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 3.
4+
*/
5+
6+
#ifndef CHIP_INFO_H
7+
#define CHIP_INFO_H
8+
9+
#include <QString>
10+
11+
enum
12+
{
13+
CHIP_PARAM_NAME,
14+
CHIP_PARAM_PAGE_SIZE,
15+
CHIP_PARAM_BLOCK_SIZE,
16+
CHIP_PARAM_TOTAL_SIZE,
17+
CHIP_PARAM_SPARE_SIZE,
18+
CHIP_PARAM_T_CS,
19+
CHIP_PARAM_T_CLS,
20+
CHIP_PARAM_T_ALS,
21+
CHIP_PARAM_T_CLR,
22+
CHIP_PARAM_T_AR,
23+
CHIP_PARAM_T_WP,
24+
CHIP_PARAM_T_RP,
25+
CHIP_PARAM_T_DS,
26+
CHIP_PARAM_T_CH,
27+
CHIP_PARAM_T_CLH,
28+
CHIP_PARAM_T_ALH,
29+
CHIP_PARAM_T_WC,
30+
CHIP_PARAM_T_RC,
31+
CHIP_PARAM_T_REA,
32+
CHIP_PARAM_ROW_CYCLES,
33+
CHIP_PARAM_COL_CYCLES,
34+
CHIP_PARAM_READ1_CMD,
35+
CHIP_PARAM_READ2_CMD,
36+
CHIP_PARAM_READ_SPARE_CMD,
37+
CHIP_PARAM_READ_ID_CMD,
38+
CHIP_PARAM_RESET_CMD,
39+
CHIP_PARAM_WRITE1_CMD,
40+
CHIP_PARAM_WRITE2_CMD,
41+
CHIP_PARAM_ERASE1_CMD,
42+
CHIP_PARAM_ERASE2_CMD,
43+
CHIP_PARAM_STATUS_CMD,
44+
CHIP_PARAM_BB_MARK_OFF,
45+
CHIP_PARAM_ID1,
46+
CHIP_PARAM_ID2,
47+
CHIP_PARAM_ID3,
48+
CHIP_PARAM_ID4,
49+
CHIP_PARAM_ID5,
50+
CHIP_PARAM_NUM,
51+
};
52+
53+
class ChipInfo
54+
{
55+
protected:
56+
QByteArray halConf;
57+
58+
public:
59+
uint32_t id;
60+
QString name;
61+
uint32_t pageSize;
62+
uint32_t blockSize;
63+
uint32_t totalSize;
64+
uint32_t spareSize;
65+
uint32_t bbMarkOffset;
66+
uint32_t params[CHIP_PARAM_NUM];
67+
68+
virtual const QByteArray &getHalConf() = 0;
69+
};
70+
71+
#endif // CHIP_INFO_H

qt/cmd.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,6 @@ typedef struct __attribute__((__packed__))
8181
uint32_t totalSize;
8282
uint32_t spareSize;
8383
uint8_t bbMarkOff;
84-
uint8_t setupTime;
85-
uint8_t waitSetupTime;
86-
uint8_t holdSetupTime;
87-
uint8_t hiZSetupTime;
88-
uint8_t clrSetupTime;
89-
uint8_t arSetupTime;
90-
uint8_t rowCycles;
91-
uint8_t colCycles;
92-
uint8_t read1Cmd;
93-
uint8_t read2Cmd;
94-
uint8_t readSpareCmd;
95-
uint8_t readIdCmd;
96-
uint8_t resetCmd;
97-
uint8_t write1Cmd;
98-
uint8_t write2Cmd;
99-
uint8_t erase1Cmd;
100-
uint8_t erase2Cmd;
101-
uint8_t statusCmd;
10284
} ConfCmd;
10385

10486
enum

0 commit comments

Comments
 (0)