This is an involuntary fork, created because the repository would not update mmSPI. SPI library used to communicate with an altera development board attached to four zigbee-header pins.
Dependents: Embedded_RTOS_Project
Fork of mmSPI by
Diff: mmSPI.cpp
- Revision:
- 7:b3e8b537d5c2
- Parent:
- 6:b480fc4e87e5
- Child:
- 8:e2d8bbc3e659
diff -r b480fc4e87e5 -r b3e8b537d5c2 mmSPI.cpp --- a/mmSPI.cpp Wed Aug 14 15:19:24 2013 +0000 +++ b/mmSPI.cpp Wed Aug 14 15:34:10 2013 +0000 @@ -43,10 +43,11 @@ // we're not going for speed, so lets go for good setup / hold. // send/receive a byte over SPI. + // MSB out/in first. void mmSPI::transceive_byte(char *cReceive, char *cSend) { *cReceive = 0; // clear receive byte. - for (cLoop01 = 7; cLoop01 >= 0; cLoop01++)// loop for 8 bits in the byte. + for (cLoop01 = 7; cLoop01 >= 0; cLoop01--)// loop for 8 bits in the byte. { *pSCLK = 0; // SPI clock negedge. wait(fSPIquarterP); // until middle of clock low. @@ -59,6 +60,15 @@ } } //----------------------------------------------//------------------------------ + // transceive a character array. + // limit is 256 characters. + // MSB out/in first. + void mmSPI::transceive_vector(char *cReceive, char *cSend, char cNumBytes) + { + for (cLoop02 = (cNumBytes - 1); cLoop02 >= 0; cLoop02--) + transceive_byte(&(cReceive[cLoop02]), &(cSend[cLoop02])); + } +//----------------------------------------------//------------------------------ @@ -68,3 +78,15 @@ + + + + + + + + + + + +