mbed-os
Fork of mbed-os by
Diff: features/unsupported/tests/mbed/spi/main.cpp
- Revision:
- 0:f269e3021894
diff -r 000000000000 -r f269e3021894 features/unsupported/tests/mbed/spi/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/features/unsupported/tests/mbed/spi/main.cpp Sun Oct 23 15:10:02 2016 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" + +#if !DEVICE_SPI + #error [NOT_SUPPORTED] SPI is not supported +#endif + +#if defined(TARGET_SAMR21G18A) +SPI spi(PB22, PB02, PB23); // mosi, miso, sclk +DigitalOut latchpin(PB03); +#elif defined(TARGET_SAMD21J18A) || defined(TARGET_SAMD21G18A) || defined(TARGET_SAML21J18A) +SPI spi(PA18, PA16, PA19); // mosi, miso, sclk +DigitalOut latchpin(PA17); +#elif defined(TARGET_SAMG55J19) +SPI spi(PA10, PA09, PB00, PA25); // mosi, miso, sclk cs +DigitalOut latchpin(PA25); +#else +SPI spi(p11, p12, p13); +DigitalOut latchpin(p10); +#endif + +int main() { + spi.format(8, 0); + spi.frequency(16 * 1000 * 1000); + + latchpin = 0; + while (1) { + latchpin = 1; + spi.write(0); + latchpin = 0; + } +}