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