sato takumi / Mbed 2 deprecated mbed_com1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 Serial pc(USBTX, USBRX);
00003 DigitalOut myled(LED1);
00004 SPI spi(p11, p12, p13); //mosi, miso, sclk
00005 DigitalOut cs(p14);
00006 #define DTIME 0.005
00007 
00008 int main() {
00009     spi.format(8,0);
00010     spi.frequency(1000000);
00011     int teste;
00012     teste=0xAA;
00013     while(1){
00014         cs=0;
00015         wait(DTIME);
00016         int result = spi.write(teste);
00017         pc.printf("Send to Slave = %d\n\r", teste);
00018         pc.printf("Reply from Slave = %d\n\r", result);
00019         pc.printf("\n\r");
00020         wait(DTIME);
00021         cs=1;
00022         wait(1);
00023     }
00024 }