資源簡介
基于Ymodem的STM32F4串口IAP,已測試成功。
代碼片段和文件信息
#include?“stm32_flash.h“
#include?“stm32f4xx.h“
#include?“stm32f4xx_flash.h“
#include?
#define?SECTOR_MAX_NUMBER?23u
static?const?uint32_t?mapTable[][2]?=
{
????{ADDR_FLASH_SECTOR_0FLASH_Sector_0}
????{ADDR_FLASH_SECTOR_1FLASH_Sector_1}
????{ADDR_FLASH_SECTOR_2FLASH_Sector_2}
????{ADDR_FLASH_SECTOR_3FLASH_Sector_3}
????{ADDR_FLASH_SECTOR_4FLASH_Sector_4}
????{ADDR_FLASH_SECTOR_5FLASH_Sector_5}?
????{ADDR_FLASH_SECTOR_6FLASH_Sector_6}?
????{ADDR_FLASH_SECTOR_7FLASH_Sector_8}
????{ADDR_FLASH_SECTOR_9FLASH_Sector_9}?
????{ADDR_FLASH_SECTOR_10FLASH_Sector_10}?
????{ADDR_FLASH_SECTOR_11FLASH_Sector_11}
????{ADDR_FLASH_SECTOR_12FLASH_Sector_12}?
????{ADDR_FLASH_SECTOR_13FLASH_Sector_13}?
????{ADDR_FLASH_SECTOR_14FLASH_Sector_14}?
????{ADDR_FLASH_SECTOR_15FLASH_Sector_15}?
????{ADDR_FLASH_SECTOR_16FLASH_Sector_16}?
????{ADDR_FLASH_SECTOR_17FLASH_Sector_17}?
????{ADDR_FLASH_SECTOR_18FLASH_Sector_18}?
????{ADDR_FLASH_SECTOR_19FLASH_Sector_19}
????{ADDR_FLASH_SECTOR_20FLASH_Sector_20}???
????{ADDR_FLASH_SECTOR_21FLASH_Sector_21}?
????{ADDR_FLASH_SECTOR_22FLASH_Sector_22}?
????{ADDR_FLASH_SECTOR_23FLASH_Sector_23}?
????
};
/********************************
//函數名稱:stm32_flashGetFlashSector
//函數功能:獲取地址所在的扇區
//函數參數:?addr?flash地址
//函數返回:正確地址所在的扇區操作碼?0xffff?參數地址不是有效的FLASH地址
*********************************/
static?uint16_t?stm32_flashGetFlashSector(uint32_t?addr)
{
????uint16_t?i?=?0;
????if?((addr?se)?||?(addr?>?STM32_FLASH_base?+?FLASH_SIZE))?return?0xffff;
????else{
????????for?(i?=?0;i ????????{
????????????if?(addr?????????????????return?mapTable[i][1];
????????}
????????return?mapTable[i][1];
????}
???
}
/********************************
//函數名稱:stm32_flashSectorSize
//函數功能:獲取指定扇區的大小
//函數參數:number?指定的扇區編號?0-23
//函數返回:正確返回扇區大小,錯誤參數超出指定大小返回-1
********************************/
static?int32_t?stm32_flashSectorSize(uint16_t?number)
{
????number?=?number%12;
????if?(number?<=?3u?)
????????return?0x4000;
????else?if?((4u?==?number)?)
????????return?0x10000;
????else?if?(((number?>=5u?)&&?(number?12u))?)
????????return?0x20000;
????else
????????return?-1;
}
static?uint16_t?stm32_flashSectorNmuber(uint16_t?code)
{
????uint16_t?i?=?0;
????for?(?i?=?0;?i????{
????????if?(mapTable[i][1]==code)
????????????return?i;
????}
????return?0xff;
}
/***************************************
//函數名稱:STMFLASH_Erase
//函數功能:從指定的扇區首地址開始,擦除指定大小的FLASH空間
//函數參數:startAddr?:需要擦除的flash空間的首地址(必須為扇區的首地址)
????????????size:?需要擦除的flash空間大小(單位字節)
//函數返回:0?成功?-1?非法地址?-2?指定擦除區域超出flash的空間大小??-3擦除失敗
***************************************/
int32_t?stm32_flashErase(uint32_t?startAddruint32_t?size?)
{
????FLASH_Status?status?=?FLASH_COMPLETE;
????uint32_t?addr?=?startAddr;
????uint32_t?endAddr?=?startAddr?+?size;
????
????FLASH_DataCacheCmd(DISABLE);//FLASH擦除期間必須禁止數
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-02?07:18??IAP_BootLaoder\
?????目錄???????????0??2016-08-03?07:10??IAP_BootLaoder\APPLIB\
?????文件????????4899??2016-08-03?07:10??IAP_BootLaoder\APPLIB\stm32_flash.c
?????文件????????3017??2016-08-03?00:10??IAP_BootLaoder\APPLIB\stm32_flash.h
?????目錄???????????0??2016-08-01?23:26??IAP_BootLaoder\CORE\
?????文件??????109142??2014-07-17?21:52??IAP_BootLaoder\CORE\core_cm4.h
?????文件???????22735??2014-07-17?21:52??IAP_BootLaoder\CORE\core_cm4_simd.h
?????文件???????17146??2014-07-17?21:52??IAP_BootLaoder\CORE\core_cmFunc.h
?????文件???????20513??2014-07-17?21:52??IAP_BootLaoder\CORE\core_cmInstr.h
?????文件???????29605??2014-08-02?00:12??IAP_BootLaoder\CORE\startup_stm32f40_41xxx.s
?????目錄???????????0??2016-08-01?23:26??IAP_BootLaoder\FWLIB\
?????目錄???????????0??2016-08-01?23:26??IAP_BootLaoder\FWLIB\inc\
?????文件????????6924??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\misc.h
?????文件???????32880??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_adc.h
?????文件???????27318??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_can.h
?????文件????????2416??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_crc.h
?????文件???????14481??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_cryp.h
?????文件???????14946??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_dac.h
?????文件????????4296??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_dbgmcu.h
?????文件???????12977??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_dcmi.h
?????文件???????28882??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_dma.h
?????文件???????19692??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_dma2d.h
?????文件????????8012??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_exti.h
?????文件???????24467??2014-08-04?22:05??IAP_BootLaoder\FWLIB\inc\stm32f4xx_flash.h
?????文件????????3275??2014-08-04?22:05??IAP_BootLaoder\FWLIB\inc\stm32f4xx_flash_ramfunc.h
?????文件???????44924??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_fmc.h
?????文件???????27181??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_fsmc.h
?????文件???????23548??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_gpio.h
?????文件???????10084??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_hash.h
?????文件???????31939??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_i2c.h
?????文件????????4323??2014-08-01?23:18??IAP_BootLaoder\FWLIB\inc\stm32f4xx_iwdg.h
............此處省略230個文件信息
評論
共有 條評論