From c82257c9badd64a95ea88cd7465ee5ed900bc6ed Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Wed, 5 May 2021 06:25:00 +0200 Subject: [PATCH] spiFlash: introduce jedec_id --- src/spiFlash.cpp | 12 ++++++------ src/spiFlash.hpp | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/spiFlash.cpp b/src/spiFlash.cpp index 4a717a2..32e0cdc 100644 --- a/src/spiFlash.cpp +++ b/src/spiFlash.cpp @@ -185,21 +185,21 @@ void SPIFlash::read_id() bool has_edid = false; _spi->spi_put(0x9F, NULL, rx, 4); - int d = 0; + _jedec_id = 0; for (int i=0; i < 4; i++) { - d = d << 8; - d |= (0x00ff & (int)rx[i]); + _jedec_id = _jedec_id << 8; + _jedec_id |= (0x00ff & (int)rx[i]); if (_verbose > 0) printf("%x ", rx[i]); } if (_verbose > 0) - printf("read %x\n", d); + printf("read %x\n", _jedec_id); /* read extented */ - if ((d & 0xff) != 0) { + if ((_jedec_id & 0xff) != 0) { has_edid = true; - len += (d & 0x0ff); + len += (_jedec_id & 0x0ff); _spi->spi_put(0x9F, NULL, rx, len); } diff --git a/src/spiFlash.hpp b/src/spiFlash.hpp index 3e5a0a0..34294cc 100644 --- a/src/spiFlash.hpp +++ b/src/spiFlash.hpp @@ -49,6 +49,7 @@ class SPIFlash { private: SPIInterface *_spi; int8_t _verbose; + uint32_t _jedec_id; /**< CHIP ID */ }; #endif