#include "custom_flash.h"
FLASH_EraseInitTypeDef EraseInitStruct;
//uint32_t PAGE_OFFSET = ((uint32_t)((4-1) * 0x0400));
uint32_t PAGE_NUMB = 127;




uint8_t *FLASH_Read(uint32_t add)
{
	return (uint8_t *)add;
}

void FLASH_Write_Data(void) //Куда записывать
{
	HAL_StatusTypeDef res;
	
	res = HAL_FLASH_Unlock();
	
	res = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, PAGE_NUMB, (uint32_t)(0x01234567));


	res = HAL_FLASH_Lock();
}




void FLASH_Erase(void) //Что стирать
{
	HAL_StatusTypeDef res;
	uint32_t PageError = 0x00;
	
	res = HAL_FLASH_Unlock();
	
	EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;// erase pages
	EraseInitStruct.PageAddress = NVIC_VectTab_FLASH;   //address
	EraseInitStruct.NbPages     = 0x01;// num of erased  pages
	
	HAL_FLASHEx_Erase(&EraseInitStruct, &PageError);
	res = HAL_FLASH_Lock();
}
