📄 pc_o.lst
字号:
C51 COMPILER V6.21 PC_O 01/23/2002 18:04:14 PAGE 1
C51 COMPILER V6.21, COMPILATION OF MODULE PC_O
OBJECT MODULE PLACED IN PC_O.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE PC_O.c OPTIMIZE(6,SIZE) BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*------------------------------------------------------------------*-
2
3 PC_O.C (v1.00)
4
5 ------------------------------------------------------------------
6
7 Core files for simple write-only PC link library for 8051 family
8 [Sends data to PC - cannot receive data from PC]
9
10 Uses the UART, and Pin 3.1 (Tx)
11
12 See text for details (Chapter 9).
13
14
15 COPYRIGHT
16 ---------
17
18 This code is associated with the book:
19
20 EMBEDDED C by Michael J. Pont
21 [Pearson Education, 2002: ISBN: 0-201-79523-X].
22
23 This code is copyright (c) 2001 by Michael J. Pont.
24
25 See book for copyright details and other information.
26
27 -*------------------------------------------------------------------*/
28
29 #include "Main.h"
30 #include "PC_O.h"
31 #include "Elap_232.h"
32
33 // ------ Public variable definitions ------------------------------
34
35 tByte Out_written_index_G; // Data in buffer that has been written
36 tByte Out_waiting_index_G; // Data in buffer not yet written
37
38 // ------ Private function prototypes ------------------------------
39
40 static void PC_LINK_O_Send_Char(const char);
41
42 // ------ Private constants ----------------------------------------
43
44 // The transmit buffer length
45 #define TRAN_BUFFER_LENGTH 20
46
47 // ------ Private variables ----------------------------------------
48
49 static tByte Tran_buffer[TRAN_BUFFER_LENGTH];
50
51 static tByte Time_count_G = 0;
52
53
54 /*------------------------------------------------------------------*-
55
C51 COMPILER V6.21 PC_O 01/23/2002 18:04:14 PAGE 2
56 PC_LINK_O_Update()
57
58 Sends next character from the software transmit buffer
59
60 NOTE: Output-only library (Cannot receive chars)
61
62 Uses on-chip UART hardware.
63
64 -*------------------------------------------------------------------*/
65 void PC_LINK_O_Update(void)
66 {
67 1 // Deal with transmit bytes here
68 1 //
69 1 // Are there any data ready to send?
70 1 if (Out_written_index_G < Out_waiting_index_G)
71 1 {
72 2 PC_LINK_O_Send_Char(Tran_buffer[Out_written_index_G]);
73 2
74 2 Out_written_index_G++;
75 2 }
76 1 else
77 1 {
78 2 // No data to send - just reset the buffer index
79 2 Out_waiting_index_G = 0;
80 2 Out_written_index_G = 0;
81 2 }
82 1 }
83
84 /*------------------------------------------------------------------*-
85
86 PC_LINK_O_Write_String_To_Buffer()
87
88 Copies a (null terminated) string to the character buffer.
89 (The contents of the buffer are then passed over the serial link)
90
91 -*------------------------------------------------------------------*/
92 void PC_LINK_O_Write_String_To_Buffer(const char* const STR_PTR)
93 {
94 1 tByte i = 0;
95 1
96 1 while (STR_PTR[i] != '\0')
97 1 {
98 2 PC_LINK_O_Write_Char_To_Buffer(STR_PTR[i]);
99 2 i++;
100 2 }
101 1 }
102
103 /*------------------------------------------------------------------*-
104
105 PC_LINK_O_Write_Char_To_Buffer()
106
107 Stores a character in the 'write' buffer, ready for
108 later transmission
109
110 -*------------------------------------------------------------------*/
111 void PC_LINK_O_Write_Char_To_Buffer(const char CHARACTER)
112 {
113 1 // Write to the buffer *only* if there is space
114 1 // (No error reporting in this simple library...)
115 1 if (Out_waiting_index_G < TRAN_BUFFER_LENGTH)
116 1 {
117 2 Tran_buffer[Out_waiting_index_G] = CHARACTER;
C51 COMPILER V6.21 PC_O 01/23/2002 18:04:14 PAGE 3
118 2 Out_waiting_index_G++;
119 2 }
120 1 }
121
122 /*------------------------------------------------------------------*-
123
124 PC_LINK_O_Send_Char()
125
126 Based on Keil sample code, with added (loop) timeouts.
127 Implements Xon / Off control.
128
129 Uses on-chip UART hardware.
130
131 -*------------------------------------------------------------------*/
132 void PC_LINK_O_Send_Char(const char CHARACTER)
133 {
134 1 tLong Timeout1 = 0;
135 1
136 1 if (CHARACTER == '\n')
137 1 {
138 2 Timeout1 = 0;
139 2 while ((++Timeout1) && (TI == 0));
140 2
141 2 if (Timeout1 == 0)
142 2 {
143 3 // UART did not respond - error
144 3 // No error reporting in this simple library...
145 3 return;
146 3 }
147 2
148 2 TI = 0;
149 2 SBUF = 0x0D; // Output CR
150 2 }
151 1
152 1 Timeout1 = 0;
153 1 while ((++Timeout1) && (TI == 0));
154 1
155 1 if (Timeout1 == 0)
156 1 {
157 2 // UART did not respond - error
158 2 // No error reporting in this simple library...
159 2 return;
160 2 }
161 1
162 1 TI = 0;
163 1
164 1 SBUF = CHARACTER;
165 1 }
166
167 /*------------------------------------------------------------------*-
168 ---- END OF FILE -------------------------------------------------
169 -*------------------------------------------------------------------*/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 189 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 23 9
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
C51 COMPILER V6.21 PC_O 01/23/2002 18:04:14 PAGE 4
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -