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

📄 lib_at91.lst

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 LST
📖 第 1 页 / 共 3 页
字号:
    556          
    557              //* Wait for previous transfer finished
    558              while (( usart_pt->usart_base->US_CSR & US_ENDTX ) == 0 ) ;
    559          
    560              //* Store the address of the buffer
    561              usart_pt->usart_base->US_TPR = (u_int) pt_buffer ;
    562          
    563              //* Store the number of bytes to transmit
    564              usart_pt->usart_base->US_TCR = size_buf ;
    565          
    566              //* Return true
    567              return ( TRUE ) ;
    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          //*-----------------------------------------------------------------------------
    583          u_int at91_usart_receive_frame ( const UsartDesc *usart_pt, char *pt_buffer, u_int max_size , u_int timeout )
    584          //* Begin
    585          {
    586          
    587              //* Store the timeout value
    588              usart_pt->usart_base->US_RTOR = (timeout * 10 / 4) ;
    589          
    590              //* Restart the timeout logic
    591              usart_pt->usart_base->US_CR = US_STTTO ;
    592          
    593              //* Store the address of the buffer
    594              usart_pt->usart_base->US_RPR = (u_int) pt_buffer ;
    595          
    596              //* Store the number of bytes to receive
    597              usart_pt->usart_base->US_RCR = max_size ;
    598          
    599              //* Return true
    600              return ( TRUE ) ;
    601          }
    602          //* End
    603          //*----------------------------------------------------------------------------
    604          //* Function Name       : at91_tc_open
    605          //* Object              : Initialize Timer Counter Channel and enable is clock
    606          //* Input Parameters    : <tc_pt> = TC Channel Descriptor Pointer
    607          //*                       <mode> = Timer Counter Mode
    608          //*                     : <tioa> = TIOA enabled as peripheral if non null
    609          //*                     : <tiob> = TIOB enabled as peripheral if non null
    610          //* Output Parameters   : None
    611          //* Functions called    : at91_clock_open, at91_pio_close
    612          //*----------------------------------------------------------------------------
    613          void at91_tc_open ( const TCDesc *tc_pt, u_int mode, u_int tioa, u_int tiob )
    614          //* Begin
    615          {
    616              u_int pio = 0 ;
    617              //* Start the Clock of the Timer
    618              at91_clock_open ( tc_pt->periph_id ) ;
    619          
    620              pio = 1<<tc_pt->pin_tclk ;
    621              //* Enable TIOA pin if requested
    622              if ( tioa == TRUE )
    623              {
    624                  pio |= 1<<tc_pt->pin_tioa ;
    625              }
    626              //* Enable TIOB pin if requested
    627              if ( tiob == TRUE )
    628              {
    629                  pio |= 1<<tc_pt->pin_tiob ;
    630              }
    631              at91_pio_close ( tc_pt->pio_ctrl, pio ) ;
    632          
    633              //* Disable the clock and the interrupts
    634              tc_pt->tc_base->TC_CCR = TC_CLKDIS ;
    635              tc_pt->tc_base->TC_IDR = 0xFFFFFFFF ;
    636              pio = tc_pt->tc_base->TC_SR ;
    637          
    638              //* Set the Mode of the Timer Counter
    639              tc_pt->tc_base->TC_CMR = mode ;
    640          
    641              //* Enable the clock
    642              tc_pt->tc_base->TC_CCR = TC_CLKEN ;
    643          //* End
    644          }
    645          
    646          //*----------------------------------------------------------------------------
    647          //* Function Name       : at91_tc_close
    648          //* Object              : Stop a Timer Counter Channel and disable is clock
    649          //* Input Parameters    : <tc_pt> = the channel number
    650          //* Output Parameters   : None
    651          //* Functions called    : at91_clock_close
    652          //*----------------------------------------------------------------------------
    653          void at91_tc_close ( const TCDesc *tc_pt )
    654          //* Begin
    655          {
    656              //* Disable the clock and interrupts
    657              tc_pt->tc_base->TC_CCR = TC_CLKDIS ;
    658              tc_pt->tc_base->TC_IDR = 0xFFFFFFFF ;
    659          
    660              //* Stop the Clock of the Timer
    661              at91_clock_close ( tc_pt->periph_id ) ;
    662          //* End
    663          }
    664          
    665          //*----------------------------------------------------------------------------
    666          //* Function Name       : at91_tc_get_status
    667          //* Object              : Read the Status of a Timer Counter Channel
    668          //* Input Parameters    : <tc_pt> = the channel number
    669          //* Output Parameters   : the status value
    670          //* Functions called    : None
    671          //*----------------------------------------------------------------------------
    672          u_int at91_tc_get_status ( const TCDesc *tc_pt )
    673          //* Begin
    674          {
    675              //* Return the value of the Status Register
    676              return ( tc_pt->tc_base->TC_SR ) ;
    677          
    678          //* End
    679          }
    680          
    681          //*----------------------------------------------------------------------------
    682          //* Function Name       : at91_tc_trig_cmd
    683          //* Object              : Generate a software trigger on a TC channel
    684          //* Input Parameters    : <tc_pt> = the channel number to trig
    685          //* Output Parameters   : None
    686          //* Functions called    : at91_error
    687          //*----------------------------------------------------------------------------
    688          void at91_tc_trig_cmd ( const TCDesc *tc_pt, u_int cmd )
    689          //* Begin
    690          {
    691              //* Depending on the command
    692              switch (cmd)
    693              {
    694                  //* Case Channel Trigger
    695                  case TC_TRIG_CHANNEL:
    696                      //* Perform a Software trigger on the corresponding channel
    697                      tc_pt->tc_base->TC_CCR = TC_SWTRG ;
    698                      break ;
    699          
    700                  //* Case Synchronization Trigger
    701                  case TC_TRIG_BLOCK:
    702                      //* Perform a synchronization trigger
    703                      ((StructTCBlock *) ((u_int)tc_pt->tc_base & 0xF0))->TC_BCR = TC_SYNC ;
    704                      break ;
    705          
    706                  //* Unkonwn
    707                //  default :
    708                      //* Run the AT91 Library Error Macro
    709                 //$$$$     at91_error ("__FILE__","__LINE__") ;
    710              //* End Switch
    711              }
    712          //* End
    713          }
    714          
    715          //*----------------------------------------------------------------------------
    716          //* Function Name       : at91_tc_set_mode
    717          //* Object              : Update Timer Counter Mode Register with mask
    718          //* Input Parameters    : <tc_pt> = the channel number
    719          //*                     : <mask> = bit to modify in the mode register
    720          //*                     : <data> = set/clear bits in the mode register
    721          //* Output Parameters   : none
    722          //* Functions called    : none
    723          //*----------------------------------------------------------------------------
    724          void at91_tc_set_mode ( const TCDesc *tc_pt, u_int mask, u_int data )
    725          //* Begin
    726          {
    727              //* If data is not null
    728              if (data != 0)
    729                  //* Set bits in the Mode Register corresponding to the mask
    730                  tc_pt->tc_base->TC_CMR |= mask ;
    731              //* Else
    732              else
    733                  //* Clear bits in the Mode Register corresponding to the mask
    734                  tc_pt->tc_base->TC_CMR &= ~mask ;
    735              //* EndIf
    736          }
    737          //* End
    738          
    739          //*----------------------------------------------------------------------------
    740          //* Function Name       : at91_tc_read
    741          //* Object              : Read all Timer Counter Register
    742          //* Input Parameters    : <tc_pt> = Channel Descriptor Pointer
    743          //*                     : <reg> = Destination Register Value Table Pointer
    744          //* Output Parameters   : None
    745          //* Functions called    : None
    746          //*----------------------------------------------------------------------------
    747          void at91_tc_read ( const TCDesc *tc_pt, u_int reg[] )
    748          //* Begin
    749          {
    750              reg[RA] = tc_pt->tc_base->TC_RA ;
    751              reg[RB] = tc_pt->tc_base->TC_RB ;
    752              reg[RC] = tc_pt->tc_base->TC_RC ;
    753              reg[CV] = tc_pt->tc_base->TC_CV ;
    754          }
    755          //* End
    756          
    757          //*----------------------------------------------------------------------------
    758          //* Function Name       : at91_tc_write
    759          //* Object              : Write Timer Counter Register
    760          //* Input Parameters    : <tc_pt> = Timer Counter Channel Descriptor Pointer
    761          //*                     : <reg> = Source Register Value Table Pointer
    762          //* Output Parameters   : None
    763          //* Functions called    : None
    764          //*----------------------------------------------------------------------------
    765          void at91_tc_write ( const TCDesc *tc_pt, u_int reg[] )
    766          //* Begin
    767          {
    768              //* First Value -> Register A
    769              tc_pt->tc_base->TC_RA = reg[RA] ;
    770              //* Second Value -> Register B
    771              tc_pt->tc_base->TC_RB = reg[RB] ;
    772              //* Third Value -> Register C
    773              tc_pt->tc_base->TC_RC = reg[RC] ;
    774          }
    775          //* End
    776          //*----------------------------------------------------------------------------
    777          //* Function Name       : Interrupt Handlig
    778          //* Output Parameters   : None
    779          //* Functions called    : None
    780          //*----------------------------------------------------------------------------
    781          
    782          void at91_default_fiq_handler  (void)
    783          {
    784          	for(;;);
    785          }
    786          void  at91_default_irq_handler (void)
    787          {
    788          	for(;;);
    789          }
    790          
    791          void  at91_spurious_handler (void)
    792          {
    793          	for(;;);
    794          }
    795          
    796          

   Maximum stack usage in bytes:

     Function                  CSTACK
     --------                  ------
     at91_clock_close              0 
     at91_clock_get_status         0 
     at91_clock_open               0 
     at91_clock_set_mode           4 
     at91_default_fiq_handler      0 
     at91_default_irq_handler      0 
     at91_pio_close                0 
     at91_pio_open                 0 
     at91_pio_read                20 
     at91_pio_set_mode             0 
     at91_pio_write                0 
     at91_spurious_handler         0 
     at91_tc_close                 4 
     at91_tc_get_status            0 
     at91_tc_open                 24 
     at91_tc_read                  0 
     at91_tc_set_mode              0 
     at91_tc_trig_cmd              4 
     at91_tc_write                 0 
     at91_usart_close             12 
     at91_usart_get_status         0 
     at91_usart_open              24 
     at91_usart_read               0 
     at91_usart_receive_frame      8 
     at91_usart_send_frame         4 
     at91_usart_trig_cmd           0 
     at91_usart_write              0 

 
    80 bytes in segment HUGE_C    
     4 bytes in segment HUGE_I    
     4 bytes in segment HUGE_ID   
    12 bytes in segment INITTAB   
 1 240 bytes in segment NEARFUNC_A
 
 1 240 bytes of CODE      memory (+ 12 bytes shared)
    84 bytes of HUGECONST memory
     4 bytes of HUGEDATA  memory

Errors: none
Warnings: 1

⌨️ 快捷键说明

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