Преглед изворни кода

Merge pull request #2233 from zhaojuntao/fix-bsp-flash-drv

[bsp][stm32/libraries] 移除 flash 驱动中 flash write 函数对 size 对齐的限制
Bernard Xiong пре 6 година
родитељ
комит
0889bafda8

+ 0 - 6
bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f0.c

@@ -84,12 +84,6 @@ int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size)
         return -RT_EINVAL;
     }
 
-    if (size % 4 != 0)
-    {
-        LOG_E("write size must be 4-byte alignment");
-        return -RT_EINVAL;
-    }
-
     if ((end_addr) > STM32_FLASH_END_ADDRESS)
     {
         LOG_E("write outrange flash size! addr is (0x%p)", (void *)(addr + size));

+ 0 - 6
bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c

@@ -84,12 +84,6 @@ int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size)
         return -RT_EINVAL;
     }
 
-    if (size % 4 != 0)
-    {
-        LOG_E("write size must be 4-byte alignment");
-        return -RT_EINVAL;
-    }
-
     if ((end_addr) > STM32_FLASH_END_ADDRESS)
     {
         LOG_E("write outrange flash size! addr is (0x%p)", (void *)(addr + size));

+ 0 - 6
bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_l4.c

@@ -140,12 +140,6 @@ int stm32_flash_write(rt_uint32_t addr, const uint8_t *buf, size_t size)
         return -RT_EINVAL;
     }
 
-    if(size % 8 != 0)
-    {
-        LOG_E("write size must be 8-byte alignment");
-        return -RT_EINVAL;
-    }
-
     HAL_FLASH_Unlock();
 
     __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR);