mbed-os
Fork of mbed-os by
features/unsupported/tests/mbed/spi/main.cpp@1:3deb71413561, 2017-07-20 (annotated)
- Committer:
- xuaner
- Date:
- Thu Jul 20 14:26:57 2017 +0000
- Revision:
- 1:3deb71413561
- Parent:
- 0:f269e3021894
mbed_os
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 | } |