Diff of /trunk/mcp3008/Libraries/SPI_MCP3008.library.xml [000000] .. [r1]  Maximize  Restore

Switch to unified view

a b/trunk/mcp3008/Libraries/SPI_MCP3008.library.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<project xmlns="http://www.plcopen.org/xml/tc6_0200">
3
  <fileHeader companyName="" productName="CODESYS" productVersion="CODESYS V3.5 SP11" creationDateTime="2018-07-16T12:59:41.4730461" />
4
  <contentHeader name="Linux SPI MCP3008" version="1.0.0.0" modificationDateTime="2018-07-16T12:51:11.5392363" organization="Open Source" author="3S - Smart Software Solutions GmbH">
5
    <Comment>Library containing device support of MCP3008. The original author was 3S. Now it is maintained as open source on CODESYS Forge.</Comment>
6
    <coordinateInfo>
7
      <fbd>
8
        <scaling x="1" y="1" />
9
      </fbd>
10
      <ld>
11
        <scaling x="1" y="1" />
12
      </ld>
13
      <sfc>
14
        <scaling x="1" y="1" />
15
      </sfc>
16
    </coordinateInfo>
17
    <addData>
18
      <data name="http://www.3s-software.com/plcopenxml/projectinformation" handleUnknown="implementation">
19
        <ProjectInformation>
20
          <property name="Author" type="string">3S - Smart Software Solutions GmbH</property>
21
          <property name="Company" type="string">Open Source</property>
22
          <property name="DefaultNamespace" type="string">MCP3008</property>
23
          <property name="Description" type="string">Library containing device support of MCP3008. The original author was 3S. Now it is maintained as open source on CODESYS Forge.</property>
24
          <property name="Placeholder" type="string">SPI MCP3008</property>
25
          <property name="Project" type="string">SPI_MCP3008</property>
26
          <property name="Released" type="boolean">false</property>
27
          <property name="Title" type="string">Linux SPI MCP3008</property>
28
          <property name="Version" type="version">1.0.0.0</property>
29
          <property name="library-category-list" type="library-category-list">Target</property>
30
        </ProjectInformation>
31
      </data>
32
    </addData>
33
  </contentHeader>
34
  <types>
35
    <dataTypes />
36
    <pous>
37
      <pou name="IoDrvMCP3008" pouType="functionBlock">
38
        <interface>
39
          <localVars>
40
            <variable name="_IIoDrv">
41
              <type>
42
                <derived name="ICmpIoDrv" />
43
              </type>
44
            </variable>
45
            <variable name="_IIoDrvParameter">
46
              <type>
47
                <derived name="ICmpIoDrvParameter" />
48
              </type>
49
            </variable>
50
            <variable name="_MCP3008">
51
              <type>
52
                <derived name="MCP3008" />
53
              </type>
54
            </variable>
55
            <variable name="_dwInUse">
56
              <type>
57
                <DWORD />
58
              </type>
59
            </variable>
60
            <variable name="_xBackGroundDiagStarted">
61
              <type>
62
                <BOOL />
63
              </type>
64
            </variable>
65
            <variable name="_bDeactivated">
66
              <type>
67
                <BOOL />
68
              </type>
69
            </variable>
70
          </localVars>
71
          <localVars constant="true">
72
            <variable name="CLASSID_CCmpIoDrvTemplate">
73
              <type>
74
                <DWORD />
75
              </type>
76
              <initialValue>
77
                <simpleValue value="16#FF03" />
78
              </initialValue>
79
              <documentation>
80
                <xhtml xmlns="http://www.w3.org/1999/xhtml"> TODO</xhtml>
81
              </documentation>
82
            </variable>
83
          </localVars>
84
          <addData>
85
            <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation">
86
              <Inheritance>
87
                <Extends>IoDrvBase</Extends>
88
                <Implements>ICmpIoDrvParameter</Implements>
89
              </Inheritance>
90
            </data>
91
          </addData>
92
        </interface>
93
        <body>
94
          <ST>
95
            <xhtml xmlns="http://www.w3.org/1999/xhtml" />
96
          </ST>
97
        </body>
98
        <addData>
99
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
100
            <Method name="FB_Exit">
101
              <interface>
102
                <returnType>
103
                  <BOOL />
104
                </returnType>
105
                <inputVars>
106
                  <variable name="bInCopyCode">
107
                    <type>
108
                      <BOOL />
109
                    </type>
110
                  </variable>
111
                </inputVars>
112
                <addData>
113
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
114
                    <Attributes>
115
                      <Attribute Name="conditionalshow" Value="" />
116
                    </Attributes>
117
                  </data>
118
                </addData>
119
              </interface>
120
              <body>
121
                <ST>
122
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Exit_Count := FB_Exit_Count + 1;
123
FB_Exit := TRUE;</xhtml>
124
                </ST>
125
              </body>
126
              <addData />
127
            </Method>
128
          </data>
129
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
130
            <Method name="FB_Init">
131
              <interface>
132
                <returnType>
133
                  <BOOL />
134
                </returnType>
135
                <inputVars>
136
                  <variable name="bInitRetains">
