From b54057e54d49c2d2371392d4b3e8f45235023452 Mon Sep 17 00:00:00 2001 From: nekuneko Date: Mon, 7 Nov 2022 00:48:47 +0100 Subject: [PATCH 1/4] Added support for ISSI IS25LP016D SPI flash --- src/Adafruit_SPIFlashBase.cpp | 2 +- src/flash_devices.h | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Adafruit_SPIFlashBase.cpp b/src/Adafruit_SPIFlashBase.cpp index 7b12671..0ce3df6 100644 --- a/src/Adafruit_SPIFlashBase.cpp +++ b/src/Adafruit_SPIFlashBase.cpp @@ -99,7 +99,7 @@ static const SPIFlash_Device_t possible_devices[] = { MB85RS64V, MB85RS1MT, MB85RS2MTA, MB85RS4MT, // Other common flash devices - W25Q16JV_IQ, W25Q32JV_IQ, AT25SF041, AT25DF081A}; + W25Q16JV_IQ, W25Q32JV_IQ, AT25SF041, AT25DF081A, IS25LP016D}; /// Flash device list count enum { diff --git a/src/flash_devices.h b/src/flash_devices.h index af35403..af2f94f 100644 --- a/src/flash_devices.h +++ b/src/flash_devices.h @@ -30,7 +30,7 @@ #include typedef struct { - uint32_t total_size; + uint32_t total_size; // in bytes uint16_t start_up_time_us; // Three response bytes to 0x9f JEDEC ID command. @@ -143,6 +143,19 @@ typedef struct { .single_status_byte = false, .is_fram = false, \ } +// Settings for the ISSI IS25LP016D 16Mib / 2MiB SPI flash. +// Datasheet: https://www.issi.com/WW/pdf/25LP-WP016D.pdf +#define IS25LP016D \ + { \ + .total_size = 2097152, /* 2MiB */ .start_up_time_us = 5000, \ + .manufacturer_id = 0x9d, .memory_type = 0x60, .capacity = 0x15, \ + .max_clock_speed_mhz = 133, .quad_enable_bit_mask = 0x40, \ + .has_sector_protection = false, .supports_fast_read = true, \ + .supports_qspi = true, .supports_qspi_writes = true, \ + .write_status_register_split = false, .single_status_byte = true, \ + .is_fram = false, \ + } + // https://www.fujitsu.com/uk/Images/MB85RS64V.pdf // RDID has continuation code: 04-7F-03-02 #define MB85RS64V \ From 993a2591c2481d199f345403c2a1ff9ca08de0cc Mon Sep 17 00:00:00 2001 From: Neku Date: Tue, 15 Nov 2022 10:22:26 +0100 Subject: [PATCH 2/4] Changed KB to KiB --- examples/SdFat_Flash_and_SDcard/SdFat_Flash_and_SDcard.ino | 2 +- examples/SdFat_format/SdFat_format.ino | 2 +- examples/flash_info/flash_info.ino | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/SdFat_Flash_and_SDcard/SdFat_Flash_and_SDcard.ino b/examples/SdFat_Flash_and_SDcard/SdFat_Flash_and_SDcard.ino index 8a7f8ee..a209887 100644 --- a/examples/SdFat_Flash_and_SDcard/SdFat_Flash_and_SDcard.ino +++ b/examples/SdFat_Flash_and_SDcard/SdFat_Flash_and_SDcard.ino @@ -39,7 +39,7 @@ void setup() { Serial.println(onboardFlash.getJEDECID(), HEX); Serial.print("Flash size: "); Serial.print(onboardFlash.size() / 1024); - Serial.println(" KB"); + Serial.println(" KiB"); Serial.print("Starting up SD Card..."); if (!onboardSdCard.begin(getSDCardPin())) { Serial.println("No card found (is one inserted?)"); diff --git a/examples/SdFat_format/SdFat_format.ino b/examples/SdFat_format/SdFat_format.ino index 83e0ef4..4f8401b 100644 --- a/examples/SdFat_format/SdFat_format.ino +++ b/examples/SdFat_format/SdFat_format.ino @@ -104,7 +104,7 @@ void setup() { } Serial.print(F("Flash chip JEDEC ID: 0x")); Serial.println(flash.getJEDECID(), HEX); - Serial.print(F("Flash size: ")); Serial.print(flash.size() / 1024); Serial.println(F(" KB")); + Serial.print(F("Flash size: ")); Serial.print(flash.size() / 1024); Serial.println(F(" KiB")); // Uncomment to flash LED while writing to flash // flash.setIndicator(LED_BUILTIN, true); diff --git a/examples/flash_info/flash_info.ino b/examples/flash_info/flash_info.ino index 30e7804..b4e77ab 100644 --- a/examples/flash_info/flash_info.ino +++ b/examples/flash_info/flash_info.ino @@ -76,7 +76,7 @@ void setup() { Serial.println(flash.getJEDECID(), HEX); Serial.print("Flash size: "); Serial.print(flash.size() / 1024); - Serial.println(" KB"); + Serial.println(" KiB"); } void loop() { From 4a0e7154ddf743203f4125228285d087f99fd020 Mon Sep 17 00:00:00 2001 From: Neku Date: Tue, 15 Nov 2022 10:23:25 +0100 Subject: [PATCH 3/4] Implemented EXTERNAL_FLASH_DEVICES checking Also removed IS25LP016D flash from Adafruit boards' possible_devices. --- src/Adafruit_SPIFlashBase.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Adafruit_SPIFlashBase.cpp b/src/Adafruit_SPIFlashBase.cpp index 0ce3df6..e66875d 100644 --- a/src/Adafruit_SPIFlashBase.cpp +++ b/src/Adafruit_SPIFlashBase.cpp @@ -87,19 +87,24 @@ bool Adafruit_SPIFlashBase::begin(SPIFlash_Device_t const *flash_devs, #else +#if defined (EXTERNAL_FLASH_DEVICES) +/// List of all possible flash devices defined by board's variant.h + static const SPIFlash_Device_t possible_devices[] = { EXTERNAL_FLASH_DEVICES }; +#else /// List of all possible flash devices used by Adafruit boards -static const SPIFlash_Device_t possible_devices[] = { - // Main devices used in current Adafruit products - GD25Q16C, GD25Q32C, GD25Q64C, S25FL116K, S25FL216K, + static const SPIFlash_Device_t possible_devices[] = { + // Main devices used in current Adafruit products + GD25Q16C, GD25Q32C, GD25Q64C, S25FL116K, S25FL216K, - // Only a handful of production run - W25Q16FW, W25Q64JV_IQ, + // Only a handful of production run + W25Q16FW, W25Q64JV_IQ, - // Fujitsu FRAM - MB85RS64V, MB85RS1MT, MB85RS2MTA, MB85RS4MT, + // Fujitsu FRAM + MB85RS64V, MB85RS1MT, MB85RS2MTA, MB85RS4MT, - // Other common flash devices - W25Q16JV_IQ, W25Q32JV_IQ, AT25SF041, AT25DF081A, IS25LP016D}; + // Other common flash devices + W25Q16JV_IQ, W25Q32JV_IQ, AT25SF041, AT25DF081A}; +#endif /* if defined (EXTERNAL_FLASH_DEVICES) */ /// Flash device list count enum { From 09ccb83b2b1e30c155eda79df227ee065d04aa0a Mon Sep 17 00:00:00 2001 From: Neku Date: Tue, 15 Nov 2022 10:26:43 +0100 Subject: [PATCH 4/4] clang-format passed --- src/Adafruit_SPIFlashBase.cpp | 22 +++++++++++----------- src/flash_devices.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Adafruit_SPIFlashBase.cpp b/src/Adafruit_SPIFlashBase.cpp index e66875d..2b6c755 100644 --- a/src/Adafruit_SPIFlashBase.cpp +++ b/src/Adafruit_SPIFlashBase.cpp @@ -87,23 +87,23 @@ bool Adafruit_SPIFlashBase::begin(SPIFlash_Device_t const *flash_devs, #else -#if defined (EXTERNAL_FLASH_DEVICES) +#if defined(EXTERNAL_FLASH_DEVICES) /// List of all possible flash devices defined by board's variant.h - static const SPIFlash_Device_t possible_devices[] = { EXTERNAL_FLASH_DEVICES }; +static const SPIFlash_Device_t possible_devices[] = {EXTERNAL_FLASH_DEVICES}; #else /// List of all possible flash devices used by Adafruit boards - static const SPIFlash_Device_t possible_devices[] = { - // Main devices used in current Adafruit products - GD25Q16C, GD25Q32C, GD25Q64C, S25FL116K, S25FL216K, +static const SPIFlash_Device_t possible_devices[] = { + // Main devices used in current Adafruit products + GD25Q16C, GD25Q32C, GD25Q64C, S25FL116K, S25FL216K, - // Only a handful of production run - W25Q16FW, W25Q64JV_IQ, + // Only a handful of production run + W25Q16FW, W25Q64JV_IQ, - // Fujitsu FRAM - MB85RS64V, MB85RS1MT, MB85RS2MTA, MB85RS4MT, + // Fujitsu FRAM + MB85RS64V, MB85RS1MT, MB85RS2MTA, MB85RS4MT, - // Other common flash devices - W25Q16JV_IQ, W25Q32JV_IQ, AT25SF041, AT25DF081A}; + // Other common flash devices + W25Q16JV_IQ, W25Q32JV_IQ, AT25SF041, AT25DF081A}; #endif /* if defined (EXTERNAL_FLASH_DEVICES) */ /// Flash device list count diff --git a/src/flash_devices.h b/src/flash_devices.h index af2f94f..c2035d9 100644 --- a/src/flash_devices.h +++ b/src/flash_devices.h @@ -143,7 +143,7 @@ typedef struct { .single_status_byte = false, .is_fram = false, \ } -// Settings for the ISSI IS25LP016D 16Mib / 2MiB SPI flash. +// Settings for the ISSI IS25LP016D 16Mib / 2MiB SPI flash. // Datasheet: https://www.issi.com/WW/pdf/25LP-WP016D.pdf #define IS25LP016D \ { \