Blame | Last modification | View Log | RSS feed
1 .file "twislave.c"
2 __SREG__ = 0x3f
3 __SP_H__ = 0x3e
4 __SP_L__ = 0x3d
5 __tmp_reg__ = 0
6 __zero_reg__ = 1
7 .global __do_copy_data
8 .global __do_clear_bss
11 .text
12 .Ltext0:
105 .global InitIC2_Slave
107 InitIC2_Slave:
108 .stabd 46,0,0
1:src/twislave.c **** /*############################################################################
2:src/twislave.c **** Slaveadr = 0x52 = Vorne, 0x54 = Hinten, 0x56 = Rechts, 0x58 = Links
3:src/twislave.c **** ############################################################################*/
4:src/twislave.c ****
5:src/twislave.c **** #include <avr/io.h>
6:src/twislave.c **** #include <util/twi.h>
7:src/twislave.c **** #include "main.h"
8:src/twislave.c ****
9:src/twislave.c **** unsigned char I2C_RXBuffer;
10:src/twislave.c **** unsigned char Byte_Counter=0;
11:src/twislave.c ****
12:src/twislave.c **** //############################################################################
13:src/twislave.c **** //I2C (TWI) Interface Init
14:src/twislave.c **** void InitIC2_Slave(uint8_t adr)
15:src/twislave.c **** //############################################################################
16:src/twislave.c **** {
110 .LM0:
111 .LFBB1:
112 /* prologue: frame size=0 */
113 /* prologue end (size=0) */
17:src/twislave.c **** TWAR = adr + (2*MotorAdresse); // Eigene Adresse setzen
115 .LM1:
116 0000 9091 0000 lds r25,MotorAdresse
117 0004 990F lsl r25
118 0006 980F add r25,r24
119 0008 92B9 out 34-0x20,r25
18:src/twislave.c **** TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA);
121 .LM2:
122 000a 85EC ldi r24,lo8(-59)
123 000c 86BF out 86-0x20,r24
124 /* epilogue: frame size=0 */
125 000e 0895 ret
126 /* epilogue end (size=1) */
127 /* function InitIC2_Slave size 8 (7) */
129 .Lscope1:
131 .stabd 78,0,0
133 .global __vector_17
135 __vector_17:
136 .stabd 46,0,0
19:src/twislave.c **** }
20:src/twislave.c ****
21:src/twislave.c **** //############################################################################
22:src/twislave.c **** //ISR, die bei einem Ereignis auf dem Bus ausgelöst wird. Im Register TWSR befindet
23:src/twislave.c **** //sich dann ein Statuscode, anhand dessen die Situation festgestellt werden kann.
24:src/twislave.c **** ISR (TWI_vect)
25:src/twislave.c **** //############################################################################
26:src/twislave.c **** {
138 .LM3:
139 .LFBB2:
140 /* prologue: frame size=0 */
141 0010 1F92 push __zero_reg__
142 0012 0F92 push __tmp_reg__
143 0014 0FB6 in __tmp_reg__,__SREG__
144 0016 0F92 push __tmp_reg__
145 0018 1124 clr __zero_reg__
146 001a 8F93 push r24
147 001c 9F93 push r25
148 /* prologue end (size=7) */
27:src/twislave.c **** switch (TWSR & 0xF8)
150 .LM4:
151 001e 81B1 in r24,33-0x20
152 0020 9927 clr r25
153 0022 887F andi r24,lo8(248)
154 0024 9070 andi r25,hi8(248)
155 0026 8038 cpi r24,128
156 0028 9105 cpc r25,__zero_reg__
157 002a 01F0 breq .L7
159 .LM5:
160 002c 8138 cpi r24,129
161 002e 9105 cpc r25,__zero_reg__
162 0030 04F4 brge .L11
163 0032 0097 sbiw r24,0
164 0034 01F0 breq .L5
165 0036 8036 cpi r24,96
166 0038 9105 cpc r25,__zero_reg__
167 003a 01F4 brne .L4
168 003c 00C0 rjmp .L6
169 .L11:
170 003e 883B cpi r24,184
171 0040 9105 cpc r25,__zero_reg__
172 0042 01F0 breq .L9
173 0044 883F cpi r24,248
174 0046 9105 cpc r25,__zero_reg__
175 0048 01F0 breq .L10
176 004a 883A cpi r24,168
177 004c 9105 cpc r25,__zero_reg__
178 004e 01F4 brne .L4
179 0050 00C0 rjmp .L9
180 .L6:
28:src/twislave.c **** {
29:src/twislave.c **** case SR_SLA_ACK:
30:src/twislave.c **** TWCR |= (1<<TWINT);
182 .LM6:
183 0052 86B7 in r24,86-0x20
184 0054 8068 ori r24,lo8(-128)
185 0056 86BF out 86-0x20,r24
31:src/twislave.c **** Byte_Counter=0;
187 .LM7:
188 0058 1092 0000 sts Byte_Counter,__zero_reg__
189 005c 00C0 rjmp .L19
190 .L7:
32:src/twislave.c **** return;
33:src/twislave.c **** // Daten Empfangen
34:src/twislave.c **** case SR_PREV_ACK:
35:src/twislave.c **** I2C_RXBuffer = TWDR;
192 .LM8:
193 005e 83B1 in r24,35-0x20
194 0060 8093 0000 sts I2C_RXBuffer,r24
36:src/twislave.c **** I2C_Timeout = 500;
196 .LM9:
197 0064 84EF ldi r24,lo8(500)
198 0066 91E0 ldi r25,hi8(500)
199 0068 9093 0000 sts (I2C_Timeout)+1,r25
200 006c 8093 0000 sts I2C_Timeout,r24
201 0070 00C0 rjmp .L18
202 .L9:
37:src/twislave.c **** TWCR |= (1<<TWINT);
38:src/twislave.c **** return;
39:src/twislave.c **** // Daten Senden
40:src/twislave.c **** case SW_SLA_ACK:
41:src/twislave.c **** if (Byte_Counter==0)
42:src/twislave.c **** {
43:src/twislave.c **** TWDR = Mittelstrom;
44:src/twislave.c **** Byte_Counter++;
45:src/twislave.c **** }
46:src/twislave.c **** else
47:src/twislave.c **** {
48:src/twislave.c **** TWDR = MaxPWM;
49:src/twislave.c **** }
50:src/twislave.c **** TWCR |= (1<<TWINT);
51:src/twislave.c **** return;
52:src/twislave.c **** // Daten Senden
53:src/twislave.c **** case SW_DATA_ACK:
54:src/twislave.c **** if (Byte_Counter==0)
204 .LM10:
205 0072 8091 0000 lds r24,Byte_Counter
206 0076 8823 tst r24
207 0078 01F4 brne .L16
55:src/twislave.c **** {
56:src/twislave.c **** TWDR = Mittelstrom;
209 .LM11:
210 007a 8091 0000 lds r24,Mittelstrom
211 007e 83B9 out 35-0x20,r24
57:src/twislave.c **** Byte_Counter++;
213 .LM12:
214 0080 81E0 ldi r24,lo8(1)
215 0082 8093 0000 sts Byte_Counter,r24
216 0086 00C0 rjmp .L18
217 .L16:
58:src/twislave.c **** }
59:src/twislave.c **** else
60:src/twislave.c **** {
61:src/twislave.c **** TWDR = MaxPWM;
219 .LM13:
220 0088 8091 0000 lds r24,MaxPWM
221 008c 83B9 out 35-0x20,r24
222 .L18:
62:src/twislave.c **** }
63:src/twislave.c **** TWCR |= (1<<TWINT);
224 .LM14:
225 008e 86B7 in r24,86-0x20
226 0090 8068 ori r24,lo8(-128)
227 0092 00C0 rjmp .L20
228 .L10:
64:src/twislave.c **** return;
65:src/twislave.c **** // Bus-Fehler zurücksetzen
66:src/twislave.c **** case TWI_BUS_ERR_2:
67:src/twislave.c **** TWCR |=(1<<TWSTO) | (1<<TWINT);
230 .LM15:
231 0094 86B7 in r24,86-0x20
232 0096 8069 ori r24,lo8(-112)
233 0098 86BF out 86-0x20,r24
234 .L5:
68:src/twislave.c **** // Bus-Fehler zurücksetzen
69:src/twislave.c **** case TWI_BUS_ERR_1:
70:src/twislave.c **** TWCR |=(1<<TWSTO) | (1<<TWINT);
236 .LM16:
237 009a 86B7 in r24,86-0x20
238 009c 8069 ori r24,lo8(-112)
239 009e 86BF out 86-0x20,r24
240 .L4:
71:src/twislave.c **** }
72:src/twislave.c **** TWCR =(1<<TWEA) | (1<<TWINT) | (1<<TWEN) | (1<<TWIE); // TWI Reset
242 .LM17:
243 00a0 85EC ldi r24,lo8(-59)
244 .L20:
245 00a2 86BF out 86-0x20,r24
246 .L19:
247 /* epilogue: frame size=0 */
248 00a4 9F91 pop r25
249 00a6 8F91 pop r24
250 00a8 0F90 pop __tmp_reg__
251 00aa 0FBE out __SREG__,__tmp_reg__
252 00ac 0F90 pop __tmp_reg__
253 00ae 1F90 pop __zero_reg__
254 00b0 1895 reti
255 /* epilogue end (size=7) */
256 /* function __vector_17 size 81 (67) */
258 .Lscope2:
260 .stabd 78,0,0
261 .global Byte_Counter
262 .global Byte_Counter
263 .section .bss
266 Byte_Counter:
267 0000 00 .skip 1,0
268 .comm I2C_RXBuffer,1,1
271 .text
273 .Letext0:
274 /* File "src/twislave.c": code 89 = 0x0059 ( 74), prologues 7, epilogues 8 */
DEFINED SYMBOLS
*ABS*:00000000 twislave.c
/tmp/ccwqDpRs.s:2 *ABS*:0000003f __SREG__
/tmp/ccwqDpRs.s:3 *ABS*:0000003e __SP_H__
/tmp/ccwqDpRs.s:4 *ABS*:0000003d __SP_L__
/tmp/ccwqDpRs.s:5 *ABS*:00000000 __tmp_reg__
/tmp/ccwqDpRs.s:6 *ABS*:00000001 __zero_reg__
/tmp/ccwqDpRs.s:107 .text:00000000 InitIC2_Slave
/tmp/ccwqDpRs.s:135 .text:00000010 __vector_17
/tmp/ccwqDpRs.s:266 .bss:00000000 Byte_Counter
*COM*:00000001 I2C_RXBuffer
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
MotorAdresse
I2C_Timeout
Mittelstrom
MaxPWM