137
                    <type>
138
                      <BOOL />
139
                    </type>
140
                  </variable>
141
                  <variable name="bInCopyCode">
142
                    <type>
143
                      <BOOL />
144
                    </type>
145
                  </variable>
146
                </inputVars>
147
                <localVars>
148
                  <variable name="Result">
149
                    <type>
150
                      <UDINT />
151
                    </type>
152
                  </variable>
153
                </localVars>
154
                <addData>
155
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
156
                    <Attributes>
157
                      <Attribute Name="conditionalshow" Value="" />
158
                    </Attributes>
159
                  </data>
160
                </addData>
161
              </interface>
162
              <body>
163
                <ST>
164
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Init_Count := FB_Init_Count + 1;
165
166
m_Info.szDriverName := 'IoDrvMCP3008';
167
m_Info.szVendorName := 'Open Source';
168
m_info.szDeviceName := 'MCP3008';
169
m_Info.wModuleType := 8000;
170
171
_IIoDrv := THIS^;
172
_IIoDrvParameter := THIS^;
173
174
m_IBaseItf := THIS^;
175
m_hInterface := IoMgrRegisterInstance2(dwClassId:=CLASSID_CCmpIoDrvTemplate, pItf:=m_IBaseItf, pResult:=ADR(Result));
176
FB_Init := TRUE;</xhtml>
177
                </ST>
178
              </body>
179
              <addData />
180
            </Method>
181
          </data>
182
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
183
            <Method name="FB_Reinit">
184
              <interface>
185
                <returnType>
186
                  <BOOL />
187
                </returnType>
188
                <addData>
189
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
190
                    <Attributes>
191
                      <Attribute Name="conditionalshow" Value="" />
192
                    </Attributes>
193
                  </data>
194
                </addData>
195
              </interface>
196
              <body>
197
                <ST>
198
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Reinit_Count := FB_Reinit_Count + 1;
199
FB_Reinit := TRUE;</xhtml>
200
                </ST>
201
              </body>
202
              <addData />
203
            </Method>
204
          </data>
205
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
206
            <Method name="Initialize">
207
              <interface>
208
                <returnType>
209
                  <UDINT />
210
                </returnType>
211
                <inputVars>
212
                  <variable name="wModuleType">
213
                    <type>
214
                      <UINT />
215
                    </type>
216
                  </variable>
217
                  <variable name="dwInstance">
218
                    <type>
219
                      <UDINT />
220
                    </type>
221
                  </variable>
222
                  <variable name="pConnector">
223
                    <type>
224
                      <pointer>
225
                        <baseType>
226
                          <derived name="IoConfigConnector" />
227
                        </baseType>
228
                      </pointer>
229
                    </type>
230
                  </variable>
231
                </inputVars>
232
                <addData>
233
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
234
                    <Attributes>
235
                      <Attribute Name="conditionalshow" Value="" />
236
                    </Attributes>
237
                  </data>
238
                </addData>
239
              </interface>
240
              <body>
241
                <ST>
242
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">Initialize_Count := Initialize_Count + 1;
243
244
m_wModuleType := wModuleType;
245
m_dwInstance := dwInstance;
246
m_Info.wModuleType := wModuleType;
247
248
_MCP3008.Initialize(wModuleType, dwInstance, pConnector);
249
250
Initialize := CmpErrors.Errors.ERR_OK;</xhtml>
251
                </ST>
252
              </body>
253
              <addData />
254
            </Method>
255
          </data>
256
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
257
            <Method name="QueryInterface">
258
              <interface>
259
                <returnType>
260
                  <pointer>
261
                    <baseType>
262
                      <pointer>
263
                        <baseType>
264
                          <BYTE />
265
                        </baseType>
266
                      </pointer>
267
                    </baseType>
268
                  </pointer>
269
                </returnType>
270
                <inputVars>
271
                  <variable name="iid">
272
                    <type>
273
                      <DWORD />
274
                    </type>
275
                    <documentation>
276
                      <xhtml xmlns="http://www.w3.org/1999/xhtml"> InterfaceID </xhtml>
277
                    </documentation>
278
                  </variable>
279
                  <variable name="pResult">
280
                    <type>
281
                      <pointer>
282
                        <baseType>
283
                          <UDINT />
284
                        </baseType>
285
                      </pointer>
286
                    </type>
287
                  </variable>
288
                </inputVars>
289
                <addData>
290
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
291
                    <Attributes>
292
                      <Attribute Name="conditionalshow" Value="" />
293
                    </Attributes>
294
                  </data>
295
                </addData>
296
              </interface>
297
              <body>
298
                <ST>
299
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">QueryInterface_Count := QueryInterface_Count + 1;
300
IF iid = ITFID_ICmpIoDrv THEN
301
    QueryInterface := ADR(_IIoDrv);
302
    AddRef();
303
    IF (pResult &lt;&gt; 0) THEN
304
        pResult^ := Errors.ERR_OK;
305
    END_IF
306
    RETURN; 
307
ELSIF iid = ITFID_ICmpIoDrvParameter THEN
308
    QueryInterface := ADR(_IIoDrvParameter);
