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

📄 initbdi_key(f,r,m,c)ok.s

📁 at91arm7处理器的启动源码
💻 S
📖 第 1 页 / 共 3 页
字号:
    
              bl delay20ms
              
              LDR  R2,=PIO_ISR
              LDR  R0,[R2]
                  
              LDR  R2,=CS4_addr
              ldrb r1,=0x00
              strb r1,[r2];re enable
;-----------------------------------------------------------------------

;- Restore used registers and LR_usr from the System/User Stack
              ldmfd sp!, {r0-r4,r14}


;- Mark the End of Interrupt on the interrupt controller
              ldr r0, = AIC_BASE
              str r0, [r0, #AIC_EOICR]
;- Restore SPSR_irq and r0 from the IRQ stack
              ldmfd sp!, {r0, r14}
              msr SPSR, r14
;- Restore ajusted LR_irq from IRQ stack directly in the PC
              ldmfd sp!, {pc}^



;-------------------------------------------------------------------
COM_download STMFD   sp!,{R0-R2,R5,lr}
             

;             BL on_p7;START TRANSFER


             LDR R1,=send_bufffer;ADDR OF STRING

             LDR R0,=0x434C4557;WELC
             STR R0,[R1]
             LDR R0,=0x21454D4F;OME!
             STR R0,[R1,#4]
             LDR R5,=0x00000008
             BL  sendstring

             BL  getbyte
             CMP R5,#82;"R"
             BNE COM_ERROR
         
             
             LDR R5,=0x00000041;"A"
             BL sendbyte
             
             LDR R5,=0x00000004;get the start address of download
             BL  getstring    
             
             LDR R1,=receive_bufffer;save the start address
             LDR R0,[R1]
             LDR R2,=addr_download
             STR R0,[R2]
;             BL DISPLAY_R0
             

             
             LDR R5,=0x00000053;"S"
             BL sendbyte
            
             LDR R5,=0x00000004;get the sector size of download,128 bytes/sector
             BL  getstring  

             LDR R0,[R1];save the sector size
             LDR R2,=secsize_download
             STR R0,[R2]     
;             BL DISPLAY_R0
            


SEC_WRI      BL  getbyte
             CMP R5,#71;"G"
             BNE COM_downloadEND

             LDR R5,=0x00000047;"G"
             BL sendbyte;start sector write
             
             LDR R5,=0x00000080;get a sector(128 bytes)
             BL  getstring  

             BL  BUF2ROM
             
             LDR R2,=secsize_download
             LDR R0,[R2]
             SUB R0,R0,#1
             CMP R0,#0
             BEQ END_FILE
             STR R0,[R2]
             B SEC_WRI

END_FILE        
             LDR R5,=0x00000045;"E"
             BL sendbyte;END OF TRANSFER
             
             BL TRANSFEROK

COM_downloadEND

             LDMFD sp!,{R0-R2,R5,PC};Return

COM_ERROR         
;              BL off_p7           
              ;B  COM_downloadEND
              B COM_ERROR         

TRANSFEROK    STMFD   sp!,{lr}                                   
;              BL on_p7 
              LDMFD sp!,{PC};Return



COM_Display
              STMFD   sp!,{R0-R4,lr}  
;Display-R,(Register)
;        M,(Memory)


             LDR R5,=0x00000041;"A"
             BL sendbyte

             BL  getbyte          

             CMP R5,#0x52;"R" File  
             bleq  COM_Register
             CMP R5,#0x4D;"M" Display
             bleq  COM_Memory

              LDMFD sp!,{R0-R4,PC};Return

COM_Register
              STMFD   sp!,{R0-R4,lr}  
;display  R,(Register) 128-Byte
              
             LDR R5,=0x00000041;"A"
             BL sendbyte
             
             BL  getbyte          
             CMP R5,#0x52;"R" reply              
             
             LDR R2,=debug_SP_End            
             STR R0,[R2]              
             LDR R2,=s_addr_display
             STR R0,[R2]         

             LDR R5,=0x00000118                         
             BL send_MEM_UART0
;s_addr_display,280-byte(0x118)r0-r15 
                      
                      
                      
                      

              LDMFD sp!,{R0-R4,PC};Return

COM_Memory
              STMFD   sp!,{R0-R4,lr}  
;display  M,(Memory) 128-Byte


             LDR R5,=0x00000041;"A"
             BL sendbyte
             
             LDR R5,=0x00000004;get the start address of download
             BL  getstring    
             
             LDR R5,=0x00000041;"A"
             BL sendbyte
             
             BL  getbyte          
             CMP R5,#0x52;"R" File              
             
             LDR R1,=receive_bufffer;save the start address
             LDR R0,[R1]
             LDR R2,=s_addr_display
             STR R0,[R2]         
 

             LDR R5,=0x00000100                         
             BL send_MEM_UART0
;s_addr_display,256-byte(0x100)               


              LDMFD sp!,{R0-R4,PC};Return
              
              
send_MEM_UART0
              STMFD   sp!,{R0-R4,lr}  
;s_addr_display   
    
;R5:COUNT OF TRANSMIT LOW 16-BIT
;SET R5,BEFORE CALL,256-byte(0x100)

          LDR R0,=USART0

              
send_MEMwait2 LDR R1,[R0,#0x14];US_CSR
           LDR  R2,=0xFFFFFFEF
           BIC  R1,R1,R2;ENDTX
           CMP  R1,#0
           BEQ  send_MEMwait2
         
            LDR R2,=s_addr_display;start ADDR OF MEM
            ldr r1,[r2]          
            STR R1,[R0,#0x38];US_TPR
                             ;ADDR OF TRANSMITTER POIONTER

            STR R5,[R0,#0x3C];US_TCR

send_MEMwait4 LDR R1,[R0,#0x14];US_CSR
           LDR  R2,=0xFFFFFFEF
           BIC  R1,R1,R2;ENDTX
           CMP  R1,#0
           BEQ  send_MEMwait4

              LDMFD sp!,{R0-R4,PC};Return



COM_Change
              STMFD   sp!,{R0-R5,lr}
                
             LDR R5,=0x00000041;"A"
             BL sendbyte
             
             LDR R5,=0x00000004;get the address to change
             BL  getstring 

             ldr r2,=receive_bufffer
             ldr r0,[r2]
             
             LDR R5,=0x00000041;"A"
             BL sendbyte
             
             LDR R5,=0x00000004;get the Value 
             BL  getstring 
             ldr r2,=receive_bufffer
             ldr r1,[r2]
             
             str r1,[r0]
 
             LDR R5,=0x00000041;"A"
             BL sendbyte

              LDMFD sp!,{R0-R5,PC};Return
              



BUF2ROM       STMFD   sp!,{R0-R4,lr}  
              LDR R2,=0x00000D80;END OF RECEIVE_BUFFER
              LDR R1,=receive_bufffer
              SUB R1,R1,#4
              LDR R4,=addr_download
              LDR R3,[R4]
              SUB R3,R3,#4              

BUFWRI_LOOP   LDR R0,[R1,#4]!
              STR R0,[R3,#4]!
              CMP R1,R2;RECEIVE_BUFFFER END
              BNE BUFWRI_LOOP

              STR R3,[R4]

;SECTOR WRITE OK,CAN WAIT 10MS OR NOT



              LDMFD sp!,{R0-R4,PC};Return



;GETCHAR      STMFD   sp!,{R0-R2,R5,lr}

             BL  getbyte

             SUB  R5,R5,#0x20 
             MOV  R5,R5,LSL #16           
         
             LDR R1,=0x0000C000;写RAM且地址+1
             ADD R2,R2,R1
     
             LDR R0,=LCDparam 
             STR R2,[R0];param
            ;BL PR11;

;             BL on_p7

             LDMFD sp!,{R0-R2,R5,PC};Return

;WRIstring  
;正常显示字符串,以0x00结尾
;入口:r6=字符串首地址!

;GETSTRING    STMFD   sp!,{R0-R2,R5-R6,lr}

             LDR R5,=0x00000003;HI!
             BL  getstring

             LDR R1,=receive_bufffer   
             LDR R0,[R1]
             
             LDR  R2,=0xFF000000
             BIC  R0,R0,R2;
            
             STR  R0,[R1]
             MOV  R6,R1
;            BL   WRIstring
;             BL on_p7
             LDMFD sp!,{R0-R2,R5-R6,PC};Return


test_USART0 STMFD   sp!,{R0-R1,lr}
            bl init_USART0
test_USART0_loop
            ldr R5,=0x55
            bl  sendbyte
            b test_USART0_loop
            
            LDMFD sp!,{R0-R1,PC};Return


init_USART0
           STMFD   sp!,{R0-R1,lr}
           LDR R0,=USART0
           ;BL DISPLAY_R0 
           
;           LDR R1,=0x000000C0;Normal mode,1 stop bit,even parity,           
                             ;Asynchoronous mode,8-bit,MCKI,
           LDR R1,=0x000008C0;Normal mode,1 stop bit,even parity,
                             ;Asynchoronous mode,8-bit,MCKI,                             
           STR R1,[R0,#0x04];US_MR

           LDR R1,=0x0000000D;115200 BPS 
           STR R1,[R0,#0x20];US_BRGR

           LDR R1,=0x0
           STR R1,[R0,#0x24];US_RTOR Disable Receive Time-out
           LDR R1,=0x0
           STR R1,[R0,#0x28];US_TTGR Disable Transmitter time-guard
           
           LDR R1,=0x00000004;Reset Receiver
           STR R1,[R0];US_CR
           LDR R1,=0x00000008;Reset Transmitter
           STR R1,[R0];US_CR
           LDR R1,=0x00000100;Reset Status bits
           STR R1,[R0];US_CR
           LDR R1,=0x00000010;Receiver Enable
           STR R1,[R0];US_CR
           LDR R1,=0x00000040;Transmitter Enable
           STR R1,[R0];US_CR


           LDR R1,=0xFFFFFE1B;DISENABLE INTERRUPT
           STR R1,[R0,#0x0C] ;US_IDR
           LDR R1,=0x000001E4;ENABLE INTERRUPT
           STR R1,[R0,#0x08] ;US_IER 
                             ;PROSESS ERROR IN TRANSMIT & RECEIVE
     
;           BL on_p7

           LDMFD sp!,{R0-R1,PC};Return


sendbyte   STMFD   sp!,{R0-R2,lr}
;R5:low 8-bit
           LDR R0,=USART0

sendbytewait  LDR R1,[R0,#0x14];US_CSR

           LDR  R2,=0xFFFFFFFD
           BIC  R1,R1,R2;TXRDY
           CMP  R1,#2
           BNE  sendbytewait

           STR R5,[R0,#0x1C];US_THR

           LDMFD sp!,{R0-R2,PC};Return


sendstring  STMFD   sp!,{R0-R2,lr}
;R5:COUNT OF TRANSMIT LOW 16-BIT
;SET R5,BEFORE CALL

          LDR R0,=USART0

sendstrwait2 LDR R1,[R0,#0x14];US_CSR
           LDR  R2,=0xFFFFFFEF
           BIC  R1,R1,R2;ENDTX
           CMP  R1,#0
           BEQ  sendstrwait2

           
            LDR R1,=send_bufffer
            STR R1,[R0,#0x38];US_TPR
                             ;ADDR OF TRANSMITTER POIONTER

            STR R5,[R0,#0x3C];US_TCR

sendstrwait4 LDR R1,[R0,#0x14];US_CSR
           LDR  R2,=0xFFFFFFEF
           BIC  R1,R1,R2;ENDTX
           CMP  R1,#0
           BEQ  sendstrwait4


            LDMFD sp!,{R0-R2,PC};Return




getbyte    STMFD   sp!,{R0-R2,lr}
;R5 low 8-bit
           LDR R0,=USART0

getbytewait  LDR R1,[R0,#0x14];US_CSR

           LDR  R2,=0xFFFFFFFE
           BIC  R1,R1,R2;RXRDY
           CMP  R1,#1
           BNE  getbytewait

           LDR  R5,[R0,#0x18];US_RHR          

           LDMFD sp!,{R0-R2,PC};Return



getstring
           STMFD   sp!,{R0-R2,lr}
;R5:COUNT OF RECEIVER,LOW 16-BIT
;SET R5,BEFORE CALL

            LDR R0,=USART0
          
            LDR R1,=receive_bufffer
            STR R1,[R0,#0x30];US_RPR
                             ;ADDR OF RECEIVER POIONTER

            STR R5,[R0,#0x34];US_RCR

getstrwait2 LDR R1,[R0,#0x14];US_CSR
           LDR  R2,=0xFFFFFFF7
           BIC  R1,R1,R2;ENDRX
           CMP  R1,#0

⌨️ 快捷键说明

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