/*
 * internal_flash.h
 *
 *  Created on: 9 нояб. 2023 г.
 *      Author: seklyuts
 */

#ifndef SRC_INTERNAL_FLASH_H_
#define SRC_INTERNAL_FLASH_H_

//
// Bank0 Sector start addresses
//
//#define FlashStartAddress           0x80000
//#define Bzero_Sector0_start         0x80000
//#define Bzero_Sector1_start         0x82000
//#define Bzero_Sector2_start         0x84000
//#define Bzero_Sector3_start         0x86000
//#define Bzero_Sector4_start         0x88000
//#define Bzero_Sector5_start         0x90000
//#define Bzero_Sector6_start         0x98000
//#define Bzero_Sector7_start         0xA0000
//#define Bzero_Sector8_start         0xA8000
//#define Bzero_Sector9_start         0xB0000
//#define Bzero_Sector10_start        0xB8000
//#define Bzero_Sector11_start        0xBA000
//#define Bzero_Sector12_start        0xBC000
//#define Bzero_Sector13_start        0xBE000
//#define FlashEndAddress             0xBFFFF

//
// Sector length in number of 32bits
//
#define Sector16KB_u32length   0x1000
#define Sector64KB_u32length   0x4000

uint32_t internal_flash_FlashBankStartAddr(uint16_t bank);
uint16_t Internal_flash_Sektor_Addr(uint32_t Addr_start);

void Internal_flash_Init(void);


uint16_t Internal_flash_Erase(uint32_t Addr_start);
uint16_t Internal_flash_Program_AutoECC(uint32_t Addr_start, uint16_t Num);
uint16_t Internal_flash_Program_DataOnlyECCOnly(uint32_t Addr_start, uint16_t Num);

uint16_t Internal_flash_lib_ProgramUsingAutoECC(uint32_t Addr_start, uint16_t Num);
uint16_t Internal_flash_lib_ProgramUsingDataOnlyECCOnly(uint32_t Addr_start, uint16_t Num);
uint16_t Internal_flash_lib_ProgramUsingDataAndECC(uint32_t Addr_start, uint16_t Num);
uint16_t Internal_flash_lib_EraseSector(uint16_t oNewFlashBank);

#endif /* SRC_INTERNAL_FLASH_H_ */
