From 56539b7f81658d7b1017acbf092b94363a2c20a5 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期三, 27 三月 2024 11:56:43 +0800 Subject: [PATCH] V1.14 加入宏定义区别杭锦urt800个,跟以后的固件,注意改宏定义后还要改魔术棒。 --- Src/OnChipDevices/Flash.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Src/OnChipDevices/Flash.c b/Src/OnChipDevices/Flash.c index 57dbc87..279997b 100644 --- a/Src/OnChipDevices/Flash.c +++ b/Src/OnChipDevices/Flash.c @@ -5,6 +5,10 @@ * @param Size: The image size,the units of Size is Byte * @retval The number of pages or error */ + unsigned short int STMFLASH_ReadHalfWord(unsigned int faddr) +{ + return *(volatile unsigned short int*)faddr; +} uint32_t FLASH_Pages_Calculate(uint32_t Size) { uint32_t Flash_Page_Number = 0; @@ -30,7 +34,7 @@ * @retval 0:error; 1:success */ - +extern uint16_t testflag; uint32_t FLASH_Prepare(uint32_t Address, uint32_t Len) //起始地址和字长 {uint32_t PageError = 0; FLASH_EraseInitTypeDef EraseInitStruct; @@ -41,9 +45,11 @@ // HAL_FLASH_Lock(); if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK) { + testflag=1; HAL_FLASH_Lock(); return 0; }else{ + testflag=0; HAL_FLASH_Lock(); return 1; } @@ -95,6 +101,7 @@ * @retval 0:error ; 1:success */ #define DATA_32 ((uint32_t)0x12345678) +uint16_t test111; uint32_t FLASH_Write( uint32_t Address, const uint8_t* pData, uint32_t Len) { uint32_t WriteCount = 0,temp; @@ -107,7 +114,7 @@ for( ; WriteCount < Len; WriteCount+=4) {temp=*(uint32_t*)FlashSource; FLASHStatus = HAL_FLASH_Program(FLASH_TYPEPROGRAMDATA_WORD, FlashDestination, temp); - + test111=FLASHStatus; if( FLASHStatus != HAL_OK) { break; -- Gitblit v1.9.3