13
13
#include " Adafruit_TinyUSB.h"
14
14
#include " Adafruit_SPIFlash.h"
15
15
16
- #if defined(__SAMD51__)
16
+ #if defined(__SAMD51__) || defined(NRF52840_XXAA)
17
17
// use QSPI libary for M4 series
18
- #include " Adafruit_QSPI_GD25Q.h"
18
+ #include " Adafruit_QSPI.h"
19
+ #include " Adafruit_QSPI_Flash.h"
19
20
20
- Adafruit_QSPI_GD25Q flash;
21
+ Adafruit_QSPI_Flash flash;
21
22
#else
22
23
// Configuration of the flash chip pins and flash fatfs object.
23
24
// You don't normally need to change these if using a Feather/Metro
@@ -42,12 +43,14 @@ Adafruit_USBD_MSC usb_msc;
42
43
// the setup function runs once when you press reset or power the board
43
44
void setup ()
44
45
{
45
- #if defined(__SAMD51__)
46
+ #if defined(__SAMD51__) || defined(NRF52840_XXAA)
46
47
flash.begin ();
47
48
#else
48
49
flash.begin (FLASH_TYPE);
49
50
#endif
50
51
52
+ pinMode (LED_BUILTIN, OUTPUT);
53
+
51
54
// Set disk vendor id, product id and revision with string up to 8, 16, 4 characters respectively
52
55
usb_msc.setID (" Adafruit" , " SPI Flash" , " 1.0" );
53
56
@@ -68,6 +71,7 @@ void setup()
68
71
Serial.println (" Adafruit TinyUSB Mass Storage SPI Flash example" );
69
72
Serial.print (" Page size: " ); Serial.println (flash.pageSize ());
70
73
Serial.print (" Page num : " ); Serial.println (flash.numPages ());
74
+ Serial.print (" JEDEC ID: " ); Serial.println (flash.GetJEDECID (), HEX);
71
75
}
72
76
73
77
void loop ()
@@ -127,12 +131,12 @@ void flash_cache_flush (void)
127
131
if ( cache_addr == FLASH_CACHE_INVALID_ADDR ) return ;
128
132
129
133
// indicator
130
- // ledOn (LED_BUILTIN);
134
+ digitalWrite (LED_BUILTIN, HIGH );
131
135
132
136
flash.eraseSector (cache_addr/FLASH_CACHE_SIZE);
133
137
flash.writeBuffer (cache_addr, cache_buf, FLASH_CACHE_SIZE);
134
138
135
- // ledOff (LED_BUILTIN);
139
+ digitalWrite (LED_BUILTIN, LOW );
136
140
137
141
cache_addr = FLASH_CACHE_INVALID_ADDR;
138
142
}
0 commit comments