moo
/
_1768_SPI_Test2
slave.receive()が動作しない
main.cpp@0:8a5fd6497727, 2016-10-18 (annotated)
- Committer:
- moo
- Date:
- Tue Oct 18 20:18:10 2016 +0000
- Revision:
- 0:8a5fd6497727
SPI_Test2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
moo | 0:8a5fd6497727 | 1 | #include "mbed.h" |
moo | 0:8a5fd6497727 | 2 | |
moo | 0:8a5fd6497727 | 3 | Serial pc(USBTX, USBRX); |
moo | 0:8a5fd6497727 | 4 | SPI mst(p11, p12, p13); |
moo | 0:8a5fd6497727 | 5 | DigitalOut cs(p14); |
moo | 0:8a5fd6497727 | 6 | SPISlave slv(p5, p6, p7, p8); |
moo | 0:8a5fd6497727 | 7 | |
moo | 0:8a5fd6497727 | 8 | int main() { |
moo | 0:8a5fd6497727 | 9 | mst.frequency(19200); |
moo | 0:8a5fd6497727 | 10 | mst.format(8,3); |
moo | 0:8a5fd6497727 | 11 | slv.frequency(19200); |
moo | 0:8a5fd6497727 | 12 | slv.format(8,3); |
moo | 0:8a5fd6497727 | 13 | pc.printf("start\r\n"); |
moo | 0:8a5fd6497727 | 14 | |
moo | 0:8a5fd6497727 | 15 | cs = 0; |
moo | 0:8a5fd6497727 | 16 | for (int i=0; i<0xff; ++i) { |
moo | 0:8a5fd6497727 | 17 | mst.write(i); |
moo | 0:8a5fd6497727 | 18 | // if (slv.receive()) { // これが1にならない |
moo | 0:8a5fd6497727 | 19 | int v = slv.read(); |
moo | 0:8a5fd6497727 | 20 | pc.printf("%02x ",v); |
moo | 0:8a5fd6497727 | 21 | // } |
moo | 0:8a5fd6497727 | 22 | wait(0.1); |
moo | 0:8a5fd6497727 | 23 | } |
moo | 0:8a5fd6497727 | 24 | } |