Kevin Moloney / Mbed 2 deprecated spi-master-demo

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #define VALUE_SENT      0xFA
00004 
00005 Serial pc(SERIAL_TX, SERIAL_RX);
00006 SPI spi(D11, D12, D13); 
00007 
00008 DigitalOut chipSelect(D10);
00009 
00010 int main()
00011 {
00012     int masterVal = VALUE_SENT;
00013     chipSelect = 1; // Deselect device
00014     
00015     spi.format(8,3);        // Setup:  bit data, high steady state clock, 2nd edge capture
00016     spi.frequency(1000000); //1MHz
00017 
00018     chipSelect = 0; // Select device
00019         
00020     spi.write(masterVal);
00021     
00022     wait(2);
00023     chipSelect = 1; // Deselect device  
00024 }