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
main.cpp
- Committer:
- DudeHD
- Date:
- 2018-11-14
- Revision:
- 0:51f9ddcf2f12
File content as of revision 0:51f9ddcf2f12:
#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;
}
}
}