![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
spi test slave
main.cpp@0:5dea2dc6ac9e, 2015-12-07 (annotated)
- Committer:
- AndyTran
- Date:
- Mon Dec 07 04:10:11 2015 +0000
- Revision:
- 0:5dea2dc6ac9e
spi_test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AndyTran | 0:5dea2dc6ac9e | 1 | #include "mbed.h" |
AndyTran | 0:5dea2dc6ac9e | 2 | |
AndyTran | 0:5dea2dc6ac9e | 3 | SPISlave slave (p11,p12,p13,p14); |
AndyTran | 0:5dea2dc6ac9e | 4 | RawSerial pc(USBTX, USBRX); |
AndyTran | 0:5dea2dc6ac9e | 5 | |
AndyTran | 0:5dea2dc6ac9e | 6 | int main() { |
AndyTran | 0:5dea2dc6ac9e | 7 | while (true) { |
AndyTran | 0:5dea2dc6ac9e | 8 | pc.baud (921600); |
AndyTran | 0:5dea2dc6ac9e | 9 | slave.format(10, 3); |
AndyTran | 0:5dea2dc6ac9e | 10 | slave.frequency(10000000); |
AndyTran | 0:5dea2dc6ac9e | 11 | slave.reply(0x00); |
AndyTran | 0:5dea2dc6ac9e | 12 | int check = slave.receive(); |
AndyTran | 0:5dea2dc6ac9e | 13 | pc.printf("receive = %d\n\r",check); |
AndyTran | 0:5dea2dc6ac9e | 14 | if(check==1) |
AndyTran | 0:5dea2dc6ac9e | 15 | { |
AndyTran | 0:5dea2dc6ac9e | 16 | int mes = slave.read(); |
AndyTran | 0:5dea2dc6ac9e | 17 | pc.printf("%d\n\r",mes); |
AndyTran | 0:5dea2dc6ac9e | 18 | } |
AndyTran | 0:5dea2dc6ac9e | 19 | } |
AndyTran | 0:5dea2dc6ac9e | 20 | |
AndyTran | 0:5dea2dc6ac9e | 21 | } |