📄 com.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/EC++ Compiler V3.10A/W32 05/Nov/2001 14:58:24 #
# Copyright 1999-2001 IAR Systems. All rights reserved. #
# #
# Cpu mode = arm #
# Code model = small #
# Endian = little #
# Source file = C:\At91\software\projects\bench\Source\com.c #
# Command line = -I C:\Compil\EW23\ARM\INC\ -I ../../..\ -lcN #
# C:\At91\software\projects\bench\IAR\ARM_INT\List\ -la #
# C:\At91\software\projects\bench\IAR\ARM_INT\List\ -o #
# C:\At91\software\projects\bench\IAR\ARM_INT\Obj\ -e #
# -s9 --debug --cpu_mode arm --code_model small --endian #
# little --cpu=arm7tdmi C:\At91\software\projects\bench\S #
# ource\com.c #
# List file = C:\At91\software\projects\bench\IAR\ARM_INT\List\com.ls #
# t #
# Object file = C:\At91\software\projects\bench\IAR\ARM_INT\Obj\com.r79 #
# #
# #
##############################################################################
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 //*----------------------------------------------------------------------------
26 void at91_open_com(ComDesc *USART_pt, int mode, u_short baud)
27 //* Begin
28 {
29
30 //* open usart in Asynchornous no time gard
31 at91_usart_open (USART_pt->usart,(mode|US_CLKS_MCK), baud, 0);
32
33 //* masque all interrup and Disable all interrupts
34 USART_pt->usart->usart_base->US_IDR = 0xFFFFFFFF ;
35
36 //* Set state
37 USART_pt->state = COM_STATE_ENABLE;
38
39 }
40 //* End
41 //*----------------------------------------------------------------------------
42 //* Function Name : at91_close_com
43 //* Object : Close com Usart
44 //* Input Parameters : com descriptor
45 //* Output Parameters : none
46 //*----------------------------------------------------------------------------
47 void at91_close_com(ComDesc *USART_pt)
48 //* Begin
49 {
50 //* Close Usart
51 at91_usart_close (USART_pt->usart) ;
52 //* Set state
53 USART_pt->state = COM_STATE_ENABLE;
54
55 }
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 //*----------------------------------------------------------------------------
63 void at91_print_frame (ComDesc *USART_pt, char * buff , u_short size)
64 //* Begin
65 {
66 //* Wait end PDC Transmission)
67 while(( USART_pt->usart->usart_base->US_TCR) !=0) {}
68 //* Wait USART ready
69 while((at91_usart_get_status(USART_pt->usart) & US_TXRDY) ==0) {}
70 //* set the PDC address
71 USART_pt->usart->usart_base->US_TPR = (at91_reg) buff;
72 //* set the size
73 USART_pt->usart->usart_base->US_TCR = size;
74 }
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 //*----------------------------------------------------------------------------
83 void at91_print(ComDesc *USART_pt, char * buff)
84 //* Begin
85 {
86 u_int i;
87 for (i=0 ; buff[i]!=0;i++)
88 {
89 //* wait the USART Ready for transmission
90 while((at91_usart_get_status(USART_pt->usart) & US_TXRDY) ==0) {}
91 //* write Char
92 at91_usart_write(USART_pt->usart,buff[i]);
93 }
94 }
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 //*----------------------------------------------------------------------------
102 void at91_send_byte(ComDesc *USART_pt, char buff)
103 //* Begin
104 {
105 //* wait the USART Ready for transmission
106 //* PDC wait
107 while(( USART_pt->usart->usart_base->US_TCR) !=0) {}
108 //* Char wait
109 while((at91_usart_get_status(USART_pt->usart) & US_TXRDY) ==0) {}
110 //* write Char
111 at91_usart_write(USART_pt->usart,buff);
112 }
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 //*----------------------------------------------------------------------------
121 void at91_print_crlf(ComDesc *USART_pt)
122 {
123 char buff[3];
124 buff[0]='\n'; buff[1]='\r';buff[2]=0x00;
125 at91_print(USART_pt,buff);
126 }
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 //*----------------------------------------------------------------------------
133 int at91_getch(ComDesc *USART_pt ,int * value )
134 {
135 u_int status;
136
137 //* Check the USART Ready for reception
138 status =(( at91_usart_get_status(USART_pt->usart) & US_RXRDY) ==0);
139 if (! status)
140 {
141 at91_usart_read (USART_pt->usart,(u_int *) value );
142 }
143 return status;
144 }
145
Maximum stack usage in bytes:
Function CSTACK
-------- ------
at91_close_com 8
at91_getch 16
at91_open_com 8
at91_print 20
at91_print_crlf 20
at91_print_frame 16
at91_send_byte 12
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 + -