]> hackdaworld.org Git - my-code/atmel.git/blob - hdw-tank/motor.asm
some more debug
[my-code/atmel.git] / hdw-tank / motor.asm
1 ; motor functions
2
3 .equ    MOT_1_1         = 0x04
4 .equ    MOT_1_2         = 0x02
5 .equ    MOT_2_1         = 0x07
6 .equ    MOT_2_2         = 0x03
7
8 MOTOR_INIT:
9
10         ; ports -> output
11         in tmp1,DDRB
12         sbr tmp1,(1<<MOT_1_1)|(1<<MOT_1_2)
13         sbr tmp1,(1<<MOT_2_1)|(1<<MOT_2_2)
14         out DDRB,tmp1
15
16 MOTOR_STOP:
17
18         ; output zero
19         in tmp1,PORTB
20         cbr tmp1,(1<<MOT_1_1)|(1<<MOT_1_2)
21         cbr tmp1,(1<<MOT_2_1)|(1<<MOT_2_2)
22         out PORTB,tmp1
23
24         ret
25
26 MOTOR_FWD:
27
28         in tmp1,PORTB
29         sbr tmp1,(1<<MOT_1_1)|(1<<MOT_2_1)
30         cbr tmp1,(1<<MOT_1_2)|(1<<MOT_2_2)
31         out PORTB,tmp1
32
33         ret
34
35 MOTOR_BWD:
36
37         in tmp1,PORTB
38         sbr tmp1,(1<<MOT_1_2)|(1<<MOT_2_2)
39         cbr tmp1,(1<<MOT_1_1)|(1<<MOT_2_1)
40         out PORTB,tmp1
41
42         ret
43
44 MOTOR_RIGHT:
45
46         in tmp1,PORTB
47         sbr tmp1,(1<<MOT_2_2)|(1<<MOT_1_1)
48         cbr tmp1,(1<<MOT_2_1)|(1<<MOT_1_2)
49         out PORTB,tmp1
50
51         ret
52
53 MOTOR_LEFT:
54
55         in tmp1,PORTB
56         sbr tmp1,(1<<MOT_1_2)|(1<<MOT_2_1)
57         cbr tmp1,(1<<MOT_1_1)|(1<<MOT_2_2)
58         out PORTB,tmp1
59
60         ret
61