Adjusted timing for QUADSPI.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
0db402d3ea
commit
02c3f7b616
|
@ -10,8 +10,8 @@
|
|||
#define APP_FLASH_SIZE (64 * 1024 * 1024) /* 2 * 256Mb */
|
||||
#define APP_FLASH_PAGE_SIZE (512) /* 2 * 256 */
|
||||
#define APP_FLASH_SECTOR_SIZE (8 * 1024) /* 2 * 4kB */
|
||||
#define APP_FLASH_SECTOR_ERASE_TIMEOUT (1000) /* 1s (400ms in manual) */
|
||||
#define APP_FLASH_PAGE_PROGRAM_TIMEOUT (100) /* 100ms (3ms in manual) */
|
||||
#define APP_FLASH_SECTOR_ERASE_TIMEOUT (5000) /* 5s (400ms in manual) */
|
||||
#define APP_FLASH_PAGE_PROGRAM_TIMEOUT (250) /* 250ms (3ms in manual) */
|
||||
#define APP_FLASH_CHIP_ERASE_TIMEOUT (400 * 1000) /* 400s (as manual) */
|
||||
|
||||
#endif // FLASH_CONFIG_H
|
||||
|
|
|
@ -108,7 +108,7 @@ static int Flash_Wait_Busy(uint32_t timeout) {
|
|||
QSPI_AutoPollingTypeDef poll_def = {
|
||||
.Match = 0U,
|
||||
.Mask = (1 << 8U) | 1U, /* Status register: Bit 0 and Bit 8 */
|
||||
.Interval = 0xFFU,
|
||||
.Interval = 0xFFFFU,
|
||||
.StatusBytesSize = 2,
|
||||
.MatchMode = QSPI_MATCH_MODE_AND,
|
||||
.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE,
|
||||
|
@ -181,12 +181,11 @@ int Flash_EraseSector(uint32_t addr) {
|
|||
};
|
||||
|
||||
if (HAL_QSPI_Command(&hqspi, &cmd, APP_FLASH_COMMAND_TIMEOUT) != HAL_OK) {
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, 0);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (Flash_Wait_Busy(APP_FLASH_SECTOR_ERASE_TIMEOUT) != 0) {
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, 1);
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, 0);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -272,10 +271,11 @@ int Flash_Map(void) {
|
|||
}
|
||||
|
||||
int Flash_UnMap(void) {
|
||||
if (HAL_QSPI_Abort(&hqspi) != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* De-init and re-init QSPI, as HAL driver has too much magic. */
|
||||
HAL_StatusTypeDef ret;
|
||||
do {
|
||||
ret = HAL_QSPI_Abort(&hqspi);
|
||||
} while (ret != HAL_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
/* Stubs for tick handling */
|
||||
|
||||
#define APP_MSEC_CYCLES (32000)
|
||||
|
||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
void HAL_Delay(uint32_t Delay) {
|
||||
for(uint32_t i = 0; i < Delay; i++) {
|
||||
for(uint32_t j = 0; j < 1000; j++) {
|
||||
asm volatile ("nop");
|
||||
for (uint32_t i = 0; i < Delay; i++) {
|
||||
for (uint32_t j = 0; j < APP_MSEC_CYCLES; j++) {
|
||||
asm volatile("nop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue