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

📄 uart.lst

📁 NXP LPC2148 GPS Demo for Keil
💻 LST
📖 第 1 页 / 共 2 页
字号:
ARM COMPILER V2.53,  uart                                                                  12/04/08  01:40:25  PAGE 1   


ARM COMPILER V2.53, COMPILATION OF MODULE uart
OBJECT MODULE PLACED IN .\Obj\uart.obj
COMPILER INVOKED BY: D:\cx\ARM\BIN\CA.exe uart.c THUMB INCDIR(..\Common\inc) DEBUG PRINT(.\LST\UART.LST) TABS(4) OBJECT(
                    -.\Obj\uart.obj) 

stmt  level    source

    1          /*****************************************************************************
    2           *   uart.c:  UART API file for Philips LPC214x Family Microprocessors
    3           *
    4           *   Copyright(C) 2006, Philips Semiconductor
    5           *   All rights reserved.
    6           *
    7           *   History
    8           *   2005.10.01  ver 1.00    Prelimnary version, first Release
    9           *
   10          ******************************************************************************/
   11          #include "LPC214x.H"                        /* LPC21xx definitions */
   12          #include "type.h"
   13          #include "target.h"
   14          #include "irq.h"
   15          #include "uart.h"
   16          
   17          DWORD UART1Status;
   18          uint8 UART1TxEmpty = 1;
   19          uint8 UART1Buffer[BUFSIZE];
   20          DWORD UART1Count = 0;
   21          
   22          /*****************************************************************************
   23          ** Function name:       UART1Handler
   24          **
   25          ** Descriptions:        UART1 interrupt handler
   26          **
   27          ** parameters:          None
   28          ** Returned value:      None
   29          ** 
   30          *****************************************************************************/
   31          void UART1Handler (void) __irq 
   32          {
   33   1          uint8 IIRValue, LSRValue;
   34   1          uint8 Dummy;
   35   1      
   36   1          IENABLE;                /* handles nested interrupt */  
   37   1          IIRValue = U1IIR;
   38   1          
   39   1          IIRValue >>= 1;         /* skip pending bit in IIR */
   40   1          IIRValue &= 0x07;           /* check bit 1~3, interrupt identification */
   41   1          if ( IIRValue == IIR_RLS )      /* Receive Line Status */
   42   1          {
   43   2          LSRValue = U1LSR;
   44   2          /* Receive Line Status */
   45   2          if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
   46   2          {
   47   3              /* There are errors or break interrupt */
   48   3              /* Read LSR will clear the interrupt */
   49   3              UART1Status = LSRValue;
   50   3              Dummy = U1RBR;      /* Dummy read on RX to clear 
   51   3                          interrupt, then bail out */
   52   3              IDISABLE;
   53   3              VICVectAddr = 0;        /* Acknowledge Interrupt */
   54   3              return;
   55   3          }
   56   2          if ( LSRValue & LSR_RDR )   /* Receive Data Ready */            
   57   2          {
   58   3              /* If no error on RLS, normal ready, save into the data buffer. */
ARM COMPILER V2.53,  uart                                                                  12/04/08  01:40:25  PAGE 2   

   59   3              /* Note: read RBR will clear the interrupt */
   60   3              UART1Buffer[UART1Count] = U1RBR;
   61   3              UART1Count++;
   62   3              if ( UART1Count == BUFSIZE )
   63   3              {
   64   4              UART1Count = 0;     /* buffer overflow */
   65   4              }   
   66   3          }
   67   2          }
   68   1          else if ( IIRValue == IIR_RDA ) /* Receive Data Available */
   69   1          {
   70   2          /* Receive Data Available */
   71   2          UART1Buffer[UART1Count] = U1RBR;
   72   2          UART1Count++;
   73   2          if ( UART1Count == BUFSIZE )
   74   2          {
   75   3              UART1Count = 0;     /* buffer overflow */
   76   3          }
   77   2          }
   78   1          else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */
   79   1          {
   80   2          /* Character Time-out indicator */
   81   2          UART1Status |= 0x100;       /* Bit 9 as the CTI error */
   82   2          }
   83   1          else if ( IIRValue == IIR_THRE )    /* THRE, transmit holding register empty */
   84   1          {
   85   2          /* THRE interrupt */
   86   2          LSRValue = U1LSR;       /* Check status in the LSR to see if
   87   2                          valid data in U1THR or not */
   88   2          if ( LSRValue & LSR_THRE )
   89   2          {
   90   3              UART1TxEmpty = 1;
   91   3          }
   92   2          else
   93   2          {
   94   3              UART1TxEmpty = 0;
   95   3          }
   96   2          }
   97   1          
   98   1          IDISABLE;
   99   1          VICVectAddr = 0;        /* Acknowledge Interrupt */
  100   1      }
  101          
  102          /*****************************************************************************
  103          ** Function name:       UARTInit
  104          **
  105          ** Descriptions:        Initialize UART1 port, setup pin select,
  106          **              clock, parity, stop bits, FIFO, etc.
  107          **
  108          ** parameters:          UART baudrate
  109          ** Returned value:      true or false, return false only if the 
  110          **              interrupt handler can't be installed to the 
  111          **              VIC table
  112          ** 
  113          *****************************************************************************/
  114          DWORD UARTInit( DWORD baudrate )
  115          {
  116   1          DWORD Fdiv;
  117   1      
  118   1          PINSEL0 = 0x00050005;       /* Enable RxD1 and TxD1, RxD0 and TxD0 */
  119   1      
  120   1          U1LCR = 0x83;               /* 8 bits, no Parity, 1 Stop bit    */
  121   1          Fdiv = ( Fpclk / 16 ) / baudrate ;  /*baud rate */
  122   1          U1DLM = Fdiv / 256;                         
  123   1          U1DLL = Fdiv % 256; 
  124   1          U1LCR = 0x03;               /* DLAB = 0                         */
ARM COMPILER V2.53,  uart                                                                  12/04/08  01:40:25  PAGE 3   

  125   1          U1FCR = 0x07;       /* Enable and reset TX and RX FIFO. */
  126   1      
  127   1          if ( install_irq( UART1_INT, (void *)UART1Handler ) == FALSE )
  128   1          {
  129   2          return (FALSE);
  130   2          }
  131   1         
  132   1          U1IER = IER_RBR | IER_THRE | IER_RLS;   /* Enable UART1 interrupt */
  133   1          return (TRUE);
  134   1      }
  135          
  136          /*****************************************************************************
  137          ** Function name:       UARTSend
  138          **
  139          ** Descriptions:        Send a block of data to the UART 0 port based
  140          **              on the data length
  141          **
  142          ** parameters:          buffer pointer, and data length
  143          ** Returned value:      None
  144          ** 
  145          *****************************************************************************/
  146          void UARTSend(uint8 *BufferPtr, DWORD Length )
  147          {
  148   1          while ( Length != 0 )
  149   1          {
  150   2          while ( !(UART1TxEmpty & 0x01) );   /* THRE status, contain valid 
  151   2                              data */
  152   2          U1THR = *BufferPtr;
  153   2          UART1TxEmpty = 0;   /* not empty in the THR until it shifts out */
  154   2          BufferPtr++;
  155   2          Length--;
  156   2          }
  157   1          return;
  158   1      }
  159          
  160          /******************************************************************************
  161          **                            End Of File
  162          ******************************************************************************/
