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

📄 lib_at91.lst

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 LST
📖 第 1 页 / 共 5 页
字号:
    443          //* Object              : Disable an USART.
    444          //* Input Parameters    : <usart_pt> = USART Descriptor pointer
    445          //* Output Parameters   : none
    446          //* Functions called    : at91_clock_close, at91_pio_open
    447          //*----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    448          void at91_usart_close ( const UsartDesc *usart_pt )
    449          //* Begin
    450          {
   \                     at91_usart_close:
   \   00000000   30402DE9              STMDB    SP!,{R4,R5,LR}     ;; Push
    451              //* Disable the clock on the Peripheral
    452              at91_clock_close ( usart_pt->periph_id ) ;
   \   00000004   0040A0E1              MOV      R4,R0
   \   00000008   0B00D4E5              LDRB     R0,[R4, #+11]
   \   0000000C   ........              BL       at91_clock_close
    453          
    454              //* Define all USARTs pins as pio
    455              at91_pio_open ( usart_pt->pio_ctrl,
    456                              (1 << usart_pt->pin_txd) |
    457                              (1 << usart_pt->pin_rxd) |
    458                              (1 << usart_pt->pin_sck),
    459                              RESET_PIO_CONF ) ;
   \   00000010   0020A0E3              MOV      R2,#+0x0
   \   00000014   0100A0E3              MOV      R0,#+0x1
   \   00000018   0910D4E5              LDRB     R1,[R4, #+9]
   \   0000001C   0030A0E1              MOV      R3,R0
   \   00000020   0850D4E5              LDRB     R5,[R4, #+8]
   \   00000024   1335A0E1              MOV      R3,R3, LSL R5
   \   00000028   100183E1              ORR      R0,R3,R0, LSL R1
   \   0000002C   0110A0E3              MOV      R1,#+0x1
   \   00000030   0A30D4E5              LDRB     R3,[R4, #+10]
   \   00000034   111380E1              ORR      R1,R0,R1, LSL R3
   \   00000038   040094E5              LDR      R0,[R4, #+4]
   \   0000003C   ........              BL       at91_pio_open
    460          
    461              //* Disable all interrupts
    462              usart_pt->usart_base->US_IDR = 0xFFFFFFFF ;
   \   00000040   0000E0E3              MVN      R0,#+0x0
   \   00000044   001094E5              LDR      R1,[R4, #+0]
   \   00000048   0C0081E5              STR      R0,[R1, #+12]
    463          
    464              //* Abort the Peripheral Data Transfers
    465              usart_pt->usart_base->US_RCR = 0 ;
   \   0000004C   0000A0E3              MOV      R0,#+0x0
   \   00000050   001094E5              LDR      R1,[R4, #+0]
   \   00000054   340081E5              STR      R0,[R1, #+52]
    466              usart_pt->usart_base->US_TCR = 0 ;
   \   00000058   001094E5              LDR      R1,[R4, #+0]
   \   0000005C   3C0081E5              STR      R0,[R1, #+60]
    467          
    468              //* Disable receiver and transmitter and stop any activity immediately
    469              usart_pt->usart_base->US_CR = US_TXDIS | US_RXDIS | US_RSTTX | US_RSTRX ;
   \   00000060   AC00A0E3              MOV      R0,#+0xAC
   \   00000064   001094E5              LDR      R1,[R4, #+0]
   \   00000068   000081E5              STR      R0,[R1, #+0]
    470          
    471          //* End
    472          }
   \   0000006C   3080BDE8              LDMIA    SP!,{R4,R5,PC}     ;; return
    473          
    474          //*----------------------------------------------------------------------------
    475          //* Function Name       : at91_usart_get_status
    476          //* Object              : Read the Status Register of an USART.
    477          //* Input Parameters    : <usart_pt> = USART Descriptor pointer
    478          //* Output Parameters   : USART Status Register
    479          //* Functions called    : none
    480          //*----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    481          u_int at91_usart_get_status ( const UsartDesc *usart_pt )
    482          //* Begin
    483          {
    484              //* Return the Control Status Register Value
    485              return ( usart_pt->usart_base->US_CSR ) ;
   \                     at91_usart_get_status:
   \   00000000   001090E5              LDR      R1,[R0, #+0]
   \   00000004   140091E5              LDR      R0,[R1, #+20]
   \   00000008   0EF0A0E1              MOV      PC,LR              ;; return
    486          
    487          //* End
    488          }
    489          
    490          //*----------------------------------------------------------------------------
    491          //* Function Name       : at91_usart_trig_cmd
    492          //* Object              : Reset the Status Bits of an USART.
    493          //* Input Parameters    : <usart_pt> = USART Descriptor pointer
    494          //*                     : <cmd>      = command mask
    495          //* Output Parameters   : none
    496          //* Functions called    : none
    497          //*----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    498          void at91_usart_trig_cmd ( const UsartDesc *usart_pt, u_int cmd )
   \                     at91_usart_trig_cmd:
   \   00000000                              REQUIRE ??Subroutine0_0
    499          //* Begin
    500          {
    501              //* Write the command in the Control Register
    502              usart_pt->usart_base->US_CR = cmd ;

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \                     ??Subroutine0_0:
   \   00000000   002090E5              LDR      R2,[R0, #+0]
   \   00000004   001082E5              STR      R1,[R2, #+0]
   \   00000008   0EF0A0E1              MOV      PC,LR              ;; return
    503          
    504          //* End
    505          }
    506          
    507          //*----------------------------------------------------------------------------
    508          //* Function Name       : at91_usart_write
    509          //* Object              : Store a character in the Transmit hold Register.
    510          //* Input Parameters    : <usart_pt>  = USART Descriptor pointer
    511          //*                     : <character> = character to transmit
    512          //* Output Parameters   : none
    513          //* Functions called    : none
    514          //*----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    515          void at91_usart_write ( const UsartDesc *usart_pt, u_int character )
    516          //* Begin
    517          {
    518              //* Write the character in the Transmit Holding Register
    519              usart_pt->usart_base->US_THR = character ;
   \                     at91_usart_write:
   \   00000000   ........              B        ??Subroutine2_0
    520          
    521          //* End
    522          }
    523          
    524          //*----------------------------------------------------------------------------
    525          //* Function Name       : at91_usart_read
    526          //* Object              : Read a character from the Receive Register
    527          //* Input Parameters    : <usart_pt> = USART Descriptor pointer
    528          //*                     : <pt_char>  = point where to save the received character
    529          //* Output Parameters   : none
    530          //* Functions called    : none
    531          //*----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    532          void at91_usart_read ( const UsartDesc *usart_pt, u_int *pt_char )
    533          //* Begin
    534          {
    535              //* Read the received character and store it
    536              *pt_char = usart_pt->usart_base->US_RHR ;
   \                     at91_usart_read:
   \   00000000   002090E5              LDR      R2,[R0, #+0]
   \   00000004   180092E5              LDR      R0,[R2, #+24]
   \   00000008   ........              B        ??Subroutine1_1
    537          
    538          //* End
    539          }
    540          
    541          //*-----------------------------------------------------------------------------
    542          //* Function Name       : at91_usart_send_frame
    543          //* Object              : Transmit a complete frame.
    544          //* Input Parameters    : <usart_pt> =  USART pointer
    545          //*                     : <pt_buffer> = the address of the receive buffer
    546          //*                     : <max_size> = the maximum number of bytes to be
    547          //*                     :              received
    548          //*                     : <timeout> = the inter-character time delay in number
    549          //*                     :             of byte
    550          //* Output Parameters   :
    551          //* Functions called    : none
    552          //*-----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    553          u_int at91_usart_send_frame ( const UsartDesc *usart_pt, char *pt_buffer, u_int size_buf )
    554          //* Begin
    555          {
   \                     at91_usart_send_frame:
   \   00000000   10002DE9              STMDB    SP!,{R4}           ;; Push
    556          
    557              //* Wait for previous transfer finished
    558              while (( usart_pt->usart_base->US_CSR & US_ENDTX ) == 0 ) ;
   \                     ??at91_usart_send_frame_0:
   \   00000004   003090E5              LDR      R3,[R0, #+0]
   \   00000008   144093E5              LDR      R4,[R3, #+20]
   \   0000000C   FF4004E2              AND      R4,R4,#+0xFF       ;; Zero extend
   \   00000010   100014E3              TST      R4,#+0x10
   \   00000014   FAFFFF0A              BEQ      ??at91_usart_send_frame_0
    559          
    560              //* Store the address of the buffer
    561              usart_pt->usart_base->US_TPR = (u_int) pt_buffer ;
   \   00000018   381083E5              STR      R1,[R3, #+56]
    562          
    563              //* Store the number of bytes to transmit
    564              usart_pt->usart_base->US_TCR = size_buf ;
   \   0000001C   001090E5              LDR      R1,[R0, #+0]
   \   00000020   3C2081E5              STR      R2,[R1, #+60]
    565          
    566              //* Return true
    567              return ( TRUE ) ;
   \   00000024   0100A0E3              MOV      R0,#+0x1
   \   00000028   1000BDE8              LDMIA    SP!,{R4}           ;; Pop
   \   0000002C   0EF0A0E1              MOV      PC,LR              ;; return
    568          }
    569          //* End
    570          
    571          //*-----------------------------------------------------------------------------
    572          //* Function Name       : at91_usart_receive_frame
    573          //* Object              : Receive a complete frame.
    574          //* Input Parameters    : <usart_pt> =  USART pointer
    575          //*                     : <pt_buffer> = the address of the receive buffer
    576          //*                     : <max_size> = the maximum number of bytes to be
    577          //*                     :              received
    578          //*                     : <timeout> = the inter-character time delay in number
    579          //*                     :             of byte
    580          //* Output Parameters   :
    581          //* Functions called    : none
    582          //*-----------------------------------------------------------------------------

   \                                 In segment NEARFUNC_A, align 4, keep-with-next
   \   00000000                         CODE32   
    583          u_int at91_usart_receive_frame ( const UsartDesc *usart_pt, char *pt_buffer, u_int max_size , u_int timeout )
    584          //* Begin
    585          {
   \                     at91_usart_receive_frame:
   \   00000000   30002DE9              STMDB    SP!,{R4,R5}        ;; Push
    586          
    587              //* Store the timeout value
    588              usart_pt->usart_base->US_RTOR = (timeout * 10 / 4) ;
   \   00000004   0A40A0E3              MOV      R4,#+0xA
   \   00000008   930405E0              MUL      R5,R3,R4
   \   0000000C   2531A0E1              MOV      R3,R5, LSR #+2
   \   00000010   004090E5              LDR      R4,[R0, #+0]
   \   00000014   243084E5              STR      R3,[R4, #+36]
    589          
    590              //* Restart the timeout logic
    591              usart_pt->usart_base->US_CR = US_STTTO ;
   \   00000018   023BA0E3              MOV      R3,#+0x800
   \   0000001C   004090E5              LDR      R4,[R0, #+0]
   \   00000020   003084E5              STR      R3,[R4, #+0]
    592          

⌨️ 快捷键说明

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