Skip to content

DM: added write_readinto to bitbangio#564

Merged
tannewt merged 3 commits into
adafruit:masterfrom
deanm1278:master
Feb 6, 2018
Merged

DM: added write_readinto to bitbangio#564
tannewt merged 3 commits into
adafruit:masterfrom
deanm1278:master

Conversation

@deanm1278
Copy link
Copy Markdown

add write_readinto support to bitbangio #472

note that in the current master branch bitbangio module is not compiled in by default and will have to be added into the makefile

code sample:

import bitbangio
import board

spi = bitbangio.SPI(board.D10, board.D6, board.D9)

while not spi.try_lock():
    pass

a = bytearray(2)
spi.write_readinto(bytes([9, 88]), a)

#if mosi and miso are connected this should print 9, 88
for b in a:
    print(b)

Copy link
Copy Markdown
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor things

Comment thread shared-bindings/bitbangio/SPI.c Outdated

{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&bitbangio_spi_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&bitbangio_spi_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&bitbangio_spi_write_readinto_obj) },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a tab instead of spaces? (I realize its pedantic.) Could please set your editor up to do 4 spaces when tab is hit?

Comment thread shared-bindings/bitbangio/SPI.c Outdated
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_spi_readinto_obj, 2, 2, bitbangio_spi_readinto);

//| .. method:: SPI.write_readinto(buf_in, buf_out)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the params to buffer_in, buffer_out to match the comment below.

@deanm1278
Copy link
Copy Markdown
Author

ok updated @tannewt

@dhalbert
Copy link
Copy Markdown
Collaborator

It looks like there are still tabs in the two SPI.c files. Could you untabify them in Atmel Studio or maybe from the command line? http://mlawire.blogspot.com/2009/07/convert-tabs-to-spaces.html

@deanm1278
Copy link
Copy Markdown
Author

@dhalbert ok updated

Copy link
Copy Markdown
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you thank you!

@tannewt tannewt merged commit 6c5cb01 into adafruit:master Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants