|
@@ -159,9 +159,8 @@ void FLASH_Lock(void);
|
|
|
|
|
|
|
|
|
/*准备写入的测试数据*/
|
|
|
-#define DATA_32 ((uint32_t)0x13246578)
|
|
|
-#define BUFLENGTH 32
|
|
|
-uint32_t wrbuf[BUFLENGTH] = {0xabcdef12};
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
@@ -176,7 +175,7 @@ uint32_t wrbuf[BUFLENGTH] = {0xabcdef12};
|
|
|
* @param None
|
|
|
* @retval None
|
|
|
*/
|
|
|
-int InternalFlash_Test(void)
|
|
|
+int InternalFlash_WriteBuf(const uint8_t* data, uint32_t length)
|
|
|
{
|
|
|
/*要擦除的起始扇区(包含)及结束扇区(不包含),如8-12,表示擦除8、9、10、11扇区*/
|
|
|
uint32_t uwStartSector = 0;
|
|
@@ -187,8 +186,16 @@ int InternalFlash_Test(void)
|
|
|
|
|
|
// __IO uint32_t uwData32 = 0;
|
|
|
__IO uint32_t uwMemoryProgramStatus = 0;
|
|
|
+ __IO uint32_t rr=0;
|
|
|
+
|
|
|
+ uint8_t* pbuf = data;
|
|
|
+ //pbuf = (uint8_t*)malloc(length*sizeof(uint8_t));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ static uint32_t i = 0;
|
|
|
+
|
|
|
|
|
|
- int i = 0;
|
|
|
|
|
|
/* FLASH 解锁 ********************************/
|
|
|
/* 使能访问FLASH控制寄存器 */
|
|
@@ -232,11 +239,12 @@ int InternalFlash_Test(void)
|
|
|
uwAddress = FLASH_USER_START_ADDR;
|
|
|
|
|
|
|
|
|
- for (i=0;i < BUFLENGTH;i++)
|
|
|
+ for (i=0;i < length;i++)
|
|
|
{
|
|
|
- if (FLASH_ProgramWord(uwAddress, DATA_32) == FLASH_COMPLETE)
|
|
|
+ rr = pbuf[i];
|
|
|
+ if (FLASH_ProgramByte(uwAddress, rr) == FLASH_COMPLETE)
|
|
|
{
|
|
|
- uwAddress = uwAddress + 4;
|
|
|
+ uwAddress = uwAddress + 1;
|
|
|
}
|
|
|
else
|
|
|
{
|