-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soft_Uart.asm
228 lines (216 loc) · 7 KB
/
Soft_Uart.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
_SoftUart_Init:
;Soft_Uart.c,22 :: void SoftUart_Init()
;Soft_Uart.c,24 :: Soft_Uart_Tx = 1;
BSF Soft_Uart_Tx+0, BitPos(Soft_Uart_Tx+0)
;Soft_Uart.c,25 :: Soft_Uart_Rx = 1;
BSF Soft_Uart_Rx+0, BitPos(Soft_Uart_Rx+0)
;Soft_Uart.c,26 :: Soft_Uart_Tx_Direction = 0;
BCF Soft_Uart_Tx_Direction+0, BitPos(Soft_Uart_Tx_Direction+0)
;Soft_Uart.c,27 :: Soft_Uart_Rx_Direction = 1;
BSF Soft_Uart_Rx_Direction+0, BitPos(Soft_Uart_Rx_Direction+0)
;Soft_Uart.c,28 :: Soft_Uart_Tx = 1;
BSF Soft_Uart_Tx+0, BitPos(Soft_Uart_Tx+0)
;Soft_Uart.c,29 :: delay_us(BITPERIOD);
MOVLW 34
MOVWF R13+0
L_SoftUart_Init0:
DECFSZ R13+0, 1
GOTO L_SoftUart_Init0
NOP
;Soft_Uart.c,30 :: }
L_end_SoftUart_Init:
RETURN
; end of _SoftUart_Init
_Soft_UART_Write:
;Soft_Uart.c,33 :: void Soft_UART_Write(unsigned char Data)
;Soft_Uart.c,36 :: Soft_Uart_Tx = 0;
BCF Soft_Uart_Tx+0, BitPos(Soft_Uart_Tx+0)
;Soft_Uart.c,37 :: delay_us(BITPERIOD);
MOVLW 34
MOVWF R13+0
L_Soft_UART_Write1:
DECFSZ R13+0, 1
GOTO L_Soft_UART_Write1
NOP
;Soft_Uart.c,40 :: for (mask = 0x01; mask != 0; mask = mask << 1)
MOVLW 1
MOVWF R1+0
L_Soft_UART_Write2:
MOVF R1+0, 0
XORLW 0
BTFSC STATUS+0, 2
GOTO L_Soft_UART_Write3
;Soft_Uart.c,42 :: if (Data & mask) Soft_Uart_Tx = 1;
MOVF R1+0, 0
ANDWF FARG_Soft_UART_Write_Data+0, 0
MOVWF R0+0
BTFSC STATUS+0, 2
GOTO L_Soft_UART_Write5
BSF Soft_Uart_Tx+0, BitPos(Soft_Uart_Tx+0)
GOTO L_Soft_UART_Write6
L_Soft_UART_Write5:
;Soft_Uart.c,43 :: else Soft_Uart_Tx = 0;
BCF Soft_Uart_Tx+0, BitPos(Soft_Uart_Tx+0)
L_Soft_UART_Write6:
;Soft_Uart.c,44 :: delay_us(BITPERIOD_FOR_WRITE); // For greater precision according to the crystal because it is 14 clock cycles
MOVLW 29
MOVWF R13+0
L_Soft_UART_Write7:
DECFSZ R13+0, 1
GOTO L_Soft_UART_Write7
NOP
NOP
;Soft_Uart.c,40 :: for (mask = 0x01; mask != 0; mask = mask << 1)
RLF R1+0, 1
BCF R1+0, 0
;Soft_Uart.c,45 :: }
GOTO L_Soft_UART_Write2
L_Soft_UART_Write3:
;Soft_Uart.c,46 :: Soft_Uart_Tx = 1;
BSF Soft_Uart_Tx+0, BitPos(Soft_Uart_Tx+0)
;Soft_Uart.c,47 :: delay_us(BITPERIOD);
MOVLW 34
MOVWF R13+0
L_Soft_UART_Write8:
DECFSZ R13+0, 1
GOTO L_Soft_UART_Write8
NOP
;Soft_Uart.c,48 :: }
L_end_Soft_UART_Write:
RETURN
; end of _Soft_UART_Write
_Soft_UART_Write_Text:
;Soft_Uart.c,51 :: void Soft_UART_Write_Text(char* Text)
;Soft_Uart.c,53 :: while (*Text)Soft_UART_Write(*Text++);
L_Soft_UART_Write_Text9:
MOVF FARG_Soft_UART_Write_Text_Text+0, 0
MOVWF FSR
MOVF INDF+0, 0
BTFSC STATUS+0, 2
GOTO L_Soft_UART_Write_Text10
MOVF FARG_Soft_UART_Write_Text_Text+0, 0
MOVWF FSR
MOVF INDF+0, 0
MOVWF FARG_Soft_UART_Write_Data+0
CALL _Soft_UART_Write+0
INCF FARG_Soft_UART_Write_Text_Text+0, 1
GOTO L_Soft_UART_Write_Text9
L_Soft_UART_Write_Text10:
;Soft_Uart.c,54 :: }
L_end_Soft_UART_Write_Text:
RETURN
; end of _Soft_UART_Write_Text
_Soft_UART_Write_Text_Const:
;Soft_Uart.c,57 :: void Soft_UART_Write_Text_Const(const char* Text)
;Soft_Uart.c,59 :: while (*Text)Soft_UART_Write(*Text++);
L_Soft_UART_Write_Text_Const11:
MOVF FARG_Soft_UART_Write_Text_Const_Text+0, 0
MOVWF ___DoICPAddr+0
MOVF FARG_Soft_UART_Write_Text_Const_Text+1, 0
MOVWF ___DoICPAddr+1
CALL _____DoICP+0
MOVWF R0+0
MOVF R0+0, 0
BTFSC STATUS+0, 2
GOTO L_Soft_UART_Write_Text_Const12
MOVF FARG_Soft_UART_Write_Text_Const_Text+0, 0
MOVWF ___DoICPAddr+0
MOVF FARG_Soft_UART_Write_Text_Const_Text+1, 0
MOVWF ___DoICPAddr+1
CALL _____DoICP+0
MOVWF FARG_Soft_UART_Write_Data+0
CALL _Soft_UART_Write+0
INCF FARG_Soft_UART_Write_Text_Const_Text+0, 1
BTFSC STATUS+0, 2
INCF FARG_Soft_UART_Write_Text_Const_Text+1, 1
GOTO L_Soft_UART_Write_Text_Const11
L_Soft_UART_Write_Text_Const12:
;Soft_Uart.c,60 :: }
L_end_Soft_UART_Write_Text_Const:
RETURN
; end of _Soft_UART_Write_Text_Const
_Soft_UART_Read:
;Soft_Uart.c,63 :: unsigned char Soft_UART_Read()
;Soft_Uart.c,66 :: char Data = 0;
CLRF Soft_UART_Read_Data_L0+0
;Soft_Uart.c,68 :: while (Soft_Uart_Rx == 1); // Wait for start bit
L_Soft_UART_Read13:
BTFSS Soft_Uart_Rx+0, BitPos(Soft_Uart_Rx+0)
GOTO L_Soft_UART_Read14
GOTO L_Soft_UART_Read13
L_Soft_UART_Read14:
;Soft_Uart.c,69 :: delay_us(HALFBITPERIOD);
MOVLW 17
MOVWF R13+0
L_Soft_UART_Read15:
DECFSZ R13+0, 1
GOTO L_Soft_UART_Read15
;Soft_Uart.c,70 :: for (mask = 0x01; mask != 0; mask = mask << 1)
MOVLW 1
MOVWF R1+0
L_Soft_UART_Read16:
MOVF R1+0, 0
XORLW 0
BTFSC STATUS+0, 2
GOTO L_Soft_UART_Read17
;Soft_Uart.c,72 :: delay_us(BITPERIOD_FOR_READ); // Delay to read
MOVLW 31
MOVWF R13+0
L_Soft_UART_Read19:
DECFSZ R13+0, 1
GOTO L_Soft_UART_Read19
;Soft_Uart.c,73 :: if (Soft_Uart_Rx) Data = Data | mask;
BTFSS Soft_Uart_Rx+0, BitPos(Soft_Uart_Rx+0)
GOTO L_Soft_UART_Read20
MOVF R1+0, 0
IORWF Soft_UART_Read_Data_L0+0, 1
L_Soft_UART_Read20:
;Soft_Uart.c,70 :: for (mask = 0x01; mask != 0; mask = mask << 1)
RLF R1+0, 1
BCF R1+0, 0
;Soft_Uart.c,74 :: }
GOTO L_Soft_UART_Read16
L_Soft_UART_Read17:
;Soft_Uart.c,75 :: Delay_us(BITPERIOD);
MOVLW 34
MOVWF R13+0
L_Soft_UART_Read21:
DECFSZ R13+0, 1
GOTO L_Soft_UART_Read21
NOP
;Soft_Uart.c,76 :: return Data;
MOVF Soft_UART_Read_Data_L0+0, 0
MOVWF R0+0
;Soft_Uart.c,77 :: }
L_end_Soft_UART_Read:
RETURN
; end of _Soft_UART_Read
_Soft_UART_Read_Text:
;Soft_Uart.c,79 :: void Soft_UART_Read_Text(char* Buffer, char StopChar)
;Soft_Uart.c,81 :: while (*(Buffer - 1) != StopChar) // Wait until desired character does not arrive
L_Soft_UART_Read_Text22:
DECF FARG_Soft_UART_Read_Text_Buffer+0, 0
MOVWF FSR
MOVF INDF+0, 0
XORWF FARG_Soft_UART_Read_Text_StopChar+0, 0
BTFSC STATUS+0, 2
GOTO L_Soft_UART_Read_Text23
;Soft_Uart.c,83 :: *Buffer++ = Soft_UART_Read(); // Keep buffering
CALL _Soft_UART_Read+0
MOVF FARG_Soft_UART_Read_Text_Buffer+0, 0
MOVWF FSR
MOVF R0+0, 0
MOVWF INDF+0
INCF FARG_Soft_UART_Read_Text_Buffer+0, 1
;Soft_Uart.c,84 :: }
GOTO L_Soft_UART_Read_Text22
L_Soft_UART_Read_Text23:
;Soft_Uart.c,85 :: *--Buffer = 0; // Put trailing zero to make it string
DECF FARG_Soft_UART_Read_Text_Buffer+0, 1
MOVF FARG_Soft_UART_Read_Text_Buffer+0, 0
MOVWF FSR
CLRF INDF+0
;Soft_Uart.c,86 :: }
L_end_Soft_UART_Read_Text:
RETURN
; end of _Soft_UART_Read_Text