1313#include " Adafruit_TinyUSB.h"
1414#include " Adafruit_SPIFlash.h"
1515
16- #if defined(__SAMD51__)
16+ #if defined(__SAMD51__) || defined(NRF52840_XXAA)
1717 // use QSPI libary for M4 series
18- #include " Adafruit_QSPI_GD25Q.h"
18+ #include " Adafruit_QSPI.h"
19+ #include " Adafruit_QSPI_Flash.h"
1920
20- Adafruit_QSPI_GD25Q flash;
21+ Adafruit_QSPI_Flash flash;
2122#else
2223 // Configuration of the flash chip pins and flash fatfs object.
2324 // You don't normally need to change these if using a Feather/Metro
@@ -42,12 +43,14 @@ Adafruit_USBD_MSC usb_msc;
4243// the setup function runs once when you press reset or power the board
4344void setup ()
4445{
45- #if defined(__SAMD51__)
46+ #if defined(__SAMD51__) || defined(NRF52840_XXAA)
4647 flash.begin ();
4748#else
4849 flash.begin (FLASH_TYPE);
4950#endif
5051
52+ pinMode (LED_BUILTIN, OUTPUT);
53+
5154 // Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively
5255 usb_msc.setID (" Adafruit" , " SPI Flash" , " 1.0" );
5356
@@ -68,6 +71,7 @@ void setup()
6871 Serial.println (" Adafruit TinyUSB Mass Storage SPI Flash example" );
6972 Serial.print (" Page size: " ); Serial.println (flash.pageSize ());
7073 Serial.print (" Page num : " ); Serial.println (flash.numPages ());
74+ Serial.print (" JEDEC ID: " ); Serial.println (flash.GetJEDECID (), HEX);
7175}
7276
7377void loop ()
@@ -127,12 +131,12 @@ void flash_cache_flush (void)
127131 if ( cache_addr == FLASH_CACHE_INVALID_ADDR ) return ;
128132
129133 // indicator
130- // ledOn (LED_BUILTIN);
134+ digitalWrite (LED_BUILTIN, HIGH );
131135
132136 flash.eraseSector (cache_addr/FLASH_CACHE_SIZE);
133137 flash.writeBuffer (cache_addr, cache_buf, FLASH_CACHE_SIZE);
134138
135- // ledOff (LED_BUILTIN);
139+ digitalWrite (LED_BUILTIN, LOW );
136140
137141 cache_addr = FLASH_CACHE_INVALID_ADDR;
138142}
0 commit comments