18 #INCLUDE ONCE "BBB/pruio.bi"
20 #INCLUDE ONCE "BBB/pruio_pins.bi"
33 IF .Errr
THEN ?"NEW failed: " & *.Errr :
EXIT DO
37 .Pwm->ForceUpDown
OR= 1
SHL 1
38 .Pwm->AqCtl(0, 1, 1) = &b000000000110
39 .Pwm->AqCtl(1, 1, 1) = &b011000000000
44 IF .Pwm->setValue(P9_14,
freq, .0)
THEN _
45 ?"failed setting P9_14 (" & *.Errr &
")" :
EXIT DO
47 IF .Pwm->setValue(P9_16,
freq, .25)
THEN _
48 ?"failed setting P9_16 (" & *.Errr &
")" :
EXIT DO
50 IF .Pwm->setValue(P9_42, .5, .00000005)
THEN _
51 ?"failed setting P9_42 (" & *.Errr &
")" :
EXIT DO
53 IF .Pwm->Value(P9_14, @
realfreq, NULL)
THEN _
54 ?"failed getting PWM value (" & *.Errr &
")" :
EXIT DO
57 IF .Qep->config(
PINS(0),
pmax, VHz)
THEN _
58 ?"QEP pin configuration failed (" & *.Errr &
")" :
EXIT DO
60 IF .config(1, 0)
THEN _
61 ?"config failed: " & *.Errr &
" --> " & .DRam[0] :
SLEEP :
EXIT DO
63 STATIC AS CONST ZSTRING PTR t(...) = {@
" A", @
" A & B", @
"A, B & I"}
73 SELECT CASE AS CONST k
74 CASE ASC(
"a"),
ASC(
"A") :
m = 0
75 CASE ASC(
"b"),
ASC(
"B") :
m = 1
76 CASE ASC(
"i"),
ASC(
"I") :
m = 2
77 CASE ASC(
"0") :
m =
p :
pmax = 0
78 CASE ASC(
"1") :
m =
p :
pmax = 1023
79 CASE ASC(
"4") :
m =
p :
pmax = 4095
80 CASE ASC(
"5") :
m =
p :
pmax = 511
81 CASE ASC(
"8") :
m =
p :
pmax = 8191
82 CASE ASC(
"+") :
m = 3 : .Pwm->AqCtl(0, 1, 1) = &b000000000110
83 CASE ASC(
"-") :
m = 3 : .Pwm->AqCtl(0, 1, 1) = &b000000001001
84 CASE ASC(
"p"),
ASC(
"P") :
m = 3 :
IF freq < 499995
THEN freq += 5
ELSE freq = 500000
85 CASE ASC(
"m"),
ASC(
"M") :
m = 3 :
IF freq > 20
THEN freq -= 5
ELSE freq = 25
86 CASE ASC(
"*") :
m = 3 :
IF freq < 250000
THEN freq *= 2
ELSE freq = 500000
87 CASE ASC(
"/") :
m = 3 :
IF freq > 50
THEN freq /= 2
ELSE freq = 25
88 CASE 13 :
m = 1 :
freq = 50
89 IF .Pwm->setValue(P9_14,
freq, -1)
THEN _
90 ?"failed setting PWM value (" & *.Errr &
")" :
EXIT DO
91 IF .Pwm->Value(P9_14, @
realfreq, NULL)
THEN _
92 ?"failed getting PWM value (" & *.Errr &
")" :
EXIT DO
95 SELECT CASE AS CONST m
97 IF .Pwm->setValue(P9_14,
freq, -1)
THEN _
98 ?"failed setting PWM value (" & *.Errr &
")" :
EXIT DO
99 IF .Pwm->Value(P9_14, @
realfreq, NULL)
THEN _
100 ?"failed getting PWM value (" & *.Errr &
")" :
EXIT DO
103 IF .Qep->config(
PINS(
p),
pmax, VHz)
THEN _
104 ?"QEP pin reconfiguration failed (" & *.Errr &
")" :
EXIT DO
109 ?"Qep->Value failed (" & *.Errr &
")" :
EXIT DO