aliazzz - 2019-12-06

Nice posting
Seems to me not too difficult to rewrite it into Structured Text.

Little advice;
1) Just write an FB (class!) which extends the SPI baseclass and try to translate this python source into it. This will be your CODESYS basic Function Block driver.
2) Study other SPI drivers for extra help. Lots of resources on it here.
3) Use CfUnit for debugging and write unit tests for your FB driver in your library ;-) It will help you develop the driver quicker and more painless and it will also serve as useful information for other developers. If you first write some tests and then develop your code you will reap the benefits from it!

*) Bonus stage: You can always embed your FB into a SPI based IoDrv. There is loads of info on this topic available here, but it will take you extra work and effort depending on your skill level.

 

Last edit: aliazzz 2019-12-06