[r2]: / trunk / legacy / Libraries / SPI_PiFace.library.xml  Maximize  Restore  History

Download this file

463 lines (455 with data), 17.0 kB

  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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://www.plcopen.org/xml/tc6_0200">
<fileHeader companyName="" productName="CODESYS" productVersion="CODESYS V3.5 SP11" creationDateTime="2018-07-16T11:54:08.0749653" />
<contentHeader name="Raspberry SPI PiFace" version="1.2.0.0" modificationDateTime="2015-11-24T04:28:44" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH">
<Comment>Library containing device support of PiFace Digital</Comment>
<coordinateInfo>
<fbd>
<scaling x="1" y="1" />
</fbd>
<ld>
<scaling x="1" y="1" />
</ld>
<sfc>
<scaling x="1" y="1" />
</sfc>
</coordinateInfo>
<addData>
<data name="http://www.3s-software.com/plcopenxml/projectinformation" handleUnknown="implementation">
<ProjectInformation>
<property name="Author" type="string">3S - Smart Software Solutions GmbH</property>
<property name="Company" type="string">3S - Smart Software Solutions GmbH</property>
<property name="DefaultNamespace" type="string">PiFace</property>
<property name="Description" type="string">Library containing device support of PiFace Digital</property>
<property name="Placeholder" type="string">PlaceholderTemplate</property>
<property name="Project" type="string">SPI_PiFace</property>
<property name="Released" type="boolean">false</property>
<property name="Title" type="string">Raspberry SPI PiFace</property>
<property name="Version" type="version">1.2.0.0</property>
<property name="library-category-list" type="library-category-list" />
</ProjectInformation>
</data>
</addData>
</contentHeader>
<types>
<dataTypes />
<pous>
<pou name="PiFaceDigital" pouType="functionBlock">
<interface>
<inputVars>
<variable name="byOut">
<type>
<BYTE />
</type>
</variable>
</inputVars>
<outputVars>
<variable name="byIn">
<type>
<BYTE />
</type>
</variable>
</outputVars>
<localVars>
<variable name="_byHardwareAddress">
<type>
<BYTE />
</type>
</variable>
</localVars>
<tempVars>
<variable name="i">
<type>
<INT />
</type>
</variable>
<variable name="k">
<type>
<INT />
</type>
</variable>
</tempVars>
<addData>
<data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation">
<Inheritance>
<Extends>spi</Extends>
</Inheritance>
</data>
</addData>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^();
CASE _iState OF
0:
IF SUPER^.init() THEN
_iState := 1;
END_IF
1:
write8(_byHardwareAddress, IOCON, 8); //enable hardware addressing
write8(_byHardwareAddress, GPIOA, 0); //turn on port A
write8(_byHardwareAddress, IODIRA, 0); //set port A as an output
write8(_byHardwareAddress, IODIRB, 16#FF); // set port B as an input
write8(_byHardwareAddress, GPPUB, 16#FF); // turn on port B pullups
_iState := 10;
END_CASE
</xhtml>
</ST>
</body>
<addData>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="Initialize">
<interface>
<returnType>
<UDINT />
</returnType>
<inputVars>
<variable name="wModuleType">
<type>
<UINT />
</type>
</variable>
<variable name="dwInstance">
<type>
<UDINT />
</type>
</variable>
<variable name="pConnector">
<type>
<pointer>
<baseType>
<derived name="IoConfigConnector" />
</baseType>
</pointer>
</type>
</variable>
</inputVars>
<localVars>
<variable name="pParam">
<type>
<pointer>
<baseType>
<derived name="IoConfigParameter" />
</baseType>
</pointer>
</type>
</variable>
<variable name="udiResult">
<type>
<UDINT />
</type>
</variable>
</localVars>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.Initialize(wModuleType, dwInstance, pConnector);
pParam := ConfigGetParameter(_pConnector, 1);
IF pParam &lt;&gt; 0 THEN
_byHardwareAddress := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult));
END_IF
</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="BeforeWriteOutputs">
<interface>
<returnType>
<INT />
</returnType>
<localVars>
<variable name="i">
<type>
<USINT />
</type>
</variable>
</localVars>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.BeforeWriteOutputs();
IF _iState = 10 THEN
write8(_byHardwareAddress, GCL_PIFace.OUTPUT_PORT, byOut);
END_IF</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="AfterReadInputs">
<interface>
<returnType>
<INT />
</returnType>
<localVars>
<variable name="aby">
<type>
<array>
<dimension lower="0" upper="13" />
<baseType>
<BYTE />
</baseType>
</array>
</type>
</variable>
</localVars>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs();
IF _iState = 10 THEN
byIn := NOT read8(_byHardwareAddress, GCL_PIFace.INPUT_PORT);
END_IF
</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="read8">
<interface>
<returnType>
<BYTE />
</returnType>
<inputVars>
<variable name="byHardwareAddress">
<type>
<subrangeSigned>
<range lower="0" upper="7" />
<baseType>
<BYTE />
</baseType>
</subrangeSigned>
</type>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> hardware address </xhtml>
</documentation>
</variable>
<variable name="byPort">
<type>
<BYTE />
</type>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> port number to read </xhtml>
</documentation>
</variable>
</inputVars>
<localVars>
<variable name="abyTxBuffer">
<type>
<array>
<dimension lower="0" upper="2" />
<baseType>
<BYTE />
</baseType>
</array>
</type>
</variable>
<variable name="abyRxBuffer">
<type>
<array>
<dimension lower="0" upper="2" />
<baseType>
<BYTE />
</baseType>
</array>
</type>
</variable>
</localVars>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> This method is used to read the data byte of one port using the following protocol:
Byte0: 16#41 + hardware address
Byte1: Port
Byte2: 16#FF
return value: data content</xhtml>
</documentation>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">abyTxBuffer[0] := 16#40 + SHL(byHardwareAddress, 1) + 1; //SPI_READ_CMD;
abyTxBuffer[1] := byPort;
abyTxBuffer[2] := 16#FF;
IF transfer(pabyTxBuffer:=ADR(abyTxBuffer) , pabyRxBuffer:=ADR(abyRxBuffer) , udiLen:=3 , uiDelayus:=5 ) THEN
read8 := abyRxBuffer[2];
ELSE
_iState := 1000;
END_IF</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
<data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
<Method name="write8">
<interface>
<returnType>
<BOOL />
</returnType>
<inputVars>
<variable name="byHardwareAddress">
<type>
<subrangeSigned>
<range lower="0" upper="7" />
<baseType>
<BYTE />
</baseType>
</subrangeSigned>
</type>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> hardware address </xhtml>
</documentation>
</variable>
<variable name="byPort">
<type>
<BYTE />
</type>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> port number to read </xhtml>
</documentation>
</variable>
<variable name="byValue">
<type>
<BYTE />
</type>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> value to write </xhtml>
</documentation>
</variable>
</inputVars>
<localVars>
<variable name="abyTxBuffer">
<type>
<array>
<dimension lower="0" upper="2" />
<baseType>
<BYTE />
</baseType>
</array>
</type>
</variable>
<variable name="abyRxBuffer">
<type>
<array>
<dimension lower="0" upper="2" />
<baseType>
<BYTE />
</baseType>
</array>
</type>
</variable>
</localVars>
<documentation>
<xhtml xmlns="http://www.w3.org/1999/xhtml"> This method is used to write a data byte into a port using the following protocol:
Byte0: 16#41 + hardware address
Byte1: Port
Byte2: Value
return value: TRUE if successful</xhtml>
</documentation>
</interface>
<body>
<ST>
<xhtml xmlns="http://www.w3.org/1999/xhtml">abyTxBuffer[0] := 16#40 + SHL(byHardwareAddress, 1); //SPI_WRITE_CMD;
abyTxBuffer[1] := byPort;
abyTxBuffer[2] := byValue;
write8 := transfer(pabyTxBuffer:=ADR(abyTxBuffer) , pabyRxBuffer:=ADR(abyRxBuffer) , udiLen:=3 , uiDelayus:=5 );
IF NOT write8 THEN
_iState := 1000;
END_IF</xhtml>
</ST>
</body>
<addData />
</Method>
</data>
</addData>
</pou>
</pous>
</types>
<instances>
<configurations />
</instances>
<addData>
<data name="http://www.3s-software.com/plcopenxml/globalvars" handleUnknown="implementation">
<globalVars name="GCL_PIFace" constant="true">
<variable name="OUTPUT_PORT">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#12" />
</initialValue>
</variable>
<variable name="INPUT_PORT">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#13" />
</initialValue>
</variable>
<variable name="IOCON">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#A" />
</initialValue>
</variable>
<variable name="GPIOA">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#12" />
</initialValue>
</variable>
<variable name="GPIOB">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#13" />
</initialValue>
</variable>
<variable name="GPPUB">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#D" />
</initialValue>
</variable>
<variable name="IODIRA">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#0" />
</initialValue>
</variable>
<variable name="IODIRB">
<type>
<USINT />
</type>
<initialValue>
<simpleValue value="16#1" />
</initialValue>
</variable>
</globalVars>
</data>
<data name="http://www.3s-software.com/plcopenxml/libraries" handleUnknown="implementation">
<Libraries>
<Library Name="#CAA Types" Namespace="CAA" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="CAA Types Extern, * (CAA Technical Workgroup)" />
<Library Name="#Standard" Namespace="Standard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Standard, * (System)" />
<Library Name="SysTypes Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
<Library Name="#IoStandard" Namespace="IoStandard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoStandard, * (System)" />
<Library Name="#Raspberry Pi Peripherals" Namespace="Raspi" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Raspberry Pi Peripherals, * (3S - Smart Software Solutions GmbH)" />
<addData />
</Libraries>
</data>
</addData>
</project>