@@ -67,7 +67,9 @@ bool flash_changed = false;
67
67
68
68
// the setup function runs once when you press reset or power the board
69
69
void setup () {
70
+ #ifdef LED_BUILTIN
70
71
pinMode (LED_BUILTIN, OUTPUT);
72
+ #endif
71
73
Serial.begin (115200 );
72
74
73
75
// MSC with 2 Logical Units: LUN0: External Flash, LUN1: SDCard
@@ -234,11 +236,12 @@ int32_t sdcard_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
234
236
// Callback invoked when received WRITE10 command.
235
237
// Process data in buffer to disk's storage and
236
238
// return number of written bytes (must be multiple of block size)
237
- int32_t sdcard_write_cb (uint32_t lba, uint8_t * buffer, uint32_t bufsize)
238
- {
239
+ int32_t sdcard_write_cb (uint32_t lba, uint8_t * buffer, uint32_t bufsize) {
239
240
bool rc;
240
241
242
+ #ifdef LED_BUILTIN
241
243
digitalWrite (LED_BUILTIN, HIGH);
244
+ #endif
242
245
243
246
#if SD_FAT_VERSION >= 20000
244
247
rc = sd.card ()->writeSectors (lba, buffer, bufsize/512 );
@@ -264,7 +267,9 @@ void sdcard_flush_cb (void)
264
267
265
268
sd_changed = true ;
266
269
270
+ #ifdef LED_BUILTIN
267
271
digitalWrite (LED_BUILTIN, LOW);
272
+ #endif
268
273
}
269
274
270
275
#ifdef SDCARD_DETECT
@@ -299,8 +304,7 @@ bool sdcard_ready_callback(void)
299
304
// Callback invoked when received READ10 command.
300
305
// Copy disk's data to buffer (up to bufsize) and
301
306
// return number of copied bytes (must be multiple of block size)
302
- int32_t external_flash_read_cb (uint32_t lba, void * buffer, uint32_t bufsize)
303
- {
307
+ int32_t external_flash_read_cb (uint32_t lba, void * buffer, uint32_t bufsize) {
304
308
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
305
309
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
306
310
return flash.readBlocks (lba, (uint8_t *) buffer, bufsize/512 ) ? bufsize : -1 ;
@@ -309,9 +313,10 @@ int32_t external_flash_read_cb (uint32_t lba, void* buffer, uint32_t bufsize)
309
313
// Callback invoked when received WRITE10 command.
310
314
// Process data in buffer to disk's storage and
311
315
// return number of written bytes (must be multiple of block size)
312
- int32_t external_flash_write_cb (uint32_t lba, uint8_t * buffer, uint32_t bufsize)
313
- {
316
+ int32_t external_flash_write_cb (uint32_t lba, uint8_t * buffer, uint32_t bufsize) {
317
+ # ifdef LED_BUILTIN
314
318
digitalWrite (LED_BUILTIN, HIGH);
319
+ #endif
315
320
316
321
// Note: SPIFLash Bock API: readBlocks/writeBlocks/syncBlocks
317
322
// already include 4K sector caching internally. We don't need to cache it, yahhhh!!
@@ -320,14 +325,15 @@ int32_t external_flash_write_cb (uint32_t lba, uint8_t* buffer, uint32_t bufsize
320
325
321
326
// Callback invoked when WRITE10 command is completed (status received and accepted by host).
322
327
// used to flush any pending cache.
323
- void external_flash_flush_cb (void )
324
- {
328
+ void external_flash_flush_cb (void ) {
325
329
flash.syncBlocks ();
326
330
327
331
// clear file system's cache to force refresh
328
332
fatfs.cacheClear ();
329
333
330
334
flash_changed = true ;
331
335
336
+ #ifdef LED_BUILTIN
332
337
digitalWrite (LED_BUILTIN, LOW);
338
+ #endif
333
339
}
0 commit comments