?? probe_rs232c.c
字號:
* ProbeRS232_RxTxISRHandler()
*
* Description: Handle Rx and Tx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*
* Note(s) : (1) The VICAddr register MUST be written by the general IRQ handler which called
* this specific IRQ handler after this function returns.
*********************************************************************************************************
*/
void ProbeRS232_RxTxISRHandler (void)
{
volatile CPU_INT08U rx_data;
volatile CPU_INT08U lsr;
volatile CPU_INT08U iir;
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_0) /* ------------------------- UART0 ------------------------ */
iir = U0IIR & 0x0F;
while (iir != 1) {
switch (iir) {
case 2: /* Transmitted character? */
ProbeRS232_TxHandler();
break;
case 4: /* Received a character? */
lsr = U0LSR;
rx_data = U0RBR;
ProbeRS232_RxHandler(rx_data); /* Call the generic Rx handler */
break;
default:
break;
}
iir = U0IIR & 0x0F;
}
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_1) /* ------------------------- UART1 ------------------------ */
iir = U1IIR & 0x0F;
while (iir != 1) {
switch (iir) {
case 2: /* Transmitted character? */
ProbeRS232_TxHandler();
break;
case 4: /* Received a character? */
lsr = U1LSR;
rx_data = U1RBR;
ProbeRS232_RxHandler(rx_data); /* Call the generic Rx handler */
break;
default:
break;
}
iir = U1IIR & 0x0F;
}
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_2) /* ------------------------- UART2 ------------------------ */
iir = U2IIR & 0x0F;
while (iir != 1) {
switch (iir) {
case 2: /* Transmitted character? */
ProbeRS232_TxHandler();
break;
case 4: /* Received a character? */
lsr = U2LSR;
rx_data = U2RBR;
ProbeRS232_RxHandler(rx_data); /* Call the generic Rx handler */
break;
default:
break;
}
iir = U2IIR & 0x0F;
}
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_3) /* ------------------------- UART3 ------------------------ */
iir = U3IIR & 0x0F;
while (iir != 1) {
switch (iir) {
case 2: /* Transmitted character? */
ProbeRS232_TxHandler();
break;
case 4: /* Received a character? */
lsr = U3LSR;
rx_data = U3RBR;
ProbeRS232_RxHandler(rx_data); /* Call the generic Rx handler */
break;
default:
break;
}
iir = U3IIR & 0x0F;
}
#endif
}
/*
*********************************************************************************************************
* ProbeRS232_RxISRHandler()
*
* Description: Handle Rx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*
* Note(s) : This function is empty because Rx interrupts are handled by ProbeRS232_RxTxISRHandler()
*********************************************************************************************************
*/
void ProbeRS232_RxISRHandler (void)
{
}
/*
*********************************************************************************************************
* ProbeRS232_RxIntDis()
*
* Description: Disable Rx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*********************************************************************************************************
*/
void ProbeRS232_RxIntDis (void)
{
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_0)
U0IER &= ~DEF_BIT_00;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_1)
U1IER &= ~DEF_BIT_00;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_2)
U2IER &= ~DEF_BIT_00;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_3)
U3IER &= ~DEF_BIT_00;
#endif
}
/*
*********************************************************************************************************
* ProbeRS232_RxIntEn()
*
* Description: Enable Rx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*********************************************************************************************************
*/
void ProbeRS232_RxIntEn (void)
{
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_0)
U0IER |= DEF_BIT_00;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_1)
U1IER |= DEF_BIT_00;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_2)
U2IER |= DEF_BIT_00;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_3)
U3IER |= DEF_BIT_00;
#endif
}
/*
*********************************************************************************************************
* ProbeRS232_TxISRHandler()
*
* Description: Handle Tx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*
* Note(s) : This function is empty because Tx interrupts are handled by ProbeRS232_RxTxISRHandler()
*********************************************************************************************************
*/
void ProbeRS232_TxISRHandler (void)
{
}
/*
*********************************************************************************************************
* ProbeRS232_Tx1()
*
* Description: Transmit one byte.
*
* Argument(s): c The byte to transmit.
*
* Return(s) : none.
*********************************************************************************************************
*/
void ProbeRS232_Tx1 (CPU_INT08U c)
{
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_0)
U0THR = c;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_1)
U1THR = c;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_2)
U2THR = c;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_3)
U3THR = c;
#endif
}
/*
*********************************************************************************************************
* ProbeRS232_TxIntDis()
*
* Description: Disable Tx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*********************************************************************************************************
*/
void ProbeRS232_TxIntDis (void)
{
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_0)
U0IER &= ~DEF_BIT_01;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_1)
U1IER &= ~DEF_BIT_01;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_2)
U2IER &= ~DEF_BIT_01;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_3)
U3IER &= ~DEF_BIT_01;
#endif
}
/*
*********************************************************************************************************
* ProbeRS232_TxIntEn()
*
* Description: Enable Tx interrupts.
*
* Argument(s): none.
*
* Return(s) : none.
*********************************************************************************************************
*/
void ProbeRS232_TxIntEn (void)
{
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_0)
U0IER |= DEF_BIT_01;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_1)
U1IER |= DEF_BIT_01;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_2)
U2IER |= DEF_BIT_01;
#endif
#if (PROBE_RS232_COMM_SEL == PROBE_RS232_UART_3)
U3IER |= DEF_BIT_01;
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -