chipKIT32/chipKIT32-MAX — pull request #354 by majenkotech (2013-06-10 22:15:14+00:00)
Title: Enabled the use of 16 and 32 bit transfers in DSPI

I have added the DSPI::setTransferSize() function to control the MODE16 and MODE32 bits of the SPI control register.

This allows a single transfer operation to transfer 8, 16 or 32 bits of data at a time.

The general transfer() function has been updated to accept and return uint32_t data (this has not been done with the buffer transfer functions - they want some special treatment later on).

Three macros have been created: DSPI_8BIT, DSPI_16BIT and DSPI_32BIT which just equate to 8, 16 and 32 respectively, for use in the setTransferSize function.

Stress test code (with loopback between SDI and SDO):
```C++
#include

DSPI0 SPI;

void setup()
{
Serial.begin(9600);
SPI.begin();
}

void loop()
{
unsigned long v;
unsigned long w;
unsigned int t;

SPI.setTransferSize(DSPI_8BIT);
delay(1000);
Serial.println("8 bit test");
for (t=0; t<10; t++) {
v = rand();
w = SPI.transfer(v);
Serial.print("Transmit ");
Serial.print(v, HEX);
Serial.print(" Receive ");
Serial.print(w, HEX);
Serial.println(((v & 0xFF) == w) ? " OK" : " ERR");
}
Serial.println();

SPI.setTransferSize(DSPI_16BIT);
delay(1000);
Serial.println("16 bit test");
for (t=0; t<10; t++) {
v = rand();
w = SPI.transfer(v);
Serial.print("Transmit ");
Serial.print(v, HEX);
Serial.print(" Receive ");
Serial.print(w, HEX);
Serial.println(((v & 0xFFFF) == w) ? " OK" : " ERR");
}
Serial.println();

SPI.setTransferSize(DSPI_32BIT);
delay(1000);
Serial.println("32 bit test");
for (t=0; t<10; t++) {
v = rand();
w = SPI.transfer(v);
Serial.print("Transmit ");
Serial.print(v, HEX);
Serial.print(" Receive ");
Serial.print(w, HEX);
Serial.println((v == w) ? " OK" : " ERR");
}
Serial.println();
}
```