
Motor Control board Slave control
Dependencies: mbed
Revision 0:673453dbcc7a, committed 2017-03-29
- Comitter:
- rvasquez6089
- Date:
- Wed Mar 29 16:05:05 2017 +0000
- Commit message:
- Working slave
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 673453dbcc7a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 29 16:05:05 2017 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +//DigitalOut myled(LED1); + +SPISlave device(PB_5,PB_4, PB_3, PA_4); // mosi, miso, sclk, ssel +Serial pc(SERIAL_TX, SERIAL_RX); + + int main() { + pc.baud(115200); + pc.printf("The F303K8 is working \n\r"); + char v = 0; + device.reply(0x00); // Prime SPI with first reply + device.format(8,3); + device.frequency(1000000); + while(1) { + //pc.printf("Slave is about to read"); + + if(device.receive()) { + + v = device.read(); // Read byte from master + // Add one to it, modulo 256 + pc.printf("Slave recieved byte %c \n\r",v); + //device.reply(v); // Make this the next reply + } + } + } \ No newline at end of file
diff -r 000000000000 -r 673453dbcc7a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 29 16:05:05 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/093f2bd7b9eb \ No newline at end of file