implement Nffs format() function
This commit is contained in:
1 parent
ec89ed68bf
commit
c9ac58478c
3 files changed
+26
-1
No files matched your search
@@ -12,6 +12,7 @@
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <bluefruit.h>
|
||||
#include <NewtNffs.h>
|
||||
|
||||
/* This example print out NFFS content up to
|
||||
@@ -33,6 +34,11 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println("Nffs List Files Example");
|
||||
|
||||
// Bluefruit module must be initialized for Nffs to work
|
||||
// Since Bluefruit's SOC event handling task is required for flash operation
|
||||
Bluefruit.begin();
|
||||
|
||||
// Initialize Nffs
|
||||
Nffs.begin();
|
||||
|
||||
// Print whole directory tree of root whose level is 0
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <bluefruit.h>
|
||||
#include <NewtNffs.h>
|
||||
|
||||
#define FILENAME "/adafruit.txt"
|
||||
@@ -25,6 +26,11 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println("Nffs Read Write File Example");
|
||||
|
||||
// Bluefruit module must be initialized for Nffs to work
|
||||
// Since Bluefruit's SOC event handling task is required for flash operation
|
||||
Bluefruit.begin();
|
||||
|
||||
// Initialize Nffs
|
||||
Nffs.begin();
|
||||
|
||||
file.open(FILENAME, FS_ACCESS_READ);
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "hal/hal_flash.h"
|
||||
|
||||
#define NFFS_AREA_MAX (7)
|
||||
#define NFFS_AREA_MAX 7
|
||||
|
||||
NewtNffs Nffs;
|
||||
|
||||
@@ -54,6 +54,8 @@ bool NewtNffs::begin(void)
|
||||
// Follow code in nffs_pkg_init()
|
||||
if (_initialized) return true;
|
||||
|
||||
_initialized = true;
|
||||
|
||||
// Init flash
|
||||
hal_flash_init();
|
||||
|
||||
@@ -76,6 +78,8 @@ bool NewtNffs::begin(void)
|
||||
// If not formatted, format it
|
||||
if (FS_ECORRUPT == errnum)
|
||||
{
|
||||
PRINT_MESS("formatting nffs");
|
||||
|
||||
errnum = nffs_format(descs);
|
||||
VERIFY_STATUS( errnum, false );
|
||||
}
|
||||
@@ -85,7 +89,16 @@ bool NewtNffs::begin(void)
|
||||
|
||||
bool NewtNffs::format(void)
|
||||
{
|
||||
struct nffs_area_desc descs[NFFS_AREA_MAX + 1];
|
||||
int cnt = NFFS_AREA_MAX;
|
||||
|
||||
errnum = nffs_misc_desc_from_flash_area( MYNEWT_VAL(NFFS_FLASH_AREA), &cnt, descs);
|
||||
VERIFY_STATUS( errnum, false );
|
||||
|
||||
errnum = nffs_format(descs);
|
||||
VERIFY_STATUS( errnum, false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NewtNffs::mkdir(const char* path)
|
||||
|
||||
Reference in new issue
Block a user