Main Site Documentation

Write my own 'driver'


#1

I’ve looked at the source for the ‘driver’ of the Stepper_L6470 board I’m using. I must say that I don’t like it very much.
As far as I can tell, a ‘driver’ is merely a class that supports the board - it has no privileged status as far as the framework (or anything else) is concerned. So is there any reason I should not replace the supplied driver by one of my own? Any difficulty in doing so?


#2

You absolutely can. This is one of the main reasons of the drivers being open source, so you can change them anyway you see fits for your needs.


#3

It reads like you know what you’re doing, but just in-case: https://www.ghielectronics.com/docs/122/gadgeteer-driver-modification


#4

[em]Sometimes[/em] I know what I’m doing, but that’s still helpful - thanks to both of you.
Phil


#5

Remember to share :wink:


#6

Understood, but are you specifically interested in this driver? Anything about it you’d like to change?


#7

@ philAtkin, what about the drive would you like to improve?


#8

[ul]I’d like to improve the readability. There’s no reason to have names like “ACC” when you can have “Acceleration”; no need for “CONFIG_OC_SD_DISABLE” when “disable” will do[/ul]
[ul]I’d like to improve the documentation. The “documentation” for routines such as Speed_Steps_to_Par tells you all the things that are obvious from the names, but nothing that you’d actually like to know (such as what the units are)[/ul]
[ul]There are some bugs: IntSpd_Steps_to_Par has the wrong factor, and it’s invalid to alter the configuration without resetting (which makes an individual change expensive)[/ul]
[ul]There’s no facility to initialize the chip properly with custom settings (no constructor that takes a RegsStruct parameter, for example). Again, this makes a custom setup expensive.[/ul]
[ul]I’d like to improve the usability: the KVal parameters are difficult to understand to start with, and in my view this driver makes them more so (by introducing the ‘percentage’ concept for no apparent reason)[/ul]
[ul]Some properties are provided as parameterless methods, such as BusySW()[/ul]

I fully accept that some of these may be matters of personal taste and that others may find the established code perfectly adequate; I have no wish to argue about it! Which is why I began by asking if it was possible to write my own…


#9

Wauw, this is going to be a really good driver. Seriously good and reasonable mods. Keep it up!


#10

All I’ve done so far is talk…


#11

Not true. Most of my projects takes many hours of thinking before I start coding. But when the coding starts your real skills are tested :wink:


#12

I suppose I should publish an updated driver in codeshare in which I have address some of those readability concerns.


#13

@ philAtkin,

https://www.ghielectronics.com/community/forum/topic?id=16043

I’ve published my driver for the l6470; which is designed for a single daisy chain. I’ll try to modify it to support as many configurations as possible including Gadgeteer spi modules.

Let me know your concerns on that thread.