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
Diff: main.cpp
- Revision:
- 0:51f9ddcf2f12
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 14 14:29:52 2018 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+//slaveprogram
+SPISlave spi_port(p5, p6, p7, p8); // mosi, miso, sclk, ssel
+Serial pc(USBTX, USBRX); // tx, rx
+BusOut led(LED1,LED2);
+int main() {
+ char podatak;
+ led = 0;
+ spi_port.format(8,0); // 8 bitni okvir, mod rada 0
+ spi_port.frequency(1000000); // frekvencija takta 1MHz
+ while (1){
+ if (spi_port.receive()){ //cekaj da master posalje podatak
+ podatak = spi_port.read(); //spremi primljeni podatak
+ spi_port.reply(podatak+1); //vrati masteru invertirani primljeni podatak
+ pc.printf("Primljeni podatak: %x\n",podatak);
+ pc.printf("Poslani podatak: %x\n",0xFF & (podatak+1));
+ pc.printf("--------------------------\n");
+ led = ~led;
+ }
+ }
+}
\ No newline at end of file