slave.receive()が動作しない

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 Serial pc(USBTX, USBRX);
00004 SPI mst(p11, p12, p13);
00005 DigitalOut cs(p14);
00006 SPISlave slv(p5, p6, p7, p8);
00007  
00008 int main() {
00009     mst.frequency(19200);
00010     mst.format(8,3);
00011     slv.frequency(19200);
00012     slv.format(8,3);
00013     pc.printf("start\r\n");
00014 
00015     cs = 0;
00016     for (int i=0; i<0xff; ++i) {
00017         mst.write(i);
00018 //        if (slv.receive()) {    // これが1にならない
00019             int v = slv.read();
00020             pc.printf("%02x  ",v);
00021 //        }
00022         wait(0.1);
00023     }
00024 }