Пример #1
0
void _kuart_int_rx_tx_isr
   (
      /* [IN] the address of the device specific information */
      pointer parameter
   )
{ /* Body */
   IO_SERIAL_INT_DEVICE_STRUCT_PTR        int_io_dev_ptr = parameter;
   KUART_INFO_STRUCT_PTR                  sci_info_ptr = int_io_dev_ptr->DEV_INFO_PTR;
   UART_MemMapPtr                         sci_ptr = sci_info_ptr->SCI_PTR;
   volatile int_32                        c;

#if MQX_ENABLE_LOW_POWER

    if (int_io_dev_ptr->LPM_INFO.FLAGS & IO_PERIPHERAL_WAKEUP_ENABLE)
    {
        /* Disable wakeup settings */
        int_io_dev_ptr->LPM_INFO.FLAGS &= (~ IO_PERIPHERAL_WAKEUP_ENABLE);
        sci_ptr->C2 &= (~ (UART_C2_RWU_MASK));
        sci_ptr->C1 &= (~ (UART_C1_WAKE_MASK | UART_C1_ILT_MASK));
        sci_ptr->C4 &= (~ (UART_C4_MAEN1_MASK | UART_C4_MAEN2_MASK));
        sci_ptr->MA1 = 0;
        sci_ptr->MA2 = 0;

        /* Do not return to CPU sleep anymore */
        if (int_io_dev_ptr->LPM_INFO.FLAGS & IO_PERIPHERAL_WAKEUP_SLEEPONEXIT_DISABLE)
        {
            int_io_dev_ptr->LPM_INFO.FLAGS &= (~ IO_PERIPHERAL_WAKEUP_SLEEPONEXIT_DISABLE);
            _lpm_wakeup_core ();
        }
    }

#endif

   ++sci_info_ptr->INTERRUPTS;

   /* try if RX buffer has some characters */
   if (sci_ptr->S1 & UART_S1_RDRF_MASK) {
      c = sci_ptr->D;
      if (!_io_serial_int_addc(int_io_dev_ptr, c)) {
          sci_info_ptr->RX_DROPPED_INPUT++;
      }
      sci_info_ptr->RX_CHARS++;
   }

   /* try if TX buffer is still not full */
   if (sci_ptr->S1 & UART_S1_TDRE_MASK) {
      c = _io_serial_int_nextc(int_io_dev_ptr);
      if (c >= 0) {
          sci_ptr->D = c;
      } else {
         /* All data sent, disable transmit interrupt */
         sci_ptr->C2 &= ~UART_C2_TIE_MASK;
      }
      sci_info_ptr->TX_CHARS++;
   }

}  /* Endbody */
Пример #2
0
/*FUNCTION****************************************************************
*
* Function Name    : _kuart_mix_rx_isr
* Returned Value   : none
* Comments         :
*  mix callback for the serial rx.
*
*************************************************************************/
void _kuart_dma_rx_isr
(
   /* [IN] the address of the device specific information */
   void * parameter,
   int tcd_done,
   uint32_t tcd_seq
)
{ /* Body */
    IO_SERIAL_INT_DEVICE_STRUCT_PTR        int_io_dev_ptr = parameter;
    KUART_INFO_STRUCT_PTR                  sci_info_ptr = int_io_dev_ptr->DEV_INFO_PTR;
    uint32_t i;
    int8_t cc;
    uint8_t *rx_buf;	

#if 0
    _int_disable();
    rx_buf = sci_info_ptr->RX_ACTIVE;
    sci_info_ptr->RX_ACTIVE = sci_info_ptr->RX_ACTIVE == sci_info_ptr->RX_BUF ?
            sci_info_ptr->RX_BUF + int_io_dev_ptr->IN_QUEUE->MAX_SIZE / 2 :
	    sci_info_ptr->RX_BUF;	
    ++sci_info_ptr->INTERRUPTS;
    for (i=sci_info_ptr->RX_BYTES; i<int_io_dev_ptr->IN_QUEUE->MAX_SIZE / 2; i++)
    {
        cc = rx_buf[i];
        _io_serial_int_addc(int_io_dev_ptr, cc);
    }
    sci_info_ptr->RX_CHARS += int_io_dev_ptr->IN_QUEUE->MAX_SIZE / 2 - sci_info_ptr->RX_BYTES;
    sci_info_ptr->RX_KEEP = 1;
    sci_info_ptr->RX_BYTES = 0;
    _int_enable();
#endif
    //_int_disable();
    sci_info_ptr->dmaC += int_io_dev_ptr->IQUEUE_SIZE;
    //_int_enable();
    //printf("UART dma rx isr \n");
    //printf("I \n");
}  /* Endbody */
Пример #3
0
/*******************************************************************************
** Function Name	:uart_isr
** Input		:
** Return		:
** Author		:wk
** Version	:
** Date		:
** Dessription	:
** Reverse	:
*******************************************************************************/
void uart_isr(pointer parameter)
{
#if 1   // wk -->  在有些工程中没有定义read_buf[]和LCDTouchSel()  --> 0 else --> 1
  /* Body */
   IO_SERIAL_INT_DEVICE_STRUCT_PTR        int_io_dev_ptr = parameter;
   KUART_INFO_STRUCT_PTR                  sci_info_ptr = int_io_dev_ptr->DEV_INFO_PTR;
   UART_MemMapPtr                         sci_ptr = sci_info_ptr->SCI_PTR;
   /*
   ** author: wk @2012-10-03
   ** description: 和上面三行的功能相同
   */
//    UART_MemMapPtr                         sci_ptr; 
//    sci_ptr=(UART_MemMapPtr)UART4_BASE_PTR;  //wk
    
    volatile int_32                        c;


   /* try if RX buffer has some characters */
#if 0  // wk _system
   if (sci_ptr->S1 & UART_S1_RDRF_MASK) {
      c = sci_ptr->D;
//        printf("c=%x\n",c);
      if (!_io_serial_int_addc(int_io_dev_ptr, c)) {
          sci_info_ptr->RX_DROPPED_INPUT++;
      }
      sci_info_ptr->RX_CHARS++;
   }
#endif 
   
#if 1 // wk --> data rec
 static   uchar  i=0,flag=0;
//  do  
   {
   if (sci_ptr->S1 & UART_S1_RDRF_MASK) {
      c = sci_ptr->D;
      
      if(c == 0xaa || flag==1)  //第一个数据是 0xaa 开始标志才开始接收
      {
          read_buffer[i++]= c ;
          flag=1;
      }
      
      if (!_io_serial_int_addc(int_io_dev_ptr, c)) {
          sci_info_ptr->RX_DROPPED_INPUT++;
      }
      sci_info_ptr->RX_CHARS++;
   }
   }
//   while(c != 0x3c);
#endif  // wk --< data rec
   
#define UART_EVENTTEST 1
#if !UART_EVENTTEST
    if(i == 8) 
    {
      i=0;flag=0;
      LCDTouchSel(); // 触摸屏按键判断程序
    }
#endif // !UART_EVENTTEST

   
#if UART_EVENTTEST
    if(i == 8) 
    {
      i=0;flag=0;     
      pointer puart_event;
      
#ifdef _UART_DBUG_      
      if(_event_open("uart_event",&puart_event) != MQX_OK)
      {
        printf("\n Open event failed of serl_int_kuart.c");
      }
      else 
        printf("\n Open event OK of serl_int_kuart.c");
      
      if (_event_set(puart_event,0x01) != MQX_OK) {
         printf("\n Set Event failed of serl_int_kuart.c");
      }  
      else
         printf("\n Set Event OK of serl_int_kuart.c");
#endif
      
#ifndef _UART_DBUG_
      _event_open("uart_event",&puart_event);
      _event_set(puart_event,0x01);
#endif
    }
#endif // UART_EVENTTEST
   
#endif  
}
Пример #4
0
void _mcf54xx_uart_serial_int_isr
   (
      /* [IN] the address of the device specific information */
      pointer parameter
   )
{ /* Body */
   IO_SERIAL_INT_DEVICE_STRUCT_PTR        int_io_dev_ptr = parameter;
   MCF54XX_UART_SERIAL_INFO_STRUCT_PTR    uart_info_ptr;
   volatile MCF54XX_UART_STRUCT _PTR_     uart_ptr;
   int_32                                 c;
   uint_16                                stat;
   boolean                                work;

   uart_info_ptr = int_io_dev_ptr->DEV_INFO_PTR;
   uart_ptr = uart_info_ptr->UART_PTR;

   ++uart_info_ptr->INTERRUPTS;

   /* Receive loop */
   work = TRUE;
   while (work) {
      work = FALSE;
      stat = uart_ptr->READ.USR;

      while (stat & MCF54XX_UART_USR_RXRDY) {
         c = uart_ptr->READ.URB;    /* this clears the status bit */

         if (stat & (MCF54XX_UART_USR_RB | MCF54XX_UART_USR_FE |
                     MCF54XX_UART_USR_PE | MCF54XX_UART_USR_OE))
         {
            if (stat & MCF54XX_UART_USR_RB) {
               ++uart_info_ptr->RX_BREAKS;
               c = uart_ptr->READ.URB;    /* read break character */
               uart_ptr->WRITE.UCR = MCF54XX_UART_UCR_RESET_BREAK;
            } /* Endif */
            if (stat & MCF54XX_UART_USR_FE) {
               ++uart_info_ptr->RX_FRAMING_ERRORS;
            } /* Endif */
            if (stat & MCF54XX_UART_USR_PE) {
               ++uart_info_ptr->RX_PARITY_ERRORS;
            } /* Endif */
            if (stat & MCF54XX_UART_USR_OE) {
               ++uart_info_ptr->RX_OVERRUNS;
            } /* Endif */
            uart_ptr->WRITE.UCR = MCF54XX_UART_UCR_RESET_ERROR;
         } /* Endif */

         uart_info_ptr->RX_CHARS++;
         work = TRUE;

         if (!_io_serial_int_addc(int_io_dev_ptr, c)) {
            uart_info_ptr->RX_DROPPED_INPUT++;
         } /* Endif */
         stat = uart_ptr->READ.USR;

      } /* Endwhile */

      while (stat & MCF54XX_UART_USR_TXRDY)  {

         c = _io_serial_int_nextc(int_io_dev_ptr);
         if (c >= 0) {
            work = TRUE;
            uart_ptr->WRITE.UTB = c;
            uart_info_ptr->INT_ENABLE_BITS |= MCF54XX_UART_UIMR_TXRDY;
            uart_ptr->WRITE.UIMR = uart_info_ptr->INT_ENABLE_BITS;
         } else {
            /* No output. Turn off transmit interrupt */
            uart_info_ptr->INT_ENABLE_BITS &= ~MCF54XX_UART_UIMR_TXRDY;
            uart_ptr->WRITE.UIMR = uart_info_ptr->INT_ENABLE_BITS;
            break;
         } /* Endif */

         stat = uart_ptr->READ.USR;
         uart_info_ptr->TX_CHARS++;

      } /* Endwhile */

   } /* Endwhile */

} /* Endbody */