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