> When SPIIN writes out a int, is SPIIN breaking it up into 4x 8bit
> Bytes? And returning 1 byte(the last one returned from the spi loop)?
>
> And thus when reading back I need to reconstruct 4 bytes back into a
int?
NO, SPIIN or for that matter all the hardware routines deal in byte
transfers, in both BASIC and C. I'm surprised you didn't get an error
in the C calling with an integer array as the declaration is
void SPIIN (int cspin, int inpin, int clkpin, int outpin, int out1,
int out2, int out3, int cnt, char *list) {
In BASIC even if an integer array is passed only values 0-255 will be
written/read.
So if you wish to send out an integer array that has values > 255, you
will need to break those values into bytes to be sent out.
SPI integers and bytes
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI integers and bytes
> No, my query is the 5,6,7th args, 'int out1', does this mean that
an int is output onto the SPI bus, OR does it only take the right most
8bits and push them there?
even though called as an integer only the low 8 bits or each argument
is passed to the SPI bus.
In some cases this is to allow 0-255 values, and -1 on error.
an int is output onto the SPI bus, OR does it only take the right most
8bits and push them there?
even though called as an integer only the low 8 bits or each argument
is passed to the SPI bus.
In some cases this is to allow 0-255 values, and -1 on error.