Skip to content

Commit c97369c

Browse files
committed
spiFlash: only uses spi_put with distinct cmd parameter
1 parent e9b8dc5 commit c97369c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/spiFlash.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,13 @@ int SPIFlash::sector_erase(int addr)
129129

130130
uint8_t cmd = (addr <= 0xffffff) ? FLASH_SE : FLASH_4SE;
131131

132-
tx[len++] = cmd;
133132
if (cmd == FLASH_4SE)
134133
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 24));
135134
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 16));
136135
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 8));
137136
tx[len++] = static_cast<uint8_t>(0xff & (addr ));
138137

139-
_spi->spi_put(tx, NULL, len);
138+
_spi->spi_put(cmd, tx, NULL, len);
140139

141140
return 0;
142141
}
@@ -148,14 +147,13 @@ int SPIFlash::block32_erase(int addr)
148147

149148
uint8_t cmd = (addr <= 0xffffff) ? FLASH_BE32 : FLASH_4BE32;
150149

151-
tx[len++] = cmd;
152150
if (cmd == FLASH_4BE32)
153151
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 24));
154152
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 16));
155153
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 8));
156154
tx[len++] = static_cast<uint8_t>(0xff & (addr ));
157155

158-
_spi->spi_put(tx, NULL, len);
156+
_spi->spi_put(cmd, tx, NULL, len);
159157

160158
return 0;
161159
}
@@ -168,14 +166,13 @@ int SPIFlash::block64_erase(int addr)
168166

169167
uint8_t cmd = (addr <= 0xffffff) ? FLASH_BE64 : FLASH_4BE64;
170168

171-
tx[len++] = cmd;
172169
if (cmd == FLASH_4BE64)
173170
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 24));
174171
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 16));
175172
tx[len++] = static_cast<uint8_t>(0xff & (addr >> 8));
176173
tx[len++] = static_cast<uint8_t>(0xff & (addr ));
177174

178-
_spi->spi_put(tx, NULL, len);
175+
_spi->spi_put(cmd, tx, NULL, len);
179176

180177
return 0;
181178
}

0 commit comments

Comments
 (0)