Skip to content

Commit 27e1e02

Browse files
committed
clean up
1 parent c23b49a commit 27e1e02

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

examples/Composite/mouse_external_flash/mouse_external_flash.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ int32_t msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
107107
{
108108
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
109109
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
110-
flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512);
111-
return bufsize;
110+
return flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512) ? bufsize : -1;
112111
}
113112

114113
// Callback invoked when received WRITE10 command.
@@ -118,8 +117,7 @@ int32_t msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize)
118117
{
119118
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
120119
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
121-
flash.writeBlocks(lba, buffer, bufsize/512);
122-
return bufsize;
120+
return flash.writeBlocks(lba, buffer, bufsize/512) ? bufsize : -1;
123121
}
124122

125123
// Callback invoked when WRITE10 command is completed (status received and accepted by host).

examples/MassStorage/msc_external_flash/msc_external_flash.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* This example demo how to expose on-board external Flash as USB Mass Storage.
55
* Following library is required
6-
* - SdFat https://github.com/greiman/SdFat
6+
* - SdFat https://github.com/adafruit/SdFat
77
* - Adafruit_SPIFlash https://github.com/adafruit/Adafruit_SPIFlash
88
*/
99

@@ -67,8 +67,7 @@ int32_t msc_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
6767
{
6868
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
6969
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
70-
flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512);
71-
return bufsize;
70+
return flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512) ? bufsize : -1;
7271
}
7372

7473
// Callback invoked when received WRITE10 command.
@@ -78,8 +77,7 @@ int32_t msc_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize)
7877
{
7978
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
8079
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
81-
flash.writeBlocks(lba, buffer, bufsize/512);
82-
return bufsize;
80+
return flash.writeBlocks(lba, buffer, bufsize/512) ? bufsize : -1;
8381
}
8482

8583
// Callback invoked when WRITE10 command is completed (status received and accepted by host).

examples/MassStorage/msc_external_flash_sdfat/msc_external_flash_sdfat.ino

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* This example exposes both external flash and SD card as mass storage
55
* using Adafruit_SPIFlash and SdFat Library
6-
* - SdFat https://github.com/greiman/SdFat
6+
* - SdFat https://github.com/adafruit/SdFat
77
* - Adafruit_SPIFlash https://github.com/adafruit/Adafruit_SPIFlash
88
*/
99

@@ -12,8 +12,6 @@
1212
#include "Adafruit_SPIFlash.h"
1313
#include "Adafruit_TinyUSB.h"
1414

15-
const int chipSelect = 10;
16-
1715
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
1816
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS, PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
1917
#else
@@ -26,9 +24,11 @@ const int chipSelect = 10;
2624

2725
Adafruit_SPIFlash flash(&flashTransport);
2826

29-
Adafruit_USBD_MSC usb_msc;
27+
const int chipSelect = 10;
3028
SdFat sd;
3129

30+
Adafruit_USBD_MSC usb_msc;
31+
3232
// the setup function runs once when you press reset or power the board
3333
void setup()
3434
{
@@ -103,8 +103,7 @@ int32_t external_flash_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
103103
{
104104
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
105105
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
106-
flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512);
107-
return bufsize;
106+
return flash.readBlocks(lba, (uint8_t*) buffer, bufsize/512) ? bufsize : -1;
108107
}
109108

110109
// Callback invoked when received WRITE10 command.
@@ -114,8 +113,7 @@ int32_t external_flash_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize
114113
{
115114
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
116115
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
117-
flash.writeBlocks(lba, buffer, bufsize/512);
118-
return bufsize;
116+
return flash.writeBlocks(lba, buffer, bufsize/512) ? bufsize : -1;
119117
}
120118

121119
// Callback invoked when WRITE10 command is completed (status received and accepted by host).

0 commit comments

Comments
 (0)