From cb76b66cd63631147dc89574b1ca01125a495858 Mon Sep 17 00:00:00 2001
From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com>
Date: Thu, 24 Nov 2022 19:51:30 -0500
Subject: [PATCH] Update `README.md` and use `allman` astyle
---
CONTRIBUTING.md | 28 ++++++--
changelog.md | 6 ++
examples/EEPROM_CRC/EEPROM_CRC.ino | 8 ++-
examples/EEPROM_Clear/EEPROM_Clear.ino | 17 +++--
examples/EEPROM_get/EEPROM_get.ino | 16 +++--
.../EEPROM_iteration/EEPROM_iteration.ino | 12 ++--
examples/EEPROM_put/EEPROM_put.ino | 13 ++--
examples/EEPROM_read/EEPROM_read.ino | 10 +--
examples/EEPROM_update/EEPROM_update.ino | 15 ++--
examples/EEPROM_write/EEPROM_write.ino | 7 +-
examples/EmulateEEPROM/EmulateEEPROM.ino | 9 ++-
.../FlashStoreAndRetrieve.ino | 7 +-
.../multiFileProject/multiFileProject.cpp | 13 ++--
examples/multiFileProject/multiFileProject.h | 2 +-
.../multiFileProject/multiFileProject.ino | 13 ++--
platformio/platformio.ini | 2 +
src/FlashStorage_STM32F1.h | 14 ++--
src/FlashStorage_STM32F1_Impl.h | 32 ++++-----
utils/astyle_library.conf | 70 +++++++++++++++++++
utils/restyle.sh | 6 ++
20 files changed, 222 insertions(+), 78 deletions(-)
create mode 100644 utils/astyle_library.conf
create mode 100644 utils/restyle.sh
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7c9cfdc..86c2511 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
-* Board Core Version (e.g. Arduino STM32 core v2.2.0, etc.)
+* Board Core Version (e.g. Arduino STM32 core v2.3.0, etc.)
* Board and Configuration
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
@@ -28,13 +28,13 @@ Please ensure to specify the following:
```
Arduino IDE version: 1.8.19
-Arduino STM32 core v2.2.0
+Arduino STM32 core v2.3.0
Board: STM32F103C8T6, 64KB Flash
OS: Ubuntu 20.04 LTS
-Linux Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
+Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
-The board couldn't autoreconnect to Local Blynk Server after router power recycling.
+I encountered a crash while using this library
Steps to reproduce:
1. ...
@@ -43,12 +43,32 @@ Steps to reproduce:
4. ...
```
+---
+
### Sending Feature Requests
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/FlashStorage_STM32F1/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
+---
+
### Sending Pull Requests
Pull Requests with changes and fixes are also welcome!
+
+Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
+
+1. Change directory to the library GitHub
+
+```
+xy@xy-Inspiron-3593:~$ cd Arduino/xy/FlashStorage_STM32F1_GitHub/
+xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_STM32F1_GitHub$
+```
+
+2. Issue astyle command
+
+```
+xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_STM32F1_GitHub$ bash utils/restyle.sh
+```
+
diff --git a/changelog.md b/changelog.md
index e4b9269..1ed69e3 100644
--- a/changelog.md
+++ b/changelog.md
@@ -6,6 +6,12 @@
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/FlashStorage_STM32F1.svg)](http://github.com/khoih-prog/FlashStorage_STM32F1/issues)
+
+
+
+
+
+
---
---
diff --git a/examples/EEPROM_CRC/EEPROM_CRC.ino b/examples/EEPROM_CRC/EEPROM_CRC.ino
index b339397..af513b8 100644
--- a/examples/EEPROM_CRC/EEPROM_CRC.ino
+++ b/examples/EEPROM_CRC/EEPROM_CRC.ino
@@ -41,7 +41,7 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include
-unsigned long eeprom_crc()
+unsigned long eeprom_crc()
{
const unsigned long crc_table[16] =
{
@@ -66,11 +66,13 @@ unsigned long eeprom_crc()
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_CRC on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_CRC on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
//Print length of data to run CRC on.
@@ -85,7 +87,7 @@ void setup()
Serial.print("Done!");
}
-void loop()
+void loop()
{
/* Empty loop */
}
diff --git a/examples/EEPROM_Clear/EEPROM_Clear.ino b/examples/EEPROM_Clear/EEPROM_Clear.ino
index c077ef5..7eed443 100644
--- a/examples/EEPROM_Clear/EEPROM_Clear.ino
+++ b/examples/EEPROM_Clear/EEPROM_Clear.ino
@@ -33,16 +33,18 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include
-void setup()
+void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_Clear on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_Clear on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
-
+
// initialize the LED pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
@@ -53,8 +55,8 @@ void setup()
EEPROM.init();
unsigned long startMillis = millis();
-
- for (int i = 0 ; i < EEPROM.length() ; i++)
+
+ for (int i = 0 ; i < EEPROM.length() ; i++)
{
EEPROM.write(i, 0);
}
@@ -63,13 +65,14 @@ void setup()
// The time spent can be very short (5-25ms) if the EEPROM is not dirty.
// For Seeed XIAO, the time is around 22 / 42 ms for 2048 / 4096 bytes of emulated-EEPROM
- Serial.print("Done clearing emulated EEPROM. Time spent (ms) = "); Serial.println(millis() - startMillis);
+ Serial.print("Done clearing emulated EEPROM. Time spent (ms) = ");
+ Serial.println(millis() - startMillis);
// turn the LED on when we're done
digitalWrite(LED_BUILTIN, HIGH);
}
-void loop()
+void loop()
{
/** Empty loop. **/
}
diff --git a/examples/EEPROM_get/EEPROM_get.ino b/examples/EEPROM_get/EEPROM_get.ino
index 6e7e10b..ca6b874 100644
--- a/examples/EEPROM_get/EEPROM_get.ino
+++ b/examples/EEPROM_get/EEPROM_get.ino
@@ -60,15 +60,19 @@ struct MyObject
void printMyObject(MyObject &customVar)
{
Serial.println("===============");
- Serial.print("Field1: "); Serial.println(customVar.field1, 5);
- Serial.print("Field2: "); Serial.println(customVar.field2);
- Serial.print("Name: "); Serial.println(customVar.name);
+ Serial.print("Field1: ");
+ Serial.println(customVar.field1, 5);
+ Serial.print("Field2: ");
+ Serial.println(customVar.field2);
+ Serial.print("Name: ");
+ Serial.println(customVar.name);
Serial.println("===============");
}
void secondTest()
{
- int eeAddress = START_ADDRESS + sizeof(WRITTEN_SIGNATURE) + sizeof(float); //Move address to the next byte after float 'f'.
+ int eeAddress = START_ADDRESS + sizeof(WRITTEN_SIGNATURE) + sizeof(
+ float); //Move address to the next byte after float 'f'.
MyObject customVar; //Variable to store custom object read from EEPROM.
EEPROM.get(eeAddress, customVar);
@@ -80,11 +84,13 @@ void secondTest()
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_get on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_get on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
diff --git a/examples/EEPROM_iteration/EEPROM_iteration.ino b/examples/EEPROM_iteration/EEPROM_iteration.ino
index 8d2b9f9..3a2739e 100644
--- a/examples/EEPROM_iteration/EEPROM_iteration.ino
+++ b/examples/EEPROM_iteration/EEPROM_iteration.ino
@@ -46,11 +46,13 @@
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_iteration on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_iteration on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
@@ -62,7 +64,7 @@ void setup()
Iterate the EEPROM using a for loop.
***/
- for (int index = 0 ; index < EEPROM.length() ; index++)
+ for (int index = 0 ; index < EEPROM.length() ; index++)
{
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
@@ -78,7 +80,7 @@ void setup()
int index = 0;
- while (index < EEPROM.length())
+ while (index < EEPROM.length())
{
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
@@ -95,7 +97,7 @@ void setup()
int idx = 0; //Used 'idx' to avoid name conflict with 'index' above.
- do
+ do
{
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
@@ -105,7 +107,7 @@ void setup()
EEPROM.commit();
Serial.println("Done do-while loop");
-
+
} //End of setup function.
void loop() {}
diff --git a/examples/EEPROM_put/EEPROM_put.ino b/examples/EEPROM_put/EEPROM_put.ino
index 6d46716..060302b 100644
--- a/examples/EEPROM_put/EEPROM_put.ino
+++ b/examples/EEPROM_put/EEPROM_put.ino
@@ -58,20 +58,25 @@ struct MyObject
void printMyObject(MyObject &customVar)
{
Serial.println("===============");
- Serial.print("Field1: "); Serial.println(customVar.field1, 5);
- Serial.print("Field2: "); Serial.println(customVar.field2);
- Serial.print("Name: "); Serial.println(customVar.name);
+ Serial.print("Field1: ");
+ Serial.println(customVar.field1, 5);
+ Serial.print("Field2: ");
+ Serial.println(customVar.field2);
+ Serial.print("Name: ");
+ Serial.println(customVar.name);
Serial.println("===============");
}
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_put on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_put on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
diff --git a/examples/EEPROM_read/EEPROM_read.ino b/examples/EEPROM_read/EEPROM_read.ino
index a274e50..a255325 100644
--- a/examples/EEPROM_read/EEPROM_read.ino
+++ b/examples/EEPROM_read/EEPROM_read.ino
@@ -46,11 +46,13 @@ byte value;
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_read on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_read on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
@@ -59,7 +61,7 @@ void setup()
EEPROM.init();
}
-void loop()
+void loop()
{
// read a byte from the current address of the EEPROM
value = EEPROM.read(address);
@@ -68,8 +70,8 @@ void loop()
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();
-
- if (++address == EEPROM.length())
+
+ if (++address == EEPROM.length())
{
address = 0;
}
diff --git a/examples/EEPROM_update/EEPROM_update.ino b/examples/EEPROM_update/EEPROM_update.ino
index 27e0238..0c51d9c 100644
--- a/examples/EEPROM_update/EEPROM_update.ino
+++ b/examples/EEPROM_update/EEPROM_update.ino
@@ -51,11 +51,13 @@ int address = 0;
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_read on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_read on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
@@ -67,12 +69,12 @@ void setup()
void loop()
{
unsigned long startMillis = millis();
-
- for (int i = 0 ; i < EEPROM.length() ; i++)
+
+ for (int i = 0 ; i < EEPROM.length() ; i++)
{
/***
The function EEPROM.update(address, val) is equivalent to the following:
-
+
if( EEPROM.read(address) != val )
{
EEPROM.write(address, val);
@@ -80,10 +82,11 @@ void loop()
***/
EEPROM.update(i, (uint8_t) analogRead(0));
}
-
+
EEPROM.commit();
- Serial.print("Done updating emulated EEPROM. Time spent (ms) = "); Serial.println(millis() - startMillis);
+ Serial.print("Done updating emulated EEPROM. Time spent (ms) = ");
+ Serial.println(millis() - startMillis);
delay(60000);
}
diff --git a/examples/EEPROM_write/EEPROM_write.ino b/examples/EEPROM_write/EEPROM_write.ino
index 70273f5..b149b6d 100644
--- a/examples/EEPROM_write/EEPROM_write.ino
+++ b/examples/EEPROM_write/EEPROM_write.ino
@@ -45,11 +45,13 @@ int address = 0;
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EEPROM_write on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EEPROM_write on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
@@ -79,7 +81,8 @@ void loop()
EEPROM.commit();
- Serial.print("Done writing emulated EEPROM. Time spent (ms) = "); Serial.println(millis() - startMillis);
+ Serial.print("Done writing emulated EEPROM. Time spent (ms) = ");
+ Serial.println(millis() - startMillis);
delay(60000);
}
diff --git a/examples/EmulateEEPROM/EmulateEEPROM.ino b/examples/EmulateEEPROM/EmulateEEPROM.ino
index 65d88f4..da8f6de 100644
--- a/examples/EmulateEEPROM/EmulateEEPROM.ino
+++ b/examples/EmulateEEPROM/EmulateEEPROM.ino
@@ -40,11 +40,13 @@ const int WRITTEN_SIGNATURE = 0xBEEFDEED;
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart EmulatedEEPROM on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart EmulatedEEPROM on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
@@ -87,7 +89,8 @@ void setup()
{
EEPROM.get(0, signature);
- Serial.print("EEPROM has been written.Signature = 0x"); Serial.println(signature, HEX);
+ Serial.print("EEPROM has been written.Signature = 0x");
+ Serial.println(signature, HEX);
Serial.println("Here is the content of the next 16 bytes:");
@@ -108,7 +111,7 @@ void setup()
Serial.println("CommitASAP not set. Need commit()");
EEPROM.commit();
}
-
+
Serial.println("Done clearing signature in emulated EEPROM. You can reset now");
}
}
diff --git a/examples/FlashStoreAndRetrieve/FlashStoreAndRetrieve.ino b/examples/FlashStoreAndRetrieve/FlashStoreAndRetrieve.ino
index d4ef118..f02e9ec 100644
--- a/examples/FlashStoreAndRetrieve/FlashStoreAndRetrieve.ino
+++ b/examples/FlashStoreAndRetrieve/FlashStoreAndRetrieve.ino
@@ -39,11 +39,13 @@
void setup()
{
Serial.begin(115200);
+
while (!Serial);
delay(200);
- Serial.print(F("\nStart FlashStoreAndRetrieve on ")); Serial.println(BOARD_NAME);
+ Serial.print(F("\nStart FlashStoreAndRetrieve on "));
+ Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
Serial.print("EEPROM length: ");
@@ -58,7 +60,8 @@ void setup()
EEPROM.get(address, number);
// Print the current number on the serial monitor
- Serial.print("Number = 0x"); Serial.println(number, HEX);
+ Serial.print("Number = 0x");
+ Serial.println(number, HEX);
// Save into emulated-EEPROM the number increased by 1 for the next run of the sketch
EEPROM.put(address, (int) (number + 1));
diff --git a/examples/multiFileProject/multiFileProject.cpp b/examples/multiFileProject/multiFileProject.cpp
index 7942089..8978c6c 100644
--- a/examples/multiFileProject/multiFileProject.cpp
+++ b/examples/multiFileProject/multiFileProject.cpp
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
multiFileProject.cpp
-
+
For STM32F1 using Flash emulated-EEPROM
The FlashStorage_STM32F1 library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
@@ -36,7 +36,10 @@ void testEEPROM()
EEPROM.get(storedAddress + sizeof(signature), owner);
// Say hello to the returning user!
- Serial.print("Hi "); Serial.print(owner.name); Serial.print(" "); Serial.print(owner.surname);
+ Serial.print("Hi ");
+ Serial.print(owner.name);
+ Serial.print(" ");
+ Serial.print(owner.surname);
Serial.println(", nice to see you again :-)");
Serial.println("Clearing WRITTEN_SIGNATURE for next try");
@@ -73,8 +76,10 @@ void testEEPROM()
}
// Print a confirmation of the data inserted.
- Serial.print("<< Your name: "); Serial.print(owner.name);
- Serial.print(". Your surname: "); Serial.print(owner.surname);
+ Serial.print("<< Your name: ");
+ Serial.print(owner.name);
+ Serial.print(". Your surname: ");
+ Serial.print(owner.surname);
Serial.println(" >> have been saved. Thank you!");
Serial.println("You can reset to check emulated-EEPROM data retention.");
}
diff --git a/examples/multiFileProject/multiFileProject.h b/examples/multiFileProject/multiFileProject.h
index e5d50f5..a020787 100644
--- a/examples/multiFileProject/multiFileProject.h
+++ b/examples/multiFileProject/multiFileProject.h
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
multiFileProject.h
-
+
For STM32F1 using Flash emulated-EEPROM
The FlashStorage_STM32F1 library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
diff --git a/examples/multiFileProject/multiFileProject.ino b/examples/multiFileProject/multiFileProject.ino
index bb954e8..ecfe109 100644
--- a/examples/multiFileProject/multiFileProject.ino
+++ b/examples/multiFileProject/multiFileProject.ino
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
multiFileProject.ino
-
+
For STM32F1 using Flash emulated-EEPROM
The FlashStorage_STM32F1 library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
@@ -18,7 +18,7 @@
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#if !( defined(STM32F1xx) || defined(STM32F3xx) )
- #error This code is intended to run on STM32F1/F3 platform! Please check your Tools->Board setting.
+ #error This code is intended to run on STM32F1/F3 platform! Please check your Tools->Board setting.
#endif
#define FLASH_STORAGE_STM32F1_VERSION_MIN_TARGET "FlashStorage_STM32F1 v1.1.0"
@@ -29,26 +29,29 @@
#include "multiFileProject.h"
-void setup()
+void setup()
{
Serial.begin(115200);
+
while (!Serial);
-
+
Serial.println("\nStart multiFileProject");
Serial.println(FLASH_STORAGE_STM32F1_VERSION);
#if defined(FLASH_STORAGE_STM32F1_VERSION_MIN)
+
if (FLASH_STORAGE_STM32F1_VERSION_INT < FLASH_STORAGE_STM32F1_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(FLASH_STORAGE_STM32F1_VERSION_MIN_TARGET);
}
+
#endif
testEEPROM();
}
-void loop()
+void loop()
{
// put your main code here, to run repeatedly:
}
diff --git a/platformio/platformio.ini b/platformio/platformio.ini
index b25bbc3..f40be72 100644
--- a/platformio/platformio.ini
+++ b/platformio/platformio.ini
@@ -28,6 +28,8 @@ upload_speed = 921600
; Checks for the compatibility with frameworks and dev/platforms
lib_compat_mode = strict
+lib_ldf_mode = chain+
+;lib_ldf_mode = deep+
lib_deps =
; PlatformIO 4.x
diff --git a/src/FlashStorage_STM32F1.h b/src/FlashStorage_STM32F1.h
index bac07e8..e6b5ac5 100644
--- a/src/FlashStorage_STM32F1.h
+++ b/src/FlashStorage_STM32F1.h
@@ -9,19 +9,19 @@
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_STM32F1
Licensed under LGPLv3 license
-
+
Orginally written by A. Christian
-
+
Copyright (c) 2015-2016 Arduino LLC. All right reserved.
Copyright (c) 2021 Khoi Hoang.
-
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
+
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along with this library.
+ You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
-
+
Version: 1.1.0
Version Modified By Date Comments
@@ -38,5 +38,5 @@
#include
#include
-
+
#endif //#ifndef FlashStorage_STM32F1_h
diff --git a/src/FlashStorage_STM32F1_Impl.h b/src/FlashStorage_STM32F1_Impl.h
index 94e289a..fc2be83 100644
--- a/src/FlashStorage_STM32F1_Impl.h
+++ b/src/FlashStorage_STM32F1_Impl.h
@@ -9,19 +9,19 @@
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_STM32F1
Licensed under LGPLv3 license
-
+
Orginally written by A. Christian
-
+
Copyright (c) 2015-2016 Arduino LLC. All right reserved.
Copyright (c) 2021 Khoi Hoang.
-
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
+
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along with this library.
+ You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
-
+
Version: 1.1.0
Version Modified By Date Comments
@@ -54,13 +54,13 @@ void FlashClass::write(const volatile void *flash_ptr, const void *data)
{
uint16_t *AddressPtr;
uint16_t *valuePtr;
-
+
AddressPtr = (uint16_t *)flash_ptr;
valuePtr = (uint16_t *)data;
-
- // we're using 16 bit words here while flash_size in bytes
+
+ // we're using 16 bit words here while flash_size in bytes
uint32_t size = flash_size / 2;
-
+
while (size)
{
// unlock the flash
@@ -70,7 +70,7 @@ void FlashClass::write(const volatile void *flash_ptr, const void *data)
FLASH->KEYR = FLASH_KEY2;
FLASH->CR &= ~(1 << 1); // ensure PER is low
FLASH->CR |= (1 << 0); // set the PG bit
-
+
*(AddressPtr) = *(valuePtr);
while (FLASH->SR & (1 << 0)); // wait while busy
@@ -116,13 +116,13 @@ void FlashClass::read(const volatile void *flash_ptr, void *data)
{
uint16_t *AddressPtr;
uint16_t *valuePtr;
-
+
AddressPtr = (uint16_t *) flash_ptr;
valuePtr = (uint16_t *) data;
-
- // we're using 16 bit words here while flash_size in bytes
+
+ // we're using 16 bit words here while flash_size in bytes
uint32_t size = flash_size / 2;
-
+
while (size)
{
*((uint16_t *)valuePtr) = *((uint16_t *)AddressPtr);
@@ -130,7 +130,7 @@ void FlashClass::read(const volatile void *flash_ptr, void *data)
valuePtr++;
AddressPtr++;
size--;
- }
+ }
}
#endif //#ifndef FlashStorage_STM32F1_Impl_hpp
diff --git a/utils/astyle_library.conf b/utils/astyle_library.conf
new file mode 100644
index 0000000..8a73bc2
--- /dev/null
+++ b/utils/astyle_library.conf
@@ -0,0 +1,70 @@
+# Code formatting rules for Arduino libraries, modified from for KH libraries:
+#
+# https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf
+#
+
+# astyle --style=allman -s2 -t2 -C -S -xW -Y -M120 -f -p -xg -H -xb -c --xC120 -xL *.h *.cpp *.ino
+
+--mode=c
+--lineend=linux
+--style=allman
+
+# -r or -R
+#--recursive
+
+# -c => Converts tabs into spaces
+convert-tabs
+
+# -s2 => 2 spaces indentation
+--indent=spaces=2
+
+# -t2 => tab =2 spaces
+#--indent=tab=2
+
+# -C
+--indent-classes
+
+# -S
+--indent-switches
+
+# -xW
+--indent-preproc-block
+
+# -Y => indent classes, switches (and cases), comments starting at column 1
+--indent-col1-comments
+
+# -M120 => maximum of 120 spaces to indent a continuation line
+--max-continuation-indent=120
+
+# -xC120 => max‑code‑length will break a line if the code exceeds # characters
+--max-code-length=120
+
+# -f =>
+--break-blocks
+
+# -p => put a space around operators
+--pad-oper
+
+# -xg => Insert space padding after commas
+--pad-comma
+
+# -H => put a space after if/for/while
+pad-header
+
+# -xb => Break one line headers (e.g. if/for/while)
+--break-one-line-headers
+
+# -c => Converts tabs into spaces
+#--convert-tabs
+
+# if you like one-liners, keep them
+#keep-one-line-statements
+
+# -xV
+--attach-closing-while
+
+#unpad-paren
+
+# -xp
+remove-comment-prefix
+
diff --git a/utils/restyle.sh b/utils/restyle.sh
new file mode 100644
index 0000000..bcd846f
--- /dev/null
+++ b/utils/restyle.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+for dir in . ; do
+ find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.ino" \) -exec astyle --suffix=none --options=./utils/astyle_library.conf \{\} \;
+done
+