STM32-FSMC-NOR FLASH (10)
- UID
- 1029342
- 性别
- 男
|
STM32-FSMC-NOR FLASH (10)
*******************************************************************************/
NOR_Status FSMC_NOR_GetStatus(u32 Timeout)
{
u16 val1 = 0x00, val2 = 0x00;
NOR_Status status = NOR_ONGOING;
u32 timeout = Timeout;/* Poll on NOR memory Ready/Busy signal ------------------------------------*/
while((GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) != RESET) && (timeout > 0))
{
timeout--;
}
timeout = Timeout;
while((GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == RESET) && (timeout > 0))
{
timeout--;
}
/* Get the NOR memory operation status -------------------------------------*/
while((Timeout != 0x00) && (status != NOR_SUCCESS))
{
Timeout--;
/* Read DQ6 and DQ5 */
val1 = *(vu16 *)(Bank1_NOR2_ADDR);
val2 = *(vu16 *)(Bank1_NOR2_ADDR);
/* If DQ6 did not toggle between the two reads then return NOR_Success */
if((val1 & 0x0040) == (val2 & 0x0040))
{
return NOR_SUCCESS;
}
if((val1 & 0x0020) != 0x0020)
{
status = NOR_ONGOING;
}
val1 = *(vu16 *)(Bank1_NOR2_ADDR);
val2 = *(vu16 *)(Bank1_NOR2_ADDR);
if((val1 & 0x0040) == (val2 & 0x0040))
{
return NOR_SUCCESS;
}
else if((val1 & 0x0020) == 0x0020)
{
return NOR_ERROR;
}
}
if(Timeout == 0x00)
{
status = NOR_TIMEOUT;
}
/* Return the operation status */
return (status);
}
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ |
|
|
|
|
|