mbed-os
Fork of mbed-os by
features/unsupported/tests/mbed/spi/main.cpp@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | #include "mbed.h" |
elessair | 0:f269e3021894 | 2 | |
elessair | 0:f269e3021894 | 3 | #if !DEVICE_SPI |
elessair | 0:f269e3021894 | 4 | #error [NOT_SUPPORTED] SPI is not supported |
elessair | 0:f269e3021894 | 5 | #endif |
elessair | 0:f269e3021894 | 6 | |
elessair | 0:f269e3021894 | 7 | #if defined(TARGET_SAMR21G18A) |
elessair | 0:f269e3021894 | 8 | SPI spi(PB22, PB02, PB23); // mosi, miso, sclk |
elessair | 0:f269e3021894 | 9 | DigitalOut latchpin(PB03); |
elessair | 0:f269e3021894 | 10 | #elif defined(TARGET_SAMD21J18A) || defined(TARGET_SAMD21G18A) || defined(TARGET_SAML21J18A) |
elessair | 0:f269e3021894 | 11 | SPI spi(PA18, PA16, PA19); // mosi, miso, sclk |
elessair | 0:f269e3021894 | 12 | DigitalOut latchpin(PA17); |
elessair | 0:f269e3021894 | 13 | #elif defined(TARGET_SAMG55J19) |
elessair | 0:f269e3021894 | 14 | SPI spi(PA10, PA09, PB00, PA25); // mosi, miso, sclk cs |
elessair | 0:f269e3021894 | 15 | DigitalOut latchpin(PA25); |
elessair | 0:f269e3021894 | 16 | #else |
elessair | 0:f269e3021894 | 17 | SPI spi(p11, p12, p13); |
elessair | 0:f269e3021894 | 18 | DigitalOut latchpin(p10); |
elessair | 0:f269e3021894 | 19 | #endif |
elessair | 0:f269e3021894 | 20 | |
elessair | 0:f269e3021894 | 21 | int main() { |
elessair | 0:f269e3021894 | 22 | spi.format(8, 0); |
elessair | 0:f269e3021894 | 23 | spi.frequency(16 * 1000 * 1000); |
elessair | 0:f269e3021894 | 24 | |
elessair | 0:f269e3021894 | 25 | latchpin = 0; |
elessair | 0:f269e3021894 | 26 | while (1) { |
elessair | 0:f269e3021894 | 27 | latchpin = 1; |
elessair | 0:f269e3021894 | 28 | spi.write(0); |
elessair | 0:f269e3021894 | 29 | latchpin = 0; |
elessair | 0:f269e3021894 | 30 | } |
elessair | 0:f269e3021894 | 31 | } |