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

Dependencies:   mbed

main.cpp

Committer:
Zbyszek
Date:
2019-02-06
Revision:
2:4cc880ea466d
Parent:
0:8e367d6d8f03
Child:
3:e33697420c4a

File content as of revision 2:4cc880ea466d:

#include "mbed.h"
#include "SPI.h"
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX); 

int masterRx = 0;
unsigned int slaveRx = 0;

int main() {
    
    init_spi1();
    
    while(1) {
        for(int x = 1; x < 128; x *= 2) { 
        slaveRx = transfer_spi_slave(x);
        pc.putc(slaveRx); 
        }
        for(int x = 128; x > 1; x /= 2) { 
        slaveRx = transfer_spi_slave(x);
        pc.putc(slaveRx); 
        } 
    }
}