--- a +++ b/trunk/mcp3008/Libraries/SPI_MCP3008.library.xml @@ -0,0 +1,1283 @@ +<?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-16T12:59:41.4730461" /> + <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"> + <Comment>Library containing device support of MCP3008. The original author was 3S. Now it is maintained as open source on CODESYS Forge.</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">Open Source</property> + <property name="DefaultNamespace" type="string">MCP3008</property> + <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> + <property name="Placeholder" type="string">SPI MCP3008</property> + <property name="Project" type="string">SPI_MCP3008</property> + <property name="Released" type="boolean">false</property> + <property name="Title" type="string">Linux SPI MCP3008</property> + <property name="Version" type="version">1.0.0.0</property> + <property name="library-category-list" type="library-category-list">Target</property> + </ProjectInformation> + </data> + </addData> + </contentHeader> + <types> + <dataTypes /> + <pous> + <pou name="IoDrvMCP3008" pouType="functionBlock"> + <interface> + <localVars> + <variable name="_IIoDrv"> + <type> + <derived name="ICmpIoDrv" /> + </type> + </variable> + <variable name="_IIoDrvParameter"> + <type> + <derived name="ICmpIoDrvParameter" /> + </type> + </variable> + <variable name="_MCP3008"> + <type> + <derived name="MCP3008" /> + </type> + </variable> + <variable name="_dwInUse"> + <type> + <DWORD /> + </type> + </variable> + <variable name="_xBackGroundDiagStarted"> + <type> + <BOOL /> + </type> + </variable> + <variable name="_bDeactivated"> + <type> + <BOOL /> + </type> + </variable> + </localVars> + <localVars constant="true"> + <variable name="CLASSID_CCmpIoDrvTemplate"> + <type> + <DWORD /> + </type> + <initialValue> + <simpleValue value="16#FF03" /> + </initialValue> + <documentation> + <xhtml xmlns="http://www.w3.org/1999/xhtml"> TODO</xhtml> + </documentation> + </variable> + </localVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> + <Inheritance> + <Extends>IoDrvBase</Extends> + <Implements>ICmpIoDrvParameter</Implements> + </Inheritance> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml" /> + </ST> + </body> + <addData> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="FB_Exit"> + <interface> + <returnType> + <BOOL /> + </returnType> + <inputVars> + <variable name="bInCopyCode"> + <type> + <BOOL /> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Exit_Count := FB_Exit_Count + 1; +FB_Exit := TRUE;</xhtml> + </ST> + </body> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="FB_Init"> + <interface> + <returnType> + <BOOL /> + </returnType> + <inputVars> + <variable name="bInitRetains"> + <type> + <BOOL /> + </type> + </variable> + <variable name="bInCopyCode"> + <type> + <BOOL /> + </type> + </variable> + </inputVars> + <localVars> + <variable name="Result"> + <type> + <UDINT /> + </type> + </variable> + </localVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Init_Count := FB_Init_Count + 1; + +m_Info.szDriverName := 'IoDrvMCP3008'; +m_Info.szVendorName := 'Open Source'; +m_info.szDeviceName := 'MCP3008'; +m_Info.wModuleType := 8000; + +_IIoDrv := THIS^; +_IIoDrvParameter := THIS^; + +m_IBaseItf := THIS^; +m_hInterface := IoMgrRegisterInstance2(dwClassId:=CLASSID_CCmpIoDrvTemplate, pItf:=m_IBaseItf, pResult:=ADR(Result)); +FB_Init := TRUE;</xhtml> + </ST> + </body> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="FB_Reinit"> + <interface> + <returnType> + <BOOL /> + </returnType> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">FB_Reinit_Count := FB_Reinit_Count + 1; +FB_Reinit := TRUE;</xhtml> + </ST> + </body> + <addData /> + </Method> + </data> + <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> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">Initialize_Count := Initialize_Count + 1; + +m_wModuleType := wModuleType; +m_dwInstance := dwInstance; +m_Info.wModuleType := wModuleType; + +_MCP3008.Initialize(wModuleType, dwInstance, pConnector); + +Initialize := CmpErrors.Errors.ERR_OK;</xhtml> + </ST> + </body> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="QueryInterface"> + <interface> + <returnType> + <pointer> + <baseType> + <pointer> + <baseType> + <BYTE /> + </baseType> + </pointer> + </baseType> + </pointer> + </returnType> + <inputVars> + <variable name="iid"> + <type> + <DWORD /> + </type> + <documentation> + <xhtml xmlns="http://www.w3.org/1999/xhtml"> InterfaceID </xhtml> + </documentation> + </variable> + <variable name="pResult"> + <type> + <pointer> + <baseType> + <UDINT /> + </baseType> + </pointer> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">QueryInterface_Count := QueryInterface_Count + 1; +IF iid = ITFID_ICmpIoDrv THEN + QueryInterface := ADR(_IIoDrv); + AddRef(); + IF (pResult <> 0) THEN + pResult^ := Errors.ERR_OK; + END_IF + RETURN; +ELSIF iid = ITFID_ICmpIoDrvParameter THEN + QueryInterface := ADR(_IIoDrvParameter); + AddRef(); + IF (pResult <> 0) THEN + pResult^ := Errors.ERR_OK; + END_IF + RETURN; +ELSE + QueryInterface := SUPER^.QueryInterface(iid, pResult); +END_IF +</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvGetModuleDiagnosis"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 THEN + //we are called from the background task + _xBackGroundDiagStarted := TRUE; +END_IF + +IoDrvGetModuleDiagnosis_Count := IoDrvGetModuleDiagnosis_Count + 1; +IoDrvGetModuleDiagnosis := Errors.ERR_NOTIMPLEMENTED;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvIdentify"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvIdentify_Count := IoDrvIdentify_Count + 1; +IoDrvIdentify := Errors.ERR_NOTIMPLEMENTED;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvReadInputs"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnectorMapList"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnectorMap" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="nCount"> + <type> + <DINT /> + </type> + </variable> + </inputVars> + <localVars> + <variable name="i"> + <type> + <DINT /> + </type> + </variable> + <variable name="j"> + <type> + <DINT /> + </type> + </variable> + </localVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvReadInputs_Count := IoDrvReadInputs_Count + 1; + +IF pConnectorMapList = 0 OR nCount = 0 THEN + IoDrvReadInputs := Errors.ERR_PARAMETER; + RETURN; +END_IF + +FOR i:=0 TO nCount - 1 DO + IF (pConnectorMapList[i].dwNumOfChannels = 0) THEN + CONTINUE; + END_IF + FOR j:= 0 TO UDINT_TO_UINT(pConnectorMapList[i].dwNumOfChannels) - 1 DO + IoMgrCopyInputLE(ADR(pConnectorMapList[i].pChannelMapList[j]), pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific); + END_FOR +END_FOR + +IoDrvReadInputs := Errors.ERR_OK;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvScanModules"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="ppConnectorList"> + <type> + <pointer> + <baseType> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </baseType> + </pointer> + </type> + </variable> + <variable name="pnCount"> + <type> + <pointer> + <baseType> + <DINT /> + </baseType> + </pointer> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvScanModules_Count := IoDrvScanModules_Count + 1; +IoDrvScanModules := Errors.ERR_NOTIMPLEMENTED;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvStartBusCycle"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvStartBusCycle_Count := IoDrvStartBusCycle_Count + 1; + +//if background diagnosis is not active call IoDrvGetModuleDiagnosis; normally it will be called by the runtime if DRVPROP_BACKGROUND_GETDIAG is set +IF NOT _xBackGroundDiagStarted THEN + IoDrvGetModuleDiagnosis(m_pConnector); //DRVPROP_BACKGROUND_GETDIAG not set or runtime version < V3.5.1.0 +END_IF + +//optional: call IoDrvWatchdogTrigger or set driver property DRVPROP_WATCHDOG in UpdateConfiguration +IoDrvWatchdogTrigger(pConnector); + +IF NOT _bDeactivated THEN + _MCP3008.AfterReadInputs(); + _MCP3008.BeforeWriteOutputs(); +END_IF + +IoDrvStartBusCycle := Errors.ERR_OK;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvUpdateConfiguration"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnectorList"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="nCount"> + <type> + <DINT /> + </type> + </variable> + </inputVars> + <localVars> + <variable name="pParameter"> + <type> + <pointer> + <baseType> + <derived name="IoConfigParameter" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pChild"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pstConnectorVendorName"> + <type> + <pointer> + <baseType> + <string /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pstConnectorDeviceName"> + <type> + <pointer> + <baseType> + <string /> + </baseType> + </pointer> + </type> + </variable> + <variable name="Result"> + <type> + <derived name="RTS_IEC_RESULT" /> + </type> + </variable> + <variable name="i"> + <type> + <INT /> + </type> + </variable> + <variable name="bySetting"> + <type> + <BYTE /> + </type> + </variable> + </localVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvUpdateConfiguration_Count := IoDrvUpdateConfiguration_Count + 1; +IoDrvUpdateConfiguration := Errors.ERR_OK; + +IF (pConnectorList = 0) THEN + RETURN; +END_IF + +m_pConnector := IoMgrConfigGetConnector(pConnectorList, ADR(nCount), m_wModuleType, m_dwInstance); + +IF m_pConnector = 0 THEN + IoDrvUpdateConfiguration := ERRORS.ERR_PARAMETER; + RETURN; +END_IF + +//check if device is enabled in the device tree +IF (m_pConnector^.dwFlags AND ConnectorFlags.CF_ENABLE) = 0 THEN + _bDeactivated := TRUE; + IoDrvUpdateConfiguration := Errors.ERR_OK; + RETURN; +END_IF + +IF m_pConnector^.hIoDrv = 0 THEN + m_pConnector^.hIoDrv := m_hInterface; + m_pConnector^.pFather^.hIoDrv := m_hInterface; + + {IF defined (pou:IoMgrConfigSetDiagnosis)} + IoMgrConfigSetDiagnosis(m_pConnector, + ConnectorFlags.CF_DRIVER_AVAILABLE OR + ConnectorFlags.CF_CONNECTOR_FOUND OR + ConnectorFlags.CF_CONNECTOR_CONFIGURED OR + ConnectorFlags.CF_CONNECTOR_ACTIVE); + {END_IF} + + {IF defined (pou:IoMgrConfigSetDiagnosis)} + IoMgrConfigSetDiagnosis(m_pConnector^.pFather, + ConnectorFlags.CF_DRIVER_AVAILABLE OR + ConnectorFlags.CF_CONNECTOR_FOUND OR + ConnectorFlags.CF_CONNECTOR_CONFIGURED OR + ConnectorFlags.CF_CONNECTOR_ACTIVE); + {END_IF} + + {IF defined (pou:IoMgrSetDriverProperties)} + IoMgrSetDriverProperties(m_hInterface, DRVPROP_CONSISTENCY OR DRVPROP_BACKGROUND_GETDIAG); + //Note: background diagnosis property flag is optional (supported with 3.5.1.0 runtime) + {END_IF} + + //Setup I/O area + FOR i:=0 TO 7 DO + pParameter := IoMgrConfigGetParameter(m_pConnector, 1000 + i); + IF (pParameter <> 0) THEN + pParameter^.dwDriverSpecific := ADR(_MCP3008.auiValue[i]); + END_IF + END_FOR +END_IF</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvUpdateMapping"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pTaskMapList"> + <type> + <pointer> + <baseType> + <derived name="IoConfigTaskMap" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="nCount"> + <type> + <DINT /> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvUpdateMapping_Count := IoDrvUpdateMapping_Count + 1; + +IF (pTaskMapList = 0) THEN + IoDrvUpdateMapping := Errors.ERR_PARAMETER; + RETURN; +END_IF + +IoDrvUpdateMapping := Errors.ERR_OK;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvWatchdogTrigger"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvWatchdogTrigger_Count := IoDrvWatchdogTrigger_Count + 1; +IoDrvWatchdogTrigger := Errors.ERR_OK;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvWriteOutputs"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnectorMapList"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnectorMap" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="nCount"> + <type> + <DINT /> + </type> + </variable> + </inputVars> + <localVars> + <variable name="i"> + <type> + <DINT /> + </type> + </variable> + <variable name="j"> + <type> + <DINT /> + </type> + </variable> + <variable name="k"> + <type> + <UINT /> + </type> + </variable> + <variable name="wSize"> + <type> + <WORD /> + </type> + </variable> + <variable name="pbyIecAddress"> + <type> + <pointer> + <baseType> + <BYTE /> + </baseType> + </pointer> + </type> + </variable> + <variable name="bySrcValue"> + <type> + <BYTE /> + </type> + </variable> + <variable name="wSrcIndex"> + <type> + <WORD /> + </type> + </variable> + <variable name="bySrcMask"> + <type> + <BYTE /> + </type> + </variable> + <variable name="wDestIndex"> + <type> + <WORD /> + </type> + </variable> + <variable name="pdw"> + <type> + <pointer> + <baseType> + <DWORD /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pw"> + <type> + <pointer> + <baseType> + <WORD /> + </baseType> + </pointer> + </type> + </variable> + </localVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IoDrvWriteOutputs_Count := IoDrvWriteOutputs_Count + 1; +IoDrvWriteOutputs := Errors.ERR_OK;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvReadParameter"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pParameter"> + <type> + <pointer> + <baseType> + <derived name="IoConfigParameter" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pData"> + <type> + <pointer> + <baseType> + <BYTE /> + </baseType> + </pointer> + </type> + </variable> + <variable name="dwBitSize"> + <type> + <DWORD /> + </type> + </variable> + <variable name="dwBitOffset"> + <type> + <DWORD /> + </type> + </variable> + </inputVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 OR pParameter = 0 OR pData = 0 THEN + IoDrvReadParameter := Errors.ERR_PARAMETER; + RETURN; +END_IF + +// All standard parameters of our device are handled by the IO-manager! +IoDrvReadParameter := Errors.ERR_FAILED; +</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> + <Method name="IoDrvWriteParameter"> + <interface> + <returnType> + <UDINT /> + </returnType> + <inputVars> + <variable name="pConnector"> + <type> + <pointer> + <baseType> + <derived name="IoConfigConnector" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pParameter"> + <type> + <pointer> + <baseType> + <derived name="IoConfigParameter" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pData"> + <type> + <pointer> + <baseType> + <BYTE /> + </baseType> + </pointer> + </type> + </variable> + <variable name="dwBitSize"> + <type> + <DWORD /> + </type> + </variable> + <variable name="dwBitOffset"> + <type> + <DWORD /> + </type> + </variable> + </inputVars> + <localVars> + <variable name="pParam"> + <type> + <pointer> + <baseType> + <derived name="IoConfigParameter" /> + </baseType> + </pointer> + </type> + </variable> + <variable name="pstDiagString"> + <type> + <pointer> + <baseType> + <string /> + </baseType> + </pointer> + </type> + </variable> + </localVars> + <addData> + <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> + <Attributes> + <Attribute Name="conditionalshow" Value="" /> + </Attributes> + </data> + </addData> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">IF pConnector = 0 OR pParameter = 0 OR pData = 0 THEN + IoDrvWriteParameter := Errors.ERR_PARAMETER; + RETURN; +END_IF + +IoDrvWriteParameter := Errors.ERR_FAILED;</xhtml> + </ST> + </body> + <BuildProperties> + <EnableSystemCall>true</EnableSystemCall> + </BuildProperties> + <addData /> + </Method> + </data> + </addData> + </pou> + <pou name="MCP3008" pouType="functionBlock"> + <interface> + <outputVars> + <variable name="auiValue"> + <type> + <array> + <dimension lower="0" upper="7" /> + <baseType> + <UINT /> + </baseType> + </array> + </type> + </variable> + </outputVars> + <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: + _iState := 10; +END_CASE +</xhtml> + </ST> + </body> + <addData> + <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="2" /> + <baseType> + <BYTE /> + </baseType> + </array> + </type> + </variable> + <variable name="usiChannel"> + <type> + <USINT /> + </type> + </variable> + <variable name="ui"> + <type> + <UINT /> + </type> + </variable> + </localVars> + </interface> + <body> + <ST> + <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs(); + +IF _iState = 10 THEN + + FOR usiChannel := 0 TO 7 DO + aby[0] := 1; + aby[1] := 16#80 + SHL(usiChannel AND 7, 4); + aby[2] := 0; + + IF NOT transfer(pabyTxBuffer:=ADR(aby) , pabyRxBuffer:=ADR(aby) , udiLen:=3 , uiDelayus:=0) THEN + _iState := 1000; + END_IF + + ui := aby[2]; + ui := ui + (BYTE_TO_UINT(aby[1]) AND 2#11) * 256; + auiValue[usiChannel] := ui; + END_FOR +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(); +</xhtml> + </ST> + </body> + <addData /> + </Method> + </data> + <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); + + +</xhtml> + </ST> + </body> + <addData /> + </Method> + </data> + </addData> + </pou> + </pous> + </types> + <instances> + <configurations /> + </instances> + <addData> + <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="#IoStandard" Namespace="IoStandard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoStandard, * (System)" /> + <Library Name="#IoDrvBase" Namespace="IoDrvBase" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoDrvBase, * (System)" /> + <Library Name="IoDriver Parameter Interfaces, * (System)" Namespace="IIoDrvParameter" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> + <Library Name="IoDriver Interfaces, * (System)" Namespace="IIoDrv" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> + <Library Name="CmpErrors2 Interfaces, * (System)" Namespace="CmpErrors" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> + <Library Name="#Raspberry Pi Peripherals" Namespace="RasPi" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Raspberry Pi Peripherals, * (3S - Smart Software Solutions GmbH)" /> + <Library Name="SysTypes2 Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> + <addData /> + </Libraries> + </data> + </addData> +</project> \ No newline at end of file