summaryrefslogtreecommitdiffstats
path: root/tmk_core/common/chibios/flash_stm32.c
diff options
context:
space:
mode:
authorTakuya Urakawa <urkwtky@gmail.com>2018-10-19 06:33:23 +0200
committerJack Humbert <jack.humb@gmail.com>2018-10-19 06:33:23 +0200
commitf4094930a393ec3dc597e06e95cd3365e3f8cb97 (patch)
tree33d53e5b898bf645965dfc99f842cf1998b857d4 /tmk_core/common/chibios/flash_stm32.c
parent8efe8b498d344928fb55ea78a289d9eb32145e48 (diff)
downloadqmk_firmware-f4094930a393ec3dc597e06e95cd3365e3f8cb97.tar.gz
qmk_firmware-f4094930a393ec3dc597e06e95cd3365e3f8cb97.tar.xz
stm32f1xx EEPROM emulation (#3914)
* * Add stm32f1xx EEPROM emulation * Fix eeprom update compare bug Squashed commit of the following: commit b8f248ae08cec0cd81ecbb8854d9b39221d4d573 Author: hsgw <urkwtky@gmail.com> Date: Sat Sep 15 19:13:48 2018 +0900 fix EEPROM_update wrong compare commit d4ed4e6ea864e967a3e17f7edee4b0c3b4a25541 Author: hsgw <urkwtky@gmail.com> Date: Sat Sep 15 17:43:47 2018 +0900 eeprom fix initialization define commit b61aa7c04d70c64df3416d63e5da08b73b6053af Author: hsgw <urkwtky@gmail.com> Date: Sat Sep 15 16:33:40 2018 +0900 maybe working * Fix FLASH_KEY defines
Diffstat (limited to 'tmk_core/common/chibios/flash_stm32.c')
-rwxr-xr-xtmk_core/common/chibios/flash_stm32.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tmk_core/common/chibios/flash_stm32.c b/tmk_core/common/chibios/flash_stm32.c
index e7199ac7b..273593484 100755
--- a/tmk_core/common/chibios/flash_stm32.c
+++ b/tmk_core/common/chibios/flash_stm32.c
@@ -10,19 +10,27 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * This files are free to use from https://github.com/rogerclarkmelbourne/Arduino_STM32 and
+ * This files are free to use from https://github.com/rogerclarkmelbourne/Arduino_STM32 and
* https://github.com/leaflabs/libmaple
*
* Modifications for QMK and STM32F303 by Yiancar
*/
-#define STM32F303xC
+#if defined(EEPROM_EMU_STM32F303xC)
+ #define STM32F303xC
+ #include "stm32f3xx.h"
+#elif defined(EEPROM_EMU_STM32F103xB)
+ #define STM32F103xB
+ #include "stm32f1xx.h"
+#else
+ #error "not implemented."
+#endif
-#include "stm32f3xx.h"
#include "flash_stm32.h"
-#define FLASH_KEY1 ((uint32_t)0x45670123)
-#define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
+#if defined(EEPROM_EMU_STM32F103xB)
+ #define FLASH_SR_WRPERR FLASH_SR_WRPRTERR
+#endif
/* Delay definition */
#define EraseTimeout ((uint32_t)0x00000FFF)
@@ -71,7 +79,7 @@ FLASH_Status FLASH_GetStatus(void)
* FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
*/
FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout)
-{
+{
FLASH_Status status;
/* Check for the Flash Status */
@@ -102,7 +110,7 @@ FLASH_Status FLASH_ErasePage(uint32_t Page_Address)
ASSERT(IS_FLASH_ADDRESS(Page_Address));
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation(EraseTimeout);
-
+
if(status == FLASH_COMPLETE)
{
/* if the previous operation is completed, proceed to erase the page */
@@ -128,7 +136,7 @@ FLASH_Status FLASH_ErasePage(uint32_t Page_Address)
* @param Address: specifies the address to be programmed.
* @param Data: specifies the data to be programmed.
* @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
- * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
*/
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
{