Минимальный функционал

Files at this revision

API Documentation at this revision

Comitter:
nikmaos
Date:
Thu Jun 25 08:28:04 2020 +0000
Commit message:
minimal func

Changed in this revision

flashwrapper.cpp Show annotated file Show diff for this revision Revisions of this file
flashwrapper.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flashwrapper.cpp	Thu Jun 25 08:28:04 2020 +0000
@@ -0,0 +1,25 @@
+/*
+ * flashwrapper.c
+ *
+ *      Author: spookee
+ */
+
+#include "stm32f4xx_hal.h"
+
+#include "flashwrapper.h"
+
+
+uint32_t flashRead(uint32_t address) {
+    return (*(uint32_t*)(address+START_ADRESS));
+}
+
+void flashWrite(uint32_t address, uint32_t *p_data, uint16_t size) {	
+	HAL_FLASH_Unlock();
+	__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR);
+	FLASH_Erase_Sector(FLASH_SECTOR_12, VOLTAGE_RANGE_3);
+	for (int i = 0; i < size; i++) {
+		HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, START_ADRESS+address + i*4, p_data[i]);
+	}
+	HAL_FLASH_Lock();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flashwrapper.h	Thu Jun 25 08:28:04 2020 +0000
@@ -0,0 +1,18 @@
+/*
+ * flashwrapper.h
+ *
+ *  Created on: 25 дек. 2018 г.
+ *      Author: spookee
+ */
+
+#pragma once
+
+#include "stdint.h"
+//начальный адрес сектора 12 банка 2
+#define START_ADRESS 0x08100000
+
+uint32_t flashRead(uint32_t address);
+void flashWrite(uint32_t address, uint32_t *p_data, uint16_t size);
+
+
+