> Serial.println((valist, i), BIN);
> SPI.transfer( (valist, i) );
You need to call va_arg to access individual arguments.
(valist,i) is a comma expression, who's value is just i.
Sufficient compiler warnings should tell you this.
Code:
int main()
{
printf("%d\n", (1,2,3) );
return 0;
}
$ gcc -Wall main.c
main.c: In function ‘main’:
main.c:31:20: warning: left-hand operand of comma expression has no effect [-Wunused-value]
printf("%d\n", (1,2,3) );
^
main.c:31:22: warning: left-hand operand of comma expression has no effect [-Wunused-value]
printf("%d\n", (1,2,3) );
^
$ ./a.out
3
> sorry, I edited it a little when I posted so I accidentally left out.
Yeah, and that's what bugs us when you do.
We've seen it endless times where people attempt to be brief, and only succeed in snipping out what was vital to the problem.
One more thing
Code:
for ( int i = 0; i < Size; i++ ){
uint32_t data;
if (i == 0){
data = SPI.transfer(0xff);
if (Size == 1){ return data; }
}
else{
data |= (uint32_t)SPI.transfer(0xff) << (8 * i);
}
return data;
}
Is that return data mis-placed?
Because as written, your for loop runs exactly once.
It's also massively convoluted.
This does the same thing with no special cases.
Code:
uint32_t data = 0;
for ( int i = 0; i < Size; i++ ){
data |= (uint32_t)SPI.transfer(0xff) << (8 * i);
}