Skip to content

Commit 9f8a26b

Browse files
committed
Opta: secure_qspi: simplify code
1 parent 2ece915 commit 9f8a26b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Diff for: variants/OPTA/variant.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,17 @@ static bool has_otp_info = false;
283283

284284
bool getSecureFlashData() {
285285
static OptaBoardInfo info;
286-
uint8_t temp_buf[sizeof(OptaBoardInfo) + 1];
287-
int ret = 0;
288-
static SecureQSPIFBlockDevice secure_root;
289-
secure_root.init();
290-
// read secure sector 2 ( address 1 << 13 )
291-
ret = secure_root.readSecure(temp_buf, (1 << 13), sizeof(temp_buf));
286+
char temp_buf[sizeof(OptaBoardInfo) + 1];
287+
int ret = QSPI_STATUS_OK;
288+
mbed::QSPI _qspi(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3, QSPI_FLASH1_SCK, QSPI_FLASH1_CSN, QSPIF_POLARITY_MODE_0);
289+
auto rxlen = sizeof(temp_buf);
290+
ret = _qspi.read(0x48, -1, 1 << 13, temp_buf, &rxlen);
292291
memcpy(&info, &temp_buf[1], sizeof(OptaBoardInfo));
293292
if (info.magic == OTP_QSPI_MAGIC) {
294293
_boardInfo = (uint8_t*)&info;
295294
has_otp_info = true;
296295
}
297-
secure_root.deinit();
298-
return ret == 0;
296+
return ret == QSPI_STATUS_OK;
299297
}
300298

301299
uint8_t* boardInfo() {

0 commit comments

Comments
 (0)