make internal fs work with or without SD enable
This commit is contained in:
1 parent
c8f4c79dd1
commit
ba0af40808
3 files changed
+27
-20
No files matched your search
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "flash_nrf52.h"
|
||||
#include "flash_cache.h"
|
||||
#include "nrf_sdm.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "rtos.h"
|
||||
|
||||
@@ -109,10 +110,16 @@ bool fal_erase (uint32_t addr)
|
||||
}
|
||||
VERIFY_STATUS(err);
|
||||
|
||||
// wait until complete
|
||||
xSemaphoreTake(_sem, portMAX_DELAY);
|
||||
VERIFY(_op_result == NRF_EVT_FLASH_OPERATION_SUCCESS);
|
||||
// wait for async event if SD is enabled
|
||||
uint8_t sd_en = 0;
|
||||
(void) sd_softdevice_is_enabled(&sd_en);
|
||||
|
||||
if ( sd_en )
|
||||
{
|
||||
xSemaphoreTake(_sem, portMAX_DELAY);
|
||||
VERIFY(_op_result == NRF_EVT_FLASH_OPERATION_SUCCESS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -126,9 +133,15 @@ static uint32_t fal_program (uint32_t dst, void const * src, uint32_t len)
|
||||
}
|
||||
VERIFY_STATUS(err);
|
||||
|
||||
// wait until complete
|
||||
xSemaphoreTake(_sem, portMAX_DELAY);
|
||||
VERIFY(_op_result == NRF_EVT_FLASH_OPERATION_SUCCESS);
|
||||
// wait for async event if SD is enabled
|
||||
uint8_t sd_en = 0;
|
||||
(void) sd_softdevice_is_enabled(&sd_en);
|
||||
|
||||
if ( sd_en )
|
||||
{
|
||||
xSemaphoreTake(_sem, portMAX_DELAY);
|
||||
VERIFY(_op_result == NRF_EVT_FLASH_OPERATION_SUCCESS);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,8 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println("InternalFS 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();
|
||||
// Initialize Internal File System
|
||||
InternalFS.begin();
|
||||
|
||||
// Print whole directory tree of root whose level is 0
|
||||
printTreeDir("/", 0);
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
#include <bluefruit.h>
|
||||
#include <FileIO.h>
|
||||
|
||||
#define FILENAME "/adafruit.txt"
|
||||
#define FILENAME "/testdir1/ada2.txt"
|
||||
|
||||
#define CONTENTS "Bluefruit Feather52's file contents"
|
||||
|
||||
File file(InternalFS);
|
||||
@@ -38,12 +39,8 @@ void setup()
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
// 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();
|
||||
// Initialize Internal File System
|
||||
InternalFS.begin();
|
||||
|
||||
file.open(FILENAME, FILE_READ);
|
||||
|
||||
@@ -61,6 +58,7 @@ void setup()
|
||||
file.close();
|
||||
}else
|
||||
{
|
||||
InternalFS.mkdir("/testdir1");
|
||||
Serial.print("Open " FILENAME " file to write ... ");
|
||||
|
||||
if( file.open(FILENAME, FILE_WRITE) )
|
||||
@@ -70,7 +68,7 @@ void setup()
|
||||
file.close();
|
||||
}else
|
||||
{
|
||||
Serial.println("Failed to open file to write");
|
||||
Serial.println("Failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user