Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- tsungta
- Date:
- 2017-06-13
- Revision:
- 5:86bcf189bbcd
- Parent:
- 4:8e796b751cd3
File content as of revision 5:86bcf189bbcd:
//#include "mbed.h" // //SPI spi(A1, A2, A3); // mosi, miso, sclk //DigitalOut cs(A0); // //uint8_t tx_buf[32] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V'}; // //int main() { // // Chip must be deselected // cs = 1; // // // Setup the spi for 8 bit data, high steady state clock, // // second edge capture, with a 1MHz clock rate // spi.format(8,1); // spi.frequency(8000000); // // // Select the device by seting chip select low // cs = 0; // // for(int i=0; i<32; i++) // spi.write(tx_buf[i]); // printf("End of transmission \r\n"); // // // Deselect the device // cs = 1; //} #include "mbed.h" #include "SPISlave_multiByte.h" SPISlave_multiByte device(A1, A2, A3, p3); // mosi, miso, sclk, ssel Serial uart(USBTX, USBRX); #define TXRX_LENGTH 224 //max is 16 int main() { uart.printf("START!"); device.format(8,1); device.frequency(8000000); device.reply((uint8_t*)"xyz", TXRX_LENGTH); while(1) { if(device.receive(TXRX_LENGTH)) { //Thread::wait(1000); int ret = device.read(); // Read byte from master uart.printf("ret = %s ", ret); } } }