Is there any ETA for this feature? I'm trying to create templates for different control objects (like motors, valves etc) with a popup dialog faceplate to control the object, it would be very nice to be able to move them around instead of having fixed positions.
XML file + Library would be one way if you want to hard code a driver. Otherwise you can do it in logic using the method "SPI_master.transferExt(...)". Then you can define what you want to send and receive at runtime. For example, the messages sent/received will be different for the MCP23017 (Microchip 16xGPIO chip) and MCP3208 (Microchip 8xADC inputs). Look at the example project "PiFace_FB.project" to see how it is used. It is very flexible.
I might be wrong but i am fairly sure codesys is leveraging the same low level linux spi driver as the python library does. A driver for codesys would be equal to the library for python. However there are very flexible drivers that lets you define the protocol yourself to write "soft" drivers in plc code and then feed it to a function.
If you define a new variable as Dint for example you can use: diNewVar := SHL(int1, 16) + int2; real3 := dint_to_real(diMyVar); Ofcourse real3 will still be an integer value in that case. Edit: Im not in front of an IDE right now so i assumed there is an Dint_to_real function, otherwise use a format that is convertable for the "diNewVar".
Otherwise make one block with all the different inputs (int, real, uint etc). Then just use one of the inputs and leave the others at 0 and if input_type > 0 convert to real and do the calculation. Do the same with the outputs, convert the result to every type you want and then you can use whatever you need for the moment. This wont work as return value though.
I feel with you, i had the same frustration with getting the MCP3208 working. However i finally cracked it and when you know how to use the SPI function it is really easy to modify however you want (the opcodes for various SPI slaves are different). Unfortunately im at work now and the example code is in my private pc at home so i wont be able to post it until tonight to give you a little pointers on what to modify to get it working with the MCP3204.