mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
82 lines
4.1 KiB
C
82 lines
4.1 KiB
C
/**
|
||
******************************************************************************
|
||
* @file STM32F4xx_IAP/inc/flash_if.h
|
||
* @author MCD Application Team
|
||
* @version V1.0.0
|
||
* @date 10-October-2011
|
||
* @brief This file provides all the headers of the flash_if 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 2011 STMicroelectronics</center></h2>
|
||
******************************************************************************
|
||
*/
|
||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||
#ifndef __FLASH_IF_H
|
||
#define __FLASH_IF_H
|
||
|
||
/* Includes ------------------------------------------------------------------*/
|
||
#include "stm32f4xx.h"
|
||
#include "main.h"
|
||
/* Exported types ------------------------------------------------------------*/
|
||
/* Exported constants --------------------------------------------------------*/
|
||
/* Base address of the Flash sectors */
|
||
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbyte */
|
||
#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbyte */
|
||
// #define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbyte */
|
||
// #define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbyte */
|
||
// #define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbyte */
|
||
// #define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbyte */
|
||
|
||
/* End of the Flash address */
|
||
#define USER_FLASH_END_ADDRESS 0x0807FFFF
|
||
/* Define the user application size */
|
||
#define USER_FLASH_SIZE (USER_FLASH_END_ADDRESS - APPLICATION_ADDRESS + 1)
|
||
|
||
/* Define the address from where user application will be loaded.
|
||
Note: the 1st sector 0x08000000-0x08003FFF is reserved for the IAP code */
|
||
#define APPLICATION_ADDRESS (uint32_t)0x0800C000
|
||
|
||
/* Exported types ------------------------------------------------------------*/
|
||
|
||
#define UPGRADE_INFO_ADDRESS (USER_FLASH_END_ADDRESS - sizeof(UpgradeInfo_t) + 1)
|
||
// 定义升级信息结构体
|
||
typedef struct {
|
||
uint32_t magic_word; // 魔法字,如 0xDEADBEEF,用于标识此结构体有效
|
||
uint32_t upgrade_status; // 升级状态标志
|
||
uint32_t new_app_size; // 新APP的固件大小
|
||
uint32_t new_app_crc32; // 新APP的CRC32校验和
|
||
} UpgradeInfo_t;
|
||
|
||
|
||
/* Exported macro ------------------------------------------------------------*/
|
||
/* Exported functions ------------------------------------------------------- */
|
||
void FLASH_If_Init(void);
|
||
uint32_t FLASH_If_Erase(uint32_t StartSector);
|
||
uint32_t FLASH_If_Erase_One_Sector(uint32_t StartSector);
|
||
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);
|
||
|
||
//
|
||
void FLASH_ProgramWord(uint32_t Address, uint32_t Data);
|
||
HAL_StatusTypeDef FLASH_OB_DisableWRP(uint32_t WRPSector, uint32_t Banks);
|
||
|
||
#endif /* __FLASH_IF_H */
|
||
|
||
/*******************(C)COPYRIGHT 2011 STMicroelectronics *****END OF FILE******/
|