Skip to content

Commit 0176c82

Browse files
committed
Moved parallel flash configuration to its class
1 parent 77ebbd4 commit 0176c82

18 files changed

+959
-588
lines changed

qt/chip_db.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ QString ChipDb::getChipName(int chipIndex)
99
{
1010
ChipInfo *ci = getChipInfo(chipIndex);
1111

12-
return ci ? ci->name : QString();
12+
return ci ? ci->getName() : QString();
1313
}
1414

1515
int ChipDb::setChipName(int chipIndex, const QString &name)
@@ -19,7 +19,7 @@ int ChipDb::setChipName(int chipIndex, const QString &name)
1919
if (!ci)
2020
return -1;
2121

22-
ci->name = name;
22+
ci->setName(name);
2323

2424
return 0;
2525
}
@@ -28,7 +28,7 @@ uint32_t ChipDb::getPageSize(int chipIndex)
2828
{
2929
ChipInfo *ci = getChipInfo(chipIndex);
3030

31-
return ci ? ci->pageSize : 0;
31+
return ci ? ci->getPageSize() : 0;
3232
}
3333

3434
int ChipDb::setPageSize(int chipIndex, uint32_t pageSize)
@@ -38,7 +38,7 @@ int ChipDb::setPageSize(int chipIndex, uint32_t pageSize)
3838
if (!ci)
3939
return -1;
4040

41-
ci->pageSize = pageSize;
41+
ci->setPageSize(pageSize);
4242

4343
return 0;
4444
}
@@ -47,7 +47,7 @@ uint32_t ChipDb::getBlockSize(int chipIndex)
4747
{
4848
ChipInfo *ci = getChipInfo(chipIndex);
4949

50-
return ci ? ci->blockSize : 0;
50+
return ci ? ci->getBlockSize() : 0;
5151
}
5252

5353
int ChipDb::setBlockSize(int chipIndex, uint32_t blockSize)
@@ -57,7 +57,7 @@ int ChipDb::setBlockSize(int chipIndex, uint32_t blockSize)
5757
if (!ci)
5858
return -1;
5959

60-
ci->blockSize = blockSize;
60+
ci->setBlockSize(blockSize);
6161

6262
return 0;
6363
}
@@ -66,7 +66,7 @@ uint32_t ChipDb::getTotalSize(int chipIndex)
6666
{
6767
ChipInfo *ci = getChipInfo(chipIndex);
6868

69-
return ci ? ci->totalSize : 0;
69+
return ci ? ci->getTotalSize() : 0;
7070
}
7171

7272
int ChipDb::setTotalSize(int chipIndex, uint32_t totalSize)
@@ -76,7 +76,7 @@ int ChipDb::setTotalSize(int chipIndex, uint32_t totalSize)
7676
if (!ci)
7777
return -1;
7878

79-
ci->totalSize = totalSize;
79+
ci->setTotalSize(totalSize);
8080

8181
return 0;
8282
}
@@ -85,7 +85,7 @@ uint32_t ChipDb::getSpareSize(int chipIndex)
8585
{
8686
ChipInfo *ci = getChipInfo(chipIndex);
8787

88-
return ci ? ci->spareSize : 0;
88+
return ci ? ci->getSpareSize() : 0;
8989
}
9090

9191
int ChipDb::setSpareSize(int chipIndex, uint32_t spareSize)
@@ -95,7 +95,7 @@ int ChipDb::setSpareSize(int chipIndex, uint32_t spareSize)
9595
if (!ci)
9696
return -1;
9797

98-
ci->spareSize = spareSize;
98+
ci->setSpareSize(spareSize);
9999

100100
return 0;
101101
}
@@ -104,7 +104,7 @@ uint8_t ChipDb::getBBMarkOffset(int chipIndex)
104104
{
105105
ChipInfo *ci = getChipInfo(chipIndex);
106106

107-
return ci ? ci->bbMarkOffset : 0;
107+
return ci ? ci->getBBMarkOffset() : 0;
108108
}
109109

110110
int ChipDb::setBBMarkOffset(int chipIndex, uint8_t bbMarkOffset)
@@ -114,7 +114,7 @@ int ChipDb::setBBMarkOffset(int chipIndex, uint8_t bbMarkOffset)
114114
if (!ci)
115115
return -1;
116116

117-
ci->bbMarkOffset = bbMarkOffset;
117+
ci->setBBMarkOffset(bbMarkOffset);
118118

119119
return 0;
120120
}

qt/chip_info.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
#include "chip_info.h"
7+
8+
ChipInfo::ChipInfo()
9+
{
10+
hal = CHIP_HAL_LAST;
11+
}
12+
13+
ChipInfo::~ChipInfo()
14+
{
15+
}
16+
17+
const QString &ChipInfo::getName()
18+
{
19+
return name;
20+
}
21+
22+
void ChipInfo::setName(const QString &name)
23+
{
24+
this->name = name;
25+
}
26+
27+
uint32_t ChipInfo::getPageSize()
28+
{
29+
return pageSize;
30+
}
31+
32+
void ChipInfo::setPageSize(uint32_t pageSize)
33+
{
34+
this->pageSize = pageSize;
35+
}
36+
37+
uint32_t ChipInfo::getBlockSize()
38+
{
39+
return blockSize;
40+
}
41+
42+
void ChipInfo::setBlockSize(uint32_t blockSize)
43+
{
44+
this->blockSize = blockSize;
45+
}
46+
47+
uint32_t ChipInfo::getTotalSize()
48+
{
49+
return totalSize;
50+
}
51+
52+
void ChipInfo::setTotalSize(uint32_t totalSize)
53+
{
54+
this->totalSize = totalSize;
55+
}
56+
57+
uint32_t ChipInfo::getSpareSize()
58+
{
59+
return spareSize;
60+
}
61+
62+
void ChipInfo::setSpareSize(uint32_t spareSize)
63+
{
64+
this->spareSize = spareSize;
65+
}
66+
67+
uint8_t ChipInfo::getBBMarkOffset()
68+
{
69+
return bbMarkOffset;
70+
}
71+
72+
void ChipInfo::setBBMarkOffset(uint8_t offset)
73+
{
74+
this->bbMarkOffset = offset;
75+
}
76+
77+
uint8_t ChipInfo::getHal()
78+
{
79+
return hal;
80+
}

qt/chip_info.h

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,40 @@
88

99
#include <QString>
1010

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-
enum CHIP_HAL
54-
{
55-
CHIP_HAL_PARALLEL = 0,
56-
CHIP_HAL_SPI = 1
57-
};
58-
5911
class ChipInfo
6012
{
6113
protected:
62-
QByteArray halConf;
14+
enum ChipHal
15+
{
16+
CHIP_HAL_PARALLEL = 0,
17+
CHIP_HAL_SPI = 1,
18+
CHIP_HAL_LAST
19+
};
6320

64-
public:
65-
uint32_t id;
6621
QString name;
6722
uint32_t pageSize;
6823
uint32_t blockSize;
6924
uint32_t totalSize;
7025
uint32_t spareSize;
7126
uint8_t bbMarkOffset;
72-
uint32_t params[CHIP_PARAM_NUM];
7327
uint32_t hal;
7428

29+
public:
30+
ChipInfo();
31+
virtual ~ChipInfo();
32+
const QString &getName();
33+
void setName(const QString &name);
34+
uint32_t getPageSize();
35+
void setPageSize(uint32_t pageSize);
36+
uint32_t getBlockSize();
37+
void setBlockSize(uint32_t blockSize);
38+
uint32_t getTotalSize();
39+
void setTotalSize(uint32_t totalSize);
40+
uint32_t getSpareSize();
41+
void setSpareSize(uint32_t spareSize);
42+
uint8_t getBBMarkOffset();
43+
void setBBMarkOffset(uint8_t offset);
44+
uint8_t getHal();
7545
virtual const QByteArray &getHalConf() = 0;
7646
};
7747

qt/nando_spi_chip_db.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# name, page size, block size, total size, spare size, tCS, tCLS, tALS, tCLR, tAR, tWP, tRP, tDS, tCH, tCLH, tALH, tWC, tRC, tREA, row cycles, col. cycles, read 1 cycle com., read 2 cycle com., read spare com., read ID com., reset com., write 1 cycle com., write 2 cycle com., erase 1 cycle com., erase 2 cycle com., status com., bad block mark off., ID1, ID2, ID3, ID4, ID5
2-
AT45DB021D, 264, 2112, 270336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 35, -, -, -
1+
# name, page size, block size, total size, ID1, ID2, ID3, ID4, ID5
2+
AT45DB021D, 264, 2112, 270336, 31, 35, -, -, -

0 commit comments

Comments
 (0)