📄 75x_smi.c
字号:
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SMI_SendWENCmd(void)
{
SMI->CR2 |= SMI_WEN_Mask;
}
/*******************************************************************************
* Function Name : SMI_SendRSRCmd
* Description : Sends a Read Status Register Command to the selected memory
* Bank.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SMI_SendRSRCmd(void)
{
SMI->CR2 |= SMI_RSR_Mask;
}
/*******************************************************************************
* Function Name : SMI_SendCmd
* Description : Sends command to the selected memory Bank. This function is
* used in Software mode only.
* Input : - Command: specifies the command to send to the external memory.
* Output : None
* Return : None
*******************************************************************************/
void SMI_SendCmd(u32 Command)
{
/* Load the command in the Transmit Register */
SMI->TR = Command;
/* Start transfer */
SMI->CR2 |= SMI_SEND_Mask;
}
/*******************************************************************************
* Function Name : SMI_FastReadConfig
* Description : Enables or disables the Fast Read Mode.
* Input : - SMI_FastRead: specifies whether the Fast Read Mode is
* enabled or disabled.
* This parameter can be one of the following values:
* - SMI_FastRead_Disable : Fast Read Mode disabled
* - SMI_FastRead_Enable : Fast Read Mode enabled
* Output : None
* Return : None
*******************************************************************************/
void SMI_FastReadConfig(u32 SMI_FastRead)
{
if(SMI_FastRead == SMI_FastRead_Enable)
{
SMI->CR1 |= SMI_FastRead_Enable;
}
else
{
SMI->CR1 &= SMI_FastRead_Disable;
}
}
/*******************************************************************************
* Function Name : SMI_WriteBurstConfig
* Description : Enables or disables the Write Burst Mode.
* Input : - SMI_WriteBurst: specifies whether the Write Burst Mode is
* enabled or disabled.
* This parameter can be one of the following values:
* - SMI_WriteBurst_Disable : Write Burst Mode disabled
* - SMI_WriteBurst_Enable : Write Burst Mode enabled
* Output : None
* Return : None
*******************************************************************************/
void SMI_WriteBurstConfig(u32 SMI_WriteBurst)
{
if(SMI_WriteBurst == SMI_WriteBurst_Enable)
{
SMI->CR1 |= SMI_WriteBurst_Enable;
}
else
{
SMI->CR1 &= SMI_WriteBurst_Disable;
}
}
/*******************************************************************************
* Function Name : SMI_WriteByte
* Description : Writes a Byte to the selected memory Bank. This function is
* used in Hardware mode only.
* Before calling this function, send a Write Enable command to
* the selected memory Bank using SMI_SendWENCmd() function.
* Input : - WriteAddr: external memory address from which the data will
* be written.
* - Data: data to be written to the external memory.
* Output : None
* Return : None
*******************************************************************************/
void SMI_WriteByte(u32 WriteAddr, u8 Data)
{
/* Transfer data to the memory */
*(u8 *) WriteAddr = Data;
}
/*******************************************************************************
* Function Name : SMI_WriteHalfWord
* Description : Writes a Half Word to the selected memory Bank. This function
* is used in Hardware mode only.
* Before calling this function, send a Write Enable command to
* the selected memory Bank using SMI_SendWENCmd() function.
* Input : - WriteAddr: external memory address from which the data will
* be written.
* - Data: data to be written to the external memory.
* Output : None
* Return : None
*******************************************************************************/
void SMI_WriteHalfWord(u32 WriteAddr, u16 Data)
{
/* Transfer data to the memory */
*(u16 *) WriteAddr = Data;
}
/*******************************************************************************
* Function Name : SMI_WriteWord
* Description : Writes a Word to the selected memory Bank. This function is
* used in Hardware mode only.
* Before calling this function, send a Write Enable command to
* the selected memory Bank using SMI_SendWENCmd() function.
* Input : - WriteAddr: external memory address from which the data will
* be written.
* - Data: data to be written to the external memory.
* Output : None
* Return : None
*******************************************************************************/
void SMI_WriteWord(u32 WriteAddr, u32 Data)
{
/* Transfer data to the memory */
*(u32 *) WriteAddr = Data;
}
/*******************************************************************************
* Function Name : SMI_ReadByte
* Description : Reads a Byte from the selected memory Bank. This function is
* used in Hardware mode only.
* Input : - ReadAddr: external memory address to read from.
* Output : None
* Return : Data read from the external memory.
*******************************************************************************/
u8 SMI_ReadByte(u32 ReadAddr)
{
return(*(u8 *) ReadAddr);
}
/*******************************************************************************
* Function Name : SMI_ReadHalfWord
* Description : Reads a Half Word from the selected memory Bank.
* This function is used in Hardware mode only.
* Input : - ReadAddr: external memory address to read from.
* Output : None
* Return : Data read from the external memory.
*******************************************************************************/
u16 SMI_ReadHalfWord(u32 ReadAddr)
{
return(*(u16 *) ReadAddr);
}
/*******************************************************************************
* Function Name : SMI_ReadWord
* Description : Reads a Word from the selected memory Bank. This function is
* used in Hardware mode only.
* Input : - ReadAddr: external memory address to read from.
* Output : None
* Return : Data read from the external memory.
*******************************************************************************/
u32 SMI_ReadWord(u32 ReadAddr)
{
return(*(u32 *) ReadAddr);
}
/*******************************************************************************
* Function Name : SMI_ReadMemoryStatusRegister
* Description : Reads the status register of the memory connected to the
* selected Bank.
* Input : None
* Output : None
* Return : External memory status register value.
*******************************************************************************/
u8 SMI_ReadMemoryStatusRegister(void)
{
return((u8) (SMI->SR & SMI_STATUSREGISTER_Mask));
}
/*******************************************************************************
* Function Name : SMI_GetFlagStatus
* Description : Checks whether the specified SMI flag is set or not.
* Input : - SMI_FLAG: specifies the flag to check.
* This parameter can be one of the following values:
* - SMI_FLAG_Bank3_WM : Memory Bank3 Write Mode flag
* - SMI_FLAG_Bank2_WM : Memory Bank2 Write Mode flag
* - SMI_FLAG_Bank1_WM : Memory Bank1 Write Mode flag
* - SMI_FLAG_Bank0_WM : Memory Bank0 Write Mode flag
* - SMI_FLAG_ERF2 : Error Flag 2: Forbidden Write Request
* - SMI_FLAG_ERF1 : Error Flag 1: Forbidden Access
* - SMI_FLAG_WC : Write Complete flag
* - SMI_FLAG_TF : Transfer Finished flag
* Output : None
* Return : The new state of SMI_FLAG (SET or RESET).
*******************************************************************************/
FlagStatus SMI_GetFlagStatus(u32 SMI_FLAG)
{
if((SMI->SR & SMI_FLAG) != RESET)
{
return SET;
}
else
{
return RESET;
}
}
/*******************************************************************************
* Function Name : SMI_ClearFlag
* Description : Clears the SMI抯 pending flags.
* Input : - SMI_FLAG: specifies the flag to clear.
* This parameter can be any combination of the following values:
* - SMI_FLAG_ERF2 : Error Flag 2: Forbidden Write Request
* - SMI_FLAG_ERF1 : Error Flag 1: Forbidden Access
* - SMI_FLAG_WC : Write Complete flag
* - SMI_FLAG_TF : Transfer Finished flag
* Output : None
* Return : None
*******************************************************************************/
void SMI_ClearFlag(u32 SMI_FLAG)
{
SMI->SR &= ~SMI_FLAG;
}
/*******************************************************************************
* Function Name : SMI_GetITStatus
* Description : Checks whether the specified SMI interrupt has occurred or not.
* Input : - SMI_FLAG: specifies the interrupt source to check.
* This parameter can be one of the following values:
* - SMI_IT_WC : Write Complete Interrupt
* - SMI_IT_TF : Transfer Finished Interrupt
* Output : None
* Return : The new state of SMI_IT (SET or RESET).
*******************************************************************************/
ITStatus SMI_GetITStatus(u32 SMI_IT)
{
if(((SMI->CR2 & SMI_IT) != RESET) && ((SMI->SR & SMI_IT) != RESET))
{
return SET;
}
else
{
return RESET;
}
}
/*******************************************************************************
* Function Name : SMI_ClearITPendingBit
* Description : Clears the SMI抯 interrupt pending bits.
* Input : - SMI_FLAG: specifies the interrupts sources to clear.
* This parameter can be any combination of the following values:
* - SMI_IT_WC : Write Complete Interrupt
* - SMI_IT_TF : Transfer Finished Interrupt
* Output : None
* Return : None
*******************************************************************************/
void SMI_ClearITPendingBit(u32 SMI_IT)
{
SMI->SR &= ~SMI_IT;
}
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -