libpruio
0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
analyse.bas
Go to the documentation of this file.
1
17
18
' include libpruio
19
#INCLUDE ONCE
"BBB/pruio.bi"
20
' include board pin header
21
#INCLUDE ONCE
"BBB/pruio_boardpins.bi"
22
23
'' Output all CPU balls or just subset of header pins?
24
'#DEFINE __ALL_BALLS__
25
26
27
#DEFINE
OUT_TYPE Init
' alternative: Conf
28
29
30
#DEFINE
REG(_R_)
RIGHT
(
" "
& #_R_, 17) &
": "
&
HEX
(.##_R_,
SIZEOF
(.##_R_) * 2)
31
32
#DEFINE
DEV(_N_) !
"\n"
& _N_ & _
33
" (DeAd: "
&
HEX
(.DeAd, 8) & _
34
", ClAd: "
&
HEX
(.ClAd, 8) & _
35
", ClVa: "
&
HEX
(.ClVa, 8) &
")"
36
37
38
#MACRO
BALL_OUT(OUT_TYPE)
39
?
!
"\nControl Module (DeAd: "
&
HEX
(.OUT_TYPE->DeAd, 8) &
")"
40
FOR
i
AS INTEGER
= 0
TO UBOUND
(.OUT_TYPE->Value)
41
?
" "
& *.get_config(i)
42
NEXT
43
#ENDMACRO
44
45
46
#MACRO
GPIO_OUT(OUT_TYPE)
47
FOR
n
AS INTEGER
= 0
TO UBOUND
(.Gpio->OUT_TYPE)
48
WITH
*.Gpio->OUT_TYPE(n)
49
?
DEV(
"GPIO-"
& n)
50
?
REG(REVISION)
51
IF 0
= .ClAd
THEN ?
" --> subsystem not handled "
& *
IIF
(.REVISION, @
"(is up)"
, @
"(is down)"
) :
CONTINUE FOR
52
IF 0
= .REVISION
THEN ?
" --> wake up failed"
:
CONTINUE FOR
53
54
?
REG(SYSCONFIG)
55
?
REG(EOI)
56
?
REG(IRQSTATUS_RAW_0)
57
?
REG(IRQSTATUS_RAW_1)
58
?
REG(IRQSTATUS_0)
59
?
REG(IRQSTATUS_1)
60
?
REG(IRQSTATUS_SET_0)
61
?
REG(IRQSTATUS_SET_1)
62
?
REG(IRQSTATUS_CLR_0)
63
?
REG(IRQSTATUS_CLR_1)
64
?
REG(IRQWAKEN_0)
65
?
REG(IRQWAKEN_1)
66
?
REG(SYSSTATUS)
67
?
REG(CTRL)
68
?
REG(OE)
69
?
REG(DATAIN)
70
?
REG(DATAOUT)
71
?
REG(LEVELDETECT0)
72
?
REG(LEVELDETECT1)
73
?
REG(RISINGDETECT)
74
?
REG(FALLINGDETECT)
75
?
REG(DEBOUNCENABLE)
76
?
REG(DEBOUNCINGTIME)
77
?
REG(CLEARDATAOUT)
78
?
REG(SETDATAOUT)
79
END WITH
80
NEXT
81
#ENDMACRO
82
83
84
#MACRO
TIMER_OUT(OUT_TYPE)
85
FOR
n
AS INTEGER
= 0
TO UBOUND
(.TimSS->OUT_TYPE)
86
WITH
*.TimSS->OUT_TYPE(n)
87
?
DEV(
"TIMER-"
& 4 + n)
88
?
REG(TIDR)
89
IF 0
= .ClAd
THEN ?
" --> subsystem not handled "
& *
IIF
(.TIDR, @
"(is up)"
, @
"(is down)"
) :
CONTINUE FOR
90
IF 0
= .TIDR
THEN ?
" --> wake up failed"
:
CONTINUE FOR
91
92
?
REG(TIOCP_CFG)
93
?
REG(IRQ_EOI)
94
?
REG(IRQSTATUS_RAW)
95
?
REG(IRQSTATUS)
96
?
REG(IRQENABLE_SET)
97
?
REG(IRQENABLE_CLR)
98
?
REG(IRQWAKEEN)
99
?
REG(TCLR)
100
?
REG(TCRR)
101
?
REG(TLDR)
102
?
REG(TTGR)
103
?
REG(TWPS)
104
?
REG(TMAR)
105
?
REG(TCAR1)
106
?
REG(TSICR)
107
?
REG(TCAR2)
108
END WITH
109
NEXT
110
#ENDMACRO
111
112
113
#MACRO
PWMSS_OUT(OUT_TYPE)
114
FOR
n
AS INTEGER
= 0
TO UBOUND
(.PwmSS->OUT_TYPE)
115
WITH
*.PwmSS->OUT_TYPE(n)
116
?
DEV(
"PWMSS-"
& n)
117
?
REG(IDVER)
118
IF 0
= .ClAd
THEN ?
" --> subsystem not handled "
& *
IIF
(.IDVER, @
"(is up)"
, @
"(is down)"
) :
CONTINUE FOR
119
IF 0
= .IDVER
THEN ?
" --> wake up failed"
:
CONTINUE FOR
120
121
?
REG(SYSCONFIG)
122
?
REG(CLKCONFIG)
123
?
REG(CLKSTATUS)
124
?
" eCAP"
125
?
REG(TSCTR)
126
?
REG(CTRPHS)
127
?
REG(CAP1)
128
?
REG(CAP2)
129
?
REG(CAP3)
130
?
REG(CAP4)
131
?
REG(ECCTL1)
132
?
REG(ECCTL2)
133
?
REG(ECEINT)
134
?
REG(ECFLG)
135
?
REG(ECCLR)
136
?
REG(ECFRC)
137
?
REG(CAP_REV)
138
?
" QEP"
139
?
REG(QPOSCNT)
140
?
REG(QPOSINIT)
141
?
REG(QPOSMAX)
142
?
REG(QPOSCMP)
143
?
REG(QPOSILAT)
144
?
REG(QPOSSLAT)
145
?
REG(QPOSLAT)
146
?
REG(QUTMR)
147
?
REG(QUPRD)
148
?
REG(QWDTMR)
149
?
REG(QWDPRD)
150
?
REG(QDECCTL)
151
?
REG(QEPCTL)
152
?
REG(QCAPCTL)
153
?
REG(QPOSCTL)
154
?
REG(QEINT)
155
?
REG(QFLG)
156
?
REG(QCLR)
157
?
REG(QFRC)
158
?
REG(QEPSTS)
159
?
REG(QCTMR)
160
?
REG(QCPRD)
161
?
REG(QCTMRLAT)
162
?
REG(QCPRDLAT)
163
?
REG(QEP_REV)
164
?
" ePWM"
165
?
REG(TBCTL)
166
?
REG(TBSTS)
167
?
REG(TBPHSHR)
168
?
REG(TBPHS)
169
?
REG(TBCNT)
170
?
REG(TBPRD)
171
?
REG(CMPCTL)
172
?
REG(CMPAHR)
173
?
REG(CMPA)
174
?
REG(CMPB)
175
?
REG(AQCTLA)
176
?
REG(AQCTLB)
177
?
REG(AQSFRC)
178
?
REG(AQCSFRC)
179
?
REG(DBCTL)
180
?
REG(DBRED)
181
?
REG(DBFED)
182
?
REG(TZSEL)
183
?
REG(TZCTL)
184
?
REG(TZEINT)
185
?
REG(TZFLG)
186
?
REG(TZCLR)
187
?
REG(TZFRC)
188
?
REG(ETSEL)
189
?
REG(ETPS)
190
?
REG(ETFLG)
191
?
REG(ETCLR)
192
?
REG(ETFRC)
193
?
REG(PCCTL)
194
END WITH
195
NEXT
196
#ENDMACRO
197
198
199
#MACRO
ADC_OUT(OUT_TYPE)
200
DO
201
WITH
*.Adc->OUT_TYPE
202
?
DEV(
"ADC"
)
203
?
REG(REVISION)
204
IF 0
= .ClAd
THEN ?
" --> subsystem not handled "
& *
IIF
(.REVISION, @
"(is up)"
, @
"(is down)"
) :
EXIT DO
205
IF 0
= .REVISION
THEN ?
" --> wake up failed"
:
EXIT DO
206
207
?
REG(SYSCONFIG)
208
?
REG(IRQSTATUS_RAW)
209
?
REG(IRQSTATUS)
210
?
REG(IRQENABLE_SET)
211
?
REG(IRQENABLE_CLR)
212
?
REG(IRQWAKEUP)
213
?
REG(DMAENABLE_SET)
214
?
REG(DMAENABLE_CLR)
215
?
REG(CTRL)
216
?
REG(ADCSTAT)
217
?
REG(ADCRANGE)
218
?
REG(ADC_CLKDIV)
219
?
REG(ADC_MISC)
220
?
REG(STEPENABLE)
221
?
REG(IDLECONFIG)
222
?
" CHARGE_STEP: "
&
HEX
(.St_p( 0).Confg, 8),
HEX
(.St_p( 0).Delay, 8)
223
FOR
i
AS INTEGER
= 1
TO UBOUND
(.St_p)
224
WITH
.St_p(i)
225
?
" STEP-"
&
RIGHT
(
"0"
& i, 2) &
": "
&
HEX
(.Confg, 8),
HEX
(.Delay, 8)
226
END WITH
227
NEXT
228
?
REG(FIFO0COUNT)
229
?
REG(FIFO0THRESHOLD)
230
?
REG(DMA0REQ)
231
?
REG(FIFO1COUNT)
232
?
REG(FIFO1THRESHOLD)
233
?
REG(DMA1REQ)
234
END WITH
235
LOOP UNTIL 1
236
#ENDMACRO
237
238
239
' ***** main *****
240
241
VAR
io
=
NEW
PruIo
242
243
WITH
*
io
244
IF
.Errr
THEN
245
?
"initialisation failed ("
& *.Errr &
")"
246
ELSE
247
#IFDEF
__ALL_BALLS__
248
BALL_OUT(OUT_TYPE)
249
#ELSE
250
VAR
typ
=
""
_
251
,
pins
=
""
252
SELECT CASE
AS CONST
.BbType
253
CASE
PBB2x36 :
typ
=
"Pocketbeagle 2x36"
:
pins
= HEADERPINS_POCKET
254
CASE
BB_Blue :
typ
=
"Beaglebone Blue"
:
pins
= HEADERPINS_BLUE
255
CASE ELSE
:
typ
=
"Beaglebone 2x46"
:
pins
= HEADERPINS_BB
256
END SELECT
257
?
"Header Pins ("
&
typ
&
"):"
258
FOR
i
AS LONG
= 0
TO LEN
(
pins
) - 1
259
?
" "
& *.Pin(
pins
[i])
260
NEXT
261
#ENDIF
262
263
GPIO_OUT(OUT_TYPE)
264
ADC_OUT(OUT_TYPE)
265
PWMSS_OUT(OUT_TYPE)
266
TIMER_OUT(OUT_TYPE)
267
END IF
268
END WITH
269
270
DELETE
io
' reset ADC, PinMux and GPIOs, clear memory
271
272
'' help Doxygen to document the main code
273
'&/** The main function. */
274
'&int main() {PruIo::PruIo(); PruIo::~PruIo();}
275
src
examples
analyse.bas
Generated on Thu May 11 2023 12:42:51 for libpruio by
1.9.1