SPI slave program to enable communication between the FPGA and the STM32L432 board.

Dependencies:   mbed

Committer:
Zbyszek
Date:
Wed Feb 06 12:28:59 2019 +0000
Revision:
2:4cc880ea466d
Parent:
0:8e367d6d8f03
Child:
3:e33697420c4a
Changed the main.cpp a little for testing purposes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Zbyszek 0:8e367d6d8f03 1 #include "mbed.h"
Zbyszek 0:8e367d6d8f03 2 #include "SPI.h"
Zbyszek 0:8e367d6d8f03 3 DigitalOut myled(LED1);
Zbyszek 0:8e367d6d8f03 4 Serial pc(USBTX, USBRX);
Zbyszek 0:8e367d6d8f03 5
Zbyszek 0:8e367d6d8f03 6 int masterRx = 0;
Zbyszek 0:8e367d6d8f03 7 unsigned int slaveRx = 0;
Zbyszek 0:8e367d6d8f03 8
Zbyszek 0:8e367d6d8f03 9 int main() {
Zbyszek 0:8e367d6d8f03 10
Zbyszek 0:8e367d6d8f03 11 init_spi1();
Zbyszek 0:8e367d6d8f03 12
Zbyszek 0:8e367d6d8f03 13 while(1) {
Zbyszek 0:8e367d6d8f03 14 for(int x = 1; x < 128; x *= 2) {
Zbyszek 0:8e367d6d8f03 15 slaveRx = transfer_spi_slave(x);
Zbyszek 2:4cc880ea466d 16 pc.putc(slaveRx);
Zbyszek 0:8e367d6d8f03 17 }
Zbyszek 0:8e367d6d8f03 18 for(int x = 128; x > 1; x /= 2) {
Zbyszek 0:8e367d6d8f03 19 slaveRx = transfer_spi_slave(x);
Zbyszek 2:4cc880ea466d 20 pc.putc(slaveRx);
Zbyszek 2:4cc880ea466d 21 }
Zbyszek 0:8e367d6d8f03 22 }
Zbyszek 0:8e367d6d8f03 23 }