28 CONSTRUCTOR GpioUdt(
BYVAL T
AS Pruio_
PTR)
33 i += 1 : .DRam[i] = &h44E07000uL
34 i += 1 : .DRam[i] =
IIF(.DevAct
AND PRUIO_ACT_GPIO0, &h44E00408uL, 0)
36 i += 1 : .DRam[i] = &h4804C000uL
37 i += 1 : .DRam[i] =
IIF(.DevAct
AND PRUIO_ACT_GPIO1, &h44E000ACuL, 0)
39 i += 1 : .DRam[i] = &h481AC000uL
40 i += 1 : .DRam[i] =
IIF(.DevAct
AND PRUIO_ACT_GPIO2, &h44E000B0uL, 0)
42 i += 1 : .DRam[i] = &h481AE000uL
43 i += 1 : .DRam[i] =
IIF(.DevAct
AND PRUIO_ACT_GPIO3, &h44E000B4uL, 0)
61 VAR p_mem = .MOffs + .DRam[InitParA] _
62 , p_raw =
CAST(
ANY PTR, .DRam) + PRUIO_DAT_GPIO
64 FOR i
AS LONG = 0
TO PRUIO_AZ_GPIO
66 p_raw +=
SIZEOF(GpioArr)
69 Conf(i) = p_mem + .DSize
72 IF .ClAd = 0
ORELSE .REVISION = 0
THEN _
73 .DeAd = 0 : .ClVa = &h30000 : p_mem += 16 : _
74 Init(i)->DeAd = 0 : Init(i)->ClAd = 0 :
CONTINUE FOR
83 var a = i * 32, e = a + 31
84 FOR b
AS INTEGER = 0
TO PRUIO_AZ_BALL
86 SELECT CASE Top->BallGpio(b)
87 CASE a
TO e :
if bit(.OE, p)
then continue for
88 if BIT(.DATAOUT, p)
then Top->BallInit[b]
OR= &b10000000
93 p_mem +=
SIZEOF(GpioSet)
131 BYVAL Ball
AS UInt8 _
134 BallCheck(
" GPIO", .Errr)
135 IF 7 <> (Mo
AND &b111)
THEN .Errr = E1 :
RETURN .Errr
136 VAR r = .BallGpio(Ball)
137 Mode = Mo
XOR .BallConf[Ball]
138 IF Mo <> PRUIO_PIN_RESET
ANDALSO Mode = 0
THEN RETURN 0
139 Indx = r
SHR 5 :
IF 2 <> Conf(Indx)->ClVa
THEN .Errr = E0 :
RETURN .Errr
140 IF Mode
AND &b10100000
THEN
142 Mask = 1
SHL (r
AND 31)
144 END IF :
RETURN .setPin(Top, Ball, Mo)
162 .CLEARDATAOUT
AND=
NOT Mask
163 .SETDATAOUT
AND=
NOT Mask
167 .CLEARDATAOUT
AND=
NOT Mask
170 .CLEARDATAOUT
OR= Mask
171 .SETDATAOUT
AND=
NOT Mask
176 IF .DRam[0] > PRUIO_MSG_IO_OK
THEN EXIT SUB
179 .DRam[5] = Conf(Indx)->OE
180 .DRam[4] = Conf(Indx)->SETDATAOUT
181 .DRam[3] = Conf(Indx)->CLEARDATAOUT
182 .DRam[2] = Conf(Indx)->DeAd + &h100
183 .DRam[1] = PRUIO_COM_GPIO_CONF
SHL 24
210 IF 2 <> Conf(Indx)->ClVa
THEN .Errr = E0 :
RETURN .Errr
211 IF .DRam[0] > PRUIO_MSG_IO_OK _
212 THEN .Errr = @
"main loop not running" :
RETURN .Errr
215 .DRam[5] = Conf(Indx)->OE
216 .DRam[4] = Conf(Indx)->SETDATAOUT
217 .DRam[3] = Conf(Indx)->CLEARDATAOUT
218 .DRam[2] = Conf(Indx)->DeAd + &h100
219 .DRam[1] = PRUIO_COM_GPIO_CONF
SHL 24
243 BYVAL Ball
AS UInt8 _
244 ,
BYVAL Mo
AS UInt8 = 0)
AS ZSTRING PTR
247 BallCheck(
" GPIO output", .Errr)
248 VAR r = .BallGpio(Ball)
249 Indx = r
SHR 5 :
IF 2 <> Conf(Indx)->ClVa
THEN .Errr = E0 :
RETURN .Errr
250 Mask = 1
SHL (r
AND 31)
251 SELECT CASE AS CONST Mo
252 CASE 0 : Mode = PRUIO_GPIO_OUT0 : r = .BallConf[Ball]
XOR Mode
253 CASE 1 : Mode = PRUIO_GPIO_OUT1 : r = .BallConf[Ball]
XOR Mode
254 CASE 255 : Mode = .BallInit[Ball] : r = Mo
255 CASE ELSE :
IF &b111 <> (Mo
AND &b111)
THEN .Errr = E1 :
RETURN .Errr
256 Mode = Mo : r = .BallConf[Ball]
XOR Mo
259 IF r
AND &b01011000
THEN _
260 IF .setPin(Top, Ball, Mode)
THEN _
261 Mode = .BallConf[Ball] :
setGpioSs() :
RETURN .Errr
262 .BallConf[Ball] = Mode :
RETURN 0
295 BallCheck(
" GPIO input", -1)
296 VAR r = .BallGpio(Ball) _
299 IF 2 <> Conf(i)->ClVa
THEN .Errr = E0 :
RETURN -1
300 IF &b111 <> (.BallConf[Ball]
AND &b111)
THEN .Errr = E2 :
RETURN -1
301 RETURN IIF(
BIT(Raw(i)->Mix, n), 1, 0)