Subversion Repositories BL-Ctrl

Rev

Details | Last modification | View Log | RSS feed

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