Huajian Huang / Mbed 2 deprecated TeensySlave_Nov16_public

Dependencies:   mbed

Fork of TeensySlave_Nov16 by Huajian Huang

Committer:
georgeHuang
Date:
Tue Nov 17 01:22:57 2015 +0000
Revision:
0:b120cb6c902f
teensySPISlave

Who changed what in which revision?

UserRevisionLine numberNew contents of line
georgeHuang 0:b120cb6c902f 1 // Reply to a SPI master as slave
georgeHuang 0:b120cb6c902f 2
georgeHuang 0:b120cb6c902f 3 #include "mbed.h"
georgeHuang 0:b120cb6c902f 4 int dataToMaster = 96;
georgeHuang 0:b120cb6c902f 5 //int MOSI=11;
georgeHuang 0:b120cb6c902f 6 //int MISO=12;
georgeHuang 0:b120cb6c902f 7 //int SCK=13;
georgeHuang 0:b120cb6c902f 8 //int CS=10;
georgeHuang 0:b120cb6c902f 9 SPISlave device(D11, D12, D13, D10); // mosi, miso, sclk, chipSelect
georgeHuang 0:b120cb6c902f 10
georgeHuang 0:b120cb6c902f 11 int main() {
georgeHuang 0:b120cb6c902f 12 device.reply(0x00); // Prime SPI with first reply
georgeHuang 0:b120cb6c902f 13 while(1) {
georgeHuang 0:b120cb6c902f 14 if(device.receive()) {
georgeHuang 0:b120cb6c902f 15 //int v = device.read(); // Read byte from master
georgeHuang 0:b120cb6c902f 16
georgeHuang 0:b120cb6c902f 17 //v = (v + 1) % 0x100; // Add one to it, modulo 256
georgeHuang 0:b120cb6c902f 18 device.reply(dataToMaster); // Make this the next reply
georgeHuang 0:b120cb6c902f 19 }
georgeHuang 0:b120cb6c902f 20 }
georgeHuang 0:b120cb6c902f 21 }