The problem is in the adafruit code itself, specifically lines 122 and 144:

https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/spimodule.c#L122

https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/spimodule.c#L144

The buffer they are using is an array of bytes (uint8_t) and then they
blindly cast each list object in the spi.xfer call to u8 (i.e. one byte).

In order to fix this, you would have to change this function to store both
the low byte and the high byte in the buf variable, probably depending on
the value of self->bpw.

If you did that, you would also have to figure out how to read 16bit values
as well.

Most likely, Your best option is to manually treat 16-bit values as two 8
bit values in your code and split or combine them as makes sense in your
application.

--David

On Thu, Mar 24, 2016 at 4:26 AM, <[email protected]> wrote:

> Hi,
> I encounter the same problem as you and i would like know if you had
> returns or if you had to find the solution to send more than 8 bits with
> this library ?
>
> thank you and good day
> Clément
>
>
> Le lundi 4 août 2014 00:36:16 UTC+2, [email protected] a écrit :
>>
>> Hello everybody,
>>
>> I am not sure if this is the correct place to post my problem. I am very
>> new to the
>> Beaglebone and embedded systems under Linux.
>>
>> I am currently trying to get a 16bit ADC running via SPI1 on my
>> Beaglebone Black.
>> My OS is Debian Wheezy with the  3.8.13 kernel. So far I have disabled
>> the HDMI
>> interface and got the spidev1.0 and spidev1.1 running. (Aside from my
>> actual
>> problem I am not sure what the last number represents.)
>>
>> I have shot wired the P9_29 and P9_30 pins to test the communication. My
>> program is written
>> in Python 2.7 and I am using the Adafruit_BBIO modul to control the  SPI
>>  (https://github.com/adafruit/adafruit-beaglebone-io-python). The SPI
>>  part of this module
>> seems to derive from the spidev module (
>> http://tightdev.net/SpiDev_Doc.pdf).
>>
>> When trying to send and receive one 16-bit word with the following code:
>>
>> import Adafruit_BBIO.SPI as SPI
>> print "Testing SPI: P9_29 and P9_30 need to be short wired"
>> spi = SPI.SPI()
>> spi.open(1,0)
>> spi.bpw = 16
>> print "Word length is : " + str(spi.bpw)
>> resp = spi.xfer([0x1234]) # transfer one word of two bytes length
>> print "Sending 0x1234 via xfer - receiving: " + str(resp)
>> spi.close() #close the port before exit
>>
>> I only receive 8 bit, being the 8 LBS "34". The same goes for the xfer2
>> method.
>>
>> Does somebody have any experience with this type of problem, or am I
>> missing something obvious?
>> Any help would be appreciated!
>>
>> Best Regards,
>> Bumin
>>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to