Board logo

标题: STM32-FSMC-NOR FLASH (10) [打印本页]

作者: yuyang911220    时间: 2014-8-24 16:57     标题: 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****/




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0