SPI integers and bytes
Posted: Thu Oct 25, 2012 2:50 pm
> 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.
> 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.