SPI to Ethernet Slave

Dependencies:   WIZnetInterface mbed

Fork of SPI_HelloWorld_Mbed by mbed official

main.cpp

Committer:
Ricky_Kwon
Date:
2016-03-09
Revision:
4:eec728094dbc
Parent:
3:30b262b6c2f9
Child:
5:709f1ad85e97

File content as of revision 4:eec728094dbc:

#include "mbed.h"
#include "EthernetInterface.h"

SPISlave slave(PA_8, PA_7, PA_6, PA_5); // mosi, miso, sclk, ssel
 
int main() {
    printf("SPI to Ethernet Slave\r\n");
  
    /*
    * SPI Setting
    */
    slave.format(8,3);
    slave.frequency(1000000);

    while(1) 
    { 
        if(slave.receive()) 
        {
            int SPI_re = slave.read();   // Read byte from master
            printf("SPI_re=%c\r\n",SPI_re);
        }
    }
}