📄 xllp_usim.c
字号:
}
/******************************************************************************
Function Name: XllpUsimClearInterruptSources
Description: Clears the interrupt sources (after they've been serviced)
Global Registers: IIR
Input Arguments:
XllpUsimBase: Base address of the USIM module
ClearMask: 1's indicate the interrupts you need to clear,
0's ==> interrupts sources are not cleared
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimClearInterruptSources(void *XllpUsimBase, XLLP_UINT32_T ClearMask)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->IIR |= (ClearMask & XLLP_USIM_IIR_VALID_MASK);
}
/******************************************************************************
Function Name: XllpUsimClearFIFO
Description: Clears the interrupt sources (after they've been serviced)
Global Registers: FCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
fifo: Either 0x1 to clear the Receive fifo, or 0x2 to clear the transmit fifo,
or 0x3 to clear both. See Enum Xllp_Usim_Clear_Fifo_T.
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimClearFIFO(void *XllpUsimBase, Xllp_Usim_Clear_Fifo_T fifo)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->FCR |= fifo;
}
/******************************************************************************
Function Name: XllpUsimModifyParityErrorMaskInFIFO
Description: Modifies the parity error mask that would enable a parity bit to
be inserted in bit8 of the receive fifo.
Global Registers: FCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Mask: "Enable" would enable the mask and NO parity bit would be inserted in bit8
of the receive fifo. "Disable" would disbale the mask, and the parity error
bit would be inserted in bit8 of the receive fifo when in T=1 mode
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimModifyParityErrorMaskInFIFO(void *XllpUsimBase, XLLP_USIM_Mode_T Mask)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
if(Mask == Enable)
USIM->FCR |= XLLP_USIM_FCR_PEM; /* Enables the mask: no parity status in bit8 of FIFO */
else
USIM->FCR &= ~XLLP_USIM_FCR_PEM; /* Disables the mask: parity status exists in bit8 of FIFO */
}
/******************************************************************************
Function Name: XllpUsimHoldTransmission
Description: Holds transmission
Global Registers: FCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimHoldTransmission(void *XllpUsimBase)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->FCR |= XLLP_USIM_FCR_TX_HOLD; /* Holds transmission */
}
/******************************************************************************
Function Name: XllpUsimContinueTransmission
Description: Holds transmission
Global Registers: FCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimContinueTransmission(void *XllpUsimBase)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->FCR &= ~XLLP_USIM_FCR_TX_HOLD; /* Resumes transmission */
}
/******************************************************************************
Function Name: XllpUsimGetNumberOfParityErrors
Description: Returns the number of bytes that contain parity errors in the receive fifo
Global Registers: FSR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
NumOfParityErrors: The number of bytes that contain parity errors in the receive fifo
Return Value:
None
*******************************************************************************/
void XllpUsimGetNumberOfParityErrors(void *XllpUsimBase, XLLP_UINT32_T NumOfParityErrors)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
NumOfParityErrors = (USIM->FSR & XLLP_USIM_FSR_PERR_NUM) >> XLLP_USIM_FSR_PERR_NUM_SHIFT;
}
/******************************************************************************
Function Name: XllpUsimGetTransmitFifoBytes
Description: Returns the number of bytes that are remaining in the transmit fifo,
waiting to be transmitted
Global Registers: FSR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
None
Return Value:
The number of bytes that are remaining in the transmit fifo
*******************************************************************************/
void XllpUsimGetTransmitFifoBytes(void *XllpUsimBase, XLLP_UINT32_T BytesInTransmitFifo)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
BytesInTransmitFifo = (USIM->FSR & XLLP_USIM_FSR_TX_LENGTH) >> XLLP_USIM_FSR_TX_LENGTH_SHIFT;
}
/******************************************************************************
Function Name: XllpUsimGetReceiveFifoBytes
Description: Returns the number of bytes that are remaining in the receive fifo
Global Registers: FSR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
ReceiveFifoBytes: Number of bytes remaining in the Receive Fifo
Return Value:
None
*******************************************************************************/
void XllpUsimGetReceiveFifoBytes(void *XllpUsimBase, XLLP_UINT32_T ReceiveFifoBytes)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
ReceiveFifoBytes = (USIM->FSR & XLLP_USIM_FSR_RX_LENGTH) >> XLLP_USIM_FSR_RX_LENGTH_SHIFT;
}
/******************************************************************************
Function Name: XllpUsimRepeatCharacterTransmission
Description: Enables the repetition of the transmission of the erronous character
in T=0 mode until error trigger level is met.
Global Registers: ECR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimRepeatCharacterTransmission(void *XllpUsimBase)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->ECR |= XLLP_USIM_ECR_T0_REPEAT;
}
/******************************************************************************
Function Name: XllpUsimClearT0Error
Description: Clears the T=0 error indicator causing the transmission to resume
without further repetition.
Global Registers: ECR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimClearT0Error(void *XllpUsimBase)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->ECR |= XLLP_USIM_ECR_T0_CLR;
}
/******************************************************************************
Function Name: XllpUsimSetParityErrorTriggerLevel
Description: Sets the number of times a character could be retransmitted in T=0 mode
due to a parity error. The errors do not generate an interrupt until
the level is met.
Global Registers: ECR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Xllp_Usim_TriggerLevel_T: Sets the trigger level.
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimSetParityErrorTriggerLevel(void *XllpUsimBase, Xllp_Usim_TriggerLevel_T TriggerLevel)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->ECR |= ((TriggerLevel << XLLP_USIM_ECR_PE_TL_SHIFT) & XLLP_USIM_ECR_PE_TL);
}
/******************************************************************************
Function Name: XllpUsimSetT0ErrorTriggerLevel
Description: Sets the number of times a character could be retransmitted in T=0 mode
due to a T=0 error. The errors do not generate an interrupt until
the level is met.
Global Registers: ECR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Xllp_Usim_TriggerLevel_T: sets the trigger level.
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimSetT0ErrorTriggerLevel(void *XllpUsimBase, Xllp_Usim_TriggerLevel_T TriggerLevel)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->ECR |= ((TriggerLevel << XLLP_USIM_ECR_T0ERR_TL_SHIFT) & XLLP_USIM_ECR_T0ERR_TL);
}
/******************************************************************************
Function Name: XllpUsimSetTransportProtocol
Description: chooses the transport protocol for both the receiver and the transmitter
as either T=0 or T=1
Global Registers: LCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimSetTransportProtocol(void *XllpUsimBase, Xllp_Usim_Protocol_T Protocol)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
switch(Protocol)
{
case XLLP_USIM_ReceiverT0_TransmitterT0:
USIM->LCR &= ~XLLP_USIM_LCR_RX_T1_MODE;
USIM->LCR &= ~XLLP_USIM_LCR_TX_T1_MODE;
break;
case XLLP_USIM_ReceiverT0_TransmitterT1:
USIM->LCR &= ~XLLP_USIM_LCR_RX_T1_MODE;
USIM->LCR |= XLLP_USIM_LCR_TX_T1_MODE;
break;
case XLLP_USIM_ReceiverT1_TransmitterT0:
USIM->LCR |= XLLP_USIM_LCR_RX_T1_MODE;
USIM->LCR &= ~XLLP_USIM_LCR_TX_T1_MODE;
break;
case XLLP_USIM_ReceiverT1_TransmitterT1:
USIM->LCR |= XLLP_USIM_LCR_RX_T1_MODE;
USIM->LCR |= XLLP_USIM_LCR_TX_T1_MODE;
break;
default:
USIM->LCR &= ~XLLP_USIM_LCR_RX_T1_MODE;
USIM->LCR &= ~XLLP_USIM_LCR_TX_T1_MODE;
break;
}
}
/******************************************************************************
Function Name: XllpUsimSelectParityType
Description: Selects whether you want to check for even or odd parity
Global Registers: LCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Xllp_Usim_ParitySelect_T: "odd" or "even". See Enum
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimSelectParityType(void *XllpUsimBase, Xllp_Usim_ParitySelect_T ParityType)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
USIM->LCR |= ((ParityType << XLLP_USIM_LCR_EPS_SHIFT) & XLLP_USIM_LCR_EPS);
}
/******************************************************************************
Function Name: XllpUsimSetConvention
Description: Sets the convention as either "Direct" or "inverse"
Global Registers: LCR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Xllp_Usim_Convention_T: XLLP_USIM_DirectConvention or XLLP_USIM_InverseConvention
Output Arguments:
None
Return Value:
None
*******************************************************************************/
void XllpUsimSetConvention(void *XllpUsimBase, Xllp_Usim_Convention_T Convention)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
if(Convention == XLLP_USIM_DirectConvention)
{
USIM->LCR &= ~XLLP_USIM_LCR_ORDER;
USIM->LCR &= ~XLLP_USIM_LCR_INVERSE;
}
else if(Convention == XLLP_USIM_InverseConvention)
{
USIM->LCR |= XLLP_USIM_LCR_ORDER;
USIM->LCR |= XLLP_USIM_LCR_INVERSE;
}
}
/******************************************************************************
Function Name: XllpUsimGetLineStatus
Description: Read the Line Status register
Global Registers: LSR
Input Arguments:
XllpUsimBase: Base address of the USIM module
Output Arguments:
LineStatus: Status bits
Return Value:
None
*******************************************************************************/
void XllpUsimGetLineStatus(void *XllpUsimBase, XLLP_UINT32_T LineStatus)
{
XLLP_USIM_T *USIM = (XLLP_USIM_T *) XllpUsimBase;
LineStatus = USIM->LSR & XLLP_USIM_LSR_VALID_MASK;
}
/******************************************************************************
Function Name: XllpUsimSetExtraGuardTime
Description: Sets the Extra Guard Time
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -