You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
3.2 KiB
67 lines
3.2 KiB
3 days ago
|
/*
|
||
|
* bsp_cpu_flash.h
|
||
|
*
|
||
|
* Created on: Aug 28, 2024
|
||
|
* Author: akeguo
|
||
|
*/
|
||
|
|
||
|
#ifndef SRC_BSP_BSP_CPU_FLASH_H_
|
||
|
#define SRC_BSP_BSP_CPU_FLASH_H_
|
||
|
|
||
|
#include "main.h"
|
||
|
|
||
|
#include "../../BASE/Inc/BSP/bsp_qspi_w25q128.h"
|
||
|
#include "quadspi.h"
|
||
|
|
||
|
#define ENABLE_INT() __set_PRIMASK(0) /* 使能全局中断 */
|
||
|
#define DISABLE_INT() __set_PRIMASK(1) /* 禁止全局中断 */
|
||
|
|
||
|
|
||
|
#define CPU_FLASH_BASE_ADDR (uint32_t)(FLASH_BASE) /* 0x08000000 */
|
||
|
#define CPU_FLASH_END_ADDR (uint32_t)(0x081FFFFF)
|
||
|
|
||
|
#define CPU_FLASH_SIZE (2 * 1024 * 1024) /* FLASH总容量 */
|
||
|
#define CPU_FLASH_SECTOR_SIZE (128 * 1024) /* 扇区大小,字节 */
|
||
|
|
||
|
/* Base address of the Flash sectors Bank 1 */
|
||
|
#define ADDR_FLASH_SECTOR_0_BANK1 ((uint32_t)0x08000000) /* Base @ of Sector 0, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_1_BANK1 ((uint32_t)0x08020000) /* Base @ of Sector 1, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_2_BANK1 ((uint32_t)0x08040000) /* Base @ of Sector 2, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_3_BANK1 ((uint32_t)0x08060000) /* Base @ of Sector 3, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_4_BANK1 ((uint32_t)0x08080000) /* Base @ of Sector 4, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_5_BANK1 ((uint32_t)0x080A0000) /* Base @ of Sector 5, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_6_BANK1 ((uint32_t)0x080C0000) /* Base @ of Sector 6, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_7_BANK1 ((uint32_t)0x080E0000) /* Base @ of Sector 7, 128 Kbytes */
|
||
|
|
||
|
/* Base address of the Flash sectors Bank 2 */
|
||
|
#define ADDR_FLASH_SECTOR_0_BANK2 ((uint32_t)0x08100000) /* Base @ of Sector 0, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_1_BANK2 ((uint32_t)0x08120000) /* Base @ of Sector 1, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_2_BANK2 ((uint32_t)0x08140000) /* Base @ of Sector 2, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_3_BANK2 ((uint32_t)0x08160000) /* Base @ of Sector 3, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_4_BANK2 ((uint32_t)0x08180000) /* Base @ of Sector 4, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_5_BANK2 ((uint32_t)0x081A0000) /* Base @ of Sector 5, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_6_BANK2 ((uint32_t)0x081C0000) /* Base @ of Sector 6, 128 Kbytes */
|
||
|
#define ADDR_FLASH_SECTOR_7_BANK2 ((uint32_t)0x081E0000) /* Base @ of Sector 7, 128 Kbytes */
|
||
|
|
||
|
#define FLASH_IS_EQU 0 /* Flash内容和待写入的数据相等,不需要擦除和写操作 */
|
||
|
#define FLASH_REQ_WRITE 1 /* Flash不需要擦除,直接写 */
|
||
|
#define FLASH_REQ_ERASE 2 /* Flash需要先擦除,再写 */
|
||
|
#define FLASH_PARAM_ERR 3 /* 函数参数错误 */
|
||
|
|
||
|
|
||
|
#define App_Start_Addr 0x08000000
|
||
|
#define App_Run_Addr 0x08020000
|
||
|
#define App_Download_Addr 0x08080000 // ADDR_FLASH_SECTOR_4_BANK1
|
||
|
|
||
|
|
||
|
|
||
|
uint8_t bsp_ReadCpuFlash(uint32_t _ulFlashAddr, uint8_t *_ucpDst, uint32_t _ulSize);
|
||
|
uint8_t bsp_WriteCpuFlash(uint32_t _ulFlashAddr, uint8_t *_ucpSrc, uint32_t _ulSize);
|
||
|
uint8_t bsp_CmpCpuFlash(uint32_t _ulFlashAddr, uint8_t *_ucpBuf, uint32_t _ulSize);
|
||
|
void JumpToApp(void);
|
||
|
void Copy_Peripheral_Download_Flash_to_App_Start(uint32_t totalBytes);
|
||
|
uint8_t bsp_EraseCpuFlash(uint32_t _ulFlashAddr);
|
||
|
void Erase_App_Download_Flash_Addr();
|
||
|
void Copy_Download_Flash_to_Start();
|
||
|
#endif /* SRC_BSP_BSP_CPU_FLASH_H_ */
|