Hardware Reference
In-Depth Information
setBitOrder() Test
The bit order of the device must be matched by the Arduino communicating with it. There are two supported
configurations:
Least significant bit (LSB)
Most significant bit (MSB)
For the first test, the slave Arduino must be configured for LSB, and for the second test, the slave Arduino needs
to be configured to MSB, as shown in Listing 13-12.
Listing 13-12. setBitOrder MSB Test
void testBitOrderMSB()
{
//Sets the bit order to MSBFRIST expects byte 0xf0
boolean result = false;
byte spireturn;
spireturn = SPITransfer(0x00, MSBFIRST, SPI_MODE0, SPI_CLOCK_DIV4);
if (spireturn == 0xf0)
{
result = true;
}
ATS_PrintTestStatus("2. setBitOrder: MSBFIRST", result);
}
setClockDivider() Test
The clock divider changes the SPI speed to be a multiple of the Arduino clock speed. This way, it is possible to change
the speed of the SPI bus to match that of the attached device. For this test, we need to set the clock divider at each of
its multiples and ask the attached Arduino for a piece of data that matches the clock speed, as shown in Listing 13-13.
Listing 13-13. setClockDivider Test for SPI_CLOCK_DIV2
void testClockDivider()
{
boolean result = false;
byte spireturn;
//SPI_MODE0 test 3
setSlaveClockDivider(SPI_CLOCK_DIV2);
SPI.setClockDivider(SPI_CLOCK_DIV2);
spireturn = SPI.transfer(0x02);
if (spireturn > 0)
{
result = true;
}
ATS_PrintTestStatus("4. setClockDivider:SPI_CLOCK_DIV2 (failure is OK)", result);
}
 
Search WWH ::




Custom Search