309
    AddRef();
310
    IF (pResult &lt;&gt; 0) THEN
311
        pResult^ := Errors.ERR_OK;
312
    END_IF  
313
    RETURN; 
314
ELSE
315
    QueryInterface := SUPER^.QueryInterface(iid, pResult);
316
END_IF
317
</xhtml>
318
                </ST>
319
              </body>
320
              <BuildProperties>
321
                <EnableSystemCall>true</EnableSystemCall>
322
              </BuildProperties>
323
              <addData />
324
            </Method>
325
          </data>
326
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
327
            <Method name="IoDrvGetModuleDiagnosis">
328
              <interface>
329
                <returnType>
330
                  <UDINT />
331
                </returnType>
332
                <inputVars>
333
                  <variable name="pConnector">
334
                    <type>
335
                      <pointer>
336
                        <baseType>
337
                          <derived name="IoConfigConnector" />
338
                        </baseType>
339
                      </pointer>
340
                    </type>
341
                  </variable>
342
                </inputVars>
343
                <addData>
344
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
345
                    <Attributes>
346
                      <Attribute Name="conditionalshow" Value="" />
347
                    </Attributes>
348
                  </data>
349
                </addData>
350
              </interface>
351
              <body>
352
                <ST>
353
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 THEN
354
    //we are called from the background task
355
    _xBackGroundDiagStarted := TRUE;
356
END_IF
357
358
IoDrvGetModuleDiagnosis_Count := IoDrvGetModuleDiagnosis_Count + 1;
359
IoDrvGetModuleDiagnosis := Errors.ERR_NOTIMPLEMENTED;</xhtml>
360
                </ST>
361
              </body>
362
              <BuildProperties>
363
                <EnableSystemCall>true</EnableSystemCall>
364
              </BuildProperties>
365
              <addData />
366
            </Method>
367
          </data>
368
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
369
            <Method name="IoDrvIdentify">
370
              <interface>
371
                <returnType>
372
                  <UDINT />
373
                </returnType>
374
                <inputVars>
375
                  <variable name="pConnector">
376
                    <type>
377
                      <pointer>
378
                        <baseType>
379
                          <derived name="IoConfigConnector" />
380
                        </baseType>
381
                      </pointer>
382
                    </type>
383
                  </variable>
384
                </inputVars>
385
                <addData>
386
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
387
                    <Attributes>
388
                      <Attribute Name="conditionalshow" Value="" />
389
                    </Attributes>
390
                  </data>
391
                </addData>
392
              </interface>
393
              <body>
394
                <ST>
395
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvIdentify_Count := IoDrvIdentify_Count + 1;
396
IoDrvIdentify := Errors.ERR_NOTIMPLEMENTED;</xhtml>
397
                </ST>
398
              </body>
399
              <BuildProperties>
400
                <EnableSystemCall>true</EnableSystemCall>
401
              </BuildProperties>
402
              <addData />
403
            </Method>
404
          </data>
405
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
406
            <Method name="IoDrvReadInputs">
407
              <interface>
408
                <returnType>
409
                  <UDINT />
410
                </returnType>
411
                <inputVars>
412
                  <variable name="pConnectorMapList">
413
                    <type>
414
                      <pointer>
415
                        <baseType>
416
                          <derived name="IoConfigConnectorMap" />
417
                        </baseType>
418
                      </pointer>
419
                    </type>
420
                  </variable>
421
                  <variable name="nCount">
422
                    <type>
423
                      <DINT />
424
                    </type>
425
                  </variable>
426
                </inputVars>
427
                <localVars>
428
                  <variable name="i">
429
                    <type>
430
                      <DINT />
431
                    </type>
432
                  </variable>
433
                  <variable name="j">
434
                    <type>
435
                      <DINT />
436
                    </type>
437
                  </variable>
438
                </localVars>
439
                <addData>
440
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
441
                    <Attributes>
442
                      <Attribute Name="conditionalshow" Value="" />
443
                    </Attributes>
444
                  </data>
445
                </addData>
446
              </interface>
447
              <body>
448
                <ST>
449
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvReadInputs_Count := IoDrvReadInputs_Count + 1;
450
451
IF pConnectorMapList = 0 OR nCount = 0 THEN
452
    IoDrvReadInputs := Errors.ERR_PARAMETER;
453
    RETURN;
454
END_IF
455
456
FOR i:=0 TO nCount - 1 DO
457
    IF (pConnectorMapList[i].dwNumOfChannels = 0) THEN
458
        CONTINUE;
459
    END_IF
460
    FOR j:= 0 TO UDINT_TO_UINT(pConnectorMapList[i].dwNumOfChannels) - 1 DO 
461
        IoMgrCopyInputLE(ADR(pConnectorMapList[i].pChannelMapList[j]), pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific);
462
    END_FOR
463
END_FOR
464
465
IoDrvReadInputs := Errors.ERR_OK;</xhtml>
466
                </ST>
467
              </body>
468
              <BuildProperties>
469
                <EnableSystemCall>true</EnableSystemCall>
470
              </BuildProperties>
471
              <addData />
472
            </Method>
473
          </data>
474
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
475
            <Method name="IoDrvScanModules">
476
              <interface>
477
                <returnType>
478
                  <UDINT />
479
                </returnType>
480
                <inputVars>
481
                  <variable name="pConnector">
482
                    <type>
483
                      <pointer>
484
                        <baseType>
485
                          <derived name="IoConfigConnector" />
486
                        </baseType>
487
                      </pointer>
488
                    </type>
489
                  </variable>
490
                  <variable name="ppConnectorList">
491
                    <type>
492
                      <pointer>
493
                        <baseType>
494
                          <pointer>
495
                            <baseType>
496
                              <derived name="IoConfigConnector" />
497
                            </baseType>
498
                          </pointer>
499
                        </baseType>
500
                      </pointer>
501
                    </type>
502
                  </variable>
503
                  <variable name="pnCount">
504
                    <type>
505
                      <pointer>
506
                        <baseType>
507
                          <DINT />
508
                        </baseType>
509
                      </pointer>
510
                    </type>
511
                  </variable>
512
                </inputVars>
513
                <addData>
514
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
515
                    <Attributes>
516
                      <Attribute Name="conditionalshow" Value="" />
517
                    </Attributes>
518
                  </data>
519
                </addData>
520
              </interface>
521
              <body>
522
                <ST>
523
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvScanModules_Count := IoDrvScanModules_Count + 1;
524
IoDrvScanModules := Errors.ERR_NOTIMPLEMENTED;</xhtml>
525
                </ST>
526
              </body>
527
              <BuildProperties>
528
                <EnableSystemCall>true</EnableSystemCall>
529
              </BuildProperties>
530
              <addData />
531
            </Method>
532
          </data>
533
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
534
            <Method name="IoDrvStartBusCycle">
535
              <interface>
536
                <returnType>
537
                  <UDINT />
538
                </returnType>
539
                <inputVars>
540
                  <variable name="pConnector">
541
                    <type>
542
                      <pointer>
543
                        <baseType>
544
                          <derived name="IoConfigConnector" />
545
                        </baseType>
546
                      </pointer>
547
                    </type>
548
                  </variable>
549
                </inputVars>
550
                <addData>
551
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
552
                    <Attributes>
553
                      <Attribute Name="conditionalshow" Value="" />
554
                    </Attributes>
555
                  </data>
556
                </addData>
557
              </interface>
558
              <body>
559
                <ST>
560
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvStartBusCycle_Count := IoDrvStartBusCycle_Count + 1;
561
562
//if background diagnosis is not active call IoDrvGetModuleDiagnosis; normally it will be called by the runtime if DRVPROP_BACKGROUND_GETDIAG is set
563
IF NOT _xBackGroundDiagStarted THEN
564
    IoDrvGetModuleDiagnosis(m_pConnector); //DRVPROP_BACKGROUND_GETDIAG not set or runtime version &lt; V3.5.1.0
565
END_IF
566
567
//optional: call IoDrvWatchdogTrigger or set driver property DRVPROP_WATCHDOG in UpdateConfiguration
568
IoDrvWatchdogTrigger(pConnector);
569
570
IF NOT _bDeactivated THEN
571
    _MCP3008.AfterReadInputs();
572
    _MCP3008.BeforeWriteOutputs();
573
END_IF
574
575
IoDrvStartBusCycle := Errors.ERR_OK;</xhtml>
576
                </ST>
577
              </body>
578
              <BuildProperties>
579
                <EnableSystemCall>true</EnableSystemCall>
580
              </BuildProperties>
581
              <addData />
582
            </Method>
583
          </data>
584
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
585
            <Method name="IoDrvUpdateConfiguration">
586
              <interface>
587
                <returnType>
588
                  <UDINT />
589
                </returnType>
590
                <inputVars>
591
                  <variable name="pConnectorList">
592
                    <type>
593
                      <pointer>
594
                        <baseType>
595
                          <derived name="IoConfigConnector" />
596
                        </baseType>
597
                      </pointer>
598
                    </type>
599
                  </variable>
600
                  <variable name="nCount">
601
                    <type>
602
                      <DINT />
603
                    </type>
604
                  </variable>
605
                </inputVars>
606
                <localVars>
607
                  <variable name="pParameter">
608
                    <type>
609
                      <pointer>
610
                        <baseType>
611
                          <derived name="IoConfigParameter" />
612
                        </baseType>
613
                      </pointer>
614
                    </type>
615
                  </variable>
616
                  <variable name="pChild">
617
                    <type>
618
                      <pointer>
619
                        <baseType>
620
                          <derived name="IoConfigConnector" />
621
                        </baseType>
622
                      </pointer>
623
                    </type>
624
                  </variable>
625
                  <variable name="pstConnectorVendorName">
626
                    <type>
627
                      <pointer>
628
                        <baseType>
629
                          <string />
630
                        </baseType>
631
                      </pointer>
632
                    </type>
633
                  </variable>
634
                  <variable name="pstConnectorDeviceName">
635
                    <type>
636
                      <pointer>
637
                        <baseType>
638
                          <string />
639
                        </baseType>
640
                      </pointer>
641
                    </type>
642
                  </variable>
643
                  <variable name="Result">
644
                    <type>
645
                      <derived name="RTS_IEC_RESULT" />
646
                    </type>
647
                  </variable>
648
                  <variable name="i">
649
                    <type>
650
                      <INT />
651
                    </type>
652
                  </variable>
653
                  <variable name="bySetting">
654
                    <type>
655
                      <BYTE />
656
                    </type>
657
                  </variable>
658
                </localVars>
659
                <addData>
660
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
661
                    <Attributes>
662
                      <Attribute Name="conditionalshow" Value="" />
663
                    </Attributes>
664
                  </data>
665
                </addData>
666
              </interface>
667
              <body>
668
                <ST>
669
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvUpdateConfiguration_Count := IoDrvUpdateConfiguration_Count + 1;
670
IoDrvUpdateConfiguration := Errors.ERR_OK;
671
672
IF (pConnectorList = 0) THEN
673
    RETURN;
674
END_IF
675
676
m_pConnector := IoMgrConfigGetConnector(pConnectorList, ADR(nCount), m_wModuleType, m_dwInstance);
677
678
IF m_pConnector = 0 THEN
679
    IoDrvUpdateConfiguration := ERRORS.ERR_PARAMETER;
680
    RETURN;
681
END_IF
682
683
//check if device is enabled in the device tree
684
IF (m_pConnector^.dwFlags AND ConnectorFlags.CF_ENABLE) = 0 THEN
685
    _bDeactivated := TRUE;
686
    IoDrvUpdateConfiguration := Errors.ERR_OK;
687
    RETURN;
688
END_IF
689
690
IF m_pConnector^.hIoDrv = 0 THEN
691
    m_pConnector^.hIoDrv := m_hInterface;
692
    m_pConnector^.pFather^.hIoDrv := m_hInterface;
693
    
694
    {IF defined (pou:IoMgrConfigSetDiagnosis)}
695
    IoMgrConfigSetDiagnosis(m_pConnector,
696
                            ConnectorFlags.CF_DRIVER_AVAILABLE OR
697
                            ConnectorFlags.CF_CONNECTOR_FOUND OR
698
                            ConnectorFlags.CF_CONNECTOR_CONFIGURED OR
699
                            ConnectorFlags.CF_CONNECTOR_ACTIVE);
700
    {END_IF}
701
    
702
    {IF defined (pou:IoMgrConfigSetDiagnosis)}
703
    IoMgrConfigSetDiagnosis(m_pConnector^.pFather,
704
                            ConnectorFlags.CF_DRIVER_AVAILABLE OR
705
                            ConnectorFlags.CF_CONNECTOR_FOUND OR
706
                            ConnectorFlags.CF_CONNECTOR_CONFIGURED OR
707
                            ConnectorFlags.CF_CONNECTOR_ACTIVE);
708
    {END_IF}
709
710
    {IF defined (pou:IoMgrSetDriverProperties)}         
711
        IoMgrSetDriverProperties(m_hInterface, DRVPROP_CONSISTENCY OR DRVPROP_BACKGROUND_GETDIAG);
712
        //Note: background diagnosis property flag is optional (supported with 3.5.1.0 runtime)
713
    {END_IF}                                        
714
    
715
    //Setup I/O area
716
    FOR i:=0 TO 7 DO
717
        pParameter := IoMgrConfigGetParameter(m_pConnector, 1000 + i);
718
        IF (pParameter &lt;&gt; 0) THEN
719
            pParameter^.dwDriverSpecific := ADR(_MCP3008.auiValue[i]);
720
        END_IF
721
    END_FOR
722
END_IF</xhtml>
723
                </ST>
724
              </body>
725
              <BuildProperties>
726
                <EnableSystemCall>true</EnableSystemCall>
727
              </BuildProperties>
728
              <addData />
729
            </Method>
730
          </data>
731
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
732
            <Method name="IoDrvUpdateMapping">
733
              <interface>
734
                <returnType>
735
                  <UDINT />
736
                </returnType>
737
                <inputVars>
738
                  <variable name="pTaskMapList">
739
                    <type>
740
                      <pointer>
741
                        <baseType>
742
                          <derived name="IoConfigTaskMap" />
743
                        </baseType>
744
                      </pointer>
745
                    </type>
746
                  </variable>
747
                  <variable name="nCount">
748
                    <type>
749
                      <DINT />
750
                    </type>
751
                  </variable>
752
                </inputVars>
753
                <addData>
754
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
755
                    <Attributes>
756
                      <Attribute Name="conditionalshow" Value="" />
757
                    </Attributes>
758
                  </data>
759
                </addData>
760
              </interface>
761
              <body>
762
                <ST>
763
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvUpdateMapping_Count := IoDrvUpdateMapping_Count + 1;
764
765
IF (pTaskMapList = 0) THEN
766
    IoDrvUpdateMapping := Errors.ERR_PARAMETER;
767
    RETURN;
768
END_IF
769
770
IoDrvUpdateMapping := Errors.ERR_OK;</xhtml>
771
                </ST>
772
              </body>
773
              <BuildProperties>
774
                <EnableSystemCall>true</EnableSystemCall>
775
              </BuildProperties>
776
              <addData />
777
            </Method>
778
          </data>
779
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
780
            <Method name="IoDrvWatchdogTrigger">
781
              <interface>
782
                <returnType>
783
                  <UDINT />
784
                </returnType>
785
                <inputVars>
786
                  <variable name="pConnector">
787
                    <type>
788
                      <pointer>
789
                        <baseType>
790
                          <derived name="IoConfigConnector" />
791
                        </baseType>
792
                      </pointer>
793
                    </type>
794
                  </variable>
795
                </inputVars>
796
                <addData>
797
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
798
                    <Attributes>
799
                      <Attribute Name="conditionalshow" Value="" />
800
                    </Attributes>
801
                  </data>
802
                </addData>
803
              </interface>
804
              <body>
805
                <ST>
806
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvWatchdogTrigger_Count := IoDrvWatchdogTrigger_Count + 1;
807
IoDrvWatchdogTrigger := Errors.ERR_OK;</xhtml>
808
                </ST>
809
              </body>
810
              <BuildProperties>
811
                <EnableSystemCall>true</EnableSystemCall>
812
              </BuildProperties>
813
              <addData />
814
            </Method>
815
          </data>
816
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
817
            <Method name="IoDrvWriteOutputs">
818
              <interface>
819
                <returnType>
820
                  <UDINT />
821
                </returnType>
822
                <inputVars>
823
                  <variable name="pConnectorMapList">
824
                    <type>
825
                      <pointer>
826
                        <baseType>
827
                          <derived name="IoConfigConnectorMap" />
828
                        </baseType>
829
                      </pointer>
830
                    </type>
831
                  </variable>
832
                  <variable name="nCount">
833
                    <type>
834
                      <DINT />
835
                    </type>
836
                  </variable>
837
                </inputVars>
838
                <localVars>
839
                  <variable name="i">
840
                    <type>
841
                      <DINT />
842
                    </type>
843
                  </variable>
844
                  <variable name="j">
845
                    <type>
846
                      <DINT />
847
                    </type>
848
                  </variable>
849
                  <variable name="k">
850
                    <type>
851
                      <UINT />
852
                    </type>
853
                  </variable>
854
                  <variable name="wSize">
855
                    <type>
856
                      <WORD />
857
                    </type>
858
                  </variable>
859
                  <variable name="pbyIecAddress">
860
                    <type>
861
                      <pointer>
862
                        <baseType>
863
                          <BYTE />
864
                        </baseType>
865
                      </pointer>
866
                    </type>
867
                  </variable>
868
                  <variable name="bySrcValue">
869
                    <type>
870
                      <BYTE />
871
                    </type>
872
                  </variable>
873
                  <variable name="wSrcIndex">
874
                    <type>
875
                      <WORD />
876
                    </type>
877
                  </variable>
878
                  <variable name="bySrcMask">
879
                    <type>
880
                      <BYTE />
881
                    </type>
882
                  </variable>
883
                  <variable name="wDestIndex">
884
                    <type>
885
                      <WORD />
886
                    </type>
887
                  </variable>
888
                  <variable name="pdw">
889
                    <type>
890
                      <pointer>
891
                        <baseType>
892
                          <DWORD />
893
                        </baseType>
894
                      </pointer>
895
                    </type>
896
                  </variable>
897
                  <variable name="pw">
898
                    <type>
899
                      <pointer>
900
                        <baseType>
901
                          <WORD />
902
                        </baseType>
903
                      </pointer>
904
                    </type>
905
                  </variable>
906
                </localVars>
907
                <addData>
908
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
909
                    <Attributes>
910
                      <Attribute Name="conditionalshow" Value="" />
911
                    </Attributes>
912
                  </data>
913
                </addData>
914
              </interface>
915
              <body>
916
                <ST>
917
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvWriteOutputs_Count := IoDrvWriteOutputs_Count + 1;
918
IoDrvWriteOutputs := Errors.ERR_OK;</xhtml>
919
                </ST>
920
              </body>
921
              <BuildProperties>
922
                <EnableSystemCall>true</EnableSystemCall>
923
              </BuildProperties>
924
              <addData />
925
            </Method>
926
          </data>
927
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
928
            <Method name="IoDrvReadParameter">
929
              <interface>
930
                <returnType>
931
                  <UDINT />
932
                </returnType>
933
                <inputVars>
934
                  <variable name="pConnector">
935
                    <type>
936
                      <pointer>
937
                        <baseType>
938
                          <derived name="IoConfigConnector" />
939
                        </baseType>
940
                      </pointer>
941
                    </type>
942
                  </variable>
943
                  <variable name="pParameter">
944
                    <type>
945
                      <pointer>
946
                        <baseType>
947
                          <derived name="IoConfigParameter" />
948
                        </baseType>
949
                      </pointer>
950
                    </type>
951
                  </variable>
952
                  <variable name="pData">
953
                    <type>
954
                      <pointer>
955
                        <baseType>
956
                          <BYTE />
957
                        </baseType>
958
                      </pointer>
959
                    </type>
960
                  </variable>
961
                  <variable name="dwBitSize">
962
                    <type>
963
                      <DWORD />
964
                    </type>
965
                  </variable>
966
                  <variable name="dwBitOffset">
967
                    <type>
968
                      <DWORD />
969
                    </type>
970
                  </variable>
971
                </inputVars>
972
                <addData>
973
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
974
                    <Attributes>
975
                      <Attribute Name="conditionalshow" Value="" />
976
                    </Attributes>
977
                  </data>
978
                </addData>
979
              </interface>
980
              <body>
981
                <ST>
982
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF    pConnector = 0 OR pParameter = 0 OR pData = 0 THEN
983
    IoDrvReadParameter := Errors.ERR_PARAMETER;
984
    RETURN; 
985
END_IF
986
987
// All standard parameters of our device are handled by the IO-manager!
988
IoDrvReadParameter := Errors.ERR_FAILED;
989
</xhtml>
990
                </ST>
991
              </body>
992
              <BuildProperties>
993
                <EnableSystemCall>true</EnableSystemCall>
994
              </BuildProperties>
995
              <addData />
996
            </Method>
997
          </data>
998
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
999
            <Method name="IoDrvWriteParameter">
1000
              <interface>
1001
                <returnType>
1002
                  <UDINT />
1003
                </returnType>
1004
                <inputVars>
1005
                  <variable name="pConnector">
1006
                    <type>
1007
                      <pointer>
1008
                        <baseType>
1009
                          <derived name="IoConfigConnector" />
1010
                        </baseType>
1011
                      </pointer>
1012
                    </type>
1013
                  </variable>
1014
                  <variable name="pParameter">
1015
                    <type>
1016
                      <pointer>
1017
                        <baseType>
1018
                          <derived name="IoConfigParameter" />
1019
                        </baseType>
1020
                      </pointer>
1021
                    </type>
1022
                  </variable>
1023
                  <variable name="pData">
1024
                    <type>
1025
                      <pointer>
1026
                        <baseType>
1027
                          <BYTE />
1028
                        </baseType>
1029
                      </pointer>
1030
                    </type>
1031
                  </variable>
1032
                  <variable name="dwBitSize">
1033
                    <type>
1034
                      <DWORD />
1035
                    </type>
1036
                  </variable>
1037
                  <variable name="dwBitOffset">
1038
                    <type>
1039
                      <DWORD />
1040
                    </type>
1041
                  </variable>
1042
                </inputVars>
1043
                <localVars>
1044
                  <variable name="pParam">
1045
                    <type>
1046
                      <pointer>
1047
                        <baseType>
1048
                          <derived name="IoConfigParameter" />
1049
                        </baseType>
1050
                      </pointer>
1051
                    </type>
1052
                  </variable>
1053
                  <variable name="pstDiagString">
1054
                    <type>
1055
                      <pointer>
1056
                        <baseType>
1057
                          <string />
1058
                        </baseType>
1059
                      </pointer>
1060
                    </type>
1061
                  </variable>
1062
                </localVars>
1063
                <addData>
1064
                  <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation">
1065
                    <Attributes>
1066
                      <Attribute Name="conditionalshow" Value="" />
1067
                    </Attributes>
1068
                  </data>
1069
                </addData>
1070
              </interface>
1071
              <body>
1072
                <ST>
1073
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 OR pParameter = 0 OR pData = 0 THEN
1074
    IoDrvWriteParameter := Errors.ERR_PARAMETER;
1075
    RETURN; 
1076
END_IF
1077
1078
IoDrvWriteParameter := Errors.ERR_FAILED;</xhtml>
1079
                </ST>
1080
              </body>
1081
              <BuildProperties>
1082
                <EnableSystemCall>true</EnableSystemCall>
1083
              </BuildProperties>
1084
              <addData />
1085
            </Method>
1086
          </data>
1087
        </addData>
1088
      </pou>
1089
      <pou name="MCP3008" pouType="functionBlock">
1090
        <interface>
1091
          <outputVars>
1092
            <variable name="auiValue">
1093
              <type>
1094
                <array>
1095
                  <dimension lower="0" upper="7" />
1096
                  <baseType>
1097
                    <UINT />
1098
                  </baseType>
1099
                </array>
1100
              </type>
1101
            </variable>
1102
          </outputVars>
1103
          <addData>
1104
            <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation">
1105
              <Inheritance>
1106
                <Extends>spi</Extends>
1107
              </Inheritance>
1108
            </data>
1109
          </addData>
1110
        </interface>
1111
        <body>
1112
          <ST>
1113
            <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^();
1114
1115
CASE _iState OF
1116
0:
1117
    IF SUPER^.init() THEN
1118
        _iState := 1;
1119
    END_IF  
1120
1:
1121
    _iState := 10;
1122
END_CASE
1123
</xhtml>
1124
          </ST>
1125
        </body>
1126
        <addData>
1127
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1128
            <Method name="AfterReadInputs">
1129
              <interface>
1130
                <returnType>
1131
                  <INT />
1132
                </returnType>
1133
                <localVars>
