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.
Dependencies: mbed-src
Fork of SPI_slave_lpc1114fn28 by
main.cpp
- Committer:
- armdran
- Date:
- 2015-04-01
- Revision:
- 1:f0831940e436
- Parent:
- 0:84a7343cd5c1
- Child:
- 3:e75751703666
File content as of revision 1:f0831940e436:
#include "mbed.h"
//SPI Slave
SPISlave device(D11, D12, D13, D10); // mosi, miso, sclk, ssel
//SPISlave device(PTA16, PTA17, PTA15, PTB9); // mosi, miso, sclk, ssel
//SPISlave device(PTD6, PTD7, PTD5, PTD4); // mosi, miso, sclk, ssel
//SPISlave device(PTA16, PTA17, PTA15, D10);
Serial pc(USBTX, USBRX);
int main() {
//pc.baud(9600);
//pc.format(8, SerialBase::None, 1);
device.frequency(100000);
device.format(8, 0);
int i = 0;
while(1) {
uint8_t instruction = 0xAB;
pc.printf("waiting for instruction");
device.reply(0xFF);
while(!device.receive()) {
if(i++ % 10000 == 0) {
printf(".");
}
}
pc.printf("\r\n");
instruction = device.read(); // Read byte from master
if(instruction == 0xFF) {
continue;
}
uint8_t reply = instruction + 0x10;
device.reply(reply);
pc.printf("waiting for reply signal");
while(!device.receive()) {
if(i++ % 10000 == 0) {
printf(".");
}
}
pc.printf("\r\n");
uint8_t ignore = device.read();
pc.printf("instruction: 0x%X; reply: 0x%X; dummy_instruction: 0x%X\r\n", instruction, reply, ignore);
}
}
