-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d152afb
commit 844736d
Showing
8 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "File.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// class File | ||
// { | ||
// public: | ||
// File(); | ||
// File(char const *filename, char const *mode); | ||
|
||
// public: | ||
// bool open(char const *filename, char const *mode); | ||
|
||
// //------------- Stream API -------------// | ||
// virtual size_t write(uint8_t ch) = 0; | ||
// virtual size_t write(uint8_t const *buf, size_t size) = 0; | ||
// size_t write(const char *str) | ||
// { | ||
// if (str == NULL) | ||
// return 0; | ||
// return write((const uint8_t *)str, strlen(str)); | ||
// } | ||
// size_t write(const char *buffer, size_t size) | ||
// { | ||
// return write((const uint8_t *)buffer, size); | ||
// } | ||
|
||
// virtual int read(void) = 0; | ||
// int read(void *buf, uint16_t nbyte); | ||
|
||
// virtual int peek(void) = 0; | ||
// virtual int available(void) = 0; | ||
// virtual void flush(void); | ||
|
||
// bool seek(uint32_t pos); | ||
// uint32_t position(void); | ||
// uint32_t size(void); | ||
|
||
// bool truncate(uint32_t pos); | ||
// bool truncate(void); | ||
|
||
// void close(void); | ||
|
||
// operator bool(void); | ||
|
||
// bool isOpen(void); | ||
// char const *name(void); | ||
|
||
// bool isDirectory(void); | ||
// File openNextFile(char const *mode = "r"); | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <FatFs.h> | ||
#include <STM32WLFS.h> | ||
|
||
uint16_t OSFS::startOfEEPROM = 1; | ||
uint16_t OSFS::endOfEEPROM = E2END; | ||
|
||
Stm32wlFS STM32WLFS; | ||
|
||
void OSFS::readNBytes(uint16_t address, unsigned int num, byte *output) | ||
{ | ||
for (uint16_t i = address; i < address + num; i++) { | ||
*output = EEPROM.read(i); | ||
output++; | ||
} | ||
} | ||
|
||
void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input) | ||
{ | ||
for (uint16_t i = address; i < address + num; i++) { | ||
EEPROM.write(i, *input); | ||
input++; | ||
} | ||
} | ||
|
||
bool Stm32wlFS::begin() | ||
{ | ||
OSFS::result r = OSFS::checkLibVersion(); | ||
if (r == OSFS::result::UNFORMATTED) { | ||
OSFS::format(); | ||
} | ||
return true; | ||
} | ||
|
||
void Stm32wlFS::mkdir(const char *dirname) {} | ||
|
||
bool Stm32wlFS::remove(const char *filename) {} | ||
|
||
bool Stm32wlFS::exists(const char *filename) | ||
{ | ||
return false; | ||
} | ||
|
||
File Stm32wlFS::open(const char *path, const char *mode, const bool create) | ||
{ | ||
return File.open(path, mode); | ||
} | ||
|
||
File Stm32wlFS::open(const String &path, const char *mode, const bool create) | ||
{ | ||
return open(path.c_str(), mode, create); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#ifndef Stm32wlFS_H | ||
#define Stm32wlFS_H | ||
|
||
#include "File.h" | ||
#include <EEPROM.h> | ||
#include <OSFS.h> | ||
|
||
extern uint16_t OSFS::startOfEEPROM; | ||
extern uint16_t OSFS::endOfEEPROM; | ||
|
||
#define FILE_READ "r" | ||
#define FILE_WRITE "w" | ||
#define FILE_APPEND "a" | ||
|
||
class Stm32wlFS | ||
{ | ||
public: | ||
bool begin(); | ||
void mkdir(const char *dirname); | ||
bool remove(const char *filename); | ||
bool exists(const char *filename); | ||
File open(char const *path, char const *mode = FILE_READ, const bool create = false); | ||
File open(const String &path, const char *mode = FILE_READ, const bool create = false); | ||
}; | ||
|
||
extern Stm32wlFS STM32WLFS; | ||
|
||
#endif // Stm32wlFS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters