We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, nice job!
The arduino's current hardware library has a 16-bit transfer routine. Would it be possible to add this routine to the library via software?
This seems to be the original code (Arduino IDE source):
inline static uint16_t transfer16(uint16_t data) { union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out; in.val = data; if (!(SPCR & _BV(DORD))) { SPDR = in.msb; asm volatile("nop"); // See transfer(uint8_t) function while (!(SPSR & _BV(SPIF))) ; out.msb = SPDR; SPDR = in.lsb; asm volatile("nop"); while (!(SPSR & _BV(SPIF))) ; out.lsb = SPDR; } else { SPDR = in.lsb; asm volatile("nop"); while (!(SPSR & _BV(SPIF))) ; out.lsb = SPDR; SPDR = in.msb; asm volatile("nop"); while (!(SPSR & _BV(SPIF))) ; out.msb = SPDR; } return out.val; }
The equivalent could be this way, as below?
inline static uint16_t transfer16(uint16_t data, bool MSB1ST = true) { union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out; in.val = data; if (MSB1ST) { out.msb = mySPI.transfer(in.msb); out.lsb = mySPI.transfer(in.lsb); } else { out.lsb = mySPI.transfer(in.lsb); out.msb = mySPI.transfer(in.msb); } return out.val; }
Thank you!
The text was updated successfully, but these errors were encountered:
#2
Sorry, something went wrong.
No branches or pull requests
Hello, nice job!
The arduino's current hardware library has a 16-bit transfer routine. Would it be possible to add this routine to the library via software?
This seems to be the original code (Arduino IDE source):
The equivalent could be this way, as below?
Thank you!
The text was updated successfully, but these errors were encountered: