Prelude-Sat Project / Mbed 2 deprecated spi_simplest_master

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers spi_master.cpp Source File

spi_master.cpp

00001 #include "mbed.h"
00002 
00003 SPI to_eps(p5,p6,p7);
00004 DigitalOut cs(p8);
00005 
00006 Serial pc(USBTX,USBRX);
00007 
00008 #define DTIME 0.1
00009 
00010 int main()
00011 {
00012     pc.printf("--Hi,this is cdh(master).\r\n");
00013     cs = 1;
00014 
00015     to_eps.format(8,3);
00016     to_eps.frequency(1000000);
00017     int cmd = 0;
00018 
00019     while(1) {
00020         char c = pc.getc();
00021         pc.printf("count: %d, ",cmd);
00022 
00023         cs=0;
00024         int dummy = to_eps.write(cmd); // send command
00025         int rdata = to_eps.write(0x00);        
00026         cs=1;
00027         
00028         pc.printf("dummy: %d, ",dummy);
00029         pc.printf("rdata: %d\r\n",rdata);
00030         
00031         cmd++;
00032     }
00033 }