Мелкие фиксы
This commit is contained in:
13
Src/memspi.c
13
Src/memspi.c
@@ -278,16 +278,17 @@ HAL_StatusTypeDef MEMSPI_FLASH_Program(MEMSPI_HandleTypeDef *hmemspi, uint32_t F
|
||||
hmemspi->hNextAddr = FLASH_Address; // address would automatically increase in this variable
|
||||
hmemspi->hNextPage = firstpage+1; // address would automatically increase in this variable
|
||||
uint16_t bytecnt = 0;
|
||||
uint16_t bytecnt_to_tx = 0;
|
||||
for(int i = 0; i < lastpage - firstpage; i++)
|
||||
{
|
||||
// calc bytes to next sector
|
||||
hmemspi->TxSize = hmemspi->hNextPage*MEMSPI_PAGE_SIZE - hmemspi->hNextAddr;
|
||||
bytecnt_to_tx = hmemspi->hNextPage*MEMSPI_PAGE_SIZE - hmemspi->hNextAddr;
|
||||
|
||||
MEMSPI_Status = MEMSPI_FLASH_Program_Page(hmemspi, hmemspi->hNextAddr, &pData[bytecnt], hmemspi->TxSize, &Timeout, &tickstart, 0); // programm page
|
||||
MEMSPI_Status = MEMSPI_FLASH_Program_Page(hmemspi, hmemspi->hNextAddr, &pData[bytecnt], bytecnt_to_tx, &Timeout, &tickstart, 0); // programm page
|
||||
if(MEMSPI_Status != HAL_OK) // note: no need waiting for end: the next call will wait for unbusy
|
||||
return MEMSPI_Status;
|
||||
// then we shift byte count to data, that shoud be on the next page
|
||||
bytecnt += hmemspi->TxSize;
|
||||
bytecnt += bytecnt_to_tx;
|
||||
}
|
||||
// PROGRAM LAST PAGE
|
||||
MEMSPI_Status = MEMSPI_FLASH_Program_Page(hmemspi, hmemspi->hNextAddr, &pData[bytecnt], lastpage_size, &Timeout, &tickstart, WaitForEnd); // programm page
|
||||
@@ -482,7 +483,7 @@ HAL_StatusTypeDef MEMSPI_FLASH_Program_Page(MEMSPI_HandleTypeDef *hmemspi, uint3
|
||||
#ifndef FLASHTYPE_BYTE_PROGRAMM
|
||||
// PROGRAM WHOLE PAGE
|
||||
// enable writting and waiting for unbusy
|
||||
if(MEMSPI_WriteEnablingUntilTimeout(hmemspi, &Timeout, &tickstart) != HAL_OK) // if writting isnt enable
|
||||
if(MEMSPI_WriteEnablingUntilTimeout(hmemspi, Timeout, tickstart) != HAL_OK) // if writting isnt enable
|
||||
return HAL_TIMEOUT; // return timeout
|
||||
|
||||
// check if flash range is placed at one page
|
||||
@@ -490,13 +491,13 @@ HAL_StatusTypeDef MEMSPI_FLASH_Program_Page(MEMSPI_HandleTypeDef *hmemspi, uint3
|
||||
return HAL_ERROR; // return error
|
||||
|
||||
// programm page (instruction)
|
||||
MEMSPI_Status = MEMSPI_CMD_FLASH_Page_Program(hmemspi, FLASH_Address, pData, Size, Timeout);
|
||||
MEMSPI_Status = MEMSPI_CMD_FLASH_Page_Program(hmemspi, FLASH_Address, pData, Size, *Timeout);
|
||||
if(MEMSPI_Status != HAL_OK)
|
||||
return MEMSPI_Status;
|
||||
|
||||
// waiting for ending of writting if need
|
||||
if(WaitForEnd)
|
||||
if(MEMSPI_WaitOnFlagsUntilTimeout(hmemspi, MEMSPI_SR_WEL|MEMSPI_SR_BUSY, 0, &Timeout, &tickstart) != HAL_OK) // if writting isnt done (MEMSPI busy and WEL bit isnt in reset state)
|
||||
if(MEMSPI_WaitOnFlagsUntilTimeout(hmemspi, MEMSPI_SR_WEL|MEMSPI_SR_BUSY, 0, Timeout, tickstart) != HAL_OK) // if writting isnt done (MEMSPI busy and WEL bit isnt in reset state)
|
||||
return HAL_TIMEOUT;
|
||||
#else
|
||||
// PROGRAM PAGE BY BYTES
|
||||
|
||||
Reference in New Issue
Block a user