98 lines
3.5 KiB
C
98 lines
3.5 KiB
C
/**
|
|
*******************************************************************************
|
|
* @file iap/iap_ymodem_boot/source/flash.h
|
|
* @brief This file contains all the functions prototypes of the Flash driver.
|
|
@verbatim
|
|
Change Logs:
|
|
Date Author Notes
|
|
2022-03-31 CDT First version
|
|
@endverbatim
|
|
*******************************************************************************
|
|
* Copyright (C) 2022-2025, Xiaohua Semiconductor Co., Ltd. All rights reserved.
|
|
*
|
|
* This software component is licensed by XHSC under BSD 3-Clause license
|
|
* (the "License"); You may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at:
|
|
* opensource.org/licenses/BSD-3-Clause
|
|
*
|
|
*******************************************************************************
|
|
*/
|
|
#ifndef __HDL_FLASH_H__
|
|
#define __HDL_FLASH_H__
|
|
|
|
#include "stdint.h"
|
|
|
|
/* C binding of definitions if building with C++ compiler */
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
/*******************************************************************************
|
|
* Include files
|
|
******************************************************************************/
|
|
#include "hc32_ll_efm.h"
|
|
|
|
#include "hc32_ll_SWDT.h"
|
|
|
|
/*******************************************************************************
|
|
* Global type definitions ('typedef')
|
|
******************************************************************************/
|
|
|
|
/*******************************************************************************
|
|
* Global pre-processor symbols/macros ('#define')
|
|
******************************************************************************/
|
|
/* Flash definitions */
|
|
#define FLASH_BASE (EFM_START_ADDR)
|
|
#define FLASH_SIZE (EFM_END_ADDR + 1U)
|
|
#define FLASH_SECTOR_SIZE (EFM_SECTOR_SIZE)
|
|
#define FLASH_SECTOR_NUM (64U)
|
|
|
|
/* SRAM definitions */
|
|
#define SRAM_SIZE (0x02F000UL)
|
|
/* Vector table */
|
|
#define VECT_TAB_STEP (0x000UL)
|
|
|
|
/* flash rom map ´æ´¢·ÖÇø*/
|
|
//boot 16k
|
|
#define FLASH_BOOT_BASE (FLASH_BASE)
|
|
#define FLASH_BOOT_SIZE (4*FLASH_SECTOR_SIZE)
|
|
//app
|
|
#define FLASH_APP_BASE (FLASH_BOOT_BASE+ FLASH_BOOT_SIZE)
|
|
#define FLASH_APP_SIZE (58*FLASH_SECTOR_SIZE)
|
|
|
|
//boot info
|
|
#define FLASH_BINFO_BASE (FLASH_APP_BASE + FLASH_APP_SIZE)
|
|
#define FLASH_BINFO_SIZE (1*FLASH_SECTOR_SIZE)
|
|
|
|
//user config
|
|
#define FLASH_CFG_BASE (FLASH_BINFO_BASE + FLASH_BINFO_SIZE)
|
|
#define FLASH_CFG_SIZE (1*FLASH_SECTOR_SIZE)
|
|
|
|
#define FLASH_CFG_MAGIC (0xa5)
|
|
|
|
/*******************************************************************************
|
|
* Global variable definitions ('extern')
|
|
******************************************************************************/
|
|
|
|
/*******************************************************************************
|
|
Global function prototypes (definition in C source)
|
|
******************************************************************************/
|
|
int32_t hdl_flash_unlock(void);
|
|
int32_t hdl_flash_lock(void);
|
|
|
|
int32_t hdl_flash_check_addralign(uint32_t u32Addr);
|
|
int32_t hdl_flash_erase_sector(uint32_t u32Addr, uint32_t u32Size);
|
|
int32_t hdl_flash_write_data(uint32_t u32Addr, uint8_t *pu8Buff, uint32_t u32Len);
|
|
int32_t hdl_flash_read_data(uint32_t u32Addr, uint8_t *pu8Buff, uint32_t u32Len);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __FLASH_H__ */
|
|
|
|
/*******************************************************************************
|
|
* EOF (not truncated)
|
|
******************************************************************************/
|