📄 com.s79
字号:
NAME com
RTMODEL "__code_model", "small"
RTMODEL "__cpu_mode", "arm"
RTMODEL "__data_model", "absolute"
RTMODEL "__endian", "little"
RTMODEL "__rt_version", "2"
RTMODEL "__thumb_aware", "enabled"
RSEG CSTACK:DATA:NOROOT(2)
EXTERN at91_usart_open
FUNCTION at91_usart_open,0202H
EXTERN at91_usart_close
FUNCTION at91_usart_close,0202H
EXTERN at91_usart_get_status
FUNCTION at91_usart_get_status,0202H
EXTERN at91_usart_write
FUNCTION at91_usart_write,0202H
EXTERN at91_usart_read
FUNCTION at91_usart_read,0202H
PUBLIC at91_close_com
FUNCTION at91_close_com,0203H
LOCFRAME CSTACK, 8, STACK
PUBLIC at91_getch
FUNCTION at91_getch,0203H
LOCFRAME CSTACK, 16, STACK
PUBLIC at91_open_com
FUNCTION at91_open_com,0203H
LOCFRAME CSTACK, 8, STACK
PUBLIC at91_print
FUNCTION at91_print,0203H
LOCFRAME CSTACK, 20, STACK
PUBLIC at91_print_crlf
FUNCTION at91_print_crlf,0203H
LOCFRAME CSTACK, 20, STACK
PUBLIC at91_print_frame
FUNCTION at91_print_frame,0203H
LOCFRAME CSTACK, 16, STACK
PUBLIC at91_send_byte
FUNCTION at91_send_byte,0203H
LOCFRAME CSTACK, 12, STACK
; C:\At91\software\projects\bench\Source\com.c
; 1 //*----------------------------------------------------------------------------
; 2 //* ATMEL Microcontroller Software Support - ROUSSET -
; 3 //*----------------------------------------------------------------------------
; 4 //* The software is delivered "AS IS" without warranty or condition of any
; 5 //* kind, either express, implied or statutory. This includes without
; 6 //* limitation any warranty or condition with respect to merchantability or
; 7 //* fitness for any particular purpose, or against the infringements of
; 8 //* intellectual property rights of others.
; 9 //*----------------------------------------------------------------------------
; 10 //* File Name : com.c
; 11 //* Object : com port terminal
; 12 //*
; 13 //* 1.0 25/08/00 JPP : Creation
; 14 //* 1.1 15/11/00 JPP : additing wait PDC in at91_send_byte
; 15 //*----------------------------------------------------------------------------
; 16
; 17 #include <stdio.h>
; 18 #include "com.h"
; 19
; 20 //*----------------------------------------------------------------------------
; 21 //* Function Name : at91_open_com
; 22 //* Object : Open com Usart
; 23 //* Input Parameters : com descriptor & mode
; 24 //* Output Parameters : none
; 25 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:REORDER:NOROOT(2)
CFI Names cfiNames0
CFI StackFrame CFA SP HUGEDATA
CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32
CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, SP:32, LR:32
CFI VirtualResource RET:32
CFI EndNames cfiNames0
CFI Common cfiCommon0 Using cfiNames0
CFI CodeAlign 4
CFI DataAlign 4
CFI ReturnAddress RET CODE
CFI CFA SP+0
CFI R0 Undefined
CFI R1 Undefined
CFI R2 Undefined
CFI R3 Undefined
CFI R4 SameValue
CFI R5 SameValue
CFI R6 SameValue
CFI R7 SameValue
CFI R8 SameValue
CFI R9 SameValue
CFI R10 SameValue
CFI R11 SameValue
CFI R12 Undefined
CFI LR Undefined
CFI RET LR
CFI EndCommon cfiCommon0
CFI Block cfiBlock0 Using cfiCommon0
CFI Function at91_open_com
CODE32
; 26 void at91_open_com(ComDesc *USART_pt, int mode, u_short baud)
; 27 //* Begin
; 28 {
at91_open_com:
STMDB SP!,{R4,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R4 Frame(CFA, -8)
CFI CFA SP+8
; 29
; 30 //* open usart in Asynchornous no time gard
; 31 at91_usart_open (USART_pt->usart,(mode|US_CLKS_MCK), baud, 0);
MOV R4,R0
MOV R3,#+0x0
MOV R2,R2, LSL #+16
MOV R2,R2, LSR #+16
LDR R0,[R4, #+0]
BL at91_usart_open
; 32
; 33 //* masque all interrup and Disable all interrupts
; 34 USART_pt->usart->usart_base->US_IDR = 0xFFFFFFFF ;
MVN R0,#+0x0
LDR R1,[R4, #+0]
LDR R2,[R1, #+0]
STR R0,[R2, #+12]
; 35
; 36 //* Set state
; 37 USART_pt->state = COM_STATE_ENABLE;
MOV R0,#+0x1
STR R0,[R4, #+4]
; 38
; 39 }
LDMIA SP!,{R4,PC} ;; return
CFI EndBlock cfiBlock0
; 40 //* End
; 41 //*----------------------------------------------------------------------------
; 42 //* Function Name : at91_close_com
; 43 //* Object : Close com Usart
; 44 //* Input Parameters : com descriptor
; 45 //* Output Parameters : none
; 46 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:REORDER:NOROOT(2)
CFI Block cfiBlock1 Using cfiCommon0
CFI Function at91_close_com
CODE32
; 47 void at91_close_com(ComDesc *USART_pt)
; 48 //* Begin
; 49 {
at91_close_com:
STMDB SP!,{R4,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R4 Frame(CFA, -8)
CFI CFA SP+8
; 50 //* Close Usart
; 51 at91_usart_close (USART_pt->usart) ;
MOV R4,R0
LDR R0,[R4, #+0]
BL at91_usart_close
; 52 //* Set state
; 53 USART_pt->state = COM_STATE_ENABLE;
MOV R0,#+0x1
STR R0,[R4, #+4]
; 54
; 55 }
LDMIA SP!,{R4,PC} ;; return
CFI EndBlock cfiBlock1
; 56 //* End
; 57 //*----------------------------------------------------------------------------
; 58 //* Function Name : at91_print_frame
; 59 //* Object : Send a string to USART with the PDC
; 60 //* Input Parameters : com descriptor, String pointer, size
; 61 //* Output Parameters : none
; 62 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:NOROOT(2)
CFI Block cfiBlock2 Using cfiCommon0
CFI Function at91_print_frame
CODE32
; 63 void at91_print_frame (ComDesc *USART_pt, char * buff , u_short size)
; 64 //* Begin
; 65 {
at91_print_frame:
STMDB SP!,{R4-R6,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R6 Frame(CFA, -8)
CFI R5 Frame(CFA, -12)
CFI R4 Frame(CFA, -16)
CFI CFA SP+16
MOV R4,R0
MOV R5,R1
MOV R6,R2
; 66 //* Wait end PDC Transmission)
; 67 while(( USART_pt->usart->usart_base->US_TCR) !=0) {}
??at91_print_frame_0:
LDR R0,[R4, #+0]
LDR R1,[R0, #+0]
LDR R0,[R1, #+60]
CMP R0,#+0x0
BNE ??at91_print_frame_0
; 68 //* Wait USART ready
; 69 while((at91_usart_get_status(USART_pt->usart) & US_TXRDY) ==0) {}
??at91_print_frame_1:
LDR R0,[R4, #+0]
BL at91_usart_get_status
AND R0,R0,#+0xFF ;; Zero extend
TST R0,#+0x2
BEQ ??at91_print_frame_1
; 70 //* set the PDC address
; 71 USART_pt->usart->usart_base->US_TPR = (at91_reg) buff;
LDR R0,[R4, #+0]
LDR R1,[R0, #+0]
STR R5,[R1, #+56]
; 72 //* set the size
; 73 USART_pt->usart->usart_base->US_TCR = size;
MOV R6,R6, LSL #+16
MOV R6,R6, LSR #+16
LDR R0,[R4, #+0]
LDR R1,[R0, #+0]
STR R6,[R1, #+60]
; 74 }
LDMIA SP!,{R4-R6,PC} ;; return
CFI EndBlock cfiBlock2
; 75 //* End
; 76
; 77 //*----------------------------------------------------------------------------
; 78 //* Function Name : at91_print
; 79 //* Object : Send a string to USART
; 80 //* Input Parameters : com descriptor & String pointer
; 81 //* Output Parameters : none
; 82 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:NOROOT(2)
CFI Block cfiBlock3 Using cfiCommon0
CFI Function at91_print
CODE32
; 83 void at91_print(ComDesc *USART_pt, char * buff)
; 84 //* Begin
; 85 {
at91_print:
STMDB SP!,{R4-R7,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA SP+20
MOV R4,R0
MOV R5,R1
; 86 u_int i;
; 87 for (i=0 ; buff[i]!=0;i++)
MOV R6,#+0x0
B ??at91_print_0
; 88 {
; 89 //* wait the USART Ready for transmission
; 90 while((at91_usart_get_status(USART_pt->usart) & US_TXRDY) ==0) {}
??at91_print_1:
LDR R0,[R4, #+0]
BL at91_usart_get_status
AND R0,R0,#+0xFF ;; Zero extend
TST R0,#+0x2
BEQ ??at91_print_1
; 91 //* write Char
; 92 at91_usart_write(USART_pt->usart,buff[i]);
LDRB R1,[R7, #+0]
LDR R0,[R4, #+0]
BL at91_usart_write
; 93 }
ADD R6,R6,#+0x1
??at91_print_0:
ADD R7,R6,R5
LDRB R0,[R7, #+0]
CMP R0,#+0x0
BNE ??at91_print_1
; 94 }
LDMIA SP!,{R4-R7,PC} ;; return
CFI EndBlock cfiBlock3
; 95 //* End
; 96 //*----------------------------------------------------------------------------
; 97 //* Function Name : at91_send_byte
; 98 //* Object : Send a char (one byte to USART)
; 99 //* Input Parameters : com descriptor & String pointer
; 100 //* Output Parameters : none
; 101 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:NOROOT(2)
CFI Block cfiBlock4 Using cfiCommon0
CFI Function at91_send_byte
CODE32
; 102 void at91_send_byte(ComDesc *USART_pt, char buff)
; 103 //* Begin
; 104 {
at91_send_byte:
STMDB SP!,{R4,R5,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R5 Frame(CFA, -8)
CFI R4 Frame(CFA, -12)
CFI CFA SP+12
MOV R4,R0
MOV R5,R1
; 105 //* wait the USART Ready for transmission
; 106 //* PDC wait
; 107 while(( USART_pt->usart->usart_base->US_TCR) !=0) {}
??at91_send_byte_0:
LDR R0,[R4, #+0]
LDR R1,[R0, #+0]
LDR R0,[R1, #+60]
CMP R0,#+0x0
BNE ??at91_send_byte_0
; 108 //* Char wait
; 109 while((at91_usart_get_status(USART_pt->usart) & US_TXRDY) ==0) {}
??at91_send_byte_1:
LDR R0,[R4, #+0]
BL at91_usart_get_status
AND R0,R0,#+0xFF ;; Zero extend
TST R0,#+0x2
BEQ ??at91_send_byte_1
; 110 //* write Char
; 111 at91_usart_write(USART_pt->usart,buff);
AND R5,R5,#+0xFF ;; Zero extend
MOV R1,R5
LDR R0,[R4, #+0]
BL at91_usart_write
; 112 }
LDMIA SP!,{R4,R5,PC} ;; return
CFI EndBlock cfiBlock4
; 113 //* End
; 114
; 115 //*----------------------------------------------------------------------------
; 116 //* Function Name : at91_print_crlf
; 117 //* Object : Send "\n\r"
; 118 //* Input Parameters : com descriptor
; 119 //* Output Parameters : none
; 120 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:NOROOT(2)
CFI Block cfiBlock5 Using cfiCommon0
CFI Function at91_print_crlf
CODE32
; 121 void at91_print_crlf(ComDesc *USART_pt)
; 122 {
at91_print_crlf:
STMDB SP!,{R4-R6,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R6 Frame(CFA, -8)
CFI R5 Frame(CFA, -12)
CFI R4 Frame(CFA, -16)
CFI CFA SP+16
SUB SP,SP,#+0x4
CFI CFA SP+20
; 123 char buff[3];
; 124 buff[0]='\n'; buff[1]='\r';buff[2]=0x00;
MOV R1,#+0xA
STRB R1,[SP, #+0]
MOV R1,#+0xD
STRB R1,[SP, #+1]
MOV R1,#+0x0
STRB R1,[SP, #+2]
; 125 at91_print(USART_pt,buff);
MOV R4,R0
MOV R5,#+0x0
B ??at91_print_crlf_0
??at91_print_crlf_1:
LDR R0,[R4, #+0]
BL at91_usart_get_status
AND R0,R0,#+0xFF ;; Zero extend
TST R0,#+0x2
BEQ ??at91_print_crlf_1
MOV R1,R6
LDR R0,[R4, #+0]
BL at91_usart_write
ADD R5,R5,#+0x1
??at91_print_crlf_0:
MOV R0,SP
LDRB R6,[R5, +R0]
CMP R6,#+0x0
BNE ??at91_print_crlf_1
; 126 }
ADD SP,SP,#+0x4 ;; stack cleaning
CFI CFA SP+16
LDMIA SP!,{R4-R6,PC} ;; return
CFI EndBlock cfiBlock5
; 127 //*----------------------------------------------------------------------------
; 128 //* Function Name : at91_getch
; 129 //* Object : Chek a char in usart
; 130 //* Input Parameters : com descriptor & pt value
; 131 //* Output Parameters : TRUE if char or FALSE
; 132 //*----------------------------------------------------------------------------
RSEG NEARFUNC_A:CODE:REORDER:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI Function at91_getch
CODE32
; 133 int at91_getch(ComDesc *USART_pt ,int * value )
; 134 {
at91_getch:
STMDB SP!,{R4-R6,LR} ;; Push
CFI RET Frame(CFA, -4)
CFI R6 Frame(CFA, -8)
CFI R5 Frame(CFA, -12)
CFI R4 Frame(CFA, -16)
CFI CFA SP+16
MOV R4,R0
MOV R5,R1
; 135 u_int status;
; 136
; 137 //* Check the USART Ready for reception
; 138 status =(( at91_usart_get_status(USART_pt->usart) & US_RXRDY) ==0);
LDR R0,[R4, #+0]
BL at91_usart_get_status
AND R0,R0,#+0xFF ;; Zero extend
TST R0,#+0x1
MOVEQ R0,#+0x1
MOVNE R0,#+0x0
MOV R6,R0
; 139 if (! status)
CMP R0,#+0x0
; 140 {
; 141 at91_usart_read (USART_pt->usart,(u_int *) value );
MOVEQ R1,R5
LDREQ R0,[R4, #+0]
BLEQ at91_usart_read
; 142 }
; 143 return status;
MOV R0,R6
LDMIA SP!,{R4-R6,PC} ;; return
CFI EndBlock cfiBlock6
; 144 }
END
; 145
;
; 492 bytes in segment NEARFUNC_A
;
; 492 bytes of CODE memory
;
;Errors: none
;Warnings: 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -