This repository was archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMove.s
107 lines (90 loc) · 2.2 KB
/
Move.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
INCLUDE stm32l476xx_constants.s
AREA Move, CODE, READONLY
EXPORT MoveInit
EXPORT MoveUp
EXPORT MoveDown ; make functions visible to linker
; When MoveUp or MoveDown is called, the motor is either moved clockwise or counterclockwise by 360 degrees.
; Output pins will be A:B11, A':B12, B:B8, B':B9
MoveUp PROC
PUSH {LR}
MOV r3, #0x200 ; Determines range of motor
uploop
;Moves motor up
LDR r0, =GPIOB_BASE
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0xA00 ;A high, A' low, B low, B' high
STR r1, [r0, #GPIO_ODR]
BL movedelay
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0x900 ;A high, A' low, B high, B' low
STR r1, [r0, #GPIO_ODR]
BL movedelay
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0x1100 ;A low, A' high, B high, B' low
STR r1, [r0, #GPIO_ODR]
BL movedelay
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0x1200 ;A low, A' high, B low, B' high
STR r1, [r0, #GPIO_ODR]
BL movedelay
SUBS r3, r3, #0x1
BPL uploop
POP {LR}
BX LR
ENDP
MoveDown PROC
PUSH {LR}
MOV r3, #0x200 ; Determines range of motor
downloop ; moves wiper back
;Wiper section
LDR r0, =GPIOB_BASE
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0x1200 ;A low, A' high, B low, B' high
STR r1, [r0, #GPIO_ODR]
BL movedelay
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0x1100 ;A low, A' high, B high, B' low
STR r1, [r0, #GPIO_ODR]
BL movedelay
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0x900 ;A high, A' low, B high, B' low
STR r1, [r0, #GPIO_ODR]
BL movedelay
LDR r1, [r0, #GPIO_ODR]
BIC r1, #0x1B00
ORR r1, #0xA00 ;A high, A' low, B low, B' high
STR r1, [r0, #GPIO_ODR]
BL movedelay
SUBS r3, r3, #0x1
BPL downloop
POP {LR}
BX LR
ENDP
movedelay
PUSH{r2}
MOV r2, #0x18000 ;initialize delay
delayinner
SUBS r2, r2, #1 ;subtract 1
BPL delayinner ;loop back if > 0
POP{r2}
BX LR
MoveInit PROC
; Set GPIOB pins 8, 9, 11, 12 as output pins (Motor)
LDR r0, =GPIOB_BASE
LDR r1, [r0, #GPIO_MODER]
BIC r1, #0xFF0000
BIC r1, #0xF000000
ORR r1, #0x50000
ORR r1, #0x1000000
ORR r1, #0x400000
STR r1, [r0, #GPIO_MODER]
BX LR
ENDP
END