Team H - TVZ Seminar / Mbed 2 deprecated KTM_03_02_S_C

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DudeHD
Date:
Wed Nov 14 14:29:52 2018 +0000
Commit message:
vj3

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 14 14:29:52 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file