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.
Diff: spi.h
- Revision:
- 4:e360384c268b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spi.h Mon Jun 08 17:48:51 2020 +0000
@@ -0,0 +1,24 @@
+//master program
+
+SPI spi_port(D11, D12, D13); // mosi, miso, sclk
+DigitalOut ss(D10); //slave select pin
+Serial pc(USBTX, USBRX);
+
+
+int main()
+{
+ char podatak;
+ int i = 0;
+ led = 0;
+ int vrijeme = 0.005;
+
+ spi_port.format(8,1); // 8 bitni okvir, mod rada 0
+ spi_port.frequency(1000000); // frekvencija takta 1MHz
+ while (1) {
+ ss = 1; //digni SS pin u jedinici, aktivan je u jedinici (oznaci slave)
+ podatak = spi_port.write(0xFF & i); //posalji podatak
+ ss = 0; //spusti SS pin u nulu (odznaci slave)
+
+ wait(vrijeme);
+ }
+}
\ No newline at end of file