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.
Fork of mbed_SPIS_multiByte_example_SOG by
main.cpp
- Committer:
- tsungta
- Date:
- 2017-06-01
- Revision:
- 4:8e796b751cd3
- Parent:
- 2:c520d7c7739d
- Child:
- 5:6a1155885fc9
File content as of revision 4:8e796b751cd3:
//#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 16 //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)) {
int ret = device.read(); // Read byte from master
uart.printf("ret = %s ", ret);
}
}
}
