This has been tested with 128D EVB SPI connection is shown as following D3 -> 128D EVB pin 82 D4 -> 128D EVB pin 12 D5 -> 128D EVB pin 39

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  
00003 SPI spi(D3, D4, D5); // mosi, miso, sclk
00004 DigitalOut cs(D2);
00005  
00006 int main() {
00007     // Chip must be deselected
00008     cs = 1;
00009  
00010     // Setup the spi for 8 bit data, high steady state clock,
00011     // second edge capture, with a 1MHz clock rate
00012     spi.format(8,3);
00013     spi.frequency(1000000);
00014 
00015     printf("Start application \r\n");   
00016     // Select the device by seting chip select low
00017     cs = 0;
00018  
00019     spi.write(0x5);
00020     spi.write(0x20);
00021     spi.write(0x00);
00022     spi.write('A');
00023     spi.write('B');
00024     spi.write('C');
00025     
00026     spi.write(0xFF);
00027     spi.write(0xFE);
00028     spi.write(0xFD);
00029     spi.write(0xFC);
00030           
00031     wait_ms(100);
00032 
00033     // Deselect the device
00034     cs = 1;
00035     printf("End of application \r\n");    
00036 }