Recep spi with no lib

Dependencies:   mbed

main.cpp

Committer:
SamirIss
Date:
2019-11-04
Revision:
0:077ff1a96d18

File content as of revision 0:077ff1a96d18:

#include "mbed.h"
 
SPI spi(A6,A5,A4); // mosi, miso, sclk
DigitalOut led(LED1);
Serial pc(D1,D0);
 
int main() {
    // Chip must be deselected
    led = 1;
    wait(1);
    led = 0;
    
        // Setup the spi for 8 bit data, high steady state clock,
        // second edge capture, with a 1MHz clock rate
        spi.format(8,3);
        spi.frequency(1000000);
    while(1){
        led = 1;
         spi.write(0x8F);
        int f = spi.write(0x00);
        pc.printf("com : 0x%X\n", f);
        wait(0.1);
        led = 0;
        wait(0.1);
    }
}