/*
 * flash_page.h
 *
 *  Created on: May 1, 2022
 *      Author: xavie
 */

#ifndef INC_FLASH_PAGE_H_
#define INC_FLASH_PAGE_H_

#include "stm32g4xx_hal.h"

#define LAGRANGE_SIZE			4

typedef struct {
	uint32_t versionID;			// Data version
	float waterConsumption;		// Water consumption in Liter
	uint16_t probeLevelBaseFrequency;	// Calibration value for water level probe
	float probeSlope;
	float LagrangeX[LAGRANGE_SIZE];
	float LagrangeY[LAGRANGE_SIZE];
} SYS_MEM_STRUCT;


#define __IO volatile
#define FLASH_USER_START_ADDR	0x0801F800

uint32_t Flash_Write_Data (uint32_t StartPageAddress, __IO uint64_t * DATA_32, uint16_t bsize);
void Flash_Read_Data (uint32_t StartPageAddress, __IO uint32_t * DATA_32, uint16_t bsize);


/********************  FLASH_Error_Codes   ***********************//*
HAL_FLASH_ERROR_NONE      0x00U  // No error
HAL_FLASH_ERROR_PROG      0x01U  // Programming error
HAL_FLASH_ERROR_WRP       0x02U  // Write protection error
HAL_FLASH_ERROR_OPTV      0x04U  // Option validity error
*/

#endif /* INC_FLASH_PAGE_H_ */