ARM COMPILER V2.53,  uart                                                                  12/04/08  01:40:25  PAGE 4   

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN CODE16 (install_irq?T)
 EXTERN CODE16 (?C?UDIV?T)



*** PUBLICS:
 PUBLIC         UARTInit?T
 PUBLIC         UARTSend?T
 PUBLIC         UART1Handler?A
 PUBLIC         UART1Status
 PUBLIC         UART1TxEmpty
 PUBLIC         UART1Buffer
 PUBLIC         UART1Count



*** DATA SEGMENT '?DT0?uart':
 00000000          UART1Status:
 00000000            DS          4
 00000004          UART1Count:
 00000004           BEGIN_INIT
 00000004  00000000  DD          0x0
 00000008           END_INIT
 00000008          UART1TxEmpty:
 00000008           BEGIN_INIT
 00000008  01        DB          0x1
 00000009           END_INIT
 00000009          UART1Buffer:
 00000009            DS          16



*** CODE SEGMENT '?PR?UART1Handler?A?uart':
   31: void UART1Handler (void) __irq 
 00000000  E92D403F  STMDB       R13!,{R0-R5,LR}
 00000004  ---- Variable 'LSRValue' assigned to Register 'R0' ----
   32: {
 00000004            ; SCOPE-START
   36:     IENABLE;                /* handles nested interrupt */  
 00000004  E14FE000  MRS         R14,SPSR
 00000008  E92D4000  STMFD       R13!,{LR}
 0000000C  E321F01F  MSR         CPSR_c,#0x1F
 00000010  E92D4000  STMFD       R13!,{LR}
   37:     IIRValue = U1IIR;
 00000014  E5101000  LDR         R1,=0xE0010008
 00000018  E5912000  LDR         R2,[R1,#0x0]
 0000001C  E1A02C02  MOV         R2,R2,LSL #24
 00000020  E1A02C22  MOV         R2,R2,LSR #24
 00000024  ---- Variable 'IIRValue' assigned to Register 'R2' ----
   39:     IIRValue >>= 1;         /* skip pending bit in IIR */
 00000024  E1A020A2  MOV         R2,R2,LSR #1 ; IIRValue
   40:     IIRValue &= 0x07;           /* check bit 1~3, interrupt identification */
 00000028  E2022007  AND         R2,R2,#0x0007 ; IIRValue
   41:     if ( IIRValue == IIR_RLS )      /* Receive Line Status */
 0000002C  E1A01002  MOV         R1,R2 ; IIRValue
 00000030  E1A01C01  MOV         R1,R1,LSL #24 ; IIRValue
 00000034  E1A01C21  MOV         R1,R1,LSR #24
 00000038  E3510003  CMP         R1,#0x0003
 0000003C  1A000030  BNE         L_1  ; Targ=0x104
   43:     LSRValue = U1LSR;
 00000040  E5100000  LDR         R0,=0xE0010014
 00000044  E5900000  LDR         R0,[R0,#0x0]
 00000048  E1A00C00  MOV         R0,R0,LSL #24
 0000004C  E1A00C20  MOV         R0,R0,LSR #24
   45:     if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
 00000050  E1A01000  MOV         R1,R0 ; LSRValue
 00000054  E1A01C01  MOV         R1,R1,LSL #24 ; LSRValue
 00000058  E1A01C21  MOV         R1,R1,LSR #24
ARM COMPILER V2.53,  uart                                                                  12/04/08  01:40:25  PAGE 5   

 0000005C  E311009E  TST         R1,#0x009E
 00000060  0A00000E  BEQ         L_2  ; Targ=0xA0
   49:         UART1Status = LSRValue;
 00000064  E1A01000  MOV         R1,R0 ; LSRValue
 00000068  E1A03C01  MOV         R3,R1,LSL #24 ; LSRValue
 0000006C  E1A03C23  MOV         R3,R3,LSR #24
 00000070  E5101000  LDR         R1,=UART1Status ; UART1Status
 00000074  E5813000  STR         R3,[R1,#0x0] ; UART1Status
   50:         Dummy = U1RBR;      /* Dummy read on RX to clear 

⌨️ 快捷键说明

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