Search Project: *:*

 
<< < 1 .. 367 368 369 370 371 .. 3690 > >> (Page 369 of 3690)

rpi-legacy: ./trunk/legacy/Devices/MPU9150.devdesc.xml Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?> <!--created with CoDeSys 3.0 (http://www.3s-software.com) by DeviceDescriptionBuilder (3S-Smart Software Solutions GmbH)--> <DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd" xmlns:ts="http://www.3s-software.com/schemas/TargetSettings-0.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Types namespace="local"> </Types> <Strings namespace="local"> <Language lang="en"> </Language> </Strings> <!-- <Files namespace="local"> <Language lang="en"> <File fileref="local" identifier="JoystickIcon"> <LocalFile>Joystick.ico</LocalFile> </File> </Language> </Files>--> <Device hideInCatalogue="false"> <DeviceIdentification> <Type>500</Type> <Id>0000 0001</Id> <Version>1.1.0.0</Version> </DeviceIdentification> <DeviceInfo> <Name name="local:ModelName">Gyro MPU9150</Name> <Description name="local:DeviceDescription">MPU9150 Gyro board</Description> <Vendor name="local:VendorName">3S - Smart Software Solutions GmbH</Vendor> <OrderNumber>-</OrderNumber> <!-- <Icon name="local:JoystickIcon">Joystick.ico</Icon> --> </DeviceInfo> <Connector moduleType="500" interface="Raspberry.I2C" role="child" explicit="false" connectorId="1" hostpath="-1"> <InterfaceName name="local:PCI">I²C-Bus</InterfaceName> <Slot count="1" allowEmpty="false"> </Slot> <DriverInfo needsBusCycle="false"> <RequiredLib libname="Raspberry I2C Gyroscopes" vendor="3S - Smart Software Solutions GmbH" version="1.1.1.0" identifier="deviceLib"> <FBInstance basename="$(DeviceName)" fbname="MPU9150"> <Initialize methodName="Initialize" /> <CyclicCall methodname="AfterReadInputs" task="#buscycletask" whentocall="afterReadInputs" /> </FBInstance> </RequiredLib> </DriverInfo> <HostParameterSet> <Parameter ParameterId="1" type="std:USINT"> <Attributes channel="none" download="true" functional="false" onlineaccess="read" /> <Default>0</Default> <Name name="local:Id393218">I²C address</Name> <Description name="local:Id393218.Desc">Address of the device</Description> </Parameter> </HostParameterSet> </Connector> </Device> </DeviceDescription>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Devices/OneWireMaster.devdesc.xml Bash bash (Bash)
<?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Bernhard Reiterer (3S-Smart Software Solutions GmbH) --> <DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd"> <Device> <DeviceIdentification> <Type>499</Type> <Id>0000 0000</Id> <Version>1.0.0.0</Version> </DeviceIdentification> <DeviceInfo> <Name name="local:typename">Onewire master</Name> <Description name="local:typedescription">Onewire master</Description> <Vendor name="local:3S">3S - Smart Software Solutions GmbH</Vendor> <OrderNumber>-</OrderNumber> </DeviceInfo> <Connector connectorId="1" moduleType="499" interface="Raspberry.OnewireMaster" role="child" hostpath="-1"> <InterfaceName name="local:Onewiremaster">OnewireMaster</InterfaceName> <Slot allowEmpty="false" count="1"/> <DriverInfo needsBusCycle="false"> <RequiredLib libname="Raspberry Pi Peripherals" vendor="3S - Smart Software Solutions GmbH" identifier="deviceLib" placeholderlib="Raspberry Pi Peripherals"> <FBInstance basename="$(DeviceName)" fbname="OnewireMaster"> <Initialize methodName="Initialize"/> </FBInstance> </RequiredLib> </DriverInfo> <HostParameterSet> <Parameter ParameterId="1" type="std:BOOL"> <Attributes offlineaccess="none" download="true" functional="false"/> <Default>FALSE</Default> <Name name="local:HiddenPointerToOwnInstance">HiddenPointerToOwnInstance</Name> <Description name="local:HiddenPointerToOwnInstance">HiddenPointerToOwnInstance</Description> </Parameter> <Parameter ParameterId="10" type="std:STRING"> <Attributes channel="none" download="true" functional="false" onlineaccess="read"/> <Default>'/sys/devices/w1_bus_master1/'</Default> <Name name="local:Id393218">1-wire port</Name> <Description name="local:Id393218.Desc">file path of the 1-wire port</Description> </Parameter> </HostParameterSet> </Connector> <Connector connectorId="2" moduleType="503" interface="Raspberry.Onewire" role="parent" hostpath="1" initialStatusFlag="241"> <InterfaceName name="local:SPIdevices">1-wire device</InterfaceName> <Var /> </Connector> </Device> </DeviceDescription>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Devices/PiCamera.devdesc.xml Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?> <!--created with CoDeSys 3.0 (http://www.3s-software.com) by DeviceDescriptionBuilder (3S-Smart Software Solutions GmbH)--> <DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd" xmlns:ts="http://www.3s-software.com/schemas/TargetSettings-0.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Types namespace="local"> </Types> <Strings namespace="local"> <Language lang="en"> </Language> </Strings> <Files namespace="local"> <Language lang="en"> <File fileref="local" identifier="Icon"> <LocalFile>Camera.ico</LocalFile> </File> </Language> </Files> <Device hideInCatalogue="false"> <DeviceIdentification> <Type>502</Type> <Id>0000 0002</Id> <Version>3.5.13.0</Version> </DeviceIdentification> <DeviceInfo> <Name name="local:ModelName">Raspberry Pi Camera</Name> <Description name="local:DeviceDescription">Raspberry Pi Camera</Description> <Vendor name="local:VendorName">3S - Smart Software Solutions GmbH</Vendor> <OrderNumber>-</OrderNumber> <Icon name="local:Icon">Camera.ico</Icon> </DeviceInfo> <Connector moduleType="502" interface="Raspberry.Camera2" role="child" explicit="false" connectorId="1" hostpath="-1"> <InterfaceName name="local:PCI">Camera-Bus</InterfaceName> <Slot count="1" allowEmpty="false"> </Slot> <DriverInfo needsBusCycle="false"> <RequiredLib libname="RaspberryPiCamera" vendor="3S - Smart Software Solutions GmbH" version="3.5.4.0" identifier="deviceLib"> <FBInstance basename="$(DeviceName)" fbname="PiCamera"> <Initialize methodName="Initialize" /> </FBInstance> </RequiredLib> </DriverInfo> <HostParameterSet> </HostParameterSet> </Connector> </Device> </DeviceDescription>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/IoDrvGPIO.library.xml Bash bash (Bash)
<?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:05.1492042" /> <contentHeader name="IoDrvGPIO" version="3.5.11.0" modificationDateTime="2017-07-03T23:33:02" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH"> <Comment>Library containing IO driver for Raspberry GPIOs</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">IoDrvGPIO</property> <property name="Description" type="string">Library containing IO driver for Raspberry GPIOs</property> <property name="Placeholder" type="string">IoDrvGPIO</property> <property name="Project" type="string">IoDrvGPIO</property> <property name="Released" type="boolean">true</property> <property name="Title" type="string">IoDrvGPIO</property> <property name="Version" type="version">3.5.11.0</property> <property name="library-category-list" type="library-category-list">Target|3S - Smart Software Solutions GmbH</property> </ProjectInformation> </data> </addData> </contentHeader> <types> <dataTypes> <dataType name="GPIOType"> <baseType> <enum> <values> <value name="I" value="2#0" /> <value name="O" value="2#1" /> <value name="ALT0" value="2#100" /> <value name="ALT1" value="2#101" /> <value name="ALT2" value="2#110" /> <value name="ALT3" value="2#111" /> <value name="ALT4" value="2#11" /> <value name="ALT5" value="2#10" /> </values> <baseType> <USINT /> </baseType> </enum> </baseType> <addData /> </dataType> <dataType name="ProcessorType"> <baseType> <enum> <values> <value name="UNKNOWN" /> <value name="BCM2708" /> <value name="BCM2709" /> </values> </enum> </baseType> <addData /> </dataType> </dataTypes> <pous> <pou name="GPIO" pouType="functionBlock"> <interface> <inputVars> <variable name="aeType"> <type> <array> <dimension lower="0" upper="31" /> <baseType> <derived name="GPIOType" /> </baseType> </array> </type> </variable> <variable name="axOutputs"> <type> <array> <dimension lower="0" upper="31" /> <baseType> <BOOL /> </baseType> </array> </type> </variable> <variable name="udiPWMFrequency"> <type> <UDINT /> </type> </variable> <variable name="uiPWMDutyCycle"> <type> <UINT /> </type> </variable> </inputVars> <outputVars> <variable name="dwInputs"> <type> <DWORD /> </type> </variable> <variable name="axInputs"> <type> <array> <dimension lower="0" upper="31" /> <baseType> <BOOL /> </baseType> </array> </type> </variable> </outputVars> <localVars> <variable name="_pConnector"> <type> <pointer> <baseType> <derived name="IoConfigConnector" /> </baseType> </pointer> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_udiInstance"> <type> <UDINT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_uiModuleType"> <type> <UINT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_aeOldType"> <type> <array> <dimension lower="0" upper="31" /> <baseType> <derived name="GPIOType" /> </baseType> </array> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_axOldOutputs"> <type> <array> <dimension lower="0" upper="31" /> <baseType> <BOOL /> </baseType> </array> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_udiOldPWMFrequency"> <type> <UDINT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_uiOldPWMDutyCycle"> <type> <UINT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_hShmGPIOBASE"> <type> <derived name="SysTypes.RTS_IEC_HANDLE" /> </type> <initialValue> <simpleValue value="RTS_INVALID_HANDLE" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_iState"> <type> <INT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_iOldState"> <type> <INT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_eProcessorType"> <type> <derived name="ProcessorType" /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="_xAfterReadInputs"> <type> <BOOL /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> </localVars> <localVars constant="true"> <variable name="BCM2708_PERI_BASE"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#20000000" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="BCM2709_PERI_BASE"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#3F000000" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMCTL"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#0" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMSTA"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#4" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMDMAC"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#8" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMRNG1"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#10" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMDAT1"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#14" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMFIF1"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#18" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMRNG2"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#20" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMDAT2"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#24" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_CM_PWMCTL"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#A0" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_CM_PWMDIV"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#A4" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="PAGE_SIZE"> <type> <DWORD /> </type> <initialValue> <simpleValue value="(4 * 1024)" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="BLOCK_SIZE"> <type> <DWORD /> </type> <initialValue> <simpleValue value="(4 * 1024)" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> </localVars> <localVars> <variable name="PERI_BASE"> <type> <DWORD /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PADS"> <type> <DWORD /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_BASE"> <type> <DWORD /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_TIMER"> <type> <DWORD /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_PWMBASE"> <type> <DWORD /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> <variable name="GPIO_CLKBASE"> <type> <DWORD /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </variable> </localVars> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide_all_locals" Value="" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This function block is the base class for SPI devices controlled via the SPI device /dev/spidev0.0. It is meant to be extended by other function blocks that overload the body and the following methods/properties and replace it with their specific implementation, always including a call of the base implementation with super^.&lt;MethodName&gt;() : - body (general handling, start-up) - AfterReadInputs (reading input data) - BeforeWriteOutputs (writing output data) - Initialize [optional] (used to read parameters from the configuration) - Operational [optional] (used to signal the status of the device) The body of this FB is called by the methods AfterReadInputs and BeforeWriteOutputs, where _xAfterReadInputs indicates the caller. Use _iState to control your statemachine. A value of 10 by default indicates that the drive is operational. Do not forget to call the base implementation with super^(), where the diagnosis indicators are set according to the Operational property.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">IF _iState &lt;&gt; _iOldState THEN IF Operational THEN IoMgrConfigResetDiagnosis(_pConnector, ConnectorFlags.CF_CONNECTOR_ERROR); IoMgrConfigSetDiagnosis(_pConnector, ConnectorFlags.CF_DRIVER_AVAILABLE OR ConnectorFlags.CF_CONNECTOR_FOUND OR ConnectorFlags.CF_CONNECTOR_CONFIGURED OR ConnectorFlags.CF_CONNECTOR_ACTIVE); ELSE IoMgrConfigResetDiagnosis(_pConnector, ConnectorFlags.CF_CONNECTOR_ACTIVE); IoMgrConfigSetDiagnosis(_pConnector, ConnectorFlags.CF_DRIVER_AVAILABLE OR ConnectorFlags.CF_CONNECTOR_FOUND OR ConnectorFlags.CF_CONNECTOR_CONFIGURED OR ConnectorFlags.CF_CONNECTOR_ERROR); END_IF _iOldState := _iState; END_IF IF _iState = 0 THEN init(); (*ELSIF _iState &gt;0 AND _iState &lt; 10 THEN ConfigurePWM();*) END_IF //SysShm.SysSharedMemoryRead(_hShmGPIOPWM, 16#4, ADR(udiTestSTatus), 4, ADR(result)); </xhtml> </ST> </body> <addData> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="AfterReadInputs"> <interface> <returnType> <INT /> </returnType> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This method can be overloaded by extending FBs. It is used to read in the inputs of the device in the beginning of the cycle. Always including a call of the base implementation with super^.AfterReadInputs() In the base implementation, the body of the FB is called.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">_xAfterReadInputs := TRUE; THIS^(); _xAfterReadInputs := FALSE; IF _iState = 10 THEN GetInputs(); 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> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This method can be overloaded by extending FBs. It is used to write the outputs to the device at the end of the cycle. Always including a call of the base implementation with super^.BeforeWriteOutputs() In the base implementation, the body of the FB is called.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">IF _iState = 10 THEN SetType(); SetOutputs(); END_IF THIS^(); </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> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This method can be overloaded by extending FBs. It is called once during initialization phase, before the PLC goes into "run". Always including a call of the base implementation with super^.Initialize(wModuleType, udiInstance, pConnector) Typically, parameter values from the configuration are read here.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">_uiModuleType := wModuleType; _udiInstance := dwInstance; _pConnector := pConnector; _eProcessorType := DetermineProcessorType(); DetermineConstants(); init();</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="ConfigurePWM"> <interface> <returnType> <BOOL /> </returnType> <localVars> <variable name="udi"> <type> <UDINT /> </type> </variable> <variable name="Result"> <type> <UDINT /> </type> </variable> <variable name="iCounter"> <type> <INT /> </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">CASE _iState OF 1: udi := 0; SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMCTL, ADR(udi), 4, ADR(result));// Turn off PWM. IF Result = Errors.ERR_OK THEN _iState := _iState + 1; ELSE _iState := 1000; END_IF 2: SysShm.SysSharedMemoryRead(_hShmGPIOCLK, GPIO_CM_PWMCTL, ADR(udi), 4, ADR(result)); IF Result &lt;&gt; Errors.ERR_OK THEN _iState := 1000; RETURN; END_IF udi.4 := FALSE; udi := udi OR 16#5A00_0000; // Turn off enable flag. SysShm.SysSharedMemoryWrite(_hShmGPIOCLK, GPIO_CM_PWMCTL, ADR(udi), 4, ADR(result)); IF Result = Errors.ERR_OK THEN _iState := _iState + 1; ELSE _iState := 1000; END_IF 3: SysShm.SysSharedMemoryRead(_hShmGPIOCLK, GPIO_CM_PWMCTL, ADR(udi), 4, ADR(result)); IF Result = Errors.ERR_OK THEN IF NOT udi.7 THEN _iState := _iState + 1; END_IF ELSE _iState := 1000; END_IF 4: udi := 16#5A000000 OR SHL(DWORD#5, 12); // Configure divider. SysShm.SysSharedMemoryWrite(_hShmGPIOCLK, GPIO_CM_PWMDIV, ADR(udi), 4, ADR(result)); IF Result = Errors.ERR_OK THEN _iState := _iState + 1; ELSE _iState := 1000; END_IF 5: udi := 16#5A00_0206; // Source=PLLD (500 MHz), 1-stage MASH. SysShm.SysSharedMemoryWrite(_hShmGPIOCLK, GPIO_CM_PWMCTL, ADR(udi), 4, ADR(result)); IF Result = Errors.ERR_OK THEN _iState := _iState + 1; ELSE _iState := 1000; END_IF 6: udi := 16#5A00_0216; // Enable clock. SysShm.SysSharedMemoryWrite(_hShmGPIOCLK, GPIO_CM_PWMCTL, ADR(udi), 4, ADR(result)); IF Result = Errors.ERR_OK THEN _iState := _iState + 1; ELSE _iState := 1000; END_IF 7: // Wait for busy flag to turn on. SysShm.SysSharedMemoryRead(_hShmGPIOCLK, GPIO_CM_PWMCTL, ADR(udi), 4, ADR(result)); IF Result = Errors.ERR_OK THEN IF udi.7 THEN _iState := _iState + 1; END_IF ELSE _iState := 1000; END_IF 8: udi := 100; SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMRNG1, ADR(udi), 4, ADR(result)); IF Result &lt;&gt; Errors.ERR_OK THEN _iState := 1000; RETURN; END_IF udi := 20; SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMDAT1, ADR(udi), 4, ADR(result)); IF Result &lt;&gt; Errors.ERR_OK THEN _iState := 1000; RETURN; END_IF udi := 16#81; SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMCTL, ADR(udi), 4, ADR(result)); // Channel 1 M/S mode, no FIFO, PWM mode, enabled. IF Result &lt;&gt; Errors.ERR_OK THEN _iState := 1000; RETURN; END_IF _iState := _iState + 1; 9: aeType[18] := ALT5; SetType(); _iState := 10; END_CASE </xhtml> </ST> </body> <BuildProperties> <ExcludeFromBuild>true</ExcludeFromBuild> </BuildProperties> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="DetermineConstants"> <interface /> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">IF _eProcessorType = ProcessorType.BCM2708 THEN // Raspberry Pi Model B+ PERI_BASE := BCM2708_PERI_BASE; ELSE // Raspberry Pi 2 Model B // Raspberry Pi 3 Model B and all others PERI_BASE := BCM2709_PERI_BASE; END_IF GPIO_PADS := (PERI_BASE + 16#00100000); GPIO_BASE := (PERI_BASE + 16#00200000); GPIO_TIMER := (PERI_BASE + 16#0000B000); GPIO_PWMBASE := (PERI_BASE + 16#0020C000); GPIO_CLKBASE := (PERI_BASE + 16#00101000);</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="DetermineProcessorType"> <interface> <returnType> <derived name="ProcessorType" /> </returnType> <localVars> <variable name="Result"> <type> <derived name="RTS_IEC_RESULT" /> </type> </variable> <variable name="Handle"> <type> <derived name="RTS_IEC_HANDLE" /> </type> </variable> <variable name="fr"> <type> <derived name="FileReader" /> </type> </variable> <variable name="str"> <type> <string length="255" /> </type> </variable> <variable name="i"> <type> <INT /> </type> </variable> <variable name="iLen"> <type> <INT /> </type> </variable> <variable name="strType"> <type> <string /> </type> </variable> <variable name="x"> <type> <BOOL /> </type> <initialValue> <simpleValue value="TRUE" /> </initialValue> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">Handle := SysFileOpen(szFile:='/proc/cpuinfo' , am:=ACCESS_MODE.AM_READ , pResult:= ADR(Result)); IF Result = CmpErrors.Errors.ERR_OK THEN fr(hFile:=Handle ); WHILE fr.GetLine(ADR(str), SIZEOF(str)) DO iLen := Len(Str); IF iLen &gt; 10 THEN IF LEFT(str, 10) = 'model name' THEN i := find(str, ':'); strType := RIGHT(str, iLen-i-1); strType := LEFT(strType, 5); EXIT; END_IF END_IF END_WHILE END_IF SysFileClose(Handle); IF strType='ARMv6' THEN // Raspberry Pi 1 and Model B+ DetermineProcessorType := ProcessorType.BCM2708; ELSE // Raspberry Pi 2 Model B // Raspberry Pi 3 Model B and all others DetermineProcessorType := ProcessorType.BCM2709; END_IF</xhtml> </ST> </body> <addData /> </Method> </data> <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> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> if TRUE, the instance afterwards gets moved into the copy code (online change)</xhtml> </documentation> </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 _hShmGPIOBASE &lt;&gt; RTS_INVALID_HANDLE THEN SysShm.SysSharedMemoryClose(_hShmGPIOBASE); _hShmGPIOBASE := RTS_INVALID_HANDLE; END_IF (* IF _hShmGPIOPWM &lt;&gt; RTS_INVALID_HANDLE THEN SysShm.SysSharedMemoryClose(_hShmGPIOPWM); _hShmGPIOPWM := RTS_INVALID_HANDLE; END_IF IF _hShmGPIOCLK &lt;&gt; RTS_INVALID_HANDLE THEN SysShm.SysSharedMemoryClose(_hShmGPIOCLK); _hShmGPIOCLK := RTS_INVALID_HANDLE; END_IF*)</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="GetInputs"> <interface> <localVars> <variable name="Result"> <type> <UDINT /> </type> </variable> <variable name="i"> <type> <INT /> </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">SysShm.SysSharedMemoryRead(_hShmGPIOBase, 16#34, ADR(dwInputs), 4, ADR(result)); FOR i:=0 TO 31 DO axInputs[i] := (dwInputs AND SHL(UDINT#1, i)) &gt; 0; END_FOR</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="GetType"> <interface> <localVars> <variable name="Result"> <type> <UDINT /> </type> </variable> <variable name="ul"> <type> <UDINT /> </type> </variable> <variable name="i"> <type> <INT /> </type> </variable> <variable name="j"> <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">j := 0; FOR i:=0 TO 31 DO IF (i MOD 10) = 0 THEN SysSharedMemoryRead(_hShmGPIOBase, j*4, ADR(ul), 4, ADR(result)); j := j + 1; END_IF aeType[i] := UDINT_TO_USINT(SHR(ul, INT_TO_UDINT(i MOD 10) * 3) AND 2#111); END_FOR _aeOldType := aeType;</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="SetOutputs"> <interface> <localVars> <variable name="Result"> <type> <UDINT /> </type> </variable> <variable name="ulOn"> <type> <UDINT /> </type> </variable> <variable name="ulOff"> <type> <UDINT /> </type> </variable> <variable name="i"> <type> <INT /> </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">FOR i:=0 TO 31 DO IF _axOldOutputs[i] &lt;&gt; axOutputs[i] AND aeType[i] = GPIOType.O THEN IF axOutputs[i] THEN ulOn := ulOn OR SHL(UDINT#1, i); ELSE ulOff := ulOff OR SHL(UDINT#1, i); END_IF END_IF END_FOR IF ulOn &gt; 0 THEN SysShm.SysSharedMemoryWrite(_hShmGPIOBase, 16#1C, ADR(ulOn), 4, ADR(result)); END_IF IF ulOff &gt; 0 THEN SysShm.SysSharedMemoryWrite(_hShmGPIOBase, 16#28, ADR(ulOff), 4, ADR(result)); END_IF _axOldOutputs := axOutputs; //PWM (* IF udiPWMFrequency &lt;&gt; _udiOldPWMFrequency THEN SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMRNG1, ADR(udiPWMFrequency), 4, ADR(result)); _udiOldPWMFrequency := udiPWMFrequency; END_IF IF uiPWMDutyCycle &lt;&gt; _uiOldPWMDutyCycle THEN ulOn := uiPWMDutyCycle; SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMDAT1, ADR(ulOn), 4, ADR(result)); _uiOldPWMDutyCycle := uiPWMDutyCycle; ulOn := 16#81; SysShm.SysSharedMemoryWrite(_hShmGPIOPWM, GPIO_PWMCTL, ADR(ulOn), 4, ADR(result)); // Channel 1 M/S mode, no FIFO, PWM mode, enabled. END_IF*)</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="SetType"> <interface> <localVars> <variable name="Result"> <type> <UDINT /> </type> </variable> <variable name="ul"> <type> <UDINT /> </type> </variable> <variable name="ulOrig"> <type> <UDINT /> </type> </variable> <variable name="i"> <type> <INT /> </type> </variable> <variable name="j"> <type> <UDINT /> </type> </variable> <variable name="udiOffset"> <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">j := 0; FOR i:=0 TO 31 DO IF (i MOD 10) = 0 THEN SysSharedMemoryRead(_hShmGPIOBase, j*4, ADR(ul), 4, ADR(result)); ulOrig := ul; END_IF IF _aeOldType[i] &lt;&gt; aeType[i] THEN IF aeType[i] = GPIOType.I OR aeType[i] = GPIOType.O THEN udiOffset := INT_TO_UDINT(i MOD 10) * 3; CASE aeType[i] OF GPIOType.I: ul := ul AND NOT SHL(7, udiOffset); GPIOType.O: ul := ul AND NOT SHL(7, udiOffset); ul := ul OR SHL(1, udiOffset); _axOldOutputs[i] := axInputs[i]; END_CASE END_IF END_IF IF ((i MOD 10) = 9 OR i=31) THEN IF ul &lt;&gt; ulOrig THEN SysSharedMemoryWrite(_hShmGPIOBase, j*4, ADR(ul), 4, ADR(result)); END_IF j := j + 1; END_IF END_FOR _aeOldType := aeType;</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="init"> <interface> <returnType> <BOOL /> </returnType> <localVars> <variable name="Result1"> <type> <UDINT /> </type> </variable> <variable name="Result2"> <type> <UDINT /> </type> </variable> <variable name="Result3"> <type> <UDINT /> </type> </variable> <variable name="ul"> <type> <UDINT /> </type> </variable> <variable name="i"> <type> <INT /> </type> </variable> <variable name="strEmpty"> <type> <string length="2" /> </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 _hShmGPIOBASE = RTS_INVALID_HANDLE THEN ul := BLOCK_SIZE; IF _hShmGPIOBASE = RTS_INVALID_HANDLE THEN _hShmGPIOBASE := SysSharedMemoryCreate(pszName:=strEmpty , ulPhysicalAddress:=GPIO_BASE , pulSize:= ADR(ul), pResult:=ADR(Result1) ); END_IF (* IF _hShmGPIOPWM = RTS_INVALID_HANDLE THEN _hShmGPIOPWM := SysSharedMemoryCreate(pszName:=strEmpty , ulPhysicalAddress:=GPIO_PWMBASE , pulSize:= ADR(ul), pResult:=ADR(Result2) ); END_IF IF _hShmGPIOCLK = RTS_INVALID_HANDLE THEN _hShmGPIOCLK := SysSharedMemoryCreate(pszName:=strEmpty , ulPhysicalAddress:=GPIO_CLKBASE , pulSize:= ADR(ul), pResult:=ADR(Result3) ); END_IF *) IF Result1 = 0 AND Result2 = 0 AND Result3 = 0 THEN init := TRUE; GetType(); GetInputs(); FOR i:=0 TO 31 DO IF aeType[i] = GPIOType.O THEN axOutputs[i] := axInputs[i]; END_IF END_FOR _axOldOutputs := axOutputs; SetOutputs(); _iState := 10; ELSE _iState := 1000; END_IF END_IF </xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation"> <Property name="Operational"> <interface> <returnType> <BOOL /> </returnType> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This property has to return TRUE, when the device is configured and running</xhtml> </documentation> </interface> <GetAccessor> <interface> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="hide" Value="" /> </Attributes> </data> </addData> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">Operational := (_iState=10);</xhtml> </ST> </body> <addData /> </GetAccessor> <addData /> </Property> </data> </addData> </pou> <pou name="IoDrvGPIO" pouType="functionBlock"> <interface> <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> <localVars> <variable name="_IIoDrv"> <type> <derived name="ICmpIoDrv" /> </type> </variable> <variable name="_IIoDrvParameter"> <type> <derived name="ICmpIoDrvParameter" /> </type> </variable> <variable name="_GPIO"> <type> <derived name="GPIO" /> </type> </variable> <variable name="_dwInUse"> <type> <DWORD /> </type> </variable> <variable name="_xBackGroundDiagStarted"> <type> <BOOL /> </type> </variable> <variable name="_bDeactivated"> <type> <BOOL /> </type> </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 := 'IoDrvGPIO'; m_Info.szVendorName := '3S - Smart Software Solutions'; m_Info.szDeviceName := 'Raspberry GPIOs'; m_Info.wModuleType := 8000; _IIoDrv := THIS^; _IIoDrvParameter := THIS^; m_IBaseItf := THIS^; m_hInterface := IoMgrRegisterInstance2(CLASSID_CCmpIoDrvTemplate, m_IBaseItf, 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; _GPIO.Initialize(wModuleType, dwInstance, pConnector); Initialize := 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 &lt;&gt; 0) THEN pResult^ := Errors.ERR_OK; END_IF RETURN; ELSIF iid = ITFID_ICmpIoDrvParameter THEN QueryInterface := ADR(_IIoDrvParameter); AddRef(); IF (pResult &lt;&gt; 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 //Todo: update connectorflags if something changed 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> <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="bySrcMask"> <type> <BYTE /> </type> </variable> <variable name="wSrcIndex"> <type> <WORD /> </type> </variable> <variable name="wDestIndex"> <type> <WORD /> </type> </variable> <variable name="pdw"> <type> <pointer> <baseType> <DWORD /> </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">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 pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress; wDestIndex := pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset / 8; IF (pConnectorMapList[i].pChannelMapList[j].wSize = 1) THEN IF _GPIO.axInputs[pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset] THEN (*IF (PiFace.byIn AND SHL(BYTE#1, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8)) &lt;&gt; 0 THEN*) {IF defined (pou:SysCpuSetBit2)} SysCpuSetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {ELSE} SysCpuSetBit(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {END_IF} ELSE {IF defined (pou:SysCpuResetBit2)} SysCpuResetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {ELSE} SysCpuResetBit(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {END_IF} END_IF ELSIF pConnectorMapList[i].pChannelMapList[j].wSize = 32 THEN pdw := pbyIecAddress + wDestIndex; pdw^ := _GPIO.dwInputs; END_IF 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 &lt; V3.5.1.0 END_IF //optional: call IoDrvWatchdogTrigger or set driver property DRVPROP_WATCHDOG in UpdateConfiguration IoDrvWatchdogTrigger(pConnector); IF NOT _bDeactivated THEN _GPIO.AfterReadInputs(); _GPIO.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 // Reset application // TODO: Free ressources 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} _dwInUse := 0; FOR i:=0 TO 31 DO pParameter := IoMgrConfigGetParameter(m_pConnector, INT_TO_DWORD(i)); IF (pParameter &lt;&gt; 0) THEN bySetting := IoMgrConfigGetParameterValueByte(pParameter, ADR(Result)); IF bySetting &gt;= 0 AND bySetting &lt;= 7 THEN _GPIO.aeType[i] := bySetting; _dwInUse := _dwInUse OR SHL(DWORD#1, i); END_IF END_IF END_FOR //Setup I/O area pParameter := IoMgrConfigGetParameter(m_pConnector, 1000); (* inputs *) IF (pParameter &lt;&gt; 0) THEN pParameter^.dwDriverSpecific := 0; (* Device offset 0 *) END_IF pParameter := IoMgrConfigGetParameter(m_pConnector, 2000); (* outputs *) IF (pParameter &lt;&gt; 0) THEN pParameter^.dwDriverSpecific := 0; (* Device offset 0 *) END_IF pParameter := IoMgrConfigGetParameter(m_pConnector, 2100); (* outputs *) IF (pParameter &lt;&gt; 0) THEN pParameter^.dwDriverSpecific := 10; (* Device offset 0 *) END_IF pParameter := IoMgrConfigGetParameter(m_pConnector, 2101); (* outputs *) IF (pParameter &lt;&gt; 0) THEN pParameter^.dwDriverSpecific := 14; (* Device offset 0 *) END_IF (* no child devices used //Go through all childs of the device pChild := IoMgrConfigGetFirstChild(m_pConnector, ADR(nCount), m_pConnector); WHILE (pChild &lt;&gt; 0) DO IF (pChild^.dwFlags AND ConnectorFlags.CF_ENABLE) &lt;&gt; 0 THEN pChild^.hIoDrv := m_hInterface; {IF defined (pou:IoMgrConfigSetDiagnosis)} IoMgrConfigSetDiagnosis(pChild, ConnectorFlags.CF_DRIVER_AVAILABLE OR ConnectorFlags.CF_CONNECTOR_FOUND OR ConnectorFlags.CF_CONNECTOR_CONFIGURED OR ConnectorFlags.CF_CONNECTOR_ACTIVE); {END_IF} END_IF pChild := IoMgrConfigGetNextChild(pChild, ADR(nCount), m_pConnector); END_WHILE*) 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; IF pConnectorMapList = 0 OR nCount = 0 THEN IoDrvWriteOutputs := 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 wSrcIndex := pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset / 8; pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress; CASE pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific OF 0: // digitals IF pConnectorMapList[i].pChannelMapList[j].wSize = 1 THEN bySrcValue := pbyIecAddress[wSrcIndex]; k := pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset; IF (_dwInUse AND SHL(DWORD#1, k)) &gt; 0 THEN _GPIO.axOutputs[k] := BYTE_TO_BOOL(pbyIecAddress[wSrcIndex] AND SHL(BYTE#1, pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8)); END_IF ELSIF pConnectorMapList[i].pChannelMapList[j].wSize = 32 THEN pdw := pbyIecAddress; FOR k:=0 TO 32 DO IF (_dwInUse AND SHL(DWORD#1, k)) &gt; 0 THEN _GPIO.axOutputs[k] := DWORD_TO_BOOL(pdw^ AND SHL(1, k)); END_IF END_FOR END_IF 10: pdw := pbyIecAddress; _GPIO.udiPWMFrequency := DWORD#100_000_000 / pdw^; 14: pw := pbyIecAddress; _GPIO.uiPWMDutyCycle := UDINT_TO_UINT(UINT_TO_UDINT(pw^) * _GPIO.udiPWMFrequency / UDINT#65536); END_CASE END_FOR END_FOR 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="IoDrvGetConnector"> <interface> <returnType> <pointer> <baseType> <derived name="IoConfigConnector" /> </baseType> </pointer> </returnType> <inputVars> <variable name="pResult"> <type> <pointer> <baseType> <derived name="RTS_IEC_RESULT" /> </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 m_pConnector = 0 THEN IF pResult &lt;&gt; 0 THEN pResult^ := Errors.ERR_FAILED; END_IF IoDrvGetConnector := 0; RETURN; END_IF IF pResult &lt;&gt; 0 THEN pResult^ := Errors.ERR_OK; END_IF IoDrvGetConnector := m_pConnector; </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> </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="#Raspberry Pi Peripherals" Namespace="Raspi" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Raspberry Pi Peripherals, * (3S - Smart Software Solutions GmbH)" /> <Library Name="#IoDrvBase" Namespace="IoDrvBase" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoDrvBase, * (System)" /> <Library Name="IoDriver Interfaces, * (System)" Namespace="IoDriver_Interfaces" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="IoDriver Parameter Interfaces, * (System)" Namespace="IIoDrvParameter" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="#SysCpuHandling" Namespace="SysCpuHandling" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="SysCpuHandling, * (System)" /> <Library Name="#SysShm" Namespace="SysShm" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="SysShm, * (System)" /> <Library Name="CmpErrors2 Interfaces, * (System)" Namespace="CmpErrors" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="SysTypes2 Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="#SysFile" Namespace="SysFile" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="SysFile, * (System)" /> <addData /> </Libraries> </data> </addData> </project>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/IoDrvPiFace.library.xml Bash bash (Bash)
<?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:05.618968" /> <contentHeader name="IoDrvPiFace" version="1.2.1.0" modificationDateTime="2015-11-24T04:28:44" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH"> <Comment>Library containing IO driver for 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">IoDrvPiFace</property> <property name="Description" type="string">Library containing IO driver for PiFace Digital</property> <property name="Placeholder" type="string">PlaceholderTemplate</property> <property name="Project" type="string">IoDrvPiFace</property> <property name="Released" type="boolean">false</property> <property name="Title" type="string">IoDrvPiFace</property> <property name="Version" type="version">1.2.1.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> <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">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> <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">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> <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">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> <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">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> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="conditionalshow" Value="" /> </Attributes> </data> </addData> <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> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="conditionalshow" Value="" /> </Attributes> </data> </addData> <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> <pou name="IoDrvPiFace" pouType="functionBlock"> <interface> <localVars constant="true"> <variable name="CLASSID_CCmpIoDrvTemplate"> <type> <DWORD /> </type> <initialValue> <simpleValue value="16#FF02" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">TODO</xhtml> </documentation> </variable> </localVars> <localVars> <variable name="_IIoDrv"> <type> <derived name="ICmpIoDrv" /> </type> </variable> <variable name="_IIoDrvParameter"> <type> <derived name="ICmpIoDrvParameter" /> </type> </variable> <variable name="_xBackGroundDiagStarted"> <type> <BOOL /> </type> </variable> <variable name="_bDeactivated"> <type> <BOOL /> </type> </variable> <variable name="PiFace"> <type> <derived name="PiFaceDigital" /> </type> </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="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> <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="bySrcMask"> <type> <BYTE /> </type> </variable> <variable name="wSrcIndex"> <type> <WORD /> </type> </variable> <variable name="wDestIndex"> <type> <WORD /> </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 pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress; wDestIndex := pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset / 8; IF (pConnectorMapList[i].pChannelMapList[j].wSize = 1) THEN IF (PiFace.byIn AND SHL(BYTE#1, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8)) &lt;&gt; 0 THEN {IF defined (pou:SysCpuSetBit2)} SysCpuSetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {ELSE} SysCpuSetBit(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {END_IF} ELSE {IF defined (pou:SysCpuResetBit2)} SysCpuResetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {ELSE} SysCpuResetBit(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8); {END_IF} END_IF ELSIF pConnectorMapList[i].pChannelMapList[j].wSize = 8 THEN pbyIecAddress[wDestIndex] := PiFace.byIn; END_IF 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="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="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="dwTest"> <type> <pointer> <baseType> <DWORD /> </baseType> </pointer> </type> </variable> <variable name="Result"> <type> <derived name="RTS_IEC_RESULT" /> </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 // Reset application // TODO: Free ressources 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 pParameter := IoMgrConfigGetParameter(m_pConnector, 1000); (* inputs *) IF (pParameter &lt;&gt; 0) THEN pParameter^.dwDriverSpecific := 0; (* Device offset 0 *) END_IF pParameter := IoMgrConfigGetParameter(m_pConnector, 2000); (* outputs *) IF (pParameter &lt;&gt; 0) THEN pParameter^.dwDriverSpecific := 0; (* Device offset 0 *) END_IF //Go through all childs of the device pChild := IoMgrConfigGetFirstChild(m_pConnector, ADR(nCount), m_pConnector); WHILE (pChild &lt;&gt; 0) DO IF (pChild^.dwFlags AND ConnectorFlags.CF_ENABLE) &lt;&gt; 0 THEN pChild^.hIoDrv := m_hInterface; {IF defined (pou:IoMgrConfigSetDiagnosis)} IoMgrConfigSetDiagnosis(pChild, ConnectorFlags.CF_DRIVER_AVAILABLE OR ConnectorFlags.CF_CONNECTOR_FOUND OR ConnectorFlags.CF_CONNECTOR_CONFIGURED OR ConnectorFlags.CF_CONNECTOR_ACTIVE); {END_IF} END_IF pChild := IoMgrConfigGetNextChild(pChild, ADR(nCount), m_pConnector); END_WHILE 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="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="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="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="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="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> </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; IF pConnectorMapList = 0 OR nCount = 0 THEN IoDrvWriteOutputs := 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 wSrcIndex := pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset / 8; pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress; IF pConnectorMapList[i].pChannelMapList[j].wSize = 1 THEN bySrcValue := pbyIecAddress[wSrcIndex]; IF (pbyIecAddress[wSrcIndex] AND SHL(BYTE#1, pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8)) &lt;&gt; 0 THEN {IF defined (pou:SysCpuSetBit2)} SysCpuSetBit2(ADR(PiFace.byOut), pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8); {ELSE} SysCpuSetBit(ADR(PiFace.byOut), pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8); {END_IF} ELSE {IF defined (pou:SysCpuResetBit2)} SysCpuResetBit2(ADR(PiFace.byOut), pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8); {ELSE} SysCpuResetBit(ADR(PiFace.byOut), pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset MOD 8); {END_IF} END_IF ELSIF pConnectorMapList[i].pChannelMapList[j].wSize = 8 THEN PiFace.byOut := pbyIecAddress[wSrcIndex]; END_IF END_FOR END_FOR 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="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 &lt; V3.5.1.0 END_IF //optional: call IoDrvWatchdogTrigger or set driver property DRVPROP_WATCHDOG in UpdateConfiguration IoDrvWatchdogTrigger(pConnector); IF NOT _bDeactivated THEN PiFace.AfterReadInputs(); PiFace.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="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 //Todo: update connectorflags if something changed 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="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> <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="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 &lt;&gt; 0) THEN pResult^ := Errors.ERR_OK; END_IF RETURN; ELSIF iid = ITFID_ICmpIoDrvParameter THEN QueryInterface := ADR(_IIoDrvParameter); AddRef(); IF (pResult &lt;&gt; 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="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; PiFace.Initialize(wModuleType, dwInstance, pConnector); Initialize := Errors.ERR_OK;</xhtml> </ST> </body> <addData /> </Method> </data> <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 := 'IoDrvPiFace'; m_Info.szVendorName := '3S - Smart Software Solutions'; m_Info.szDeviceName := 'Raspberry PiFace Digital'; m_Info.wModuleType := 501; _IIoDrv := THIS^; _IIoDrvParameter := THIS^; m_IBaseItf := THIS^; m_hInterface := IoMgrRegisterInstance2(CLASSID_CCmpIoDrvTemplate, m_IBaseItf, ADR(Result)); FB_Init := TRUE;</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="IoDrvGetConnector"> <interface> <returnType> <pointer> <baseType> <derived name="IoConfigConnector" /> </baseType> </pointer> </returnType> <inputVars> <variable name="pResult"> <type> <pointer> <baseType> <derived name="RTS_IEC_RESULT" /> </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 m_pConnector = 0 THEN IF pResult &lt;&gt; 0 THEN pResult^ := Errors.ERR_FAILED; END_IF IoDrvGetConnector := 0; RETURN; END_IF IF pResult &lt;&gt; 0 THEN pResult^ := Errors.ERR_OK; END_IF IoDrvGetConnector := m_pConnector; </xhtml> </ST> </body> <BuildProperties> <EnableSystemCall>true</EnableSystemCall> </BuildProperties> <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)" /> <Library Name="#IoDrvBase" Namespace="IoDrvBase" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="IoDrvBase, * (System)" /> <Library Name="IoDriver Interfaces, * (System)" Namespace="IoDriver_Interfaces" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="CmpErrors Interfaces, * (System)" Namespace="CmpErrors" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="IoDriver Parameter Interfaces, * (System)" Namespace="IIoDrvParameter" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="#SysCpuHandling" Namespace="SysCpuHandling" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="SysCpuHandling, * (System)" /> <addData /> </Libraries> </data> </addData> </project>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/I2C_Gyroscopes.library.xml Bash bash (Bash)
<?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:04.3741209" /> <contentHeader name="Raspberry I2C Gyroscopes" version="1.1.1.0" modificationDateTime="2015-11-24T04:28:44" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH"> <Comment>Library containing device support for different gyroscopes under Raspberry Pi</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">Gyro</property> <property name="Description" type="string">Library containing device support for different gyroscopes under Raspberry Pi</property> <property name="Placeholder" type="string">PlaceholderTemplate</property> <property name="Project" type="string">I2C_Gyroscopes</property> <property name="Released" type="boolean">false</property> <property name="Title" type="string">Raspberry I2C Gyroscopes</property> <property name="Version" type="version">1.1.1.0</property> <property name="library-category-list" type="library-category-list" /> </ProjectInformation> </data> </addData> </contentHeader> <types> <dataTypes /> <pous> <pou name="MPU6050" pouType="functionBlock"> <interface> <outputVars> <variable name="lrAX"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration in axes direction [m/s²]</xhtml> </documentation> </variable> <variable name="lrAY"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration in axes direction [m/s²]</xhtml> </documentation> </variable> <variable name="lrAZ"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration in axes direction [m/s²]</xhtml> </documentation> </variable> <variable name="lrGX"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration of rotation velocity around axes [°/s²]</xhtml> </documentation> </variable> <variable name="lrGY"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration of rotation velocity around axes [°/s²]</xhtml> </documentation> </variable> <variable name="lrGZ"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration of rotation velocity around axes [°/s²]</xhtml> </documentation> </variable> <variable name="lrTemp"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Temperature [°C]</xhtml> </documentation> </variable> </outputVars> <localVars> <variable name="iAX"> <type> <INT /> </type> </variable> <variable name="iAY"> <type> <INT /> </type> </variable> <variable name="iAZ"> <type> <INT /> </type> </variable> <variable name="iGX"> <type> <INT /> </type> </variable> <variable name="iGY"> <type> <INT /> </type> </variable> <variable name="iGZ"> <type> <INT /> </type> </variable> <variable name="uiTemp"> <type> <UINT /> </type> </variable> <variable name="lrOffsetGX"> <type> <LREAL /> </type> </variable> <variable name="lrOffsetGY"> <type> <LREAL /> </type> </variable> <variable name="lrOffsetGZ"> <type> <LREAL /> </type> </variable> <variable name="iCounter"> <type> <INT /> </type> </variable> </localVars> <addData> <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> <Inheritance> <Extends>i2c</Extends> </Inheritance> </data> </addData> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#69; END_IF IF init() THEN _iState := 5; END_IF 5: write8(16#6B, 16#80); _iState := 6; 6: write8(16#6B, 16#3); //SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference) writeBits(16#1B, 4, 2, 3); writeBits(16#1C, 4, 2, 2); write8(16#1A, 2); //0: Config 260Hz 0ms delay 4: 21Hz 8.5ms _iState := 8; 8: iCounter := iCounter + 1; IF iCounter = 200 THEN iCounter := 0; _iState := 9; END_IF 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="13" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs(); IF _iState = 9 OR _iState = 10 THEN readregister(59, ADR(aby), 14); iAX := UINT_TO_INT(aby[0] * UINT#256 + aby[1]); iAY := UINT_TO_INT(aby[2] * UINT#256 + aby[3]); iAZ := UINT_TO_INT(aby[4] * UINT#256 + aby[5]); uiTemp := aby[6] * UINT#256 + aby[7]; iGX := UINT_TO_INT(aby[8] * UINT#256 + aby[9]); iGY := UINT_TO_INT(aby[10] * UINT#256 + aby[11]); iGZ := UINT_TO_INT(aby[12] * UINT#256 + aby[13]); lrAX := iAX * LREAL#9.81 / LREAL#4096; lrAY := iAY * LREAL#9.81 / LREAL#4096; lrAZ := iAZ * LREAL#9.81 / LREAL#4096; IF _iState = 9 THEN //calibrate iCounter := iCounter + 1; lrOffsetGX := lrOffsetGX + iGX * 2000 / LREAL#16384; lrOffsetGY := lrOffsetGY + iGY * 2000 / LREAL#16384; lrOffsetGZ := lrOffsetGZ + iGZ * 2000 / LREAL#16384; IF iCounter = 2000 THEN lrOffsetGX := -lrOffsetGX / iCounter; lrOffsetGY := -lrOffsetGY / iCounter; lrOffsetGZ := -lrOffsetGZ / iCounter; _iState := 10; END_IF ELSE lrGX := INT_TO_LREAL(iGX) * LREAL#2000 / LREAL#16384 + lrOffsetGX; lrGY := INT_TO_LREAL(iGY) * LREAL#2000 / LREAL#16384 + lrOffsetGY; lrGZ := INT_TO_LREAL(iGZ) * LREAL#2000 / LREAL#16384 + lrOffsetGZ; END_IF lrTemp := (UINT_TO_INT(uiTemp) + LREAL#12412) / LREAL#340.0; END_IF</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="Calibrate"> <interface /> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">lrOffsetGX := 0; lrOffsetGY := 0; lrOffsetGZ := 0; iCounter := 0; _iState := 9;</xhtml> </ST> </body> <addData /> </Method> </data> </addData> </pou> <pou name="AK8975" pouType="functionBlock"> <interface> <outputVars> <variable name="iMX"> <type> <INT /> </type> </variable> <variable name="iMY"> <type> <INT /> </type> </variable> <variable name="iMZ"> <type> <INT /> </type> </variable> </outputVars> <localVars> <variable name="aby"> <type> <array> <dimension lower="0" upper="5" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> <variable name="timer"> <type> <derived name="ton" /> </type> <initialValue> <structValue> <value member="IN"> <simpleValue value="TRUE" /> </value> <value member="pt"> <simpleValue value="TIME#10ms" /> </value> </structValue> </initialValue> </variable> </localVars> <addData> <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> <Inheritance> <Extends>i2c</Extends> </Inheritance> </data> </addData> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#0C; END_IF IF init() THEN write8(16#0A, 1); _iState := 10; timer(IN:=TRUE); END_IF END_CASE </xhtml> </ST> </body> <addData> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="AfterReadInputs"> <interface> <returnType> <INT /> </returnType> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs(); IF _iState = 10 THEN timer(); IF timer.Q THEN timer(IN := FALSE); timer(IN := TRUE); readregister(3, ADR(aby), 6); iMX := UINT_TO_INT(aby[0]*UINT#256 + aby[1]); iMY := UINT_TO_INT(aby[2]*UINT#256 + aby[3]); iMZ := UINT_TO_INT(aby[4]*UINT#256 + aby[5]); write8(16#0A, 1); //retrigger END_IF END_IF</xhtml> </ST> </body> <addData /> </Method> </data> </addData> </pou> <pou name="MPU9150" pouType="functionBlock"> <interface> <outputVars> <variable name="lrAX"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration in axes direction [m/s²]</xhtml> </documentation> </variable> <variable name="lrAY"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration in axes direction [m/s²]</xhtml> </documentation> </variable> <variable name="lrAZ"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration in axes direction [m/s²]</xhtml> </documentation> </variable> <variable name="lrGX"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration of rotation velocity around axes [°/s²]</xhtml> </documentation> </variable> <variable name="lrGY"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration of rotation velocity around axes [°/s²]</xhtml> </documentation> </variable> <variable name="lrGZ"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Acceleration of rotation velocity around axes [°/s²]</xhtml> </documentation> </variable> <variable name="lrTemp"> <type> <LREAL /> </type> </variable> </outputVars> <localVars> <variable name="Magnet"> <type> <derived name="AK8975" /> </type> </variable> <variable name="iAX"> <type> <INT /> </type> </variable> <variable name="iAY"> <type> <INT /> </type> </variable> <variable name="iAZ"> <type> <INT /> </type> </variable> <variable name="iGX"> <type> <INT /> </type> </variable> <variable name="iGY"> <type> <INT /> </type> </variable> <variable name="iGZ"> <type> <INT /> </type> </variable> <variable name="uiTemp"> <type> <UINT /> </type> </variable> <variable name="lrOffsetGX"> <type> <LREAL /> </type> </variable> <variable name="lrOffsetGY"> <type> <LREAL /> </type> </variable> <variable name="lrOffsetGZ"> <type> <LREAL /> </type> </variable> <variable name="iCounter"> <type> <INT /> </type> </variable> </localVars> <addData> <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> <Inheritance> <Extends>i2c</Extends> </Inheritance> </data> </addData> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#69; END_IF IF SUPER^.init() THEN _iState := 5; END_IF 5: write8(16#6B, 16#80); _iState := 6; 6: write8(16#6B, 16#3); //SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference) writeBits(16#1B, 4, 2, 3); writeBits(16#1C, 4, 2, 2); write8(16#1A, 2); //0: Config 260Hz 0ms delay 4: 21Hz 8.5ms write8(16#37, 2); _iState := 7; 7: Magnet(); IF Magnet.Operational THEN _iState := 8; END_IF 8: iCounter := iCounter + 1; IF iCounter = 200 THEN iCounter := 0; _iState := 9; END_IF 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="13" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs(); IF _iState = 9 OR _iState = 10 THEN readregister(59, ADR(aby), 14); iAX := UINT_TO_INT(aby[0] * UINT#256 + aby[1]); iAY := UINT_TO_INT(aby[2] * UINT#256 + aby[3]); iAZ := UINT_TO_INT(aby[4] * UINT#256 + aby[5]); uiTemp := aby[6] * UINT#256 + aby[7]; iGX := UINT_TO_INT(aby[8] * UINT#256 + aby[9]); iGY := UINT_TO_INT(aby[10] * UINT#256 + aby[11]); iGZ := UINT_TO_INT(aby[12] * UINT#256 + aby[13]); lrAX := iAX * LREAL#9.81 / LREAL#4096; lrAY := iAY * LREAL#9.81 / LREAL#4096; lrAZ := iAZ * LREAL#9.81 / LREAL#4096; IF _iState = 9 THEN //calibrate iCounter := iCounter + 1; lrOffsetGX := lrOffsetGX + iGX; lrOffsetGY := lrOffsetGY + iGY; lrOffsetGZ := lrOffsetGZ + iGZ; IF iCounter = 2000 THEN lrOffsetGX := -lrOffsetGX / iCounter; lrOffsetGY := -lrOffsetGY / iCounter; lrOffsetGZ := -lrOffsetGZ / iCounter; _iState := 10; END_IF ELSE lrGX := (INT_TO_LREAL(iGX) + lrOffsetGX) / 16.4; lrGY := (INT_TO_LREAL(iGY) + lrOffsetGY) / 16.4; lrGZ := (INT_TO_LREAL(iGZ) + lrOffsetGZ) / 16.4; END_IF lrTemp := (UINT_TO_INT(uiTemp) + LREAL#12412) / LREAL#340.0; END_IF Magnet.AfterReadInputs();</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="Calibrate"> <interface /> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">lrOffsetGX := 0; lrOffsetGY := 0; lrOffsetGZ := 0; iCounter := 0; _iState := 9;</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> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This method can be overloaded by extending FBs. It is called once during initialization phase, before the PLC goes into "run". Always including a call of the base implementation with super^.Initialize(wModuleType, udiInstance, pConnector) Typically, parameter values from the configuration are read here.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.Initialize(wModuleType, dwInstance, pConnector); Magnet.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="#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)" /> <Library Name="#Standard" Namespace="Standard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Standard, * (System)" /> <addData /> </Libraries> </data> </addData> </project>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/I2C_SRF02.library.xml Bash bash (Bash)
<?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:04.7350592" /> <contentHeader name="Raspberry I2C SRF02" version="1.1.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 for SRF02 under Raspberry Pi</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">SRF02</property> <property name="Description" type="string">Library containing device support for SRF02 under Raspberry Pi</property> <property name="Placeholder" type="string">PlaceholderTemplate</property> <property name="Project" type="string">I2C_SRF02</property> <property name="Released" type="boolean">false</property> <property name="Title" type="string">Raspberry I2C SRF02</property> <property name="Version" type="version">1.1.0.0</property> <property name="library-category-list" type="library-category-list" /> </ProjectInformation> </data> </addData> </contentHeader> <types> <dataTypes /> <pous> <pou name="SRF02_Supersonic" pouType="functionBlock"> <interface> <inputVars> <variable name="lrMinDistance"> <type> <LREAL /> </type> <initialValue> <simpleValue value="0.15" /> </initialValue> </variable> <variable name="lrMaxDistance"> <type> <LREAL /> </type> <initialValue> <simpleValue value="16" /> </initialValue> </variable> </inputVars> <outputVars> <variable name="lrDistance"> <type> <LREAL /> </type> <initialValue> <simpleValue value="-1" /> </initialValue> </variable> <variable name="xValid"> <type> <BOOL /> </type> </variable> <variable name="xNewMeasurement"> <type> <BOOL /> </type> </variable> </outputVars> <localVars> <variable name="timer"> <type> <derived name="TON" /> </type> <initialValue> <structValue> <value member="IN"> <simpleValue value="TRUE" /> </value> </structValue> </initialValue> </variable> </localVars> <addData> <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> <Inheritance> <Extends>i2c</Extends> </Inheritance> </data> </addData> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">xNewMeasurement := FALSE; SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#70; END_IF IF SUPER^.init() THEN _iState := 5; END_IF 5: Timer.pt := T#70MS; _iState := 10; xValid := FALSE; 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="Buffer"> <type> <array> <dimension lower="0" upper="3" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> <variable name="len"> <type> <DINT /> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.AfterReadInputs(); IF _iState = 10 THEN timer(IN:=TRUE); IF timer.Q THEN len := Read(ADR(Buffer), 4); IF len = 4 THEN lrDistance := BYTE_TO_LREAL(Buffer[2])*0.01 + BYTE_TO_LREAL(Buffer[3]) * 2.56; xValid := (lrDistance &gt;= lrMinDistance AND lrDistance &lt;= lrMaxDistance); xNewMeasurement := TRUE; ELSE xValid := FALSE; END_IF Write8(0, 16#51); //new measurement timer(IN:=FALSE); END_IF 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> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^.BeforeWriteOutputs(); </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="#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="#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>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/I2C_AdafruitPWM.library.md Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?>--- ~~~ST FUNCTION_BLOCK AdafruitPwm EXTENDS i2c VAR_INPUT alrPWM: ARRAY [..] OF ; axEnable: ARRAY [..] OF ; END_VAR VAR _freq: UINT; _usiSMAxes: USINT; _rPeriod: LREAL; _alrOldPWM: ARRAY [..] OF ; _alrMin: ARRAY [..] OF ; _alrMax: ARRAY [..] OF ; END_VAR VAR_TEMP i: USINT; usi: USINT; END_VAR ~~~ ~~~ST SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#40; END_IF IF SUPER^.init() THEN _iState := 5; END_IF 5: write8(PCA9685_MODE1, 16#10); // go to sleep usi := LREAL_TO_USINT(25000000 / 4096.0 / 0.88 (*0.88 after check with oszi*) / _freq) - 1; write8(PCA9685_PRESCALE, usi); // set the prescaler _rPeriod := LREAL#1.0 / _freq * 1000; //Periode in ms _iState := 6; 6: write8(PCA9685_MODE1, 16#A0); // This sets the MODE1 register to turn on auto increment. FOR i := 0 TO 15 DO _alrOldPWM[i] := -1; END_FOR _iState := 10; END_CASE ~~~ --- ~~~ST METHOD BeforeWriteOutputs: INT VAR i: USINT; END_VAR ~~~ ~~~ST SUPER^.BeforeWriteOutputs(); IF _iState = 10 THEN FOR i:=0 TO 15 DO IF alrPWM[i] &lt;&gt; _alrOldPWM[i] AND axEnable[i] &gt; 0 THEN setPWM(i, alrPWM[i]); _alrOldPWM[i] := alrPWM[i]; END_IF END_FOR END_IF ~~~ --- ~~~ST METHOD Initialize: UDINT VAR_INPUT wModuleType: UINT; dwInstance: UDINT; pConnector: pointer; END_VAR VAR pParam: pointer; udiResult: UDINT; END_VAR ~~~ ~~~ST SUPER^.Initialize(wModuleType, dwInstance, pConnector); pParam := ConfigGetParameter(_pConnector, 2); IF pParam &lt;&gt; 0 THEN _freq := IoStandard.ConfigGetParameterValueWord(pParam, ADR(udiResult)); END_IF (* no longer supported pParam := ConfigGetParameter(_pConnector, 3); IF pParam &lt;&gt; 0 THEN _usiUsedOutputs := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF *) pParam := ConfigGetParameter(_pConnector, 1); IF pParam &lt;&gt; 0 THEN //store own pointer in this param pParam^.dwDriverSpecific := THIS; END_IF _usiSMAxes := 0; ~~~ --- ~~~ST METHOD setPWMRaw: VAR_INPUT usiChannel: USINT; ui: UINT; END_VAR VAR aby: ARRAY [..] OF ; END_VAR ~~~ ~~~ST aby[0] := LED0_ON_L + 4*usiChannel; aby[3] := UINT_TO_USINT(ui); aby[4] := UINT_TO_USINT(ui/256); write(ADR(aby), 5); ~~~ --- ~~~ST METHOD setPWM: VAR_INPUT usiChannel: USINT; rValue: LREAL; END_VAR VAR aby: ARRAY [..] OF ; ui: UINT; END_VAR ~~~ ~~~ST aby[0] := LED0_ON_L + 4 * usiChannel; ui := LREAL_TO_UINT((_alrMin[usiChannel] + LIMIT(0, rValue, 1) * (_alrMax[usiChannel] - _alrMin[usiChannel])) / _rPeriod * 4096 - 1); aby[3] := UINT_TO_USINT(ui); aby[4] := UINT_TO_USINT(ui/256); write(ADR(aby), 5); ~~~ --- ~~~ST METHOD RegisterAxis: USINT ~~~ ~~~ST IF _usiSMAxes &lt; 16 THEN RegisterAxis := _usiSMAxes; _usiSMAxes := _usiSMAxes + 1; ELSE RegisterAxis := 255; END_IF ~~~ --- ~~~ST METHOD setPWMRange: VAR_INPUT usiChannel: USINT; alrMin: LREAL; alrMax: LREAL; END_VAR ~~~ ~~~ST IF usiChannel &lt; 16 THEN _alrMin[usiChannel] := alrMin; _alrMax[usiChannel] := alrMax; END_IF ~~~ VAR_GLOBAL PCA9685_MODE1: USINT; PCA9685_PRESCALE: USINT; LED0_ON_L: USINT; LED0_ON_H: USINT; LED0_OFF_L: USINT; LED0_OFF_H: USINT; END_VAR
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Devices/SPIMaster.devdesc.xml Bash bash (Bash)
<?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Bernhard Reiterer (3S-Smart Software Solutions GmbH) --> <DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd"> <Device> <DeviceIdentification> <Type>497</Type> <Id>0000 0000</Id> <Version>1.0.0.0</Version> </DeviceIdentification> <DeviceInfo> <Name name="local:typename">SPI master</Name> <Description name="local:typedescription">SPI master</Description> <Vendor name="local:3S">3S - Smart Software Solutions GmbH</Vendor> <OrderNumber>-</OrderNumber> </DeviceInfo> <Connector connectorId="1" moduleType="497" interface="Raspberry.SPIMaster" role="child" hostpath="-1"> <InterfaceName name="local:SPImaster">SPI master</InterfaceName> <Slot allowEmpty="false" count="1"/> <DriverInfo needsBusCycle="false"> <RequiredLib libname="Raspberry Pi Peripherals" vendor="3S - Smart Software Solutions GmbH" identifier="deviceLib" placeholderlib="Raspberry Pi Peripherals"> <FBInstance basename="$(DeviceName)" fbname="spiMaster"> <Initialize methodName="Initialize"/> </FBInstance> </RequiredLib> </DriverInfo> <HostParameterSet> <Parameter ParameterId="1" type="std:BOOL"> <Attributes offlineaccess="none" download="true" functional="false"/> <Default>FALSE</Default> <Name name="local:HiddenPointerToOwnInstance">HiddenPointerToOwnInstance</Name> <Description name="local:HiddenPointerToOwnInstance">HiddenPointerToOwnInstance</Description> </Parameter> <Parameter ParameterId="10" type="std:STRING"> <Attributes channel="none" download="true" functional="false" onlineaccess="read"/> <Default>'/dev/spidev0.0'</Default> <Name name="local:Id393218">SPI port</Name> <Description name="local:Id393218.Desc">file path of the SPI port</Description> </Parameter> <Parameter ParameterId="11" type="std:DINT"> <Attributes channel="none" download="true" functional="false" onlineaccess="read"/> <Default>0</Default> <Name name="local:Id393218">_diMode</Name> <Description name="local:Id393218.Desc">SPI mode</Description> </Parameter> <Parameter ParameterId="12" type="std:DINT"> <Attributes channel="none" download="true" functional="false" onlineaccess="read"/> <Default>0</Default> <Name name="local:Id393218">_diBitsPerWord</Name> <Description name="local:Id393218.Desc">SPI bits per word</Description> </Parameter> <Parameter ParameterId="13" type="std:DINT"> <Attributes channel="none" download="true" functional="false" onlineaccess="read"/> <Default>0</Default> <Name name="local:Id393218">_diMaxSpeed</Name> <Description name="local:Id393218.Desc">SPI max speed setting [Hz]</Description> </Parameter> </HostParameterSet> </Connector> <Connector connectorId="2" moduleType="501" interface="Raspberry.SPI" role="parent" hostpath="1" initialStatusFlag="241"> <InterfaceName name="local:SPIdevices">SPI devices</InterfaceName> <Var /> </Connector> </Device> </DeviceDescription>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Devices/StandardParameters.xml Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?> <ParameterSection> <Name name="local:AXIS_REF">AXIS_REF: Standard</Name> <Parameter ParameterId="1021" type="std:WORD"> <Attributes download="true" functional="false" /> <Default>1</Default> <Name name="x">wDriveID</Name> <Description name="x">Unique ID of the drive</Description> <Custom /> </Parameter> <Parameter ParameterId="1040" type="std:BOOL"> <Attributes download="true" functional="false" /> <Default>FALSE</Default> <Name name="x">bVirtual</Name> <Description name="x">Whether the drive is simulated</Description> <Custom /> </Parameter> <Parameter ParameterId="1060" type="std:INT"> <Attributes download="true" functional="false" /> <Default>1</Default> <Name name="x">iMovementType</Name> <Description name="x">Movement type: 0: modulo, 1: finite</Description> <Custom /> </Parameter> <Parameter ParameterId="1061" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>360.0</Default> <Name name="x">fPositionPeriod</Name> <Description name="x">Modulo period value for modulo drives [u]</Description> <Custom /> </Parameter> <Parameter ParameterId="1205" type="std:BOOL"> <Attributes download="true" functional="false" /> <Default>FALSE</Default> <Name name="x">bSWLimitEnable</Name> <Description name="x">Activate/deactivate software limits</Description> <Custom /> </Parameter> <Parameter ParameterId="1201" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>0.0</Default> <Name name="x">fSWLimitNegative</Name> <Description name="x">Software limit in negative direction</Description> <Custom /> </Parameter> <Parameter ParameterId="1200" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>1000.0</Default> <Name name="x">fSWLimitPositive</Name> <Description name="x">Software limit in positive direction</Description> <Custom /> </Parameter> <Parameter ParameterId="1062" type="std:INT"> <Attributes download="true" functional="false" /> <Default>0</Default> <Name name="x">eRampType</Name> <Description name="x">The velocity ramp used for trajectories.</Description> <Custom /> </Parameter> <Parameter ParameterId="1144" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>0</Default> <Name name="x">fRampJerk</Name> <Description name="x">Jerk used for bringing acceleration to 0 when sin² ramp is interrupted.</Description> <Custom /> </Parameter> <Parameter ParameterId="1113" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>30</Default> <Name name="x">fSWMaxVelocity</Name> <Description name="x">Maximum velocity magnitude (software limit)</Description> <Custom /> </Parameter> <Parameter ParameterId="1123" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>1000</Default> <Name name="x">fSWMaxAcceleration</Name> <Description name="x">Maximum acceleration magnitude (software limit)</Description> <Custom /> </Parameter> <Parameter ParameterId="1133" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>1000</Default> <Name name="x">fSWMaxDeceleration</Name> <Description name="x">Maximum deceleration magnitude (software limit)</Description> <Custom /> </Parameter> <Parameter ParameterId="1143" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>10000</Default> <Name name="x">fSWMaxJerk</Name> <Description name="x">Maximum jerk magnitude (software limit)</Description> <Custom /> </Parameter> <Parameter ParameterId="1207" type="std:INT"> <Attributes download="true" functional="false" /> <Default>0</Default> <Name name="x">eCheckPositionLag</Name> <Description name="x">Position lag mode</Description> <Custom /> </Parameter> <Parameter ParameterId="1208" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>1.0</Default> <Name name="x">fMaxPositionLag</Name> <Description name="x">Maximum position lag (magnitude) [u]</Description> <Custom /> </Parameter> <Parameter ParameterId="1203" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>0</Default> <Name name="x">fSWLimitDeceleration</Name> <Description name="x">Deceleration for stop on software error [u/s²]</Description> <Custom /> </Parameter> <Parameter ParameterId="1250" type="std:LREAL"> <Attributes download="true" functional="false" /> <Default>0</Default> <Name name="x">fSWErrorMaxDistance</Name> <Description name="x">Maximum distance that may be travelled for ramping down after a software error has been detected [u]</Description> <Custom /> </Parameter> </ParameterSection>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Devices/SRF02.devdesc.xml Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?> <!--created with CoDeSys 3.0 (http://www.3s-software.com) by DeviceDescriptionBuilder (3S-Smart Software Solutions GmbH)--> <DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd" xmlns:ts="http://www.3s-software.com/schemas/TargetSettings-0.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Types namespace="local"> </Types> <Strings namespace="local"> <Language lang="en"> </Language> </Strings> <!-- <Files namespace="local"> <Language lang="en"> <File fileref="local" identifier="JoystickIcon"> <LocalFile>Joystick.ico</LocalFile> </File> </Language> </Files>--> <Device hideInCatalogue="false"> <DeviceIdentification> <Type>500</Type> <Id>0000 0003</Id> <Version>1.1.0.0</Version> </DeviceIdentification> <DeviceInfo> <Name name="local:ModelName">SRF02</Name> <Description name="local:DeviceDescription">Distance sensor SRF02</Description> <Vendor name="local:VendorName">3S - Smart Software Solutions GmbH</Vendor> <OrderNumber>-</OrderNumber> <!-- <Icon name="local:JoystickIcon">Joystick.ico</Icon> --> </DeviceInfo> <Connector moduleType="500" interface="Raspberry.I2C" role="child" explicit="false" connectorId="1" hostpath="-1"> <InterfaceName name="local:PCI">I²C-Bus</InterfaceName> <Slot count="1" allowEmpty="false"> </Slot> <DriverInfo needsBusCycle="false"> <RequiredLib libname="Raspberry I2C SRF02" vendor="3S - Smart Software Solutions GmbH" version="1.1.0.0" identifier="deviceLib"> <FBInstance basename="$(DeviceName)" fbname="SRF02_Supersonic"> <Initialize methodName="Initialize" /> <CyclicCall methodname="AfterReadInputs" task="#buscycletask" whentocall="afterReadInputs" /> </FBInstance> </RequiredLib> </DriverInfo> <HostParameterSet> <Parameter ParameterId="1" type="std:USINT"> <Attributes channel="none" download="true" functional="false" onlineaccess="read" /> <Default>0</Default> <Name name="local:Id393218">I²C address</Name> <Description name="local:Id393218.Desc">Address of the device</Description> </Parameter> </HostParameterSet> </Connector> </Device> </DeviceDescription>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Devices/SenseHat.devdesc.xml Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?> <!--created with CoDeSys 3.0 (http://www.3s-software.com) by DeviceDescriptionBuilder (3S-Smart Software Solutions GmbH)--> <DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd" xmlns:ts="http://www.3s-software.com/schemas/TargetSettings-0.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Types namespace="local"> </Types> <Strings namespace="local"> <Language lang="en"> </Language> </Strings> <!-- <Files namespace="local"> <Language lang="en"> <File fileref="local" identifier="JoystickIcon"> <LocalFile>Joystick.ico</LocalFile> </File> </Language> </Files>--> <Device hideInCatalogue="false"> <DeviceIdentification> <Type>500</Type> <Id>0000 0007</Id> <Version>3.5.12.0</Version> </DeviceIdentification> <DeviceInfo> <Name name="local:ModelName">Sense Hat</Name> <Description name="local:DeviceDescription">Sense Hat extension for Raspberry Pi</Description> <Vendor name="local:VendorName">3S - Smart Software Solutions GmbH</Vendor> <OrderNumber>-</OrderNumber> <!-- <Icon name="local:JoystickIcon">Joystick.ico</Icon> --> </DeviceInfo> <Connector moduleType="500" interface="Raspberry.I2C" role="child" explicit="false" connectorId="1" hostpath="-1"> <InterfaceName name="local:PCI">I²C-Bus</InterfaceName> <Slot count="1" allowEmpty="false"> </Slot> <DriverInfo needsBusCycle="false"> <RequiredLib libname="Sense Hat" vendor="3S - Smart Software Solutions GmbH" version="3.5.12.0" identifier="deviceLib"> <FBInstance basename="$(DeviceName)" fbname="SenseHat"> <Initialize methodName="Initialize" /> <CyclicCall methodname="AfterReadInputs" task="#buscycletask" whentocall="afterReadInputs" /> <CyclicCall methodname="BeforeWriteOutputs" task="#buscycletask" whentocall="beforeWriteOutputs" /> </FBInstance> </RequiredLib> </DriverInfo> </Connector> </Device> </DeviceDescription>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/SenseHat.library.xml Bash bash (Bash)
<?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:06.5505205" /> <contentHeader name="Sense Hat" version="3.5.12.0" modificationDateTime="2017-12-15T05:12:32" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH"> <Comment>Library containing device support for the Sense Hat under Raspberry Pi.</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">SenseHat</property> <property name="Description" type="string">Library containing device support for the Sense Hat under Raspberry Pi.</property> <property name="DocFormat" type="string">reStructuredText</property> <property name="IsEndUserLibrary" type="boolean">false</property> <property name="LanguageModelAttribute" type="string">qualified-access-only</property> <property name="Placeholder" type="string">SenseHat</property> <property name="Project" type="string">SenseHat</property> <property name="Released" type="boolean">true</property> <property name="SourceLibrary" type="boolean">true</property> <property name="Title" type="string">Sense Hat</property> <property name="Version" type="version">3.5.12.0</property> <property name="library-category-list" type="library-category-list">Target</property> </ProjectInformation> </data> </addData> </contentHeader> <types> <dataTypes> <dataType name="JoystickEvent"> <baseType> <enum> <values> <value name="EV_KEY" value="1" /> <value name="NONE" value="0" /> </values> <baseType> <WORD /> </baseType> </enum> </baseType> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="qualified_only" Value="" /> <Attribute Name="strict" Value="" /> </Attributes> </data> </addData> </dataType> <dataType name="JoystickInput"> <baseType> <struct> <variable name="dwTimeSec"> <type> <DWORD /> </type> </variable> <variable name="dwTimeUSec"> <type> <DWORD /> </type> </variable> <variable name="eEvent"> <type> <derived name="JoystickEvent" /> </type> </variable> <variable name="eKey"> <type> <derived name="JoystickKey" /> </type> </variable> <variable name="eState"> <type> <derived name="JoystickState" /> </type> </variable> </struct> </baseType> <addData /> </dataType> <dataType name="JoystickKey"> <baseType> <enum> <values> <value name="KEY_UP" value="103" /> <value name="KEY_LEFT" value="105" /> <value name="KEY_RIGHT" value="106" /> <value name="KEY_DOWN" value="108" /> <value name="KEY_ENTER" value="28" /> <value name="NONE" value="0" /> </values> <baseType> <WORD /> </baseType> </enum> </baseType> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="qualified_only" Value="" /> <Attribute Name="strict" Value="" /> </Attributes> </data> </addData> </dataType> <dataType name="JoystickState"> <baseType> <enum> <values> <value name="STATE_RELEASE" value="0" /> <value name="STATE_PRESS" value="1" /> <value name="STATE_HOLD" value="2" /> </values> <baseType> <WORD /> </baseType> </enum> </baseType> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="qualified_only" Value="" /> <Attribute Name="strict" Value="" /> </Attributes> </data> </addData> </dataType> </dataTypes> <pous> <pou name="SenseHat" pouType="functionBlock"> <interface> <inputVars> <variable name="adwPixel"> <type> <array> <dimension lower="0" upper="63" /> <baseType> <DWORD /> </baseType> </array> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Pixel array for LED-Output of Sensehat (0..7 Row 1, 8..17 Row 2, etc.). Use 32Bit ARGB color coding to set the color of each pixel.</xhtml> </documentation> </variable> <variable name="xUpdatePixel"> <type> <BOOL /> </type> <initialValue> <simpleValue value="TRUE" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Update Pixel Output: default TRUE</xhtml> </documentation> </variable> <variable name="xUpdateJoystick"> <type> <BOOL /> </type> <initialValue> <simpleValue value="TRUE" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Update Joystick Input: default TRUE</xhtml> </documentation> </variable> <variable name="xUpdateLSM9DS1"> <type> <BOOL /> </type> <initialValue> <simpleValue value="TRUE" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Update LSM9DS1 Input: default TRUE</xhtml> </documentation> </variable> <variable name="xUpdateHTS221"> <type> <BOOL /> </type> <initialValue> <simpleValue value="TRUE" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Update HTS221 Input: default TRUE</xhtml> </documentation> </variable> <variable name="xUpdateLPS25H"> <type> <BOOL /> </type> <initialValue> <simpleValue value="TRUE" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Update LPS25H Input: default TRUE</xhtml> </documentation> </variable> </inputVars> <outputVars> <variable name="xJoystickUp"> <type> <BOOL /> </type> <initialValue> <simpleValue value="FALSE" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Joystick input interpretated in senses of the given booleans</xhtml> </documentation> </variable> <variable name="xJoystickDown"> <type> <BOOL /> </type> <initialValue> <simpleValue value="FALSE" /> </initialValue> </variable> <variable name="xJoystickLeft"> <type> <BOOL /> </type> <initialValue> <simpleValue value="FALSE" /> </initialValue> </variable> <variable name="xJoystickRight"> <type> <BOOL /> </type> <initialValue> <simpleValue value="FALSE" /> </initialValue> </variable> <variable name="xJoystickEnter"> <type> <BOOL /> </type> <initialValue> <simpleValue value="FALSE" /> </initialValue> </variable> <variable name="rTemperatureHTS221"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Temperature of HTS221 in degree celcius (°C).</xhtml> </documentation> </variable> <variable name="rHumidity"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Humidity of HTS221 in percent of 100 (%).</xhtml> </documentation> </variable> <variable name="rTemperatureLPS25H"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Temperature of LPS25H in degree celcius (°C).</xhtml> </documentation> </variable> <variable name="lrPressure"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Pressure of LPS25H in hecto pascal (hPA).</xhtml> </documentation> </variable> <variable name="rGyroX"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Gyroscope X direction data of LSM9DS1 (dps - degree per second)</xhtml> </documentation> </variable> <variable name="rGyroY"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Gyroscope Y direction data of LSM9DS1 (dps - degree per second)</xhtml> </documentation> </variable> <variable name="rGyroZ"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Gyroscope Z direction data of LSM9DS1 (dps - degree per second)</xhtml> </documentation> </variable> <variable name="rAccelX"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Acceleration X direction data of LSM9DS1 (G ~ 9,81 m/s^2)</xhtml> </documentation> </variable> <variable name="rAccelY"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Acceleration Y direction data of LSM9DS1 (G ~ 9,81 m/s^2)</xhtml> </documentation> </variable> <variable name="rAccelZ"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Acceleration Z direction data of LSM9DS1 (G ~ 9,81 m/s^2)</xhtml> </documentation> </variable> <variable name="rCompX"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Compass X direction data of LSM9DS1 (microTesla)</xhtml> </documentation> </variable> <variable name="rCompY"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Compass Y direction data of LSM9DS1 (microTesla)</xhtml> </documentation> </variable> <variable name="rCompZ"> <type> <REAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Compass Z direction data of LSM9DS1 (microTesla)</xhtml> </documentation> </variable> </outputVars> <localVars> <variable name="_sFilePixel"> <type> <string length="80" /> </type> </variable> <variable name="_sFileJoy"> <type> <string length="80" /> </type> </variable> <variable name="_sName"> <type> <string length="80" /> </type> </variable> <variable name="_hJoystickFile"> <type> <derived name="RTS_IEC_HANDLE" /> </type> <initialValue> <simpleValue value="RTS_INVALID_HANDLE" /> </initialValue> </variable> <variable name="_Joystick"> <type> <derived name="JoystickInput" /> </type> </variable> <variable name="_awWordPixel"> <type> <array> <dimension lower="0" upper="63" /> <baseType> <WORD /> </baseType> </array> </type> </variable> <variable name="_Timer100"> <type> <derived name="TON" /> </type> <initialValue> <structValue> <value member="IN"> <simpleValue value="TRUE" /> </value> <value member="pt"> <simpleValue value="TIME#100ms" /> </value> </structValue> </initialValue> </variable> <variable name="_rTemperature_S"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_rTemperature_C"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_rHumidity_S"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_rHumidity_C"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_usiMagAddress"> <type> <USINT /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_rGyroScale"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_rAccelScale"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_rMagScale"> <type> <REAL /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> </localVars> <tempVars> <variable name="_i"> <type> <INT /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="_hFile"> <type> <derived name="RTS_IEC_HANDLE" /> </type> <initialValue> <simpleValue value="RTS_INVALID_HANDLE" /> </initialValue> </variable> <variable name="_diResult"> <type> <DINT /> </type> </variable> <variable name="_xResult"> <type> <BOOL /> </type> </variable> <variable name="_abyData"> <type> <array> <dimension lower="0" upper="7" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> <variable name="_uiT0_C_8"> <type> <UINT /> </type> </variable> <variable name="_uiT1_C_8"> <type> <UINT /> </type> </variable> <variable name="_byH0_H_2"> <type> <BYTE /> </type> </variable> <variable name="_byH1_H_2"> <type> <BYTE /> </type> </variable> <variable name="_iT0_OUT"> <type> <INT /> </type> </variable> <variable name="_iT1_OUT"> <type> <INT /> </type> </variable> <variable name="_iH0_T0_OUT"> <type> <INT /> </type> </variable> <variable name="_iH1_T0_OUT"> <type> <INT /> </type> </variable> <variable name="_rT0"> <type> <REAL /> </type> </variable> <variable name="_rT1"> <type> <REAL /> </type> </variable> <variable name="_rH0"> <type> <REAL /> </type> </variable> <variable name="_rH1"> <type> <REAL /> </type> </variable> </tempVars> <addData> <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> <Inheritance> <Extends>i2c</Extends> </Inheritance> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">This Function Block is instanciated along with the Sense Hat device of the raspberry PI. It's inputs and outputs allow to easily access the sensors, inputs and LED outputs of the Sense Hat Device.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^(); CASE _iState OF 0: //Pixel map _sName := ''; {analysis -26} FOR _i := 0 TO 10 DO _sFilePixel := CONCAT('/sys/class/graphics/fb', INT_TO_STRING(_i)); _sFilePixel := CONCAT(_sFilePixel, '/name'); {analysis -130} _hFile := CmpCharDevice.CDOpen(_sFilePixel, CmpCharDevice.ACCESS_MODE.O_RDONLY, ADR(_diResult)); {analysis +130} IF NOT(_hFile = RTS_INVALID_HANDLE) THEN {analysis -19} _diResult := CmpCharDevice.CDRead(_hFile, ADR(_sName), 12, ADR(_diResult)); {analysis +19} _diResult := CmpCharDevice.CDClose(_hFile, ADR(_diResult)); IF _sName = 'RPi-Sense FB' THEN _sFilePixel := CONCAT('/dev/fb', INT_TO_STRING(_i)); EXIT; END_IF END_IF END_FOR {analysis +26} _iState := 10; 10: //Joystick Input _sName := ''; {analysis -26} FOR _i := 0 TO 10 DO _sFileJoy := CONCAT('/sys/class/input/event', INT_TO_STRING(_i)); _sFileJoy := CONCAT(_sFileJoy, '/device/name'); {analysis -130} _hFile := CmpCharDevice.CDOpen(_sFileJoy, CmpCharDevice.ACCESS_MODE.O_RDONLY, ADR(_diResult)); {analysis +130} IF NOT(_hFile = RTS_INVALID_HANDLE) THEN {analysis -19} _diResult := CmpCharDevice.CDRead(_hFile, ADR(_sName), 31, ADR(_diResult)); {analysis +19} _diResult := CmpCharDevice.CDClose(_hFile, ADR(_diResult)); IF _sName = 'Raspberry Pi Sense HAT Joystick' THEN _sFileJoy := CONCAT('/dev/input/event', INT_TO_STRING(_i)); EXIT; END_IF END_IF END_FOR {analysis +26} _iState := 20; 20: //Humidity and Temperature HTS221 usiAddress := 16#5F; //Power up and set sample rate _xResult := write8(16#20, 2#10000110); //Pressure and Temperature LPS25H usiAddress := 16#5C; //Reset _xResult := write8(16#20, 2#10100100); //Gyro- and Accelereometer LSM9DS1 usiAddress := 16#6A; //Reset _xResult := write8(16#22, 2#11000000); _iState := 25; 25: //Short waiting for the actions done in state 40 to //be done by the sense hat _Timer100(IN:=TRUE); IF _Timer100.Q THEN _Timer100(IN:=FALSE); _iState := 30; END_IF 30: //Humidity- and Temperature HTS221 usiAddress := 16#5F; //Configure Averaging _xResult := write8(16#10, 2#000101011); // Get calibration data // Temperature Calibration {analysis -52} IF ReadRegister(16#35, ADR(_abyData[1]), 1) = 1 THEN // + 16#80 ? IF ReadRegister(16#32, ADR(_abyData), 1) = 1 THEN _uiT0_C_8 := SHL(BYTE_TO_UINT(_abyData[1] AND 16#3), 8) OR BYTE_TO_UINT(_abyData[0]); _rT0 := UINT_TO_REAL(_uiT0_C_8) / 8; END_IF END_IF IF ReadRegister(16#33, ADR(_abyData), 1) = 1 THEN _uiT1_C_8 := SHL(BYTE_TO_UINT(_abyData[1] AND 16#C), 6) OR BYTE_TO_UINT(_abyData[0]); _rT1 := UINT_TO_REAL(_uiT1_C_8) / 8; END_IF IF ReadRegister(16#3C, ADR(_abyData[0]), 1) = 1 AND ReadRegister(16#3D, ADR(_abyData[1]), 1) = 1 THEN _iT0_OUT := UINT_TO_INT(SHL(BYTE_TO_UINT(_abyData[1]), 8) OR BYTE_TO_UINT(_abyData[0])); END_IF IF ReadRegister(16#3E, ADR(_abyData[0]), 1) = 1 AND ReadRegister(16#3F, ADR(_abyData[1]), 1) = 1 THEN _iT1_OUT := UINT_TO_INT(SHL(BYTE_TO_UINT(_abyData[1]), 8) OR BYTE_TO_UINT(_abyData[0])); END_IF // Humidity Calibration IF ReadRegister(16#30, ADR(_byH0_H_2), 1) = 1 THEN _rH0 := BYTE_TO_REAL(_byH0_H_2) / 2; END_IF IF ReadRegister(16#31, ADR(_byH1_H_2), 1) = 1 THEN _rH1 := BYTE_TO_REAL(_byH1_H_2) / 2; END_IF IF ReadRegister(16#36, ADR(_abyData[0]), 1) = 1 AND ReadRegister(16#37, ADR(_abyData[1]), 1) = 1 THEN _iH0_T0_OUT := UINT_TO_INT(SHL(BYTE_TO_UINT(_abyData[1]), 8) OR BYTE_TO_UINT(_abyData[0])); END_IF IF ReadRegister(16#3A, ADR(_abyData[0]), 1) = 1 AND ReadRegister(16#3B, ADR(_abyData[1]), 1) = 1 THEN _iH1_T0_OUT := UINT_TO_INT(SHL(BYTE_TO_UINT(_abyData[1]), 8) OR BYTE_TO_UINT(_abyData[0])); END_IF {analysis +52} {analysis -66} {analysis -40} IF _iT1_OUT-_iT0_OUT &lt;&gt; 0 THEN _rTemperature_S := (_rT1-_rT0)/INT_TO_REAL(_iT1_OUT-_iT0_OUT); END_IF _rTemperature_C := _rT0-(_rTemperature_S*INT_TO_REAL(_iT0_OUT)); IF _iH1_T0_OUT-_iH0_T0_OUT &lt;&gt; 0 THEN _rHumidity_S := (_rH1-_rH0)/INT_TO_REAL(_iH1_T0_OUT-_iH0_T0_OUT); END_IF _rHumidity_C := (_rH0)-(_rHumidity_S*INT_TO_REAL(_iH0_T0_OUT)); {analysis +40} {analysis +66} _iState := 40; 40: //Pressure and Temperature LPS25H usiAddress := 16#5C; //Configure Averaging _xResult := write8(16#10, 2#00001010); //Configure FIFO _xResult := write8(16#2E, 2#00000000); //Set FIFO mode _xResult := write8(16#21, 2#01000000); _iState := 45; 45: //Short waiting for the actions done in state 40 to //be done by the sense hat _Timer100(IN:=TRUE); IF _Timer100.Q THEN _Timer100(IN:=FALSE); _iState := 50; END_IF 50: //Magnetsensor LSM9DS1 //Find out Mag-Address usiAddress := 16#1C; IF ReadRegister(16#0F, ADR(_abyData[0]), 1) = 1 AND _abyData[0] = 16#3D THEN _usiMagAddress := usiAddress; ELSE usiAddress := 16#1D; IF ReadRegister(16#0F, ADR(_abyData[0]), 1) = 1 AND _abyData[0] = 16#3D THEN _usiMagAddress := usiAddress; ELSE usiAddress := 16#1E; IF ReadRegister(16#0F, ADR(_abyData[0]), 1) = 1 AND _abyData[0] = 16#3D THEN _usiMagAddress := usiAddress; ELSE usiAddress := 16#1F; IF ReadRegister(16#0F, ADR(_abyData[0]), 1) = 1 AND _abyData[0] = 16#3D THEN _usiMagAddress := usiAddress; END_IF END_IF END_IF END_IF //Gyro LSM9DS1 usiAddress := 16#6A; //Gyro set bandwidth and rate and scale //500dps --&gt; Scale 0.07 _xResult := write8(16#10, 2#01001011); _rGyroScale := 0.0175; //Gyro activate HP filter _xResult := write8(16#12, 2#01000100); //Accel LSM9DS1 usiAddress := 16#6A; //Accel set bandwidth and rate and scale _xResult := write8(16#20, 2#01110000); _rAccelScale := 0.000122; //Accel set no filters _xResult := write8(16#21, 2#00000000); //Mag LSM9DS1 usiAddress := _usiMagAddress; //Mag set sample rate _xResult := write8(16#20, 2#00010000); //Mag set scale _xResult := write8(16#21, 2#01000000); _rMagScale := 0.029; //Mag set continuous conversion mode _xResult := write8(16#22, 2#00000000); _iState := 100; ELSE _iState := 100; END_CASE</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> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> TRUE: The exit method is called in order to leave the instance, which will be copied afterwards (Online-Change). </xhtml> </documentation> </variable> </inputVars> <localVars> <variable name="diResult"> <type> <DINT /> </type> </variable> <variable name="diFunRes"> <type> <DINT /> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">IF NOT(_hJoystickFile = RTS_INVALID_HANDLE) THEN diFunRes := CmpCharDevice.CDClose(_hJoystickFile, ADR(diResult)); _hJoystickFile := RTS_INVALID_HANDLE; 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="diResult"> <type> <DINT /> </type> </variable> <variable name="diFunRes"> <type> <DINT /> </type> </variable> <variable name="byStatus"> <type> <BYTE /> </type> </variable> <variable name="abyData"> <type> <array> <dimension lower="0" upper="7" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> <variable name="iData"> <type> <INT /> </type> </variable> <variable name="diData"> <type> <DINT /> </type> </variable> <variable name="pbyE"> <type> <pointer> <baseType> <BYTE /> </baseType> </pointer> </type> <initialValue> <simpleValue value="ADR('E')" /> </initialValue> </variable> <variable name="xSet"> <type> <BOOL /> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">AfterReadInputs := SUPER^.AfterReadInputs(); IF _iState = 100 THEN //Joystick Readout IF xUpdateJoystick THEN IF _hJoystickFile = RTS_INVALID_HANDLE THEN {analysis -58} {analysis -130} _hJoystickFile := CmpCharDevice.CDOpen(_sFileJoy, CmpCharDevice.ACCESS_MODE.O_RDONLY + DINT#4000 (* CmpCharDevice.ACCESS_MODE.O_NONBLOCK*), ADR(diResult)); {analysis +130} {analysis +58} END_IF (* Ioctl was used, when "Blocking-Read-Out" was done: --&gt; EVIOCGKEY(len) for testing if joystick data is available; we need to call Ioctl with an ADR operator so disable the corresponding compiler warning {warning disable C0033} CmpCharDevice.CDIoctl(hFile, UDINT_TO_DINT(RASPI._IOC(2, pbyE^, 16#18, SIZEOF(ariData))), ADR(ariData), ADR(udiResult)); {warning restore C0033} IF udiResult = 0 AND ariData[1] + ariData[6] &gt; 0 THEN ... *) IF NOT(_hJoystickFile = RTS_INVALID_HANDLE) THEN diResult := 0; WHILE diResult = 0 DO {analysis -19} diFunRes := CmpCharDevice.CDRead(_hJoystickFile, ADR(_Joystick), SIZEOF(_Joystick), ADR(diResult)); {analysis +19} IF diResult &lt;&gt; 0 THEN //no data to read EXIT; END_IF IF _Joystick.eEvent = JoystickEvent.EV_KEY THEN xSet := FALSE; IF _Joystick.eState = JoystickState.STATE_PRESS THEN xSet := TRUE; ELSIF _Joystick.eState = JoystickState.STATE_RELEASE THEN xSet := FALSE; ELSE CONTINUE; END_IF ///Set booleans {analysis -75} {analysis -76} CASE _Joystick.eKey OF JoystickKey.KEY_UP: xJoystickUp := xSet; JoystickKey.KEY_DOWN: xJoystickDown := xSet; JoystickKey.KEY_LEFT: xJoystickLeft := xSet; JoystickKey.KEY_RIGHT: xJoystickRight:= xSet; JoystickKey.KEY_ENTER: xJoystickEnter := xSet; END_CASE {analysis +76} {analysis +75} END_IF END_WHILE END_IF ELSE IF NOT(_hJoystickFile = RTS_INVALID_HANDLE) THEN diFunRes := CmpCharDevice.CDClose(_hJoystickFile, ADR(diResult)); _hJoystickFile := RTS_INVALID_HANDLE; END_IF END_IF //Gyro, Accelerometer and Magnetometer LSM9DS1 IF xUpdateLSM9DS1 THEN //Gyro and Accelerometer {analysis -52} usiAddress := 16#6A; IF ReadRegister(16#17, ADR(byStatus), 1) = 1 THEN IF (byStatus AND 2) &gt; 0 THEN //Gyro data available IF ReadRegister(16#18, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#19, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rGyroX := INT_TO_REAL(iData) * _rGyroScale; END_IF IF ReadRegister(16#1A, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#1B, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rGyroY := INT_TO_REAL(iData) * _rGyroScale; END_IF IF ReadRegister(16#1C, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#1D, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rGyroZ := INT_TO_REAL(iData) * _rGyroScale; END_IF END_IF IF (byStatus AND 1) &gt; 0 THEN //Accel data available IF ReadRegister(16#28, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#29, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rAccelX := INT_TO_REAL(iData) * _rAccelScale; END_IF IF ReadRegister(16#2A, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#2B, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rAccelY := INT_TO_REAL(iData) * _rAccelScale; END_IF IF ReadRegister(16#2C, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#2D, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rAccelZ := INT_TO_REAL(iData) * _rAccelScale; END_IF END_IF END_IF //Magnetometer usiAddress := _usiMagAddress; IF ReadRegister(16#27, ADR(byStatus), 1) = 1 THEN IF (byStatus AND 1) &gt; 0 THEN IF ReadRegister(16#28, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#29, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rCompX := INT_TO_REAL(iData) * _rMagScale; END_IF END_IF IF (byStatus AND 2) &gt; 0 THEN IF ReadRegister(16#2A, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#2B, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rCompY := INT_TO_REAL(iData) * _rMagScale; END_IF END_IF IF (byStatus AND 4) &gt; 0 THEN IF ReadRegister(16#2C, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#2D, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rCompZ := INT_TO_REAL(iData) * _rMagScale; END_IF END_IF END_IF {analysis +52} END_IF //Pressure and Temperature LPS25h IF xUpdateLPS25H THEN {analysis -52} usiAddress := 16#5C; IF ReadRegister(16#27, ADR(byStatus), 1) = 1 THEN IF (byStatus AND 2) &gt; 0 THEN IF ReadRegister(16#28, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#29, ADR(abyData[1]), 1) = 1 AND ReadRegister(16#2A, ADR(abyData[2]), 1) = 1 THEN diData := UDINT_TO_DINT(SHL(BYTE_TO_UDINT(abyData[2]), 16) OR SHL(BYTE_TO_UDINT(abyData[1]), 8) OR BYTE_TO_UDINT(abyData[0])); lrPressure := DINT_TO_LREAL(diData) / 4096; END_IF END_IF IF (byStatus AND 1) &gt; 0 THEN IF ReadRegister(16#2B, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#2C, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rTemperatureLPS25H := INT_TO_REAL(iData) / 480 + 42.5; END_IF END_IF END_IF {analysis +52} END_IF //Humidity and Temperature HTS221 IF xUpdateHTS221 THEN usiAddress := 16#5F; {analysis -52} IF ReadRegister(16#27, ADR(byStatus), 1) = 1 THEN IF (byStatus AND 2) &gt; 0 THEN IF ReadRegister(16#28, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#29, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rHumidity := INT_TO_REAL(iData) * _rHumidity_S + _rHumidity_C; END_IF END_IF IF (byStatus AND 1) &gt; 0 THEN IF ReadRegister(16#2A, ADR(abyData[0]), 1) = 1 AND ReadRegister(16#2B, ADR(abyData[1]), 1) = 1 THEN iData := UINT_TO_INT(SHL(BYTE_TO_UINT(abyData[1]), 8) OR BYTE_TO_UINT(abyData[0])); rTemperatureHTS221 := INT_TO_REAL(iData) * _rTemperature_S + _rTemperature_C; END_IF END_IF END_IF {analysis +52} END_IF 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> <INT /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="hFile"> <type> <derived name="RTS_IEC_HANDLE" /> </type> <initialValue> <simpleValue value="RTS_INVALID_HANDLE" /> </initialValue> </variable> <variable name="diResult"> <type> <DINT /> </type> </variable> <variable name="diFunRes"> <type> <DINT /> </type> </variable> </localVars> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This method can be overloaded by extending FBs. It is used to write the outputs to the device at the end of the cycle. Always including a call of the base implementation with ``super^.BeforeWriteOutputs()`` In the base implementation, the body of the FB is called.</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">BeforeWriteOutputs := SUPER^.BeforeWriteOutputs(); IF _iState = 100 THEN //Pixel IF xUpdatePixel THEN //Convert 32Bit ARGB value to 16Bit RGB565 {analysis -52} FOR i := 0 TO 63 DO _awWordPixel[i] := UDINT_TO_WORD(SHL(SHR(adwPixel[i] AND 16#00FF0000, 16 + 3) AND 16#1F, 11) + //R SHL(SHR(adwPixel[i] AND 16#0000FF00, 8 + 2) AND 16#3F, 5) + //G (SHR(adwPixel[i] AND 16#000000FF, 3) AND 16#1F)); //B END_FOR {analysis +52} {analysis -130} hFile := CmpCharDevice.CDOpen(_sFilePixel, CmpCharDevice.ACCESS_MODE.O_WRONLY, ADR(diResult)); {analysis +130} IF NOT(hFile = RTS_INVALID_HANDLE) THEN {analysis -19} diFunRes := CmpCharDevice.CDWrite(hFile, ADR(_awWordPixel), 128, ADR(diResult)); {analysis +19} diFunRes := CmpCharDevice.CDClose(hFile, ADR(diResult)); END_IF END_IF END_IF</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/property" handleUnknown="implementation"> <Property name="Operational"> <interface> <returnType> <BOOL /> </returnType> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This property has to return ``TRUE``, when the device is configured and running</xhtml> </documentation> </interface> <GetAccessor> <interface> <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">Operational := (_iState=100);</xhtml> </ST> </body> <addData /> </GetAccessor> <addData /> </Property> </data> </addData> </pou> </pous> </types> <instances> <configurations /> </instances> <addData> <data name="http://www.3s-software.com/plcopenxml/libraries" handleUnknown="implementation"> <Libraries> <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)" /> <Library Name="#Standard" Namespace="Standard" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="Standard, * (System)" /> <Library Name="#CmpCharDevice" Namespace="CmpCharDevice" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="CmpCharDevice, * (3S - Smart Software Solutions GmbH)" /> <Library Name="SysTypes2 Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <Library Name="#SysTask" Namespace="SysTask" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" DefaultResolution="SysTask, * (System)" /> <addData /> </Libraries> </data> </addData> </project>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/SPI_MCP23S17.library.xml Bash bash (Bash)
<?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:07.5050027" /> <contentHeader name="Raspberry SPI MCP23S17" version="3.5.11.0" modificationDateTime="2017-07-03T23:33:28" organization="3S - Smart Software Solutions GmbH" author="3S - Smart Software Solutions GmbH"> <Comment>Library containing device support of MCP23S17</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">MCP23S17_Lib</property> <property name="Description" type="string">Library containing device support of MCP23S17</property> <property name="Placeholder" type="string">SPI MCP23S17</property> <property name="Project" type="string">SPI_MCP23S17</property> <property name="Released" type="boolean">true</property> <property name="Title" type="string">Raspberry SPI MCP23S17</property> <property name="Version" type="version">3.5.11.0</property> <property name="library-category-list" type="library-category-list">Target</property> </ProjectInformation> </data> </addData> </contentHeader> <types> <dataTypes /> <pous> <pou name="MCP23S17_FB" pouType="functionBlock"> <interface> <inputVars> <variable name="byOutputsA"> <type> <WORD /> </type> </variable> <variable name="byOutputsB"> <type> <WORD /> </type> </variable> </inputVars> <outputVars> <variable name="auiValue"> <type> <array> <dimension lower="0" upper="7" /> <baseType> <UINT /> </baseType> </array> </type> </variable> <variable name="byInputsA"> <type> <BYTE /> </type> </variable> <variable name="byInputsB"> <type> <BYTE /> </type> </variable> <variable name="_byGPIOSelectInputA"> <type> <BYTE /> </type> </variable> <variable name="_byGPIOSelectInputB"> <type> <BYTE /> </type> </variable> <variable name="_byGPIOPullupA"> <type> <BYTE /> </type> </variable> <variable name="_byGPIOPullupB"> <type> <BYTE /> </type> </variable> </outputVars> <localVars> <variable name="_byHardwareAddress"> <type> <BYTE /> </type> </variable> </localVars> <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, 16#28); // set HAEN and SEQOP write8(_byHardwareAddress, IODIRA, _byGPIOSelectInputA); write8(_byHardwareAddress, IODIRB, _byGPIOSelectInputB); write8(_byHardwareAddress, GPIOA, 0); //reset outputs write8(_byHardwareAddress, GPIOB, 0); write8(_byHardwareAddress, GPPUA, _byGPIOPullupA); write8(_byHardwareAddress, GPPUB, _byGPIOPullupB); _iState := 10; END_CASE </xhtml> </ST> </body> <addData> <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> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="writeBit"> <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="byBit"> <type> <subrangeSigned> <range lower="0" upper="7" /> <baseType> <BYTE /> </baseType> </subrangeSigned> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> bit number to read/write </xhtml> </documentation> </variable> <variable name="xValue"> <type> <BOOL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> value to write </xhtml> </documentation> </variable> </inputVars> <localVars> <variable name="byValue"> <type> <BYTE /> </type> </variable> </localVars> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> This method is used to modify one bit of a certain register: It first reads the register, modifies the bit and then writes the register (no matter if the bit already had the desired value) return value: TRUE if successful</xhtml> </documentation> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">byValue := read8(byHardwareAddress, byPort); IF xValue THEN byValue := byValue OR SHL(USINT#1, byBit); ELSE byValue := byValue AND NOT SHL(USINT#1, byBit); END_IF writeBit := write8(byHardwareAddress, byPort, byValue); </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="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(); byInputsA := read8(_byHardwareAddress, GPIOA); byInputsB := read8(_byHardwareAddress, GPIOB); </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 _byGPIOSelectInputA &lt; 255 THEN write8(_byHardwareAddress, GPIOA, WORD_TO_BYTE(byOutputsA)); END_IF IF _byGPIOSelectInputB &lt; 255 THEN write8(_byHardwareAddress, GPIOB, WORD_TO_BYTE(byOutputsB)); END_IF</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); pParam := ConfigGetParameter(_pConnector, 1); IF pParam &lt;&gt; 0 THEN _byHardwareAddress := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 2); IF pParam &lt;&gt; 0 THEN _byGPIOSelectInputA := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 3); IF pParam &lt;&gt; 0 THEN _byGPIOSelectInputB := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 4); IF pParam &lt;&gt; 0 THEN _byGPIOPullupA := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 5); IF pParam &lt;&gt; 0 THEN _byGPIOPullupB := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); 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" constant="true"> <variable name="IODIRA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#0" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Data Direction Register for PORTA </xhtml> </documentation> </variable> <variable name="IODIRB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#1" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Data Direction Register for PORTB</xhtml> </documentation> </variable> <variable name="IPOLA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#2" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Input Polarity Register for PORTA</xhtml> </documentation> </variable> <variable name="IPOLB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#3" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Input Polarity Register for PORTB</xhtml> </documentation> </variable> <variable name="GPINTENA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#4" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt-on-change enable Register for PORTA</xhtml> </documentation> </variable> <variable name="GPINTENB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#5" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt-on-change enable Register for PORTB</xhtml> </documentation> </variable> <variable name="DEFVALA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#6" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Default Value Register for PORTA </xhtml> </documentation> </variable> <variable name="DEFVALB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#7" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Default Value Register for PORTB </xhtml> </documentation> </variable> <variable name="INTCONA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#8" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt-on-change control Register for PORTA </xhtml> </documentation> </variable> <variable name="INTCONB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#9" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt-on-change control Register for PORTB </xhtml> </documentation> </variable> <variable name="IOCON"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#A" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Configuration register for device </xhtml> </documentation> </variable> <variable name="GPPUA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#C" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">100kOhm pullup resistor register for PORTA (sets pin to input when set) </xhtml> </documentation> </variable> <variable name="GPPUB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#D" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">100kOhm pullup resistor register for PORTB (sets pin to input when set) </xhtml> </documentation> </variable> <variable name="INTFA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#E" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt flag Register for PORTA </xhtml> </documentation> </variable> <variable name="INTFB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#F" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt flag Register for PORTB </xhtml> </documentation> </variable> <variable name="INTCAPA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#10" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt captured value Register for PORTA </xhtml> </documentation> </variable> <variable name="INTCAPB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#11" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Interrupt captured value Register for PORTB </xhtml> </documentation> </variable> <variable name="GPIOA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#12" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">General purpose I/O Register for PORTA </xhtml> </documentation> </variable> <variable name="GPIOB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#13" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">General purpose I/O Register for PORTB</xhtml> </documentation> </variable> <variable name="OLATA"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#14" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Output latch Register for PORTA</xhtml> </documentation> </variable> <variable name="OLATB"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#15" /> </initialValue> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml">Output latch Register for PORTB </xhtml> </documentation> </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="#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)" /> <Library Name="SysTypes2 Interfaces, * (System)" Namespace="SysTypes" HideWhenReferencedAsDependency="false" PublishSymbolsInContainer="false" SystemLibrary="false" LinkAllContent="false" /> <addData /> </Libraries> </data> </addData> </project>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/I2C_AdafruitPWM.library.xml Bash bash (Bash)
<?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:02.7510852" /> <contentHeader name="Raspberry I2C AdafruitPWM" 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 for Adafruit PWM (815) under Raspberry Pi</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">AdafruitPWM</property> <property name="Description" type="string">Library containing device support for Adafruit PWM (815) under Raspberry Pi</property> <property name="Placeholder" type="string">AdafruitPWM</property> <property name="Project" type="string">I2C_AdafruitPWM</property> <property name="Released" type="boolean">false</property> <property name="Title" type="string">Raspberry I2C AdafruitPWM</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="AdafruitPwm" pouType="functionBlock"> <interface> <inputVars> <variable name="alrPWM"> <type> <array> <dimension lower="0" upper="15" /> <baseType> <LREAL /> </baseType> </array> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> 0..1 = 1ms..2ms Signal On </xhtml> </documentation> </variable> <variable name="axEnable"> <type> <array> <dimension lower="0" upper="15" /> <baseType> <BOOL /> </baseType> </array> </type> <initialValue> <arrayValue> <value repetitionValue="4"> <simpleValue value="TRUE" /> </value> </arrayValue> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Bit x = TRUE: set PWM output channel x; FALSE: do not modify output signal of channel x </xhtml> </documentation> </variable> </inputVars> <localVars> <variable name="_freq"> <type> <UINT /> </type> <initialValue> <simpleValue value="50" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> frequency [Hz] </xhtml> </documentation> </variable> <variable name="_usiSMAxes"> <type> <USINT /> </type> <initialValue> <simpleValue value="0" /> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> internal counter for registered SM axes </xhtml> </documentation> </variable> <variable name="_rPeriod"> <type> <LREAL /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> Period [ms], time between two rising edges </xhtml> </documentation> </variable> <variable name="_alrOldPWM"> <type> <array> <dimension lower="0" upper="15" /> <baseType> <LREAL /> </baseType> </array> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> </variable> <variable name="_alrMin"> <type> <array> <dimension lower="0" upper="15" /> <baseType> <LREAL /> </baseType> </array> </type> <initialValue> <arrayValue> <value repetitionValue="16"> <simpleValue value="1.0" /> </value> </arrayValue> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> minimum time [ms], the pulse is ON </xhtml> </documentation> </variable> <variable name="_alrMax"> <type> <array> <dimension lower="0" upper="15" /> <baseType> <LREAL /> </baseType> </array> </type> <initialValue> <arrayValue> <value repetitionValue="16"> <simpleValue value="2.0" /> </value> </arrayValue> </initialValue> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> maximum time [ms], the pulse is ON </xhtml> </documentation> </variable> </localVars> <tempVars> <variable name="i"> <type> <USINT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> </variable> <variable name="usi"> <type> <USINT /> </type> <addData> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> </variable> </tempVars> <addData> <data name="http://www.3s-software.com/plcopenxml/pouinheritance" handleUnknown="implementation"> <Inheritance> <Extends>i2c</Extends> </Inheritance> </data> <data name="http://www.3s-software.com/plcopenxml/attributes" handleUnknown="implementation"> <Attributes> <Attribute Name="setPWMRange" Value="" /> <Attribute Name="suppress_warning_0" Value="C0351" /> </Attributes> </data> </addData> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#40; END_IF IF SUPER^.init() THEN _iState := 5; END_IF 5: write8(PCA9685_MODE1, 16#10); // go to sleep usi := LREAL_TO_USINT(25000000 / 4096.0 / 0.88 (*0.88 after check with oszi*) / _freq) - 1; write8(PCA9685_PRESCALE, usi); // set the prescaler _rPeriod := LREAL#1.0 / _freq * 1000; //Periode in ms _iState := 6; 6: write8(PCA9685_MODE1, 16#A0); // This sets the MODE1 register to turn on auto increment. FOR i := 0 TO 15 DO _alrOldPWM[i] := -1; END_FOR _iState := 10; END_CASE</xhtml> </ST> </body> <addData> <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 FOR i:=0 TO 15 DO IF alrPWM[i] &lt;&gt; _alrOldPWM[i] AND axEnable[i] &gt; 0 THEN setPWM(i, alrPWM[i]); _alrOldPWM[i] := alrPWM[i]; END_IF END_FOR END_IF</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); pParam := ConfigGetParameter(_pConnector, 2); IF pParam &lt;&gt; 0 THEN _freq := IoStandard.ConfigGetParameterValueWord(pParam, ADR(udiResult)); END_IF (* no longer supported pParam := ConfigGetParameter(_pConnector, 3); IF pParam &lt;&gt; 0 THEN _usiUsedOutputs := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF *) pParam := ConfigGetParameter(_pConnector, 1); IF pParam &lt;&gt; 0 THEN //store own pointer in this param pParam^.dwDriverSpecific := THIS; END_IF _usiSMAxes := 0;</xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="setPWMRaw"> <interface> <inputVars> <variable name="usiChannel"> <type> <USINT /> </type> </variable> <variable name="ui"> <type> <UINT /> </type> </variable> </inputVars> <localVars> <variable name="aby"> <type> <array> <dimension lower="0" upper="4" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">aby[0] := LED0_ON_L + 4*usiChannel; aby[3] := UINT_TO_USINT(ui); aby[4] := UINT_TO_USINT(ui/256); write(ADR(aby), 5); </xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="setPWM"> <interface> <inputVars> <variable name="usiChannel"> <type> <USINT /> </type> </variable> <variable name="rValue"> <type> <LREAL /> </type> </variable> </inputVars> <localVars> <variable name="aby"> <type> <array> <dimension lower="0" upper="4" /> <baseType> <BYTE /> </baseType> </array> </type> </variable> <variable name="ui"> <type> <UINT /> </type> </variable> </localVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">aby[0] := LED0_ON_L + 4 * usiChannel; ui := LREAL_TO_UINT((_alrMin[usiChannel] + LIMIT(0, rValue, 1) * (_alrMax[usiChannel] - _alrMin[usiChannel])) / _rPeriod * 4096 - 1); aby[3] := UINT_TO_USINT(ui); aby[4] := UINT_TO_USINT(ui/256); write(ADR(aby), 5); </xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="RegisterAxis"> <interface> <returnType> <USINT /> </returnType> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">IF _usiSMAxes &lt; 16 THEN RegisterAxis := _usiSMAxes; _usiSMAxes := _usiSMAxes + 1; ELSE RegisterAxis := 255; END_IF </xhtml> </ST> </body> <addData /> </Method> </data> <data name="http://www.3s-software.com/plcopenxml/method" handleUnknown="implementation"> <Method name="setPWMRange"> <interface> <inputVars> <variable name="usiChannel"> <type> <USINT /> </type> </variable> <variable name="alrMin"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> minimum time [ms], the pulse is ON </xhtml> </documentation> </variable> <variable name="alrMax"> <type> <LREAL /> </type> <documentation> <xhtml xmlns="http://www.w3.org/1999/xhtml"> maximum time [ms], the pulse is ON </xhtml> </documentation> </variable> </inputVars> </interface> <body> <ST> <xhtml xmlns="http://www.w3.org/1999/xhtml">IF usiChannel &lt; 16 THEN _alrMin[usiChannel] := alrMin; _alrMax[usiChannel] := alrMax; 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_Adafruit" constant="true"> <variable name="PCA9685_MODE1"> <type> <USINT /> </type> <initialValue> <simpleValue value="0" /> </initialValue> </variable> <variable name="PCA9685_PRESCALE"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#FE" /> </initialValue> </variable> <variable name="LED0_ON_L"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#6" /> </initialValue> </variable> <variable name="LED0_ON_H"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#7" /> </initialValue> </variable> <variable name="LED0_OFF_L"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#8" /> </initialValue> </variable> <variable name="LED0_OFF_H"> <type> <USINT /> </type> <initialValue> <simpleValue value="16#9" /> </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>
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/SPI_PiFaceCaD.library.md Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?>--- ~~~ST FUNCTION_BLOCK PiFaceCaD EXTENDS spi VAR_OUTPUT bySwitches: BYTE; END_VAR VAR _byHardwareAddress: BYTE; _byCurDisplayControl: BYTE; _byCurEntryMode: BYTE; _byCurAddress: BYTE; END_VAR VAR_TEMP i: INT; k: INT; END_VAR ~~~ ~~~ST SUPER^(); CASE _iState OF 0: IF SUPER^.init() THEN _iState := 1; END_IF 1: write8(_byHardwareAddress, IOCON, 8); //enable hardware addressing // Set GPIO Port A as inputs (switches) write8(_byHardwareAddress, IODIRA, 255); write8(_byHardwareAddress, GPPUA, 255); // Set GPIO Port B as outputs (connected to HD44780) write8(_byHardwareAddress, IODIRB, 0); // enable interrupts write8(_byHardwareAddress, GPINTENA, 255); sleep_ns(DELAY_SETUP_0_NS); write8(_byHardwareAddress, LCD_PORT, 3); LCDPulseEnable(); sleep_ns(DELAY_SETUP_1_NS); write8(_byHardwareAddress, LCD_PORT, 3); LCDPulseEnable(); sleep_ns(DELAY_SETUP_2_NS); write8(_byHardwareAddress, LCD_PORT, 3); LCDPulseEnable(); write8(_byHardwareAddress, LCD_PORT, 2); LCDPulseEnable(); LCDSendCommand(LCD_FUNCTIONSET OR LCD_4BITMODE OR LCD_2LINE OR LCD_5X8DOTS); LCDSendCommand(LCD_DISPLAYCONTROL OR LCD_DISPLAYOFF OR LCD_CURSOROFF OR LCD_BLINKOFF); Clear(); _byCurEntryMode := LCD_ENTRYLEFT OR LCD_ENTRYSHIFTDECREMENT; LCDSendCommand(LCD_ENTRYMODESET OR _byCurEntryMode); _byCurDisplayControl := LCD_DISPLAYON OR LCD_CURSORON OR LCD_BLINKON; LCDSendCommand(LCD_DISPLAYCONTROL OR _byCurDisplayControl); SetText('CODESYS ON', 'RASPBERRY PI'); _iState := 10; END_CASE ~~~ --- ~~~ST METHOD Initialize: UDINT VAR_INPUT wModuleType: UINT; dwInstance: UDINT; pConnector: pointer; END_VAR VAR pParam: pointer; udiResult: UDINT; END_VAR ~~~ ~~~ST SUPER^.Initialize(wModuleType, dwInstance, pConnector); (*pParam := ConfigGetParameter(_pConnector, 1); IF pParam &lt;&gt; 0 THEN _byHardwareAddress := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF*) ~~~ --- ~~~ST METHOD BeforeWriteOutputs: INT VAR i: USINT; END_VAR ~~~ ~~~ST SUPER^.BeforeWriteOutputs(); ~~~ --- ~~~ST METHOD AfterReadInputs: INT VAR aby: ARRAY [..] OF ; END_VAR ~~~ ~~~ST SUPER^.AfterReadInputs(); IF _iState = 10 THEN bySwitches := NOT read8(_byHardwareAddress, SWITCH_PORT); END_IF ~~~ --- ~~~ST METHOD read8: BYTE VAR_INPUT byHardwareAddress: subrangeSigned; byPort: BYTE; END_VAR VAR abyTxBuffer: ARRAY [..] OF ; abyRxBuffer: ARRAY [..] OF ; END_VAR ~~~ ~~~ST 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 ~~~ --- ~~~ST METHOD write8: BOOL VAR_INPUT byHardwareAddress: subrangeSigned; byPort: BYTE; byValue: BYTE; END_VAR VAR abyTxBuffer: ARRAY [..] OF ; abyRxBuffer: ARRAY [..] OF ; END_VAR ~~~ ~~~ST 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 ~~~ --- ~~~ST METHOD LCDPulseEnable: ~~~ ~~~ST LCDSetEnable(TRUE); sleep_ns(DELAY_PULSE_NS); LCDSetEnable(FALSE); sleep_ns(DELAY_PULSE_NS); ~~~ --- ~~~ST METHOD LCDSendCommand: VAR_INPUT usiCommand: USINT; END_VAR ~~~ ~~~ST LCDSetRs(FALSE); LCDSendByte(usiCommand); sleep_ns(DELAY_SETTLE_NS); ~~~ --- ~~~ST METHOD LCDSendByte: VAR_INPUT usi: USINT; END_VAR VAR usiCurrentState: USINT; usiNew: USINT; END_VAR ~~~ ~~~ST // get current lcd port state and clear the data bits usiCurrentState := read8(_byHardwareAddress, LCD_PORT) AND 16#F0; // send first nibble (0bXXXX0000) usiNew := usiCurrentState OR SHR(usi, 4); write8(_byHardwareAddress, LCD_PORT, usiNew); LCDPulseEnable(); // send second nibble (0b0000XXXX) usiNew := usiCurrentState OR (usi AND 2#1111); write8(_byHardwareAddress, LCD_PORT, usiNew); LCDPulseEnable(); ~~~ --- ~~~ST METHOD writeBit: BOOL VAR_INPUT byHardwareAddress: subrangeSigned; byPort: BYTE; byBit: subrangeSigned; xValue: BOOL; END_VAR VAR byValue: BYTE; END_VAR ~~~ ~~~ST byValue := read8(byHardwareAddress, byPort); IF xValue THEN byValue := byValue OR SHL(USINT#1, byBit); ELSE byValue := byValue AND NOT SHL(USINT#1, byBit); END_IF writeBit := write8(byHardwareAddress, byPort, byValue); ~~~ --- ~~~ST METHOD LCDSetRs: VAR_INPUT x: BOOL; END_VAR ~~~ ~~~ST writeBit(_byHardwareAddress, LCD_PORT, PIN_RS, x); ~~~ --- ~~~ST METHOD sleep_ns: VAR_INPUT udiNs: UDINT; END_VAR VAR udi1: ULINT; udi2: ULINT; END_VAR ~~~ ~~~ST SysTimeGetNs(udi1); REPEAT SysTimeGetNs(udi2); UNTIL udi2-udi1 &gt;= udiNs END_REPEAT ~~~ --- ~~~ST METHOD LCDSetEnable: VAR_INPUT x: BOOL; END_VAR ~~~ ~~~ST writeBit(_byHardwareAddress, LCD_PORT, PIN_ENABLE, x); ~~~ --- ~~~ST METHOD Write: VAR_INPUT sText: string; END_VAR VAR i: INT; pby: pointer; END_VAR ~~~ ~~~ST LCDSendCommand(LCD_SETDDRAMADDR OR _byCurAddress); pby := ADR(sText); FOR i:=0 TO len(sText)-1 DO IF pby[i] = 10 THEN SetCursor(0,1); ELSE LCDSendData(pby[i]); _byCurAddress := _byCurAddress + 1; END_IF END_FOR ~~~ --- ~~~ST METHOD Clear: ~~~ ~~~ST LCDSendCommand(LCD_CLEARDISPLAY); _byCurAddress := 0; sleep_ns(DELAY_CLEAR_NS); ~~~ --- ~~~ST METHOD Home: ~~~ ~~~ST LCDSendCommand(LCD_RETURNHOME); _byCurAddress := 0; sleep_ns(DELAY_CLEAR_NS); ~~~ --- ~~~ST METHOD SetCursor: VAR_INPUT usiColumn: USINT; usiRow: USINT; END_VAR ~~~ ~~~ST usiColumn := MAX(0, MIN(usiColumn, (LCD_RAM_WIDTH / 2) - 1)); usiRow := MAX(0, MIN(usiRow, LCD_MAX_LINES - 1)); _byCurAddress := (usiColumn + ROW_OFFSETS[usiRow]) MOD LCD_RAM_WIDTH; LCDSendCommand(LCD_SETDDRAMADDR OR _byCurAddress); ~~~ --- ~~~ST METHOD LCDSendData: VAR_INPUT data: USINT; END_VAR ~~~ ~~~ST LCDSetRs(TRUE); LCDSendByte(data); sleep_ns(DELAY_SETTLE_NS); ~~~ --- ~~~ST METHOD MoveLeft: ~~~ ~~~ST LCDSendCommand(LCD_CURSORSHIFT OR LCD_DISPLAYMOVE OR LCD_MOVELEFT); ~~~ --- ~~~ST METHOD MoveRight: ~~~ ~~~ST LCDSendCommand(LCD_CURSORSHIFT OR LCD_DISPLAYMOVE OR LCD_MOVERIGHT); ~~~ --- ~~~ST METHOD SetText: VAR_INPUT sLine1: string; sLine2: string; END_VAR ~~~ ~~~ST SetCursor(0, 0); Write(sLine1); SetCursor(0, 1); Write(sLine2); ~~~ --- ~~~ST METHOD WriteCustomBitmap: VAR_INPUT byLocation: subrangeSigned; END_VAR ~~~ ~~~ST LCDSendCommand(LCD_SETDDRAMADDR OR _byCurAddress); LCDSendData(byLocation); _byCurAddress := _byCurAddress + 1; ~~~ --- ~~~ST METHOD DefineCustomBitmap: VAR_INPUT byLocation: subrangeSigned; abyBitmap: ARRAY [..] OF ; END_VAR VAR i: INT; END_VAR ~~~ ~~~ST LCDSendCommand(LCD_SETCGRAMADDR OR SHL(byLocation, 3)); FOR i := 0 TO 7 DO LCDSendData(abyBitmap[i]); END_FOR ~~~ VAR_GLOBAL IODIRA: USINT; IODIRB: USINT; IPOLA: USINT; IPOLB: USINT; GPINTENA: USINT; GPINTENB: USINT; DEFVALA: USINT; DEFVALB: USINT; INTCONA: USINT; INTCONB: USINT; IOCON: USINT; GPPUA: USINT; GPPUB: USINT; INTFA: USINT; INTFB: USINT; INTCAPA: USINT; INTCAPB: USINT; GPIOA: USINT; GPIOB: USINT; OLATA: USINT; OLATB: USINT; BANK_OFF: USINT; BANK_ON: USINT; INT_MIRROR_ON: USINT; INT_MIRROR_OFF: USINT; SEQOP_OFF: USINT; SEQOP_ON: USINT; DISSLW_ON: USINT; DISSLW_OFF: USINT; HAEN_ON: USINT; HAEN_OFF: USINT; ODR_ON: USINT; ODR_OFF: USINT; INTPOL_HIGH: USINT; INTPOL_LOW: USINT; DELAY_PULSE_NS: UDINT; DELAY_SETTLE_NS: UDINT; DELAY_CLEAR_NS: UDINT; DELAY_SETUP_0_NS: UDINT; DELAY_SETUP_1_NS: UDINT; DELAY_SETUP_2_NS: UDINT; PIN_D4: USINT; PIN_D5: USINT; PIN_D6: USINT; PIN_D7: USINT; PIN_ENABLE: USINT; PIN_RW: USINT; PIN_RS: USINT; PIN_BACKLIGHT: USINT; LCD_CLEARDISPLAY: USINT; LCD_RETURNHOME: USINT; LCD_ENTRYMODESET: USINT; LCD_DISPLAYCONTROL: USINT; LCD_CURSORSHIFT: USINT; LCD_FUNCTIONSET: USINT; LCD_SETCGRAMADDR: USINT; LCD_SETDDRAMADDR: USINT; LCD_NEWLINE: USINT; LCD_ENTRYRIGHT: USINT; LCD_ENTRYLEFT: USINT; LCD_ENTRYSHIFTINCREMENT: USINT; LCD_ENTRYSHIFTDECREMENT: USINT; LCD_DISPLAYON: USINT; LCD_DISPLAYOFF: USINT; LCD_CURSORON: USINT; LCD_CURSOROFF: USINT; LCD_BLINKON: USINT; LCD_BLINKOFF: USINT; LCD_DISPLAYMOVE: USINT; LCD_CURSORMOVE: USINT; LCD_MOVERIGHT: USINT; LCD_MOVELEFT: USINT; LCD_8BITMODE: USINT; LCD_4BITMODE: USINT; LCD_2LINE: USINT; LCD_1LINE: USINT; LCD_5X10DOTS: USINT; LCD_5X8DOTS: USINT; LCD_MAX_LINES: USINT; LCD_WIDTH: USINT; LCD_RAM_WIDTH: USINT; ROW_OFFSETS: ARRAY [..] OF ; SWITCH_PORT: USINT; LCD_PORT: USINT; END_VAR
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/SM3_Drive_Servo.library.md Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?>--- ~~~ST FUNCTION_BLOCK AXIS_REF_SERVO EXTENDS AXIS_REF_VIRTUAL_SM3 VAR pAdafruitPWM: pointer; usiAxisIndex: USINT; lrMinPos: LREAL; lrMaxPos: LREAL; lrMinPwm: LREAL; lrMaxPwm: LREAL; lrInitPos: LREAL; END_VAR ~~~ ~~~ST ; ~~~ --- ~~~ST METHOD CommunicationStateMachine: BOOL VAR x: LREAL; pParam: pointer; END_VAR ~~~ ~~~ST IF pAdafruitPWM = 0 THEN IF m_pConnector&lt;&gt;0 THEN IF m_pConnector^.pFather &lt;&gt; 0 THEN IF m_pConnector^.pFather^.pFather &lt;&gt; 0 THEN pParam := ConfigGetParameter(m_pConnector^.pFather^.pFather, 1); IF pParam &lt;&gt; 0 THEN pAdafruitPWM := pParam^.dwDriverSpecific; IF pAdafruitPWM &lt;&gt; 0 THEN usiAxisIndex := pAdafruitPWM^.RegisterAxis(); END_IF END_IF END_IF END_IF END_IF END_IF IF pAdafruitPwm &lt;&gt; 0 THEN bCommunication := pAdafruitPwm^.Operational; ELSE bCommunication := 0; SMC_LogFBError(pDrive:=THIS, wID:=300, pbyErrorInstance:=THIS); wCommunicationState := 1000; END_IF IF NOT bVirtual THEN CASE wCommunicationState OF 0: IF usiAxisIndex &lt;&gt; 255 THEN {IF hasattribute (pou: AdafruitPwm, 'setPWMRange')} pAdafruitPWM^.setPWMRange(usiAxisIndex, lrMinPwm, lrMaxPwm); {END_IF} wCommunicationState := 10; END_IF 10: fActPosition := lrInitPos; IF bCommunication THEN wCommunicationState := 100; END_IF END_CASE // simulate actual values IF bRegulatorOn THEN IF pAdafruitPWM &gt; 0 THEN IF lrMinPos &lt; lrMaxPos THEN x := LIMIT(lrMinPos, fSetPosition, lrMaxPos); ELSE x := LIMIT(lrMaxPos, fSetPosition, lrMinPos); END_IF pAdafruitPWM^.alrPWM[usiAxisIndex] := (x + fOffsetPosition - lrMinPos) / (lrMaxPos - lrMinPos); END_IF fActPosition := fSetPosition; IF iMovementType = 0 THEN (*modulo*) x := SM0.fmod(fActPosition + fOffsetPosition (* + fLogicalOffsetPosition logisch ist nicht gleichzeitig virtuell, oder?*) - fLastActPosition - fLastPositionOffset, fPositionPeriod); IF x*2 &gt; fPositionPeriod THEN x := x - fPositionPeriod; END_IF fActVelocity := x / fTaskCycle; ELSE fActVelocity := (fActPosition + fOffsetPosition (* + fLogicalOffsetPosition logisch ist nicht gleichzeitig virtuell, oder?*) - fLastActPosition - fLastPositionOffset) / fTaskCycle; END_IF fActAcceleration := (fActVelocity - fLastActVelocity) / fTaskCycle; fActJerk := fSetJerk; fActTorque := fSetTorque; END_IF //check limits IF nAxisState&lt;&gt;errorstop AND nAxisState&lt;&gt;power_off THEN IF fMaxVelocity &gt; 0 AND fMaxVelocity &lt; ABS(fActVelocity) THEN SMC_LogFBError(THIS, SMC_VD_MAX_VELOCITY_EXCEEDED, 0); iOwner := -1; nAxisState := errorstop; END_IF IF fActAcceleration*fActVelocity &gt; 0 THEN //acceleration IF fMaxAcceleration &gt; 0 AND fMaxAcceleration &lt; ABS(fActAcceleration) AND NOT bError THEN SMC_LogFBError(THIS, SMC_VD_MAX_ACCELERATION_EXCEEDED, 0); iOwner := -1; nAxisState := errorstop; END_IF ELSE //deceleration IF fMaxDeceleration &gt; 0 AND fMaxDeceleration &lt; ABS(fActAcceleration) AND NOT bError THEN SMC_LogFBError(THIS, SMC_VD_MAX_DECELERATION_EXCEEDED, 0); iOwner := -1; nAxisState := errorstop; END_IF END_IF END_IF IF nAxisState=errorstop OR nAxisState=power_off OR bySwitchingState=0 THEN fActVelocity := 0; fActAcceleration := 0; END_IF //store old values fLastActPosition := fActPosition; fLastPositionOffset := fOffsetPosition(* + fLogicalOffsetPosition logisch ist nicht gleichzeitig virtuell, oder?*); fLastActVelocity := fActVelocity; pAdafruitPWM^.axEnable[usiAxisIndex] := bRegulatorOn; bRegulatorRealState := bRegulatorOn AND bCommunication; (* immitate power/halt states *) bDriveStartRealState := bDriveStart; IF bErrorAckn THEN bError:=FALSE; bErrorAckn := FALSE; END_IF END_IF CommunicationStateMachine := SUPER^.CommunicationStateMachine(); ~~~ --- ~~~ST METHOD GetMappedDriveParameter: BOOL VAR_INPUT bRead: BOOL; diParameterNumber: DINT; END_VAR VAR_OUTPUT diDriveParameterNumber: DINT; usiDataLength: USINT; END_VAR ~~~ ~~~ST IF diParameterNumber = 1030 OR diParameterNumber = 1031 OR diParameterNumber = 1032 THEN diDriveParameterNumber := 0; GetMappedDriveParameter:=TRUE; ELSE GetMappedDriveParameter := SUPER^.GetMappedDriveParameter( bRead:=bRead, diParameterNumber:=diParameterNumber, diDriveParameterNumber =&gt; diDriveParameterNumber, usiDataLength =&gt; usiDataLength); END_IF ~~~ --- ~~~ST METHOD GetStandardConfigParams: BOOL VAR pParam: pointer; END_VAR ~~~ ~~~ST GetStandardConfigParams := SUPER^.GetStandardConfigParams(); IF m_pConnector &lt;&gt; 0 THEN pParam := ConfigGetParameter(m_pConnector, 65536); IF pParam &lt;&gt; 0 THEN lrMinPos := ConfigGetParameterValueLREAL(pParam, 0); END_IF pParam := ConfigGetParameter(m_pConnector, 65537); IF pParam &lt;&gt; 0 THEN lrMaxPos := ConfigGetParameterValueLREAL(pParam, 0); END_IF pParam := ConfigGetParameter(m_pConnector, 65538); IF pParam &lt;&gt; 0 THEN lrInitPos := ConfigGetParameterValueLREAL(pParam, 0); END_IF pParam := ConfigGetParameter(m_pConnector, 65539); IF pParam &lt;&gt; 0 THEN lrMinPwm := ConfigGetParameterValueLREAL(pParam, 0); END_IF pParam := ConfigGetParameter(m_pConnector, 65540); IF pParam &lt;&gt; 0 THEN lrMaxPwm := ConfigGetParameterValueLREAL(pParam, 0); END_IF END_IF byRealControllerMode := SMC_position; ~~~ --- ~~~ST FUNCTION_BLOCK SMC_PosControlInput VAR_INPUT bLimitPos: BOOL; bLimitNeg: BOOL; wActPosition: WORD; dwActPosition: DWORD; bExternalError: BOOL; bRegulatorRealState: BOOL; bDriveStartRealState: BOOL; dwEncoderCounterModulo: DWORD; END_VAR VAR_OUTPUT bUseWord: BOOL; END_VAR ~~~ ~~~ST IF wActPosition &lt;&gt; 0 THEN bUseWord := TRUE; END_IF ~~~ --- ~~~ST FUNCTION_BLOCK SMC_PosControlOutput VAR_INPUT bRegulatorOnIn: BOOL; bDriveStartIn: BOOL; fSetVelocity: LREAL; fMaxVelocityNeg: LREAL; fMaxVelocityPos: LREAL; diMaxVelocityNeg: DINT; diZeroVelocity: DINT; diMaxVelocityPos: DINT; bInvertDirection: BOOL; END_VAR VAR_OUTPUT bRegulatorOn: BOOL; bDriveStart: BOOL; diSetVelocity: DINT; iSetVelocity: INT; END_VAR ~~~ ~~~ST bRegulatorOn := bRegulatorOnIn; bDriveStart := bDriveStartIn; IF bDriveStartIn THEN IF bInvertDirection THEN fSetVelocity := fSetVelocity*-1; END_IF IF fSetVelocity &lt; 0 THEN fSetVelocity := MAX(fSetVelocity, fMaxVelocityNeg); diSetVelocity := diZeroVelocity + LREAL_TO_DINT(fSetVelocity/fMaxVelocityNeg* DINT_TO_LREAL(diMaxVelocityNeg-diZeroVelocity)); ELSE fSetVelocity := MIN(fSetVelocity, fMaxVelocityPos); diSetVelocity := diZeroVelocity + LREAL_TO_DINT(fSetVelocity/fMaxVelocityPos* DINT_TO_LREAL(diMaxVelocityPos-diZeroVelocity)); END_IF ELSE diSetVelocity := diZeroVelocity; END_IF iSetVelocity := DINT_TO_INT(diSetVelocity); ~~~
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/I2C_Gyroscopes.library.md Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?>--- ~~~ST FUNCTION_BLOCK MPU6050 EXTENDS i2c VAR_OUTPUT lrAX: LREAL; lrAY: LREAL; lrAZ: LREAL; lrGX: LREAL; lrGY: LREAL; lrGZ: LREAL; lrTemp: LREAL; END_VAR VAR iAX: INT; iAY: INT; iAZ: INT; iGX: INT; iGY: INT; iGZ: INT; uiTemp: UINT; lrOffsetGX: LREAL; lrOffsetGY: LREAL; lrOffsetGZ: LREAL; iCounter: INT; END_VAR ~~~ ~~~ST SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#69; END_IF IF init() THEN _iState := 5; END_IF 5: write8(16#6B, 16#80); _iState := 6; 6: write8(16#6B, 16#3); //SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference) writeBits(16#1B, 4, 2, 3); writeBits(16#1C, 4, 2, 2); write8(16#1A, 2); //0: Config 260Hz 0ms delay 4: 21Hz 8.5ms _iState := 8; 8: iCounter := iCounter + 1; IF iCounter = 200 THEN iCounter := 0; _iState := 9; END_IF END_CASE ~~~ --- ~~~ST METHOD AfterReadInputs: INT VAR aby: ARRAY [..] OF ; END_VAR ~~~ ~~~ST SUPER^.AfterReadInputs(); IF _iState = 9 OR _iState = 10 THEN readregister(59, ADR(aby), 14); iAX := UINT_TO_INT(aby[0] * UINT#256 + aby[1]); iAY := UINT_TO_INT(aby[2] * UINT#256 + aby[3]); iAZ := UINT_TO_INT(aby[4] * UINT#256 + aby[5]); uiTemp := aby[6] * UINT#256 + aby[7]; iGX := UINT_TO_INT(aby[8] * UINT#256 + aby[9]); iGY := UINT_TO_INT(aby[10] * UINT#256 + aby[11]); iGZ := UINT_TO_INT(aby[12] * UINT#256 + aby[13]); lrAX := iAX * LREAL#9.81 / LREAL#4096; lrAY := iAY * LREAL#9.81 / LREAL#4096; lrAZ := iAZ * LREAL#9.81 / LREAL#4096; IF _iState = 9 THEN //calibrate iCounter := iCounter + 1; lrOffsetGX := lrOffsetGX + iGX * 2000 / LREAL#16384; lrOffsetGY := lrOffsetGY + iGY * 2000 / LREAL#16384; lrOffsetGZ := lrOffsetGZ + iGZ * 2000 / LREAL#16384; IF iCounter = 2000 THEN lrOffsetGX := -lrOffsetGX / iCounter; lrOffsetGY := -lrOffsetGY / iCounter; lrOffsetGZ := -lrOffsetGZ / iCounter; _iState := 10; END_IF ELSE lrGX := INT_TO_LREAL(iGX) * LREAL#2000 / LREAL#16384 + lrOffsetGX; lrGY := INT_TO_LREAL(iGY) * LREAL#2000 / LREAL#16384 + lrOffsetGY; lrGZ := INT_TO_LREAL(iGZ) * LREAL#2000 / LREAL#16384 + lrOffsetGZ; END_IF lrTemp := (UINT_TO_INT(uiTemp) + LREAL#12412) / LREAL#340.0; END_IF ~~~ --- ~~~ST METHOD Calibrate: ~~~ ~~~ST lrOffsetGX := 0; lrOffsetGY := 0; lrOffsetGZ := 0; iCounter := 0; _iState := 9; ~~~ --- ~~~ST FUNCTION_BLOCK AK8975 EXTENDS i2c VAR_OUTPUT iMX: INT; iMY: INT; iMZ: INT; END_VAR VAR aby: ARRAY [..] OF ; timer: ton; END_VAR ~~~ ~~~ST SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#0C; END_IF IF init() THEN write8(16#0A, 1); _iState := 10; timer(IN:=TRUE); END_IF END_CASE ~~~ --- ~~~ST METHOD AfterReadInputs: INT ~~~ ~~~ST SUPER^.AfterReadInputs(); IF _iState = 10 THEN timer(); IF timer.Q THEN timer(IN := FALSE); timer(IN := TRUE); readregister(3, ADR(aby), 6); iMX := UINT_TO_INT(aby[0]*UINT#256 + aby[1]); iMY := UINT_TO_INT(aby[2]*UINT#256 + aby[3]); iMZ := UINT_TO_INT(aby[4]*UINT#256 + aby[5]); write8(16#0A, 1); //retrigger END_IF END_IF ~~~ --- ~~~ST FUNCTION_BLOCK MPU9150 EXTENDS i2c VAR_OUTPUT lrAX: LREAL; lrAY: LREAL; lrAZ: LREAL; lrGX: LREAL; lrGY: LREAL; lrGZ: LREAL; lrTemp: LREAL; END_VAR VAR Magnet: AK8975; iAX: INT; iAY: INT; iAZ: INT; iGX: INT; iGY: INT; iGZ: INT; uiTemp: UINT; lrOffsetGX: LREAL; lrOffsetGY: LREAL; lrOffsetGZ: LREAL; iCounter: INT; END_VAR ~~~ ~~~ST SUPER^(); CASE _iState OF 0: IF usiAddress = 0 THEN usiAddress := 16#69; END_IF IF SUPER^.init() THEN _iState := 5; END_IF 5: write8(16#6B, 16#80); _iState := 6; 6: write8(16#6B, 16#3); //SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference) writeBits(16#1B, 4, 2, 3); writeBits(16#1C, 4, 2, 2); write8(16#1A, 2); //0: Config 260Hz 0ms delay 4: 21Hz 8.5ms write8(16#37, 2); _iState := 7; 7: Magnet(); IF Magnet.Operational THEN _iState := 8; END_IF 8: iCounter := iCounter + 1; IF iCounter = 200 THEN iCounter := 0; _iState := 9; END_IF END_CASE ~~~ --- ~~~ST METHOD AfterReadInputs: INT VAR aby: ARRAY [..] OF ; END_VAR ~~~ ~~~ST SUPER^.AfterReadInputs(); IF _iState = 9 OR _iState = 10 THEN readregister(59, ADR(aby), 14); iAX := UINT_TO_INT(aby[0] * UINT#256 + aby[1]); iAY := UINT_TO_INT(aby[2] * UINT#256 + aby[3]); iAZ := UINT_TO_INT(aby[4] * UINT#256 + aby[5]); uiTemp := aby[6] * UINT#256 + aby[7]; iGX := UINT_TO_INT(aby[8] * UINT#256 + aby[9]); iGY := UINT_TO_INT(aby[10] * UINT#256 + aby[11]); iGZ := UINT_TO_INT(aby[12] * UINT#256 + aby[13]); lrAX := iAX * LREAL#9.81 / LREAL#4096; lrAY := iAY * LREAL#9.81 / LREAL#4096; lrAZ := iAZ * LREAL#9.81 / LREAL#4096; IF _iState = 9 THEN //calibrate iCounter := iCounter + 1; lrOffsetGX := lrOffsetGX + iGX; lrOffsetGY := lrOffsetGY + iGY; lrOffsetGZ := lrOffsetGZ + iGZ; IF iCounter = 2000 THEN lrOffsetGX := -lrOffsetGX / iCounter; lrOffsetGY := -lrOffsetGY / iCounter; lrOffsetGZ := -lrOffsetGZ / iCounter; _iState := 10; END_IF ELSE lrGX := (INT_TO_LREAL(iGX) + lrOffsetGX) / 16.4; lrGY := (INT_TO_LREAL(iGY) + lrOffsetGY) / 16.4; lrGZ := (INT_TO_LREAL(iGZ) + lrOffsetGZ) / 16.4; END_IF lrTemp := (UINT_TO_INT(uiTemp) + LREAL#12412) / LREAL#340.0; END_IF Magnet.AfterReadInputs(); ~~~ --- ~~~ST METHOD Calibrate: ~~~ ~~~ST lrOffsetGX := 0; lrOffsetGY := 0; lrOffsetGZ := 0; iCounter := 0; _iState := 9; ~~~ --- ~~~ST METHOD Initialize: UDINT VAR_INPUT wModuleType: UINT; dwInstance: UDINT; pConnector: pointer; END_VAR ~~~ ~~~ST SUPER^.Initialize(wModuleType, dwInstance, pConnector); Magnet.Initialize(wModuleType, dwInstance, pConnector); ~~~
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/SPI_MCP23S17.library.md Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?>--- ~~~ST FUNCTION_BLOCK MCP23S17_FB EXTENDS spi VAR_INPUT byOutputsA: WORD; byOutputsB: WORD; END_VAR VAR_OUTPUT auiValue: ARRAY [..] OF ; byInputsA: BYTE; byInputsB: BYTE; _byGPIOSelectInputA: BYTE; _byGPIOSelectInputB: BYTE; _byGPIOPullupA: BYTE; _byGPIOPullupB: BYTE; END_VAR VAR _byHardwareAddress: BYTE; END_VAR ~~~ ~~~ST SUPER^(); CASE _iState OF 0: IF SUPER^.init() THEN _iState := 1; END_IF 1: write8(_byHardwareAddress, IOCON, 16#28); // set HAEN and SEQOP write8(_byHardwareAddress, IODIRA, _byGPIOSelectInputA); write8(_byHardwareAddress, IODIRB, _byGPIOSelectInputB); write8(_byHardwareAddress, GPIOA, 0); //reset outputs write8(_byHardwareAddress, GPIOB, 0); write8(_byHardwareAddress, GPPUA, _byGPIOPullupA); write8(_byHardwareAddress, GPPUB, _byGPIOPullupB); _iState := 10; END_CASE ~~~ --- ~~~ST METHOD read8: BYTE VAR_INPUT byHardwareAddress: subrangeSigned; byPort: BYTE; END_VAR VAR abyTxBuffer: ARRAY [..] OF ; abyRxBuffer: ARRAY [..] OF ; END_VAR ~~~ ~~~ST 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 ~~~ --- ~~~ST METHOD write8: BOOL VAR_INPUT byHardwareAddress: subrangeSigned; byPort: BYTE; byValue: BYTE; END_VAR VAR abyTxBuffer: ARRAY [..] OF ; abyRxBuffer: ARRAY [..] OF ; END_VAR ~~~ ~~~ST 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 ~~~ --- ~~~ST METHOD writeBit: BOOL VAR_INPUT byHardwareAddress: subrangeSigned; byPort: BYTE; byBit: subrangeSigned; xValue: BOOL; END_VAR VAR byValue: BYTE; END_VAR ~~~ ~~~ST byValue := read8(byHardwareAddress, byPort); IF xValue THEN byValue := byValue OR SHL(USINT#1, byBit); ELSE byValue := byValue AND NOT SHL(USINT#1, byBit); END_IF writeBit := write8(byHardwareAddress, byPort, byValue); ~~~ --- ~~~ST METHOD AfterReadInputs: INT VAR aby: ARRAY [..] OF ; usiChannel: USINT; ui: UINT; END_VAR ~~~ ~~~ST SUPER^.AfterReadInputs(); byInputsA := read8(_byHardwareAddress, GPIOA); byInputsB := read8(_byHardwareAddress, GPIOB); ~~~ --- ~~~ST METHOD BeforeWriteOutputs: INT VAR i: USINT; END_VAR ~~~ ~~~ST SUPER^.BeforeWriteOutputs(); IF _byGPIOSelectInputA &lt; 255 THEN write8(_byHardwareAddress, GPIOA, WORD_TO_BYTE(byOutputsA)); END_IF IF _byGPIOSelectInputB &lt; 255 THEN write8(_byHardwareAddress, GPIOB, WORD_TO_BYTE(byOutputsB)); END_IF ~~~ --- ~~~ST METHOD Initialize: UDINT VAR_INPUT wModuleType: UINT; dwInstance: UDINT; pConnector: pointer; END_VAR VAR pParam: pointer; udiResult: UDINT; END_VAR ~~~ ~~~ST SUPER^.Initialize(wModuleType, dwInstance, pConnector); pParam := ConfigGetParameter(_pConnector, 1); IF pParam &lt;&gt; 0 THEN _byHardwareAddress := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 2); IF pParam &lt;&gt; 0 THEN _byGPIOSelectInputA := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 3); IF pParam &lt;&gt; 0 THEN _byGPIOSelectInputB := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 4); IF pParam &lt;&gt; 0 THEN _byGPIOPullupA := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF pParam := ConfigGetParameter(_pConnector, 5); IF pParam &lt;&gt; 0 THEN _byGPIOPullupB := IoStandard.ConfigGetParameterValueByte(pParam, ADR(udiResult)); END_IF ~~~ VAR_GLOBAL IODIRA: USINT; IODIRB: USINT; IPOLA: USINT; IPOLB: USINT; GPINTENA: USINT; GPINTENB: USINT; DEFVALA: USINT; DEFVALB: USINT; INTCONA: USINT; INTCONB: USINT; IOCON: USINT; GPPUA: USINT; GPPUB: USINT; INTFA: USINT; INTFB: USINT; INTCAPA: USINT; INTCAPB: USINT; GPIOA: USINT; GPIOB: USINT; OLATA: USINT; OLATB: USINT; END_VAR
Last updated: 2018-07-16

rpi-legacy: ./trunk/legacy/Libraries/OneWire_DS18B20.library.md Bash bash (Bash)
<?xml version="1.0" encoding="utf-8"?>--- ~~~ST FUNCTION_BLOCK OneWire_DS18B20 EXTENDS OneWire VAR_OUTPUT rTemp: REAL; stdTimeStamp: RTS_SYSTIMEDATE; xSignalOk: BOOL; END_VAR ~~~ ~~~ST super^(); ~~~ --- ~~~ST METHOD AfterReadInputs: INT ~~~ ~~~ST Evaluate(); SUPER^.AfterReadInputs(); ~~~ --- ~~~ST METHOD Evaluate: VAR fr: FileReader; hFile: RTS_IEC_HANDLE; result: RTS_IEC_RESULT; udiRead: UDINT; sPath: string; sData: string; i: INT; END_VAR ~~~ ~~~ST IF _pMaster &lt;&gt; 0 THEN sPath := DataPath; hFile := SysFileOpen(sPath, ACCESS_MODE.AM_READ, ADR(result)); IF hFile &lt;&gt; RTS_INVALID_HANDLE THEN fr(hFile := hFile); IF fr.GetLine(ADR(sData), SIZEOF(sData)) AND LEN(sData) &gt; 3 THEN IF RIGHT(sData, 3) = 'YES' THEN xSignalOk := TRUE; ELSE xSignalOk := FALSE; END_IF ELSE xSignalOk := FALSE; END_IF IF xSignalOk THEN IF fr.GetLine(ADR(sData), SIZEOF(sData)) THEN i := FIND(sData, 't='); IF i &gt; 0 THEN sData := RIGHT(sData, LEN(sData) - i - 1); IF sData = '85000' THEN xSignalOk := FALSE; ELSE rTemp := STRING_TO_REAL(sData) * 1E-3; SysTimeRtcConvertUtcToDate(SysTimeRtcGet(result), stdTimeStamp); END_IF ELSE xSignalOk := FALSE; END_IF END_IF END_IF ELSE xSignalOk := FALSE; END_IF SysFileClose(hFile); END_IF ~~~
Last updated: 2018-07-16

Home (version 18) discussion MCP3008 home (Thread)
Home (version 18) discussion
Last updated: 2018-09-03

Home (version 11) discussion MCP3008 home (Thread)
Home (version 11) discussion
Last updated: 2018-09-03

Home (version 19) discussion MCP3008 home (Thread)
Home (version 19) discussion
Last updated: 2018-09-02

Home (version 8) discussion MCP3008 home (Thread)
Home (version 8) discussion
Last updated: 2018-09-02

Home (version 5) discussion MCP3008 home (Thread)
Home (version 5) discussion
Last updated: 2018-09-02

<< < 1 .. 367 368 369 370 371 .. 3690 > >> (Page 369 of 3690)

Showing results of 92247

Sort by relevance or date