libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
pruio.bi
Go to the documentation of this file.
1 
9 
10 #IFNDEF __PRUIO_COMPILING__
11 #INCLIB "pruio"
12 #ENDIF
13 ' PruIo global declarations.
14 #INCLUDE ONCE "pruio_globals.bi"
15 ' Header for ADC part.
16 #INCLUDE ONCE "pruio_adc.bi"
17 ' Header for GPIO part.
18 #INCLUDE ONCE "pruio_gpio.bi"
19 ' Header for PWMSS part, containing modules QEP, CAP and PWM.
20 #INCLUDE ONCE "pruio_pwmss.bi"
21 ' Header for TIMER part.
22 #INCLUDE ONCE "pruio_timer.bi"
23 ' Header for interrupt controller.
24 #INCLUDE ONCE "pruio_intc.bi"
25 
26 
27 #DEFINE BallCheck(_T_,_R_) IF Ball > PRUIO_AZ_BALL THEN .Errr = @"unknown" _T_ " pin number" : RETURN _R_
28 
29 
30 
34 ENUM BBTypes
35  BBB2x46 = 0
36  PBB2x36 = 1
37  BB_Blue = 2
38 END ENUM
39 
40 
41 
59 ENUM AdcStepMask
60  AIN0 = &b000000010
61  AIN1 = &b000000100
62  AIN2 = &b000001000
63  AIN3 = &b000010000
64  AIN4 = &b000100000
65  AIN5 = &b001000000
66  AIN6 = &b010000000
67  AIN7 = &b100000000
68 END ENUM
69 
70 
71 
90 ENUM ActivateDevice
91  PRUIO_ACT_PRU1 = &b0000000000001
92  PRUIO_ACT_ADC = &b0000000000010
93  PRUIO_ACT_GPIO0 = &b0000000000100
94  PRUIO_ACT_GPIO1 = &b0000000001000
95  PRUIO_ACT_GPIO2 = &b0000000010000
96  PRUIO_ACT_GPIO3 = &b0000000100000
97  PRUIO_ACT_PWM0 = &b0000001000000
98  PRUIO_ACT_PWM1 = &b0000010000000
99  PRUIO_ACT_PWM2 = &b0000100000000
100  PRUIO_ACT_TIM4 = &b0001000000000
101  PRUIO_ACT_TIM5 = &b0010000000000
102  PRUIO_ACT_TIM6 = &b0100000000000
103  PRUIO_ACT_TIM7 = &b1000000000000
104  PRUIO_DEF_ACTIVE = &b1111111111111
105  PRUIO_ACT_FREMUX = &b1000000000000000
106 END ENUM
107 
108 
109 
117 TYPE BallSet
118  AS UInt32 DeAd
120 END TYPE
121 
122 
123 
124 TYPE setPinFunc AS FUNCTION CDECL( _
125  BYVAL Top AS Pruio_ PTR _
126  , BYVAL Ball AS UInt8 _
127  , BYVAL Mo AS UInt8) AS ZSTRING PTR
128 
129 
130 
138 TYPE PruIo
139  AS ZSTRING PTR _
140  Errr = 0
141 
142  AS AdcUdt PTR Adc
143  AS GpioUdt PTR Gpio
144  AS PwmssUdt PTR PwmSS
145  AS TimerUdt PTR TimSS
146  AS PwmMod PTR Pwm
147  AS CapMod PTR Cap
148  AS QepMod PTR Qep
149  AS TimerUdt PTR Tim
150 
151  AS UInt32 PTR DRam
152  AS BallSet PTR _
153  Init _
154  , Conf
155  AS ANY PTR _
156  ERam _
157  , DInit _
158  , DConf _
159  , MOffs
160  AS UInt8 PTR _
161  BallInit _
162  , BallConf
163  AS UInt32 _
164  EAddr _
165  , ESize _
166  , DSize _
167  , PruNo _
168  , PruIRam _
169  , PruDRam _
170  , PruIntNo
171  AS Int16 _
172  ParOffs _
173  , DevAct
174 
175  AS UInt32 _
176  BbType _
177  , MuxFnr
178  AS ZSTRING PTR MuxAcc
179 
180  '& FUNCTION_CDECL_AS_ZSTRING_PTR (setPin) (BYVAL_AS_Pruio__PTR Top, BYVAL_AS_UInt8 Ball, BYVAL_AS_UInt8 Mo); /*
235  setPin AS setPinFunc '& */
236 
237 
238  AS UInt8 BallGpio(PRUIO_AZ_BALL) = { _
239  32, 33, 34, 35, 36, 37, 38, 39, 22, 23 _
240  , 26, 27, 44, 45, 46, 47, 48, 49, 50, 51 _ ' 10
241  , 52, 53, 54, 55, 56, 57, 58, 59, 30, 31 _
242  , 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 _ ' 30
243  , 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 _
244  , 80, 81, 8, 9, 10, 11, 86, 87, 88, 89 _ ' 50
245  , 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 _
246  , 100, 16, 17, 21, 28, 105, 106, 82, 83, 84 _ ' 70
247  , 85, 29, 0, 1, 2, 3, 4, 5, 6, 7 _
248  , 40, 41, 42, 43, 12, 13, 14, 15, 101, 102 _ ' 90
249  , 110, 111, 112, 113, 114, 115, 116, 117, 19, 20}
250 
251 
252  AS tpruss_intc_initdata PTR IntcInit = @DEF_INTC_INIT
253  AS UInt32 WaitCycles
254 
255  DECLARE CONSTRUCTOR( _
256  BYVAL AS UInt16 = PRUIO_DEF_ACTIVE _
257  , BYVAL AS UInt8 = PRUIO_DEF_AVRAGE _
258  , BYVAL AS UInt32 = PRUIO_DEF_ODELAY _
259  , BYVAL AS UInt8 = PRUIO_DEF_SDELAY)
260  DECLARE DESTRUCTOR()
261  DECLARE FUNCTION config CDECL( _
262  BYVAL AS UInt32 = PRUIO_DEF_SAMPLS _
263  , BYVAL AS UInt32 = PRUIO_DEF_STPMSK _
264  , BYVAL AS UInt32 = PRUIO_DEF_TIMERV _
265  , BYVAL AS UInt16 = PRUIO_DEF_LSLMOD) AS ZSTRING PTR
266  DECLARE FUNCTION Pin CDECL( _
267  BYVAL AS UInt8 _
268  , BYVAL AS UInt8 = 1) AS ZSTRING PTR
269  DECLARE FUNCTION nameBall CDECL( _
270  BYVAL AS UInt8) AS ZSTRING PTR
271  DECLARE FUNCTION rb_start CDECL() AS ZSTRING PTR
272  DECLARE FUNCTION mm_start CDECL( _
273  BYVAL AS UInt32 = 0 _
274  , BYVAL AS UInt32 = 0 _
275  , BYVAL AS UInt32 = 0 _
276  , BYVAL AS UInt32 = 0) AS ZSTRING PTR
277 END TYPE
278 
279