⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uart.c

📁 瑞萨CAN通讯单片机程序
💻 C
📖 第 1 页 / 共 3 页
字号:
 * Notes	: Do not always need to wait for end of transmission
 *""FUNC COMMENT END""***************************************************/
void  SIO5_Tr( unsigned char *TrBuf, unsigned int TrNum)
{
	unsigned long	i;

	for( i = 0; i < TrNum; i++) {
		while(( S5TCNT & TBE) == 0);			/* Wait until transmit buffer is empty */
		S5TXB_L = *TrBuf++;				/* Transfer return data */
	}
	while(( S5TCNT & TSTAT) != 0);				/* Wait for end of transmission */
}

/*""FUNC COMMENT""*******************************************************
 * Function name: SIO0_RcvInt()
 *-----------------------------------------------------------------------
 * Description	: Reads out received data
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: -
 *""FUNC COMMENT END""***************************************************/
void	SIO0_RcvInt(void)
{
	unsigned char	data;
	unsigned char	status;

	status = S0RCNT;					/* Read receive status */
	data = S0RXB_L;						/* Read out received data */
	status |= S0RCNT;					/* Handle overrun */

	if(( status & ERS) == 0) {				/* Check receive error sum */
		RcvBuf0[ rx_cnt0++] = data;			/* Store received data */

	} else {						/* Disable reception */

		/* Error processing by user */

		S0RCNT &= ~REN;					/* Disable reception */
		S0RCNT |= REN;					/* Enable reception */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: SIO1_RcvInt()
 *-----------------------------------------------------------------------
 * Description	: Reads out received data
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	:
 *""FUNC COMMENT END""***************************************************/
void	SIO1_RcvInt(void)
{
	unsigned char	data;
	unsigned char	status;

	status = S1RCNT;					/* Read receive status */
	data = S1RXB_L;						/* Read out received data */
	status |= S1RCNT;					/* Handle overrun */

	if(( status & ERS) == 0) {				/* Check receive error sum */
		RcvBuf1[ rx_cnt1++] = data;			/* Store received data */

	} else {						/* Disable reception */

		/* Error processing by user */

		S1RCNT &= ~REN;					/* Disable reception */
		S1RCNT |= REN;					/* Enable reception */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: SIO2_RcvInt()
 *-----------------------------------------------------------------------
 * Description	: Reads out received data
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: -
 *""FUNC COMMENT END""***************************************************/
void	SIO2_RcvInt(void)
{
	unsigned char	data;
	unsigned char	status;

	status = S2RCNT;					/* Read receive status */
	data = S2RXB_L;						/* Read out received data */
	status |= S2RCNT;					/* Handle overrun */

	if(( status & ERS) == 0) {				/* Check receive error sum */
		RcvBuf2[ rx_cnt2++] = data;			/* Store received data */

	} else {						/* Disable reception */

		/* Error processing by user */

		S2RCNT &= ~REN;					/* Disable reception */
		S2RCNT |= REN;					/* Enable reception */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: SIO3_RcvInt()
 *-----------------------------------------------------------------------
 * Description	: Reads out received data
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: -
 *""FUNC COMMENT END""***************************************************/
void	SIO3_RcvInt(void)
{
	unsigned char	data;
	unsigned char	status;

	status = S3RCNT;					/* Read receive status */
	data = S3RXB_L;						/* Read out received data */
	status |= S3RCNT;					/* Handle overrun */

	if(( status & ERS) == 0) {				/* Check receive error sum */
		RcvBuf3[ rx_cnt3++] = data;			/* Store received data */

	} else {						/* Disable reception */

		/* Error processing by user */

		S3RCNT &= ~REN;					/* Disable reception */
		S3RCNT |= REN;					/* Enable reception */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: SIO4_RcvInt()
 *-----------------------------------------------------------------------
 * Description	: Reads out received data
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: -
 *""FUNC COMMENT END""***************************************************/
void	SIO4_RcvInt(void)
{
	unsigned char	data;
	unsigned char	status;

	status = S4RCNT;					/* Read receive status */
	data = S4RXB_L;						/* Read out received data */
	status |= S4RCNT;					/* Handle overrun */

	if(( status & ERS) == 0) {				/* Check receive error sum */
	RcvBuf4[ rx_cnt4++] = data;				/* Store received data */

	} else {

		/* Error processing by user */

		S4RCNT &= ~REN;					/* Disable reception */
		S4RCNT |= REN;					/* Enable reception */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: SIO5_RcvInt()
 *-----------------------------------------------------------------------
 * Description	: Reads out received data
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: -
 *""FUNC COMMENT END""***************************************************/
void	SIO5_RcvInt(void)
{
	unsigned char	data;
	unsigned char	status;

	status = S5RCNT;					/* Read receive status */
	data = S5RXB_L;						/* Read out received data */
	status |= S5RCNT;					/* Handle overrun */

	if(( status & ERS) == 0) {				/* Check receive error sum */
		RcvBuf5[ rx_cnt5++] = data;			/* Store received data */

	} else {						/* Disable reception */

		/* Error processing by user */

		S5RCNT &= ~REN;					/* Disable reception */
		S5RCNT |= REN;					/* Enable reception */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: IntHand_SIO23()
 *-----------------------------------------------------------------------
 * Description	: Processing by SIO2,3 transmit/receive interrupt handlers
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: Transmit interrupt is not considering
 *""FUNC COMMENT END""***************************************************/
void	IntHand_SIO23(void)
{
	if(( SI23STAT & IRQR3) != 0) {				/* Judge interrupt request */
		SI23STAT = ~IRQR3;				/* Clear interrupt request status */
		SIO3_RcvInt();					/* Process SIO3 receive interrupt */
	}

	if(( SI23STAT & IRQR2) != 0) {				/* Judge interrupt request */
		SI23STAT = ~IRQR2;				/* Clear interrupt request status */
		SIO2_RcvInt();					/* Process SIO2 receive interrupt */
	}
}

/*""FUNC COMMENT""*******************************************************
 * Function name: IntHand_SIO45()
 *-----------------------------------------------------------------------
 * Description	: Processing by SIO4,5 transmit/receive interrupt handlers
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: Transmit interrupt is not considering
 *""FUNC COMMENT END""***************************************************/
void	IntHand_SIO45()
{
	if(( SI45STAT & IRQR5) != 0) {				/* Judge interrupt request */
		SI45STAT = ~IRQR5;				/* Clear interrupt request status */
		SIO5_RcvInt();					/* Process SIO5 receive interrupt */
	}

	if(( SI45STAT & IRQR4) != 0) {				/* Judge interrupt request */
		SI45STAT = ~IRQR4;				/* Clear interrupt request status */
		SIO4_RcvInt();					/* Process SIO4 receive interrupt */
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -