-
Notifications
You must be signed in to change notification settings - Fork 8
[RFC][DNM] First Draft #1
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
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.
Looks pretty good! Just a couple comments. Thanks!
Introduction | ||
============ | ||
|
||
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-bluefruitspi/badge/?version=latest |
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.
Super nitpicky but the portion after the circuitpython piece should match the GitHub repo. So, I'd recommend dropping the friend from the github url. That way our adabot checks can match them all up.
COMMAND = const(0x10) # Command message | ||
RESPONSE = const(0x20) # Response message | ||
ALERT = const(0x40) # Alert message | ||
ERROR = const(0x80) # Error message |
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'd suggest removing these consts. It's a micropythonism that doesn't do anything in this case. (It only works on globals with names that start with _)
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.
im redoing these as all plain consts since we only use them internally
adafruit_bluefruitspi.py
Outdated
pass | ||
|
||
# Configure SPI for 4MHz | ||
self._spi.configure(baudrate=4000000, phase=0, polarity=0) |
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.
Give these args to SPIDevice() and it'll manage it for you (it sets it each transaction in case its a shared bus.)
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.
done!
adafruit_bluefruitspi.py
Outdated
|
||
# Check out the SPI bus | ||
while not self._spi.try_lock(): | ||
pass |
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.
Do you have to lock across these multiple transactions? Otherwise I'd suggest using a context manager to manage the transaction using SPIDevice.
with self._spi as spi:
spi.write(self._buf_tx, end=len(cmd) + 4)
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.
ditto
adafruit_bluefruitspi.py
Outdated
|
||
# Wait up to 200ms for a response | ||
timeout = 0.2 | ||
while timeout > 0.0 and self._irq is False: |
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.
this should be self._irq.value
hey i updated this code to use contexts for SPI, seems to work without debug, i also made the digitalio stuff a little more 'pythonic' the way we like to do em. i dont know how to adapt a PR with a new PR so here's the file, you can just paste it over |
added reset connection, some wrappers @microbuilder what we need next is data rx and tx which i think are wholy new packet types right? also commands need to be really short to fit into an SDEP 16 byte packet, can we split that up? AT+GAPDEVNAME= is a good test |
im going to merge, then do my updates to fix the above |
First draft of a helper class for the AT command based Bluefruit LE SPI friend.