SPI示例不适用于NUCLEO-F411RE

时间:2017-06-07 10:00:49

标签: c spi mbed nucleo

我已经设置了一个非常简单的spi master示例,但是看一下逻辑分析器没有spi时钟线。那么我在spi的配置中做错了什么。

#include "mbed.h"
#include <stdio.h>

SPI spi(D4, D5, D3); // mosi, miso, sclk
DigitalOut cs(A2);

Serial pc(USBTX, USBRX); // tx, rx

int main() {
    cs = 1;
    spi.format(8,3);
    spi.frequency(1000000);

    // Select the spi by seting chip select low
    cs = 0;

    // Send some data
    spi.write(0xFA);

    // Send a dummy byte to receive the contents of the WHOAMI register
    int whoami = spi.write(0x00);
    pc.printf("WHOAMI register = 0x%X\n", whoami);

}

0 个答案:

没有答案