-
Notifications
You must be signed in to change notification settings - Fork 116
Add driver design page #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Nice. This would hav helped me when I was writing the TMC drivers. I like the practical aspect of the write up. You should do something similar for tips and tricks for more tinygo topics. |
I like "To abstract |
@ysoldak I've applied your suggestions- thank you so much! |
content/docs/guides/driver-design.md
Outdated
- Store HAL required for peripheral operation here such as communication buses (I2C, SPI drivers) and pins | ||
- **Avoid**: using TinyGo `machine` package constructs in your driver (read as *don't import `"machine"`*). Users of the Go language (not only TinyGo) also consume the drivers package and they can't compile a program that uses the `"machine"` package. To abstract `machine.Pin` one can define `type PinOutput func(level bool)` and `type PinInput func() bool` functional interfaces. | ||
|
||
- Define a `Config` struct for peripherals with many configuration options. See example of a Config struct in action: https://github.com/soypat/lora/blob/main/lora.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would point to a driver under the tinygo-org repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! I've deleted that link and added a list of compliant drivers below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, sadly all the drivers are mine :(. Be great to start working on making other existing drivers compliant so we can expand the list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we have resolved this question yet, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find other examples which do a good job to sticking to the guidlines except for the ones added in 7905de7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it!
…hotloop note; typos
Found a couple typos and in the heat of it added a concurrency section which I felt was missing based on my experiences programming and using async drivers in TinyGo. |
Last call for comments before merging! Will wait until Monday :) |
Mergerino the pull requesterino |
Thank you @ysoldak, @conejoninja for the feedback <3 |
recently was inspired to start working on protips for people designing drivers.
Still a WIP.
Would love a review and suggestions from driver developer extraordinaires @aykevl @deadprogram @ysoldak @sago35