remove external examples
This commit is contained in:
1 parent
f2e7ef6fc4
commit
a122cef5a8
3 files changed
-278
No files matched your search
@@ -1,49 +0,0 @@
|
||||
/*********************************************************************
|
||||
This is an example for our nRF52 based Bluefruit LE modules
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
MIT license, check LICENSE for more information
|
||||
All text above, and the splash screen below must be included in
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <Bluefruit_FileIO.h>
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while ( !Serial ) delay(10); // for nrf52840 with native usb
|
||||
|
||||
Serial.println("ExternalFS Format Example");
|
||||
Serial.println();
|
||||
|
||||
// Wait for user input to run.
|
||||
Serial.println("This sketch will destroy all of your data in External Flash!");
|
||||
Serial.print("Enter any keys to continue:");
|
||||
while ( !Serial.available() ) delay(10);
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
// Initialize Internal File System
|
||||
ExternalFS.begin();
|
||||
|
||||
Serial.print("Formating ...");
|
||||
|
||||
// Format without erase
|
||||
// Pass true for full external flash erasing (take time)
|
||||
ExternalFS.format(false);
|
||||
|
||||
Serial.println("Done");
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/*********************************************************************
|
||||
This is an example for our nRF52 based Bluefruit LE modules
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
MIT license, check LICENSE for more information
|
||||
All text above, and the splash screen below must be included in
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include "flash/flash_qspi.h"
|
||||
#include <bluefruit.h>
|
||||
#include "Adafruit_TinyUSB.h"
|
||||
#include <Bluefruit_FileIO.h>
|
||||
|
||||
/* This example print out External Flash contents up to
|
||||
* MAX_LEVEL level of directories (including root)
|
||||
* WARNING: This example uses recursive call to print out directory tree
|
||||
* be extra careful, high number of MAX_LEVEL can cause memory overflow
|
||||
*/
|
||||
#define MAX_LEVEL 2
|
||||
|
||||
Adafruit_USBD_MSC usbmsc;
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup()
|
||||
{
|
||||
// block count and size are defined in variant.h
|
||||
usbmsc.setCapacity(USB_MSC_BLOCK_COUNT, USB_MSC_BLOCK_SIZE);
|
||||
usbmsc.setCallback(fl_read_cb, fl_write_cb, fl_flush_cb);
|
||||
usbmsc.begin();
|
||||
|
||||
Serial.begin(115200);
|
||||
while ( !Serial ) delay(10); // for nrf52840 with native usb
|
||||
|
||||
Serial.println("ExternalFS List Files Example");
|
||||
|
||||
// Initialize Internal File System
|
||||
ExternalFS.begin();
|
||||
|
||||
// Print whole directory tree of root whose level is 0
|
||||
printTreeDir("/", 0);
|
||||
|
||||
// Print prompt
|
||||
Serial.println();
|
||||
Serial.println("Enter anything to print directory tree (again):");
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop()
|
||||
{
|
||||
if ( Serial.available() )
|
||||
{
|
||||
delay(10); // delay for all input arrived
|
||||
while( Serial.available() ) Serial.read();
|
||||
|
||||
printTreeDir("/", 0);
|
||||
|
||||
// Print prompt
|
||||
Serial.println();
|
||||
Serial.println("Enter anything to print directory tree (again):");
|
||||
}
|
||||
}
|
||||
|
||||
int32_t fl_read_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) lun;
|
||||
return flash_qspi_read(buffer, lba * USB_MSC_BLOCK_SIZE + offset, bufsize);
|
||||
}
|
||||
|
||||
int32_t fl_write_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
uint32_t wrcount = flash_qspi_write(lba * USB_MSC_BLOCK_SIZE + offset, buffer, bufsize);
|
||||
|
||||
// update ExternalFS cache since USB write it out of its awareness
|
||||
ExternalFS.updateCache(lba, buffer, bufsize);
|
||||
|
||||
return wrcount;
|
||||
}
|
||||
|
||||
void fl_flush_cb (uint8_t lun)
|
||||
{
|
||||
(void) lun;
|
||||
flash_qspi_flush();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Print out whole directory tree of an folder
|
||||
until the level reach MAX_LEVEL
|
||||
|
||||
@note Recursive call
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void printTreeDir(const char* cwd, uint8_t level)
|
||||
{
|
||||
// Open the input folder
|
||||
File dir(cwd, FILE_READ, ExternalFS);
|
||||
|
||||
// Print root
|
||||
if (level == 0) Serial.println("root");
|
||||
|
||||
// File within folder
|
||||
File item(ExternalFS);
|
||||
|
||||
// Loop through the directory
|
||||
while( (item = dir.openNextFile(FILE_READ)) )
|
||||
{
|
||||
// Indentation according to dir level
|
||||
for(int i=0; i<level; i++) Serial.print("| ");
|
||||
|
||||
Serial.print("|_ ");
|
||||
Serial.print( item.name() );
|
||||
|
||||
if ( item.isDirectory() )
|
||||
{
|
||||
Serial.println("/");
|
||||
|
||||
// ATTENTION recursive call to print sub folder with level+1 !!!!!!!!
|
||||
// High number of MAX_LEVEL can cause memory overflow
|
||||
if ( level < MAX_LEVEL )
|
||||
{
|
||||
printTreeDir( item.path(), level+1 );
|
||||
}
|
||||
}else
|
||||
{
|
||||
// Print file size starting from position 30
|
||||
int pos = level*3 + 3 + strlen(item.name());
|
||||
|
||||
// Print padding
|
||||
for (int i=pos; i<30; i++) Serial.print(' ');
|
||||
|
||||
// Print at least one extra space in case current position > 50
|
||||
Serial.print(' ');
|
||||
|
||||
Serial.print( item.size() );
|
||||
Serial.println( " Bytes");
|
||||
}
|
||||
|
||||
item.close();
|
||||
}
|
||||
|
||||
dir.close();
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*********************************************************************
|
||||
This is an example for our nRF52 based Bluefruit LE modules
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
MIT license, check LICENSE for more information
|
||||
All text above, and the splash screen below must be included in
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <Bluefruit_FileIO.h>
|
||||
|
||||
#define FILENAME "/adafruit.txt"
|
||||
|
||||
#define CONTENTS "Bluefruit Feather52's file contents"
|
||||
|
||||
File file (ExternalFS);
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while ( !Serial ) delay(10); // for nrf52840 with native usb
|
||||
|
||||
Serial.println("External Read Write File Example");
|
||||
Serial.println();
|
||||
|
||||
// Wait for user input to run. Otherwise the code will
|
||||
// always run immediately after flash and create the FILENAME in advance
|
||||
Serial.print("Enter to any keys to continue:");
|
||||
while ( !Serial.available() )
|
||||
{
|
||||
delay(1);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
// Initialize Internal File System
|
||||
ExternalFS.begin();
|
||||
|
||||
file.open(FILENAME, FILE_READ);
|
||||
|
||||
// file existed
|
||||
if ( file )
|
||||
{
|
||||
Serial.println(FILENAME " file exists");
|
||||
|
||||
uint32_t readlen;
|
||||
char buffer[64] = { 0 };
|
||||
readlen = file.read(buffer, sizeof(buffer));
|
||||
|
||||
buffer[readlen] = 0;
|
||||
Serial.println(buffer);
|
||||
file.close();
|
||||
}else
|
||||
{
|
||||
Serial.print("Open " FILENAME " file to write ... ");
|
||||
|
||||
if( file.open(FILENAME, FILE_WRITE) )
|
||||
{
|
||||
Serial.println("OK");
|
||||
file.write(CONTENTS, strlen(CONTENTS));
|
||||
file.close();
|
||||
}else
|
||||
{
|
||||
Serial.println("Failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
Reference in new issue
Block a user