104 lines
4.7 KiB
C
104 lines
4.7 KiB
C
/**
|
|
******************************************************************************
|
|
* @file flash_if.h
|
|
* @author AMG Energy Solution Team
|
|
* @version V1.0.0
|
|
* @date 07-Feb-2022
|
|
* @brief This file provides all the headers of the flash memory functions.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
|
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
*
|
|
* <h2><center>© COPYRIGHT 2022 AMG</center></h2>
|
|
******************************************************************************
|
|
*/
|
|
|
|
/** @addtogroup mBMS2
|
|
* @{
|
|
*/
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef __FLASH_IF_H
|
|
#define __FLASH_IF_H
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "hc32_ddl.h"
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
typedef struct
|
|
{
|
|
uint32_t AppFileSize;
|
|
uint8_t BootVer[4];
|
|
uint8_t AppVer[4];
|
|
uint8_t FileName[30];
|
|
uint8_t BootUpdate;
|
|
uint8_t AppUpdate;
|
|
} FW_INFO;
|
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
/* Base address of the Flash sectors */
|
|
#define SECTOR_SIZE 8192 // 0X2000
|
|
|
|
#define ADDR_FLASH_SECTOR_00 ((uint32_t)0x00000000) /* Base @ of Sector 0, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_01 ((uint32_t)0x00002000) /* Base @ of Sector 1, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_02 ((uint32_t)0x00004000) /* Base @ of Sector 2, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_03 ((uint32_t)0x00006000) /* Base @ of Sector 3, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_04 ((uint32_t)0x00008000) /* Base @ of Sector 4, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_05 ((uint32_t)0x0000A000) /* Base @ of Sector 5, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_06 ((uint32_t)0x0000C000) /* Base @ of Sector 6, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_07 ((uint32_t)0x0000E000) /* Base @ of Sector 7, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_08 ((uint32_t)0x00010000) /* Base @ of Sector 8, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_09 ((uint32_t)0x00012000) /* Base @ of Sector 9, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x00014000) /* Base @ of Sector 10, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x00016000) /* Base @ of Sector 11, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_12 ((uint32_t)0x00018000) /* Base @ of Sector 12, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_13 ((uint32_t)0x0001A000) /* Base @ of Sector 13, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_14 ((uint32_t)0x0001C000) /* Base @ of Sector 14, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_15 ((uint32_t)0x0001E000) /* Base @ of Sector 15, 8 Kbyte */
|
|
|
|
#define ADDR_FLASH_SECTOR_16 ((uint32_t)0x00020000) /* Base @ of Sector 16, 8 Kbyte */
|
|
#define ADDR_FLASH_SECTOR_32 ((uint32_t)0x00040000) /* Base @ of Sector 32, 8 Kbyte */
|
|
|
|
#define ADDR_FLASH_SECTOR_48 ((uint32_t)0x00060000) /* Base @ of Sector 1, 16 Kbyte */
|
|
|
|
/* Define the address from where user application will be loaded.
|
|
Note: the 1st sector 0x00000000-0x00020000 is reserved for the IAP code */
|
|
#define mBMS_FW_RN_ADDRESS ADDR_FLASH_SECTOR_16
|
|
|
|
#define mBMS_FW_DN_ADDRESS ADDR_FLASH_SECTOR_48
|
|
|
|
/* End of the Flash address */
|
|
#define mBMS_FW_DN_END_ADDRESS ((uint32_t)0x00080000)
|
|
/* Define the user application size */
|
|
#define mBMS_FW_FLASH_SIZE (mBMS_FW_DN_END_ADDRESS - mBMS_FW_DN_ADDRESS)
|
|
#define mBMS_FW_PACKET_SIZE 0x800 // 2048
|
|
|
|
#define mBMS_SOC_BASE_ADDR ADDR_FLASH_SECTOR_11
|
|
|
|
#define mBMS_PARAM_BASE_ADDR ADDR_FLASH_SECTOR_12
|
|
#define mBMS_INV_BASE_ADDR ADDR_FLASH_SECTOR_13
|
|
#define mBMS_CALIB_BASE_ADDR ADDR_FLASH_SECTOR_14
|
|
#define mBMS_FW_INFO_BASE_ADDR ADDR_FLASH_SECTOR_15
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
/* Exported functions ------------------------------------------------------- */
|
|
void FLASH_If_Init(void);
|
|
uint32_t FLASH_If_Erase(uint32_t StartSector, uint32_t uSize);
|
|
uint32_t FLASH_If_SingleSectorErase(uint32_t SectorAddr);
|
|
|
|
uint32_t FLASH_If_Write(__IO uint32_t* FlashAddress, uint32_t* Data, uint32_t DataLength);
|
|
uint16_t FLASH_If_GetWriteProtectionStatus(void);
|
|
uint32_t FLASH_If_DisableWriteProtection(void);
|
|
|
|
extern FW_INFO fwinfo;
|
|
|
|
#endif /* __FLASH_IF_H */
|
|
|
|
/*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/
|