Skip to content

Commit f95f330

Browse files
committed
update msc external flash example
1 parent 0a82119 commit f95f330

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# Adafruit_TinyUSB_Arduino
2-
Arduino IDE support for TinyUSB stack
2+
TinyUSB stack library for Arduino IDE. This library works with core platform that support TinyUSB stack, typically you will see folder `Adafruit_TinyUSB_Core` inside core folder. Support platform are:
3+
4+
- <https://github.com/adafruit/Adafruit_nRF52_Arduino>
5+
- <https://github.com/adafruit/ArduinoCore-samd> `TinyUSB` must be selected in `Tools->USB Stack`
6+
7+
In addition to CDC that provided by the core, this library provide platform-independent MSC, HID
8+
9+
More document to write ...

examples/MassStorage/msc_external_flash/msc_external_flash.ino

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
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
4344
void 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

7377
void 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

Comments
 (0)