📄 servo.lst
字号:
1 .file "servo.c"
2 __SREG__ = 0x3f
3 __SP_H__ = 0x3e
4 __SP_L__ = 0x3d
5 __CCP__ = 0x34
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
11 .text
12 .Ltext0:
92 .global servo_set_pos
94 servo_set_pos:
1:io/servo.c **** /*
2:io/servo.c **** ,-----------------------------------------------------------------------------------------.
3:io/servo.c **** | io/servo
4:io/servo.c **** |-----------------------------------------------------------------------------------------
5:io/servo.c **** | this file implements functions to control a rc-car servo motor
6:io/servo.c **** |
7:io/servo.c **** | Author : Simon Schulz / avr{AT}auctionant.de
8:io/servo.c **** |
9:io/servo.c **** |
10:io/servo.c **** |
11:io/servo.c **** |-----------------------------------------------------------------------------------------
12:io/servo.c **** | License:
13:io/servo.c **** | This program is free software; you can redistribute it and/or modify it under
14:io/servo.c **** | the terms of the GNU General Public License as published by the Free Software
15:io/servo.c **** | Foundation; either version 2 of the License, or (at your option) any later
16:io/servo.c **** | version.
17:io/servo.c **** | This program is distributed in the hope that it will be useful, but
18:io/servo.c **** |
19:io/servo.c **** | WITHOUT ANY WARRANTY;
20:io/servo.c **** |
21:io/servo.c **** | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22:io/servo.c **** | PURPOSE. See the GNU General Public License for more details.
23:io/servo.c **** |
24:io/servo.c **** | You should have received a copy of the GNU General Public License along with
25:io/servo.c **** | this program; if not, write to the Free Software Foundation, Inc., 51
26:io/servo.c **** | Franklin St, Fifth Floor, Boston, MA 02110, USA
27:io/servo.c **** |
28:io/servo.c **** | http://www.gnu.de/gpl-ger.html
29:io/servo.c **** `-----------------------------------------------------------------------------------------*/
30:io/servo.c **** #include "servo.h"
31:io/servo.c **** #include "debug.h"
32:io/servo.c ****
33:io/servo.c **** #include <avr/delay.h>
34:io/servo.c **** unsigned char servo_pos;
35:io/servo.c ****
36:io/servo.c **** #define SERVO_BMP_HEADER_LENGTH 62
37:io/servo.c **** //bmp data must be a multiple of 16 ?! -> maybe add padding !
38:io/servo.c **** #define SERVO_BMP_WIDTH 256
39:io/servo.c **** //256 pixel -> 256/8 = 32 ! must be divided by 4 -> ok!
40:io/servo.c **** #define SERVO_BMP_LINE_WIDTH 256
41:io/servo.c **** #define SERVO_BMP_HEIGHT 1
42:io/servo.c **** #define SERVO_BMP_FILESIZE (SERVO_BMP_LINE_WIDTH/8)*(SERVO_BMP_HEIGHT)+62
43:io/servo.c ****
44:io/servo.c **** PROGMEM unsigned char SERVO_BMP_HEAD [] = {
45:io/servo.c **** 0x42, 0x4D, 0x5E, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //10
46:io/servo.c **** 0x3E, 0x00, 0x00, 0x00, //first image data at pos 0x3E -> at byte 62
47:io/servo.c **** 0x28, 0x00, 0x00, 0x00, //header size (infoheader only!!) -> 40 bytes
48:io/servo.c **** lo8(SERVO_BMP_WIDTH), hi8(SERVO_BMP_WIDTH), 0x00, 0x00, //width <lo,hi,0,0>
49:io/servo.c **** lo8(SERVO_BMP_HEIGHT), hi8(SERVO_BMP_HEIGHT), 0x00, 0x00, //height <lo,hi,0,0>
50:io/servo.c **** 0x01, 0x00, //1color plane
51:io/servo.c **** 0x01, 0x00, //1bit
52:io/servo.c **** 0x00, 0x00, 0x00, 0x00, //no compression
53:io/servo.c **** lo8(SERVO_BMP_FILESIZE), hi8(SERVO_BMP_FILESIZE), 0x00, 0x00, //imagesize in bytes
54:io/servo.c **** 0x10, 0x0B, 0x00, 0x00, //x pixels per meter
55:io/servo.c **** 0x10, 0x0B, 0x00, 0x00, //y pixels per meter
56:io/servo.c **** 0x02, 0x00, 0x00, 0x00, //2 colors (B/W)
57:io/servo.c **** 0x02, 0x00, 0x00, 0x00, //2 important colors
58:io/servo.c ****
59:io/servo.c **** 0xFF, //background B
60:io/servo.c **** 0xFF, //background G
61:io/servo.c **** 0xFF, //background R
62:io/servo.c **** 0x00,
63:io/servo.c **** 0xC0, //foreground B
64:io/servo.c **** 0xC0, //foreground G
65:io/servo.c **** 0xC0, //foreground R
66:io/servo.c **** 0x00 //62
67:io/servo.c **** };
68:io/servo.c ****
69:io/servo.c **** void servo_init(){
70:io/servo.c **** //set up fast pwm mode:
71:io/servo.c **** #define WGM_CFG (1<<WGM00 | 1<<WGM01) //fast pwm
72:io/servo.c **** #define COM_CFG (1<<COM01 | 0<<COM00) //clr on match, set on max
73:io/servo.c **** #define CLK_CFG (0<<CS00 | 1<<CS01 | 1<<CS02) //set up clock source
74:io/servo.c **** TCCR2 = WGM_CFG | COM_CFG | CLK_CFG;
75:io/servo.c ****
76:io/servo.c **** //set pin as output
77:io/servo.c **** SERVO_DDR |= (1<<SERVO_PIN);
78:io/servo.c ****
79:io/servo.c **** //initialise
80:io/servo.c **** servo_set_pos(127);
81:io/servo.c **** }
82:io/servo.c ****
83:io/servo.c **** void servo_set_pos(unsigned char val){
95 n 68,0,85,.LM1-.LFBB1
96 .LM1:
97 sts servo_pos,r24
99 .LM2:
84:io/servo.c **** os(127);
85:io/servo.c **** }
100 r25,lo8(0)
101 ldi r26,lo8(0)
102 0000 8093 0000 ldi r27,hi8(0)
86:io/servo.c **** 1<<SERVO_PIN);
103 vw r22,r24
104 movw r24,r26
105 0004 90E0 ldi r18,lo8(28800)
106 0006 A0E0 ldi r19,hi8(28800)
107 0008 B0E0 ldi r20,hlo8(28800)
108 000a BC01 ldi r21,hhi8(28800)
109 000c CD01 call __mulsi3
110 000e 20E8 ldi r18,lo8(255000)
111 0010 30E7 ldi r19,hi8(255000)
112 0012 40E0 ldi r20,hlo8(255000)
113 0014 50E0 ldi r21,hhi8(255000)
114 0016 0E94 0000 call __divmodsi4
115 001a 28E1 subi r18,lo8(-(23))
116 001c 34EE out 67-32,r18
117 001e 43E0 /* epilogue start */
119 0022 0E94 0000 .LM3:
120 0026 295E ret
122 .Lscope1:
87:io/servo.c **** CFG;
123 F(0,15)",36,0,0,servo_init
124 .global servo_init
126 servo_init:
128 .LM4:
129 .LFBB2:
130 /* prologue: function */
131 /* frame size = 0 */
133 .LM5:
134 ldi r24,lo8(110)
135 out 69-32,r24
137 .LM6:
138 sbi 49-32,7
140 002e 85BD .LM7:
141 ldi r24,lo8(127)
142 call servo_set_pos
143 0030 8F9A /* epilogue start */
145 .LM8:
146 0032 8FE7 ret
148 .Lscope2:
154 .global servo_generate_bmp
156 servo_generate_bmp:
158 .LM9:
159 .LFBB3:
160 push r16
161 push r17
88:io/servo.c **** //set up clock source
89:io/servo.c **** TCCR2 = WGM_CFG | COM_CFG | CLK_CFG;
162 on */
163 /* frame size = 0 */
164 movw r16,r24
165 003a 0F93 movw r26,r20
167 003e CF93 .LM10:
168 0040 DF93 movw r28,r24
169 add r28,r22
170 adc r29,r23
171 0042 8C01 ldi r30,lo8(SERVO_BMP_HEAD)
172 0044 DA01 ldi r31,hi8(SERVO_BMP_HEAD)
173 rjmp .L6
174 .L8:
175 0046 EC01 .LBB2:
177 004a D71F .LM11:
178 004c E0E0 /* #APP */
179 004e F0E0 ; 97 "io/servo.c" 1
180 0050 00C0 lpm r24, Z
181
182 ; 0 "" 2
90:io/servo.c **** //set up clock source
91:io/servo.c **** TCCR2 = WGM_CFG | COM_CFG | CLK_CFG;
92:io/servo.c ****
93:io/servo.c **** //set pin as output
94:io/servo.c **** SERVO_DDR |= (1<<SERVO_PIN);
95:io/servo.c ****
96:io/servo.c **** //initialise
97:io/servo.c **** servo_set_pos(127);
183 24
184 add r28,r22
185 adc r29,r23
186 ldi r30,lo8(SERVO_BMP_HEAD)
187 0052 8491 ldi r31,hi8(SERVO_BMP_HEAD)
188 rjmp .L6
189 .L8:
190 .LBB2:
192 0054 8993 .LM11:
98:io/servo.c **** = (1<<SERVO_PIN);
99:io/servo.c ****
193 4
194 movw r26,r20
100:io/servo.c **** G;
101:io/servo.c ****
196 mp, @function
197 servo_generate_bmp:
199 .LM9:
200 .LFBB3:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -