SPI

Ingo
There is a newer version of this page. You can find it here.

Preface

This documentation describes the process of creating an own SPI driver for CODESYS, based on the SPI Template, which can be found in the Code Repository. The driver consists of a "Device Description" as well as a CODESYS Library. All essential settings in the Library or the Device Description are repeated in this documentation. For more detailed informations about the Device Descriptions, please check the general I/O driver documentation.

Device Description

You can use a copy of the Device Description "SPI_Template.devdesc.xml" as a starting point. You need to adapt the following sections of the device description for your needs.

Device Identification

  • Set the Type to 501 for all SPI devices
<DeviceDescription>
  ...
  <Device>
    ...
    <DeviceIdentification>
      ...
      <Type>501</Type>
      ...
    </DeviceIdentification>
    ...
  </Device>
  ...
</DeviceDescription>
  • The ID consists of the "Vendor ID" (0003 for Open Source) and the "Device ID". As the Device ID needs to be unique, you have to register it in the Device Database.
<DeviceDescription>
  ...
  <Device>
    ...
    <DeviceIdentification>
      ...
      <Id>0003 0001</Id>
      ...
    </DeviceIdentification>
    ...
  </Device>
  ...
</DeviceDescription>
  • The version can be freely defined. Just, the format is fix. And you should take care that you never release two different device descriptions with the same Type, ID and Version. As this might produce conflicts in the repositories of other users.
<DeviceDescription>
  ...
  <Device>
    ...
    <DeviceIdentification>
      ...
      <Version>1.0.0.0</Version>
      ...
    </DeviceIdentification>
    ...
  </Device>
  ...
</DeviceDescription>