![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Recep spi with no lib
Diff: main.cpp
- Revision:
- 0:077ff1a96d18
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 04 08:29:01 2019 +0000 @@ -0,0 +1,26 @@ +#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); + } +}