1134
                  <variable name="aby">
1135
                    <type>
1136
                      <array>
1137
                        <dimension lower="0" upper="2" />
1138
                        <baseType>
1139
                          <BYTE />
1140
                        </baseType>
1141
                      </array>
1142
                    </type>
1143
                  </variable>
1144
                  <variable name="usiChannel">
1145
                    <type>
1146
                      <USINT />
1147
                    </type>
1148
                  </variable>
1149
                  <variable name="ui">
1150
                    <type>
1151
                      <UINT />
1152
                    </type>
1153
                  </variable>
1154
                </localVars>
1155
              </interface>
1156
              <body>
1157
                <ST>
1158
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs();
1159
1160
IF _iState = 10 THEN
1161
1162
    FOR usiChannel := 0 TO 7 DO
1163
        aby[0] := 1;
1164
        aby[1] := 16#80 + SHL(usiChannel AND 7, 4);
1165
        aby[2] := 0;    
1166
        
1167
        IF NOT transfer(pabyTxBuffer:=ADR(aby) , pabyRxBuffer:=ADR(aby) , udiLen:=3 , uiDelayus:=0) THEN
1168
            _iState := 1000;
1169
        END_IF
1170
1171
        ui := aby[2];
1172
        ui := ui + (BYTE_TO_UINT(aby[1]) AND 2#11) * 256;
1173
        auiValue[usiChannel] := ui;
1174
    END_FOR     
1175
END_IF
1176
</xhtml>
1177
                </ST>
1178
              </body>
1179
              <addData />
1180
            </Method>
1181
          </data>
1182
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1183
            <Method name="BeforeWriteOutputs">
1184
              <interface>
1185
                <returnType>
1186
                  <INT />
1187
                </returnType>
1188
                <localVars>
1189
                  <variable name="i">
1190
                    <type>
1191
                      <USINT />
1192
                    </type>
1193
                  </variable>
1194
                </localVars>
1195
              </interface>
1196
              <body>
1197
                <ST>
1198
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.BeforeWriteOutputs();
1199
</xhtml>
1200
                </ST>
1201
              </body>
1202
              <addData />
1203
            </Method>
1204
          </data>
1205
          <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation">
1206
            <Method name="Initialize">
1207
              <interface>
1208
                <returnType>
1209
                  <UDINT />
1210
                </returnType>
1211
                <inputVars>
1212
                  <variable name="wModuleType">
1213
                    <type>
1214
                      <UINT />
1215
                    </type>
1216
                  </variable>
1217
                  <variable name="dwInstance">
1218
                    <type>
1219
                      <UDINT />
1220
                    </type>
1221
                  </variable>
1222
                  <variable name="pConnector">
1223
                    <type>
1224
                      <pointer>
1225
                        <baseType>
1226
                          <derived name="IoConfigConnector" />
1227
                        </baseType>
1228
                      </pointer>
1229
                    </type>
1230
                  </variable>
1231
                </inputVars>
1232
                <localVars>
1233
                  <variable name="pParam">
1234
                    <type>
1235
                      <pointer>
1236
                        <baseType>
1237
                          <derived name="IoConfigParameter" />
1238
                        </baseType>
1239
                      </pointer>
1240
                    </type>
1241
                  </variable>
1242
                  <variable name="udiResult">
1243
                    <type>
1244
                      <UDINT />
1245
                    </type>
1246
                  </variable>
1247
                </localVars>
1248
              </interface>
1249
              <body>
1250
                <ST>
1251
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.Initialize(wModuleType, dwInstance, pConnector);
1252
1253
1254
</xhtml>
1255
                </ST>
1256
              </body>
1257
              <addData />
1258
            </Method>
1259
          </data>
1260
        </addData>
1261
      </pou>
1262
    </pous>
1263
  </types>
1264
  <instances>
1265
    <configurations />
1266
  </instances>
1267
  <addData>
1268
    <data name="http://www.3s-software.com/plcopenxml/libraries" handleUnknown="implementation">
1269
      <Libraries>
1270
        <Library Name="#CAA Types" Namespace="CAA" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="CAA Types Extern, * (CAA Technical Workgroup)" />
1271
        <Library Name="#Standard" Namespace="Standard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Standard, * (System)" />
1272
        <Library Name="#IoStandard" Namespace="IoStandard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoStandard, * (System)" />
1273
        <Library Name="#IoDrvBase" Namespace="IoDrvBase" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoDrvBase, * (System)" />
1274
        <Library Name="IoDriver Parameter Interfaces, * (System)" Namespace="IIoDrvParameter" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
1275
        <Library Name="IoDriver Interfaces, * (System)" Namespace="IIoDrv" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
1276
        <Library Name="CmpErrors2 Interfaces, * (System)" Namespace="CmpErrors" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
1277
        <Library Name="#Raspberry Pi Peripherals" Namespace="RasPi" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Raspberry Pi Peripherals, * (3S - Smart Software Solutions GmbH)" />
1278
        <Library Name="SysTypes2 Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" />
1279
        <addData />
1280
      </Libraries>
1281
    </data>
1282
  </addData>
1283
</project>